diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/client.go new file mode 100644 index 00000000000..8be706c5f03 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/client.go @@ -0,0 +1,181 @@ +package v2025_03_31 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterdelete" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointdelete" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus" + "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + CloudHSMClusterBackupCreate *cloudhsmclusterbackupcreate.CloudHSMClusterBackupCreateClient + CloudHSMClusterCreateOrUpdate *cloudhsmclustercreateorupdate.CloudHSMClusterCreateOrUpdateClient + CloudHSMClusterDelete *cloudhsmclusterdelete.CloudHSMClusterDeleteClient + CloudHSMClusterGet *cloudhsmclusterget.CloudHSMClusterGetClient + CloudHSMClusterGetByResourceGroup *cloudhsmclustergetbyresourcegroup.CloudHSMClusterGetByResourceGroupClient + CloudHSMClusterGetBySubscription *cloudhsmclustergetbysubscription.CloudHSMClusterGetBySubscriptionClient + CloudHSMClusterPrivateEndpointConnectionsGet *cloudhsmclusterprivateendpointconnectionsget.CloudHSMClusterPrivateEndpointConnectionsGetClient + CloudHSMClusterPrivateEndpointCreate *cloudhsmclusterprivateendpointcreate.CloudHSMClusterPrivateEndpointCreateClient + CloudHSMClusterPrivateEndpointDelete *cloudhsmclusterprivateendpointdelete.CloudHSMClusterPrivateEndpointDeleteClient + CloudHSMClusterPrivateEndpointGet *cloudhsmclusterprivateendpointget.CloudHSMClusterPrivateEndpointGetClient + CloudHSMClusterPrivateLinkGet *cloudhsmclusterprivatelinkget.CloudHSMClusterPrivateLinkGetClient + CloudHSMClusterUpdate *cloudhsmclusterupdate.CloudHSMClusterUpdateClient + CloudHSMClusterValidateBackupProperties *cloudhsmclustervalidatebackupproperties.CloudHSMClusterValidateBackupPropertiesClient + CloudHSMClustersBackupOperationStatusGet *cloudhsmclustersbackupoperationstatusget.CloudHSMClustersBackupOperationStatusGetClient + CloudHSMClustersRestoreOperationCreate *cloudhsmclustersrestoreoperationcreate.CloudHSMClustersRestoreOperationCreateClient + DedicatedHsms *dedicatedhsms.DedicatedHsmsClient + ReturnsRestoreOperationStatus *returnsrestoreoperationstatus.ReturnsRestoreOperationStatusClient + ValidateCloudHSMClusterRestoreProperties *validatecloudhsmclusterrestoreproperties.ValidateCloudHSMClusterRestorePropertiesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + cloudHSMClusterBackupCreateClient, err := cloudhsmclusterbackupcreate.NewCloudHSMClusterBackupCreateClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudHSMClusterBackupCreate client: %+v", err) + } + configureFunc(cloudHSMClusterBackupCreateClient.Client) + + cloudHSMClusterCreateOrUpdateClient, err := cloudhsmclustercreateorupdate.NewCloudHSMClusterCreateOrUpdateClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudHSMClusterCreateOrUpdate client: %+v", err) + } + configureFunc(cloudHSMClusterCreateOrUpdateClient.Client) + + cloudHSMClusterDeleteClient, err := cloudhsmclusterdelete.NewCloudHSMClusterDeleteClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudHSMClusterDelete client: %+v", err) + } + configureFunc(cloudHSMClusterDeleteClient.Client) + + cloudHSMClusterGetByResourceGroupClient, err := cloudhsmclustergetbyresourcegroup.NewCloudHSMClusterGetByResourceGroupClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudHSMClusterGetByResourceGroup client: %+v", err) + } + configureFunc(cloudHSMClusterGetByResourceGroupClient.Client) + + cloudHSMClusterGetBySubscriptionClient, err := cloudhsmclustergetbysubscription.NewCloudHSMClusterGetBySubscriptionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudHSMClusterGetBySubscription client: %+v", err) + } + configureFunc(cloudHSMClusterGetBySubscriptionClient.Client) + + cloudHSMClusterGetClient, err := cloudhsmclusterget.NewCloudHSMClusterGetClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudHSMClusterGet client: %+v", err) + } + configureFunc(cloudHSMClusterGetClient.Client) + + cloudHSMClusterPrivateEndpointConnectionsGetClient, err := cloudhsmclusterprivateendpointconnectionsget.NewCloudHSMClusterPrivateEndpointConnectionsGetClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudHSMClusterPrivateEndpointConnectionsGet client: %+v", err) + } + configureFunc(cloudHSMClusterPrivateEndpointConnectionsGetClient.Client) + + cloudHSMClusterPrivateEndpointCreateClient, err := cloudhsmclusterprivateendpointcreate.NewCloudHSMClusterPrivateEndpointCreateClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudHSMClusterPrivateEndpointCreate client: %+v", err) + } + configureFunc(cloudHSMClusterPrivateEndpointCreateClient.Client) + + cloudHSMClusterPrivateEndpointDeleteClient, err := cloudhsmclusterprivateendpointdelete.NewCloudHSMClusterPrivateEndpointDeleteClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudHSMClusterPrivateEndpointDelete client: %+v", err) + } + configureFunc(cloudHSMClusterPrivateEndpointDeleteClient.Client) + + cloudHSMClusterPrivateEndpointGetClient, err := cloudhsmclusterprivateendpointget.NewCloudHSMClusterPrivateEndpointGetClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudHSMClusterPrivateEndpointGet client: %+v", err) + } + configureFunc(cloudHSMClusterPrivateEndpointGetClient.Client) + + cloudHSMClusterPrivateLinkGetClient, err := cloudhsmclusterprivatelinkget.NewCloudHSMClusterPrivateLinkGetClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudHSMClusterPrivateLinkGet client: %+v", err) + } + configureFunc(cloudHSMClusterPrivateLinkGetClient.Client) + + cloudHSMClusterUpdateClient, err := cloudhsmclusterupdate.NewCloudHSMClusterUpdateClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudHSMClusterUpdate client: %+v", err) + } + configureFunc(cloudHSMClusterUpdateClient.Client) + + cloudHSMClusterValidateBackupPropertiesClient, err := cloudhsmclustervalidatebackupproperties.NewCloudHSMClusterValidateBackupPropertiesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudHSMClusterValidateBackupProperties client: %+v", err) + } + configureFunc(cloudHSMClusterValidateBackupPropertiesClient.Client) + + cloudHSMClustersBackupOperationStatusGetClient, err := cloudhsmclustersbackupoperationstatusget.NewCloudHSMClustersBackupOperationStatusGetClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudHSMClustersBackupOperationStatusGet client: %+v", err) + } + configureFunc(cloudHSMClustersBackupOperationStatusGetClient.Client) + + cloudHSMClustersRestoreOperationCreateClient, err := cloudhsmclustersrestoreoperationcreate.NewCloudHSMClustersRestoreOperationCreateClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudHSMClustersRestoreOperationCreate client: %+v", err) + } + configureFunc(cloudHSMClustersRestoreOperationCreateClient.Client) + + dedicatedHsmsClient, err := dedicatedhsms.NewDedicatedHsmsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DedicatedHsms client: %+v", err) + } + configureFunc(dedicatedHsmsClient.Client) + + returnsRestoreOperationStatusClient, err := returnsrestoreoperationstatus.NewReturnsRestoreOperationStatusClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReturnsRestoreOperationStatus client: %+v", err) + } + configureFunc(returnsRestoreOperationStatusClient.Client) + + validateCloudHSMClusterRestorePropertiesClient, err := validatecloudhsmclusterrestoreproperties.NewValidateCloudHSMClusterRestorePropertiesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ValidateCloudHSMClusterRestoreProperties client: %+v", err) + } + configureFunc(validateCloudHSMClusterRestorePropertiesClient.Client) + + return &Client{ + CloudHSMClusterBackupCreate: cloudHSMClusterBackupCreateClient, + CloudHSMClusterCreateOrUpdate: cloudHSMClusterCreateOrUpdateClient, + CloudHSMClusterDelete: cloudHSMClusterDeleteClient, + CloudHSMClusterGet: cloudHSMClusterGetClient, + CloudHSMClusterGetByResourceGroup: cloudHSMClusterGetByResourceGroupClient, + CloudHSMClusterGetBySubscription: cloudHSMClusterGetBySubscriptionClient, + CloudHSMClusterPrivateEndpointConnectionsGet: cloudHSMClusterPrivateEndpointConnectionsGetClient, + CloudHSMClusterPrivateEndpointCreate: cloudHSMClusterPrivateEndpointCreateClient, + CloudHSMClusterPrivateEndpointDelete: cloudHSMClusterPrivateEndpointDeleteClient, + CloudHSMClusterPrivateEndpointGet: cloudHSMClusterPrivateEndpointGetClient, + CloudHSMClusterPrivateLinkGet: cloudHSMClusterPrivateLinkGetClient, + CloudHSMClusterUpdate: cloudHSMClusterUpdateClient, + CloudHSMClusterValidateBackupProperties: cloudHSMClusterValidateBackupPropertiesClient, + CloudHSMClustersBackupOperationStatusGet: cloudHSMClustersBackupOperationStatusGetClient, + CloudHSMClustersRestoreOperationCreate: cloudHSMClustersRestoreOperationCreateClient, + DedicatedHsms: dedicatedHsmsClient, + ReturnsRestoreOperationStatus: returnsRestoreOperationStatusClient, + ValidateCloudHSMClusterRestoreProperties: validateCloudHSMClusterRestorePropertiesClient, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/README.md b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/README.md new file mode 100644 index 00000000000..538a2efa4b4 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate` Documentation + +The `cloudhsmclusterbackupcreate` SDK allows for interaction with Azure Resource Manager `hardwaresecuritymodules` (API Version `2025-03-31`). + +This readme covers example usages, but further information on [using this SDK can be 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/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate" +``` + + +### Client Initialization + +```go +client := cloudhsmclusterbackupcreate.NewCloudHSMClusterBackupCreateClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CloudHSMClusterBackupCreateClient.CloudHsmClustersBackup` + +```go +ctx := context.TODO() +id := cloudhsmclusterbackupcreate.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +payload := cloudhsmclusterbackupcreate.BackupRestoreRequestBaseProperties{ + // ... +} + + +if err := client.CloudHsmClustersBackupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/client.go new file mode 100644 index 00000000000..d8678d468ec --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/client.go @@ -0,0 +1,26 @@ +package cloudhsmclusterbackupcreate + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHSMClusterBackupCreateClient struct { + Client *resourcemanager.Client +} + +func NewCloudHSMClusterBackupCreateClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudHSMClusterBackupCreateClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cloudhsmclusterbackupcreate", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudHSMClusterBackupCreateClient: %+v", err) + } + + return &CloudHSMClusterBackupCreateClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/constants.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/constants.go new file mode 100644 index 00000000000..c7a2ce54275 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/constants.go @@ -0,0 +1,57 @@ +package cloudhsmclusterbackupcreate + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRestoreOperationStatus string + +const ( + BackupRestoreOperationStatusCancelled BackupRestoreOperationStatus = "Cancelled" + BackupRestoreOperationStatusFailed BackupRestoreOperationStatus = "Failed" + BackupRestoreOperationStatusInProgress BackupRestoreOperationStatus = "InProgress" + BackupRestoreOperationStatusSucceeded BackupRestoreOperationStatus = "Succeeded" +) + +func PossibleValuesForBackupRestoreOperationStatus() []string { + return []string{ + string(BackupRestoreOperationStatusCancelled), + string(BackupRestoreOperationStatusFailed), + string(BackupRestoreOperationStatusInProgress), + string(BackupRestoreOperationStatusSucceeded), + } +} + +func (s *BackupRestoreOperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupRestoreOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupRestoreOperationStatus(input string) (*BackupRestoreOperationStatus, error) { + vals := map[string]BackupRestoreOperationStatus{ + "cancelled": BackupRestoreOperationStatusCancelled, + "failed": BackupRestoreOperationStatusFailed, + "inprogress": BackupRestoreOperationStatusInProgress, + "succeeded": BackupRestoreOperationStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupRestoreOperationStatus(input) + return &out, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/id_cloudhsmcluster.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/id_cloudhsmcluster.go new file mode 100644 index 00000000000..0a5a44dd33b --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/id_cloudhsmcluster.go @@ -0,0 +1,130 @@ +package cloudhsmclusterbackupcreate + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CloudHsmClusterId{}) +} + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +// CloudHsmClusterId is a struct representing the Resource ID for a Cloud Hsm Cluster +type CloudHsmClusterId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string +} + +// NewCloudHsmClusterID returns a new CloudHsmClusterId struct +func NewCloudHsmClusterID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string) CloudHsmClusterId { + return CloudHsmClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + } +} + +// ParseCloudHsmClusterID parses 'input' into a CloudHsmClusterId +func ParseCloudHsmClusterID(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudHsmClusterIDInsensitively parses 'input' case-insensitively into a CloudHsmClusterId +// note: this method should only be used for API response data and not user input +func ParseCloudHsmClusterIDInsensitively(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudHsmClusterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + return nil +} + +// ValidateCloudHsmClusterID checks that 'input' can be parsed as a Cloud Hsm Cluster ID +func ValidateCloudHsmClusterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCloudHsmClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud Hsm Cluster ID +func (id CloudHsmClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + } +} + +// String returns a human-readable description of this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + } + return fmt.Sprintf("Cloud Hsm Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/id_cloudhsmcluster_test.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/id_cloudhsmcluster_test.go new file mode 100644 index 00000000000..f4b17073726 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/id_cloudhsmcluster_test.go @@ -0,0 +1,282 @@ +package cloudhsmclusterbackupcreate + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +func TestNewCloudHsmClusterID(t *testing.T) { + id := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudHsmClusterName != "cloudHsmClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudHsmClusterName'", id.CloudHsmClusterName, "cloudHsmClusterName") + } +} + +func TestFormatCloudHsmClusterID(t *testing.T) { + actual := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCloudHsmClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestParseCloudHsmClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudHsmClusterName: "cLoUdHsMcLuStErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestSegmentsForCloudHsmClusterId(t *testing.T) { + segments := CloudHsmClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CloudHsmClusterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/method_cloudhsmclustersbackup.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/method_cloudhsmclustersbackup.go new file mode 100644 index 00000000000..01e7dc47061 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/method_cloudhsmclustersbackup.go @@ -0,0 +1,75 @@ +package cloudhsmclusterbackupcreate + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClustersBackupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BackupResult +} + +// CloudHsmClustersBackup ... +func (c CloudHSMClusterBackupCreateClient) CloudHsmClustersBackup(ctx context.Context, id CloudHsmClusterId, input BackupRestoreRequestBaseProperties) (result CloudHsmClustersBackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/backup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CloudHsmClustersBackupThenPoll performs CloudHsmClustersBackup then polls until it's completed +func (c CloudHSMClusterBackupCreateClient) CloudHsmClustersBackupThenPoll(ctx context.Context, id CloudHsmClusterId, input BackupRestoreRequestBaseProperties) error { + result, err := c.CloudHsmClustersBackup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CloudHsmClustersBackup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CloudHsmClustersBackup: %+v", err) + } + + return nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/model_backuprestorerequestbaseproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/model_backuprestorerequestbaseproperties.go new file mode 100644 index 00000000000..a78c2524217 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/model_backuprestorerequestbaseproperties.go @@ -0,0 +1,9 @@ +package cloudhsmclusterbackupcreate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRestoreRequestBaseProperties struct { + AzureStorageBlobContainerUri string `json:"azureStorageBlobContainerUri"` + Token *string `json:"token,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/model_backupresult.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/model_backupresult.go new file mode 100644 index 00000000000..6bc719e53d5 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/model_backupresult.go @@ -0,0 +1,8 @@ +package cloudhsmclusterbackupcreate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResult struct { + Properties *BackupResultProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/model_backupresultproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/model_backupresultproperties.go new file mode 100644 index 00000000000..c197e5ad1ba --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/model_backupresultproperties.go @@ -0,0 +1,45 @@ +package cloudhsmclusterbackupcreate + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResultProperties struct { + AzureStorageBlobContainerUri *string `json:"azureStorageBlobContainerUri,omitempty"` + BackupId *string `json:"backupId,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + JobId *string `json:"jobId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *BackupRestoreOperationStatus `json:"status,omitempty"` + StatusDetails *string `json:"statusDetails,omitempty"` +} + +func (o *BackupResultProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupResultProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *BackupResultProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupResultProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/model_erroradditionalinfo.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/model_erroradditionalinfo.go new file mode 100644 index 00000000000..a1dac1f5a4c --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package cloudhsmclusterbackupcreate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/model_errordetail.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/model_errordetail.go new file mode 100644 index 00000000000..d0bb18ab965 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/model_errordetail.go @@ -0,0 +1,12 @@ +package cloudhsmclusterbackupcreate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/version.go new file mode 100644 index 00000000000..ba132450f97 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterbackupcreate/version.go @@ -0,0 +1,10 @@ +package cloudhsmclusterbackupcreate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cloudhsmclusterbackupcreate/2025-03-31" +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/README.md b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/README.md new file mode 100644 index 00000000000..eda1db20c96 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate` Documentation + +The `cloudhsmclustercreateorupdate` SDK allows for interaction with Azure Resource Manager `hardwaresecuritymodules` (API Version `2025-03-31`). + +This readme covers example usages, but further information on [using this SDK can be 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/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate" +``` + + +### Client Initialization + +```go +client := cloudhsmclustercreateorupdate.NewCloudHSMClusterCreateOrUpdateClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CloudHSMClusterCreateOrUpdateClient.CloudHsmClustersCreateOrUpdate` + +```go +ctx := context.TODO() +id := cloudhsmclustercreateorupdate.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +payload := cloudhsmclustercreateorupdate.CloudHsmCluster{ + // ... +} + + +if err := client.CloudHsmClustersCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/client.go new file mode 100644 index 00000000000..d8cad6e6433 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/client.go @@ -0,0 +1,26 @@ +package cloudhsmclustercreateorupdate + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHSMClusterCreateOrUpdateClient struct { + Client *resourcemanager.Client +} + +func NewCloudHSMClusterCreateOrUpdateClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudHSMClusterCreateOrUpdateClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cloudhsmclustercreateorupdate", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudHSMClusterCreateOrUpdateClient: %+v", err) + } + + return &CloudHSMClusterCreateOrUpdateClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/constants.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/constants.go new file mode 100644 index 00000000000..a6a14853954 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/constants.go @@ -0,0 +1,377 @@ +package cloudhsmclustercreateorupdate + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActivationState string + +const ( + ActivationStateActive ActivationState = "Active" + ActivationStateFailed ActivationState = "Failed" + ActivationStateNotActivated ActivationState = "NotActivated" + ActivationStateNotDefined ActivationState = "NotDefined" + ActivationStateUnknown ActivationState = "Unknown" +) + +func PossibleValuesForActivationState() []string { + return []string{ + string(ActivationStateActive), + string(ActivationStateFailed), + string(ActivationStateNotActivated), + string(ActivationStateNotDefined), + string(ActivationStateUnknown), + } +} + +func (s *ActivationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActivationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseActivationState(input string) (*ActivationState, error) { + vals := map[string]ActivationState{ + "active": ActivationStateActive, + "failed": ActivationStateFailed, + "notactivated": ActivationStateNotActivated, + "notdefined": ActivationStateNotDefined, + "unknown": ActivationStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ActivationState(input) + return &out, nil +} + +type AutoGeneratedDomainNameLabelScope string + +const ( + AutoGeneratedDomainNameLabelScopeNoReuse AutoGeneratedDomainNameLabelScope = "NoReuse" + AutoGeneratedDomainNameLabelScopeResourceGroupReuse AutoGeneratedDomainNameLabelScope = "ResourceGroupReuse" + AutoGeneratedDomainNameLabelScopeSubscriptionReuse AutoGeneratedDomainNameLabelScope = "SubscriptionReuse" + AutoGeneratedDomainNameLabelScopeTenantReuse AutoGeneratedDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForAutoGeneratedDomainNameLabelScope() []string { + return []string{ + string(AutoGeneratedDomainNameLabelScopeNoReuse), + string(AutoGeneratedDomainNameLabelScopeResourceGroupReuse), + string(AutoGeneratedDomainNameLabelScopeSubscriptionReuse), + string(AutoGeneratedDomainNameLabelScopeTenantReuse), + } +} + +func (s *AutoGeneratedDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoGeneratedDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoGeneratedDomainNameLabelScope(input string) (*AutoGeneratedDomainNameLabelScope, error) { + vals := map[string]AutoGeneratedDomainNameLabelScope{ + "noreuse": AutoGeneratedDomainNameLabelScopeNoReuse, + "resourcegroupreuse": AutoGeneratedDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": AutoGeneratedDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": AutoGeneratedDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoGeneratedDomainNameLabelScope(input) + return &out, nil +} + +type CloudHsmClusterSkuFamily string + +const ( + CloudHsmClusterSkuFamilyB CloudHsmClusterSkuFamily = "B" +) + +func PossibleValuesForCloudHsmClusterSkuFamily() []string { + return []string{ + string(CloudHsmClusterSkuFamilyB), + } +} + +func (s *CloudHsmClusterSkuFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudHsmClusterSkuFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudHsmClusterSkuFamily(input string) (*CloudHsmClusterSkuFamily, error) { + vals := map[string]CloudHsmClusterSkuFamily{ + "b": CloudHsmClusterSkuFamilyB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudHsmClusterSkuFamily(input) + return &out, nil +} + +type CloudHsmClusterSkuName string + +const ( + CloudHsmClusterSkuNameStandardBOne CloudHsmClusterSkuName = "Standard_B1" + CloudHsmClusterSkuNameStandardBOneZero CloudHsmClusterSkuName = "Standard B10" +) + +func PossibleValuesForCloudHsmClusterSkuName() []string { + return []string{ + string(CloudHsmClusterSkuNameStandardBOne), + string(CloudHsmClusterSkuNameStandardBOneZero), + } +} + +func (s *CloudHsmClusterSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudHsmClusterSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudHsmClusterSkuName(input string) (*CloudHsmClusterSkuName, error) { + vals := map[string]CloudHsmClusterSkuName{ + "standard_b1": CloudHsmClusterSkuNameStandardBOne, + "standard b10": CloudHsmClusterSkuNameStandardBOneZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudHsmClusterSkuName(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCanceled PrivateEndpointConnectionProvisioningState = "Canceled" + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateInternalError PrivateEndpointConnectionProvisioningState = "InternalError" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" + PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCanceled), + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateInternalError), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + string(PrivateEndpointConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "canceled": PrivateEndpointConnectionProvisioningStateCanceled, + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "internalerror": PrivateEndpointConnectionProvisioningStateInternalError, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + "updating": PrivateEndpointConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + } +} + +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/id_cloudhsmcluster.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/id_cloudhsmcluster.go new file mode 100644 index 00000000000..9423288abc4 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/id_cloudhsmcluster.go @@ -0,0 +1,130 @@ +package cloudhsmclustercreateorupdate + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CloudHsmClusterId{}) +} + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +// CloudHsmClusterId is a struct representing the Resource ID for a Cloud Hsm Cluster +type CloudHsmClusterId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string +} + +// NewCloudHsmClusterID returns a new CloudHsmClusterId struct +func NewCloudHsmClusterID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string) CloudHsmClusterId { + return CloudHsmClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + } +} + +// ParseCloudHsmClusterID parses 'input' into a CloudHsmClusterId +func ParseCloudHsmClusterID(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudHsmClusterIDInsensitively parses 'input' case-insensitively into a CloudHsmClusterId +// note: this method should only be used for API response data and not user input +func ParseCloudHsmClusterIDInsensitively(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudHsmClusterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + return nil +} + +// ValidateCloudHsmClusterID checks that 'input' can be parsed as a Cloud Hsm Cluster ID +func ValidateCloudHsmClusterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCloudHsmClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud Hsm Cluster ID +func (id CloudHsmClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + } +} + +// String returns a human-readable description of this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + } + return fmt.Sprintf("Cloud Hsm Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/id_cloudhsmcluster_test.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/id_cloudhsmcluster_test.go new file mode 100644 index 00000000000..f0bad585bd4 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/id_cloudhsmcluster_test.go @@ -0,0 +1,282 @@ +package cloudhsmclustercreateorupdate + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +func TestNewCloudHsmClusterID(t *testing.T) { + id := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudHsmClusterName != "cloudHsmClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudHsmClusterName'", id.CloudHsmClusterName, "cloudHsmClusterName") + } +} + +func TestFormatCloudHsmClusterID(t *testing.T) { + actual := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCloudHsmClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestParseCloudHsmClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudHsmClusterName: "cLoUdHsMcLuStErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestSegmentsForCloudHsmClusterId(t *testing.T) { + segments := CloudHsmClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CloudHsmClusterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/method_cloudhsmclusterscreateorupdate.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/method_cloudhsmclusterscreateorupdate.go new file mode 100644 index 00000000000..5bf007f0fef --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/method_cloudhsmclusterscreateorupdate.go @@ -0,0 +1,75 @@ +package cloudhsmclustercreateorupdate + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClustersCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CloudHsmCluster +} + +// CloudHsmClustersCreateOrUpdate ... +func (c CloudHSMClusterCreateOrUpdateClient) CloudHsmClustersCreateOrUpdate(ctx context.Context, id CloudHsmClusterId, input CloudHsmCluster) (result CloudHsmClustersCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CloudHsmClustersCreateOrUpdateThenPoll performs CloudHsmClustersCreateOrUpdate then polls until it's completed +func (c CloudHSMClusterCreateOrUpdateClient) CloudHsmClustersCreateOrUpdateThenPoll(ctx context.Context, id CloudHsmClusterId, input CloudHsmCluster) error { + result, err := c.CloudHsmClustersCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CloudHsmClustersCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CloudHsmClustersCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_cloudhsmcluster.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_cloudhsmcluster.go new file mode 100644 index 00000000000..9b89e674f82 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_cloudhsmcluster.go @@ -0,0 +1,21 @@ +package cloudhsmclustercreateorupdate + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmCluster struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CloudHsmClusterProperties `json:"properties,omitempty"` + Sku *CloudHsmClusterSku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_cloudhsmclusterproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_cloudhsmclusterproperties.go new file mode 100644 index 00000000000..dd3c40120f0 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_cloudhsmclusterproperties.go @@ -0,0 +1,14 @@ +package cloudhsmclustercreateorupdate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterProperties struct { + ActivationState *ActivationState `json:"activationState,omitempty"` + AutoGeneratedDomainNameLabelScope *AutoGeneratedDomainNameLabelScope `json:"autoGeneratedDomainNameLabelScope,omitempty"` + Hsms *[]CloudHsmProperties `json:"hsms,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + StatusMessage *string `json:"statusMessage,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_cloudhsmclustersku.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_cloudhsmclustersku.go new file mode 100644 index 00000000000..71a5111d7df --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_cloudhsmclustersku.go @@ -0,0 +1,10 @@ +package cloudhsmclustercreateorupdate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterSku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family CloudHsmClusterSkuFamily `json:"family"` + Name CloudHsmClusterSkuName `json:"name"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_cloudhsmproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_cloudhsmproperties.go new file mode 100644 index 00000000000..f112657eb04 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_cloudhsmproperties.go @@ -0,0 +1,10 @@ +package cloudhsmclustercreateorupdate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmProperties struct { + Fqdn *string `json:"fqdn,omitempty"` + State *string `json:"state,omitempty"` + StateMessage *string `json:"stateMessage,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_privateendpoint.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_privateendpoint.go new file mode 100644 index 00000000000..252f15bb815 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_privateendpoint.go @@ -0,0 +1,8 @@ +package cloudhsmclustercreateorupdate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_privateendpointconnection.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_privateendpointconnection.go new file mode 100644 index 00000000000..61e3d64ca48 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_privateendpointconnection.go @@ -0,0 +1,17 @@ +package cloudhsmclustercreateorupdate + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_privateendpointconnectionproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..8691d7adfaf --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package cloudhsmclustercreateorupdate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_privatelinkserviceconnectionstate.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..39692ee5ede --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package cloudhsmclustercreateorupdate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/version.go new file mode 100644 index 00000000000..e5aa7bc3b07 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustercreateorupdate/version.go @@ -0,0 +1,10 @@ +package cloudhsmclustercreateorupdate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cloudhsmclustercreateorupdate/2025-03-31" +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterdelete/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterdelete/client.go new file mode 100644 index 00000000000..48c6996630f --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterdelete/client.go @@ -0,0 +1,26 @@ +package cloudhsmclusterdelete + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHSMClusterDeleteClient struct { + Client *resourcemanager.Client +} + +func NewCloudHSMClusterDeleteClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudHSMClusterDeleteClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cloudhsmclusterdelete", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudHSMClusterDeleteClient: %+v", err) + } + + return &CloudHSMClusterDeleteClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterdelete/id_cloudhsmcluster.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterdelete/id_cloudhsmcluster.go new file mode 100644 index 00000000000..f0d2f0c96ff --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterdelete/id_cloudhsmcluster.go @@ -0,0 +1,130 @@ +package cloudhsmclusterdelete + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CloudHsmClusterId{}) +} + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +// CloudHsmClusterId is a struct representing the Resource ID for a Cloud Hsm Cluster +type CloudHsmClusterId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string +} + +// NewCloudHsmClusterID returns a new CloudHsmClusterId struct +func NewCloudHsmClusterID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string) CloudHsmClusterId { + return CloudHsmClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + } +} + +// ParseCloudHsmClusterID parses 'input' into a CloudHsmClusterId +func ParseCloudHsmClusterID(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudHsmClusterIDInsensitively parses 'input' case-insensitively into a CloudHsmClusterId +// note: this method should only be used for API response data and not user input +func ParseCloudHsmClusterIDInsensitively(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudHsmClusterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + return nil +} + +// ValidateCloudHsmClusterID checks that 'input' can be parsed as a Cloud Hsm Cluster ID +func ValidateCloudHsmClusterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCloudHsmClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud Hsm Cluster ID +func (id CloudHsmClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + } +} + +// String returns a human-readable description of this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + } + return fmt.Sprintf("Cloud Hsm Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterdelete/id_cloudhsmcluster_test.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterdelete/id_cloudhsmcluster_test.go new file mode 100644 index 00000000000..ee03ff26253 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterdelete/id_cloudhsmcluster_test.go @@ -0,0 +1,282 @@ +package cloudhsmclusterdelete + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +func TestNewCloudHsmClusterID(t *testing.T) { + id := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudHsmClusterName != "cloudHsmClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudHsmClusterName'", id.CloudHsmClusterName, "cloudHsmClusterName") + } +} + +func TestFormatCloudHsmClusterID(t *testing.T) { + actual := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCloudHsmClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestParseCloudHsmClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudHsmClusterName: "cLoUdHsMcLuStErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestSegmentsForCloudHsmClusterId(t *testing.T) { + segments := CloudHsmClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CloudHsmClusterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterdelete/method_cloudhsmclustersdelete.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterdelete/method_cloudhsmclustersdelete.go new file mode 100644 index 00000000000..a755281a49f --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterdelete/method_cloudhsmclustersdelete.go @@ -0,0 +1,70 @@ +package cloudhsmclusterdelete + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClustersDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CloudHsmClustersDelete ... +func (c CloudHSMClusterDeleteClient) CloudHsmClustersDelete(ctx context.Context, id CloudHsmClusterId) (result CloudHsmClustersDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CloudHsmClustersDeleteThenPoll performs CloudHsmClustersDelete then polls until it's completed +func (c CloudHSMClusterDeleteClient) CloudHsmClustersDeleteThenPoll(ctx context.Context, id CloudHsmClusterId) error { + result, err := c.CloudHsmClustersDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing CloudHsmClustersDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CloudHsmClustersDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterdelete/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterdelete/version.go new file mode 100644 index 00000000000..0988fad1c41 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterdelete/version.go @@ -0,0 +1,10 @@ +package cloudhsmclusterdelete + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cloudhsmclusterdelete/2025-03-31" +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/README.md b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/README.md new file mode 100644 index 00000000000..819658e20f5 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget` Documentation + +The `cloudhsmclusterget` SDK allows for interaction with Azure Resource Manager `hardwaresecuritymodules` (API Version `2025-03-31`). + +This readme covers example usages, but further information on [using this SDK can be 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/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget" +``` + + +### Client Initialization + +```go +client := cloudhsmclusterget.NewCloudHSMClusterGetClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CloudHSMClusterGetClient.CloudHsmClustersGet` + +```go +ctx := context.TODO() +id := cloudhsmclusterget.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +read, err := client.CloudHsmClustersGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/client.go new file mode 100644 index 00000000000..20cd6d5c48c --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/client.go @@ -0,0 +1,26 @@ +package cloudhsmclusterget + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHSMClusterGetClient struct { + Client *resourcemanager.Client +} + +func NewCloudHSMClusterGetClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudHSMClusterGetClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cloudhsmclusterget", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudHSMClusterGetClient: %+v", err) + } + + return &CloudHSMClusterGetClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/constants.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/constants.go new file mode 100644 index 00000000000..e872b388f43 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/constants.go @@ -0,0 +1,377 @@ +package cloudhsmclusterget + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActivationState string + +const ( + ActivationStateActive ActivationState = "Active" + ActivationStateFailed ActivationState = "Failed" + ActivationStateNotActivated ActivationState = "NotActivated" + ActivationStateNotDefined ActivationState = "NotDefined" + ActivationStateUnknown ActivationState = "Unknown" +) + +func PossibleValuesForActivationState() []string { + return []string{ + string(ActivationStateActive), + string(ActivationStateFailed), + string(ActivationStateNotActivated), + string(ActivationStateNotDefined), + string(ActivationStateUnknown), + } +} + +func (s *ActivationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActivationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseActivationState(input string) (*ActivationState, error) { + vals := map[string]ActivationState{ + "active": ActivationStateActive, + "failed": ActivationStateFailed, + "notactivated": ActivationStateNotActivated, + "notdefined": ActivationStateNotDefined, + "unknown": ActivationStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ActivationState(input) + return &out, nil +} + +type AutoGeneratedDomainNameLabelScope string + +const ( + AutoGeneratedDomainNameLabelScopeNoReuse AutoGeneratedDomainNameLabelScope = "NoReuse" + AutoGeneratedDomainNameLabelScopeResourceGroupReuse AutoGeneratedDomainNameLabelScope = "ResourceGroupReuse" + AutoGeneratedDomainNameLabelScopeSubscriptionReuse AutoGeneratedDomainNameLabelScope = "SubscriptionReuse" + AutoGeneratedDomainNameLabelScopeTenantReuse AutoGeneratedDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForAutoGeneratedDomainNameLabelScope() []string { + return []string{ + string(AutoGeneratedDomainNameLabelScopeNoReuse), + string(AutoGeneratedDomainNameLabelScopeResourceGroupReuse), + string(AutoGeneratedDomainNameLabelScopeSubscriptionReuse), + string(AutoGeneratedDomainNameLabelScopeTenantReuse), + } +} + +func (s *AutoGeneratedDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoGeneratedDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoGeneratedDomainNameLabelScope(input string) (*AutoGeneratedDomainNameLabelScope, error) { + vals := map[string]AutoGeneratedDomainNameLabelScope{ + "noreuse": AutoGeneratedDomainNameLabelScopeNoReuse, + "resourcegroupreuse": AutoGeneratedDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": AutoGeneratedDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": AutoGeneratedDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoGeneratedDomainNameLabelScope(input) + return &out, nil +} + +type CloudHsmClusterSkuFamily string + +const ( + CloudHsmClusterSkuFamilyB CloudHsmClusterSkuFamily = "B" +) + +func PossibleValuesForCloudHsmClusterSkuFamily() []string { + return []string{ + string(CloudHsmClusterSkuFamilyB), + } +} + +func (s *CloudHsmClusterSkuFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudHsmClusterSkuFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudHsmClusterSkuFamily(input string) (*CloudHsmClusterSkuFamily, error) { + vals := map[string]CloudHsmClusterSkuFamily{ + "b": CloudHsmClusterSkuFamilyB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudHsmClusterSkuFamily(input) + return &out, nil +} + +type CloudHsmClusterSkuName string + +const ( + CloudHsmClusterSkuNameStandardBOne CloudHsmClusterSkuName = "Standard_B1" + CloudHsmClusterSkuNameStandardBOneZero CloudHsmClusterSkuName = "Standard B10" +) + +func PossibleValuesForCloudHsmClusterSkuName() []string { + return []string{ + string(CloudHsmClusterSkuNameStandardBOne), + string(CloudHsmClusterSkuNameStandardBOneZero), + } +} + +func (s *CloudHsmClusterSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudHsmClusterSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudHsmClusterSkuName(input string) (*CloudHsmClusterSkuName, error) { + vals := map[string]CloudHsmClusterSkuName{ + "standard_b1": CloudHsmClusterSkuNameStandardBOne, + "standard b10": CloudHsmClusterSkuNameStandardBOneZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudHsmClusterSkuName(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCanceled PrivateEndpointConnectionProvisioningState = "Canceled" + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateInternalError PrivateEndpointConnectionProvisioningState = "InternalError" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" + PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCanceled), + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateInternalError), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + string(PrivateEndpointConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "canceled": PrivateEndpointConnectionProvisioningStateCanceled, + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "internalerror": PrivateEndpointConnectionProvisioningStateInternalError, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + "updating": PrivateEndpointConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + } +} + +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/id_cloudhsmcluster.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/id_cloudhsmcluster.go new file mode 100644 index 00000000000..98fd7436e7d --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/id_cloudhsmcluster.go @@ -0,0 +1,130 @@ +package cloudhsmclusterget + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CloudHsmClusterId{}) +} + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +// CloudHsmClusterId is a struct representing the Resource ID for a Cloud Hsm Cluster +type CloudHsmClusterId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string +} + +// NewCloudHsmClusterID returns a new CloudHsmClusterId struct +func NewCloudHsmClusterID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string) CloudHsmClusterId { + return CloudHsmClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + } +} + +// ParseCloudHsmClusterID parses 'input' into a CloudHsmClusterId +func ParseCloudHsmClusterID(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudHsmClusterIDInsensitively parses 'input' case-insensitively into a CloudHsmClusterId +// note: this method should only be used for API response data and not user input +func ParseCloudHsmClusterIDInsensitively(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudHsmClusterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + return nil +} + +// ValidateCloudHsmClusterID checks that 'input' can be parsed as a Cloud Hsm Cluster ID +func ValidateCloudHsmClusterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCloudHsmClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud Hsm Cluster ID +func (id CloudHsmClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + } +} + +// String returns a human-readable description of this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + } + return fmt.Sprintf("Cloud Hsm Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/id_cloudhsmcluster_test.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/id_cloudhsmcluster_test.go new file mode 100644 index 00000000000..181e2c9df83 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/id_cloudhsmcluster_test.go @@ -0,0 +1,282 @@ +package cloudhsmclusterget + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +func TestNewCloudHsmClusterID(t *testing.T) { + id := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudHsmClusterName != "cloudHsmClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudHsmClusterName'", id.CloudHsmClusterName, "cloudHsmClusterName") + } +} + +func TestFormatCloudHsmClusterID(t *testing.T) { + actual := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCloudHsmClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestParseCloudHsmClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudHsmClusterName: "cLoUdHsMcLuStErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestSegmentsForCloudHsmClusterId(t *testing.T) { + segments := CloudHsmClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CloudHsmClusterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/method_cloudhsmclustersget.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/method_cloudhsmclustersget.go new file mode 100644 index 00000000000..90a67557baf --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/method_cloudhsmclustersget.go @@ -0,0 +1,53 @@ +package cloudhsmclusterget + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClustersGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CloudHsmCluster +} + +// CloudHsmClustersGet ... +func (c CloudHSMClusterGetClient) CloudHsmClustersGet(ctx context.Context, id CloudHsmClusterId) (result CloudHsmClustersGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CloudHsmCluster + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_cloudhsmcluster.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_cloudhsmcluster.go new file mode 100644 index 00000000000..b085b103ec1 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_cloudhsmcluster.go @@ -0,0 +1,21 @@ +package cloudhsmclusterget + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmCluster struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CloudHsmClusterProperties `json:"properties,omitempty"` + Sku *CloudHsmClusterSku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_cloudhsmclusterproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_cloudhsmclusterproperties.go new file mode 100644 index 00000000000..f1fa8469fa8 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_cloudhsmclusterproperties.go @@ -0,0 +1,14 @@ +package cloudhsmclusterget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterProperties struct { + ActivationState *ActivationState `json:"activationState,omitempty"` + AutoGeneratedDomainNameLabelScope *AutoGeneratedDomainNameLabelScope `json:"autoGeneratedDomainNameLabelScope,omitempty"` + Hsms *[]CloudHsmProperties `json:"hsms,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + StatusMessage *string `json:"statusMessage,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_cloudhsmclustersku.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_cloudhsmclustersku.go new file mode 100644 index 00000000000..481b1d6b3a2 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_cloudhsmclustersku.go @@ -0,0 +1,10 @@ +package cloudhsmclusterget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterSku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family CloudHsmClusterSkuFamily `json:"family"` + Name CloudHsmClusterSkuName `json:"name"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_cloudhsmproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_cloudhsmproperties.go new file mode 100644 index 00000000000..57da66f705d --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_cloudhsmproperties.go @@ -0,0 +1,10 @@ +package cloudhsmclusterget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmProperties struct { + Fqdn *string `json:"fqdn,omitempty"` + State *string `json:"state,omitempty"` + StateMessage *string `json:"stateMessage,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_privateendpoint.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_privateendpoint.go new file mode 100644 index 00000000000..c185c1612f5 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_privateendpoint.go @@ -0,0 +1,8 @@ +package cloudhsmclusterget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_privateendpointconnection.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_privateendpointconnection.go new file mode 100644 index 00000000000..216284a149f --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_privateendpointconnection.go @@ -0,0 +1,17 @@ +package cloudhsmclusterget + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_privateendpointconnectionproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..75ffc2cf358 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package cloudhsmclusterget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_privatelinkserviceconnectionstate.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..8a710e79799 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package cloudhsmclusterget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/version.go new file mode 100644 index 00000000000..3ca3e2fc5ac --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterget/version.go @@ -0,0 +1,10 @@ +package cloudhsmclusterget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cloudhsmclusterget/2025-03-31" +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/README.md b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/README.md new file mode 100644 index 00000000000..0fa405d8a60 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/README.md @@ -0,0 +1,38 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup` Documentation + +The `cloudhsmclustergetbyresourcegroup` SDK allows for interaction with Azure Resource Manager `hardwaresecuritymodules` (API Version `2025-03-31`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup" +``` + + +### Client Initialization + +```go +client := cloudhsmclustergetbyresourcegroup.NewCloudHSMClusterGetByResourceGroupClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CloudHSMClusterGetByResourceGroupClient.CloudHsmClustersListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.CloudHsmClustersListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.CloudHsmClustersListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/client.go new file mode 100644 index 00000000000..bcaf3182c63 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/client.go @@ -0,0 +1,26 @@ +package cloudhsmclustergetbyresourcegroup + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHSMClusterGetByResourceGroupClient struct { + Client *resourcemanager.Client +} + +func NewCloudHSMClusterGetByResourceGroupClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudHSMClusterGetByResourceGroupClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cloudhsmclustergetbyresourcegroup", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudHSMClusterGetByResourceGroupClient: %+v", err) + } + + return &CloudHSMClusterGetByResourceGroupClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/constants.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/constants.go new file mode 100644 index 00000000000..f22cecc460e --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/constants.go @@ -0,0 +1,377 @@ +package cloudhsmclustergetbyresourcegroup + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActivationState string + +const ( + ActivationStateActive ActivationState = "Active" + ActivationStateFailed ActivationState = "Failed" + ActivationStateNotActivated ActivationState = "NotActivated" + ActivationStateNotDefined ActivationState = "NotDefined" + ActivationStateUnknown ActivationState = "Unknown" +) + +func PossibleValuesForActivationState() []string { + return []string{ + string(ActivationStateActive), + string(ActivationStateFailed), + string(ActivationStateNotActivated), + string(ActivationStateNotDefined), + string(ActivationStateUnknown), + } +} + +func (s *ActivationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActivationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseActivationState(input string) (*ActivationState, error) { + vals := map[string]ActivationState{ + "active": ActivationStateActive, + "failed": ActivationStateFailed, + "notactivated": ActivationStateNotActivated, + "notdefined": ActivationStateNotDefined, + "unknown": ActivationStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ActivationState(input) + return &out, nil +} + +type AutoGeneratedDomainNameLabelScope string + +const ( + AutoGeneratedDomainNameLabelScopeNoReuse AutoGeneratedDomainNameLabelScope = "NoReuse" + AutoGeneratedDomainNameLabelScopeResourceGroupReuse AutoGeneratedDomainNameLabelScope = "ResourceGroupReuse" + AutoGeneratedDomainNameLabelScopeSubscriptionReuse AutoGeneratedDomainNameLabelScope = "SubscriptionReuse" + AutoGeneratedDomainNameLabelScopeTenantReuse AutoGeneratedDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForAutoGeneratedDomainNameLabelScope() []string { + return []string{ + string(AutoGeneratedDomainNameLabelScopeNoReuse), + string(AutoGeneratedDomainNameLabelScopeResourceGroupReuse), + string(AutoGeneratedDomainNameLabelScopeSubscriptionReuse), + string(AutoGeneratedDomainNameLabelScopeTenantReuse), + } +} + +func (s *AutoGeneratedDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoGeneratedDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoGeneratedDomainNameLabelScope(input string) (*AutoGeneratedDomainNameLabelScope, error) { + vals := map[string]AutoGeneratedDomainNameLabelScope{ + "noreuse": AutoGeneratedDomainNameLabelScopeNoReuse, + "resourcegroupreuse": AutoGeneratedDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": AutoGeneratedDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": AutoGeneratedDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoGeneratedDomainNameLabelScope(input) + return &out, nil +} + +type CloudHsmClusterSkuFamily string + +const ( + CloudHsmClusterSkuFamilyB CloudHsmClusterSkuFamily = "B" +) + +func PossibleValuesForCloudHsmClusterSkuFamily() []string { + return []string{ + string(CloudHsmClusterSkuFamilyB), + } +} + +func (s *CloudHsmClusterSkuFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudHsmClusterSkuFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudHsmClusterSkuFamily(input string) (*CloudHsmClusterSkuFamily, error) { + vals := map[string]CloudHsmClusterSkuFamily{ + "b": CloudHsmClusterSkuFamilyB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudHsmClusterSkuFamily(input) + return &out, nil +} + +type CloudHsmClusterSkuName string + +const ( + CloudHsmClusterSkuNameStandardBOne CloudHsmClusterSkuName = "Standard_B1" + CloudHsmClusterSkuNameStandardBOneZero CloudHsmClusterSkuName = "Standard B10" +) + +func PossibleValuesForCloudHsmClusterSkuName() []string { + return []string{ + string(CloudHsmClusterSkuNameStandardBOne), + string(CloudHsmClusterSkuNameStandardBOneZero), + } +} + +func (s *CloudHsmClusterSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudHsmClusterSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudHsmClusterSkuName(input string) (*CloudHsmClusterSkuName, error) { + vals := map[string]CloudHsmClusterSkuName{ + "standard_b1": CloudHsmClusterSkuNameStandardBOne, + "standard b10": CloudHsmClusterSkuNameStandardBOneZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudHsmClusterSkuName(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCanceled PrivateEndpointConnectionProvisioningState = "Canceled" + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateInternalError PrivateEndpointConnectionProvisioningState = "InternalError" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" + PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCanceled), + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateInternalError), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + string(PrivateEndpointConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "canceled": PrivateEndpointConnectionProvisioningStateCanceled, + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "internalerror": PrivateEndpointConnectionProvisioningStateInternalError, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + "updating": PrivateEndpointConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + } +} + +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/method_cloudhsmclusterslistbyresourcegroup.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/method_cloudhsmclusterslistbyresourcegroup.go new file mode 100644 index 00000000000..3923f40f8be --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/method_cloudhsmclusterslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package cloudhsmclustergetbyresourcegroup + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClustersListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CloudHsmCluster +} + +type CloudHsmClustersListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []CloudHsmCluster +} + +type CloudHsmClustersListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *CloudHsmClustersListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// CloudHsmClustersListByResourceGroup ... +func (c CloudHSMClusterGetByResourceGroupClient) CloudHsmClustersListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result CloudHsmClustersListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &CloudHsmClustersListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CloudHsmCluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CloudHsmClustersListByResourceGroupComplete retrieves all the results into a single object +func (c CloudHSMClusterGetByResourceGroupClient) CloudHsmClustersListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (CloudHsmClustersListByResourceGroupCompleteResult, error) { + return c.CloudHsmClustersListByResourceGroupCompleteMatchingPredicate(ctx, id, CloudHsmClusterOperationPredicate{}) +} + +// CloudHsmClustersListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CloudHSMClusterGetByResourceGroupClient) CloudHsmClustersListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate CloudHsmClusterOperationPredicate) (result CloudHsmClustersListByResourceGroupCompleteResult, err error) { + items := make([]CloudHsmCluster, 0) + + resp, err := c.CloudHsmClustersListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = CloudHsmClustersListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_cloudhsmcluster.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_cloudhsmcluster.go new file mode 100644 index 00000000000..1d08ce05663 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_cloudhsmcluster.go @@ -0,0 +1,21 @@ +package cloudhsmclustergetbyresourcegroup + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmCluster struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CloudHsmClusterProperties `json:"properties,omitempty"` + Sku *CloudHsmClusterSku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_cloudhsmclusterproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_cloudhsmclusterproperties.go new file mode 100644 index 00000000000..8954cf4c15b --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_cloudhsmclusterproperties.go @@ -0,0 +1,14 @@ +package cloudhsmclustergetbyresourcegroup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterProperties struct { + ActivationState *ActivationState `json:"activationState,omitempty"` + AutoGeneratedDomainNameLabelScope *AutoGeneratedDomainNameLabelScope `json:"autoGeneratedDomainNameLabelScope,omitempty"` + Hsms *[]CloudHsmProperties `json:"hsms,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + StatusMessage *string `json:"statusMessage,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_cloudhsmclustersku.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_cloudhsmclustersku.go new file mode 100644 index 00000000000..6993859562a --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_cloudhsmclustersku.go @@ -0,0 +1,10 @@ +package cloudhsmclustergetbyresourcegroup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterSku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family CloudHsmClusterSkuFamily `json:"family"` + Name CloudHsmClusterSkuName `json:"name"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_cloudhsmproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_cloudhsmproperties.go new file mode 100644 index 00000000000..df510dd784f --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_cloudhsmproperties.go @@ -0,0 +1,10 @@ +package cloudhsmclustergetbyresourcegroup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmProperties struct { + Fqdn *string `json:"fqdn,omitempty"` + State *string `json:"state,omitempty"` + StateMessage *string `json:"stateMessage,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_privateendpoint.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_privateendpoint.go new file mode 100644 index 00000000000..c11159ae8fd --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_privateendpoint.go @@ -0,0 +1,8 @@ +package cloudhsmclustergetbyresourcegroup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_privateendpointconnection.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_privateendpointconnection.go new file mode 100644 index 00000000000..a9e22cb7e83 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_privateendpointconnection.go @@ -0,0 +1,17 @@ +package cloudhsmclustergetbyresourcegroup + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_privateendpointconnectionproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..f9f46236415 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package cloudhsmclustergetbyresourcegroup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_privatelinkserviceconnectionstate.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..83630d9f16e --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package cloudhsmclustergetbyresourcegroup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/predicates.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/predicates.go new file mode 100644 index 00000000000..a88c0d1ae4d --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/predicates.go @@ -0,0 +1,32 @@ +package cloudhsmclustergetbyresourcegroup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p CloudHsmClusterOperationPredicate) Matches(input CloudHsmCluster) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/version.go new file mode 100644 index 00000000000..bec6840c6a4 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbyresourcegroup/version.go @@ -0,0 +1,10 @@ +package cloudhsmclustergetbyresourcegroup + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cloudhsmclustergetbyresourcegroup/2025-03-31" +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/README.md b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/README.md new file mode 100644 index 00000000000..65c724f62ae --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/README.md @@ -0,0 +1,38 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription` Documentation + +The `cloudhsmclustergetbysubscription` SDK allows for interaction with Azure Resource Manager `hardwaresecuritymodules` (API Version `2025-03-31`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription" +``` + + +### Client Initialization + +```go +client := cloudhsmclustergetbysubscription.NewCloudHSMClusterGetBySubscriptionClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CloudHSMClusterGetBySubscriptionClient.CloudHsmClustersListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.CloudHsmClustersListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.CloudHsmClustersListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/client.go new file mode 100644 index 00000000000..350f5d79aca --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/client.go @@ -0,0 +1,26 @@ +package cloudhsmclustergetbysubscription + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHSMClusterGetBySubscriptionClient struct { + Client *resourcemanager.Client +} + +func NewCloudHSMClusterGetBySubscriptionClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudHSMClusterGetBySubscriptionClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cloudhsmclustergetbysubscription", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudHSMClusterGetBySubscriptionClient: %+v", err) + } + + return &CloudHSMClusterGetBySubscriptionClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/constants.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/constants.go new file mode 100644 index 00000000000..c239d30dc65 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/constants.go @@ -0,0 +1,377 @@ +package cloudhsmclustergetbysubscription + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActivationState string + +const ( + ActivationStateActive ActivationState = "Active" + ActivationStateFailed ActivationState = "Failed" + ActivationStateNotActivated ActivationState = "NotActivated" + ActivationStateNotDefined ActivationState = "NotDefined" + ActivationStateUnknown ActivationState = "Unknown" +) + +func PossibleValuesForActivationState() []string { + return []string{ + string(ActivationStateActive), + string(ActivationStateFailed), + string(ActivationStateNotActivated), + string(ActivationStateNotDefined), + string(ActivationStateUnknown), + } +} + +func (s *ActivationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActivationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseActivationState(input string) (*ActivationState, error) { + vals := map[string]ActivationState{ + "active": ActivationStateActive, + "failed": ActivationStateFailed, + "notactivated": ActivationStateNotActivated, + "notdefined": ActivationStateNotDefined, + "unknown": ActivationStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ActivationState(input) + return &out, nil +} + +type AutoGeneratedDomainNameLabelScope string + +const ( + AutoGeneratedDomainNameLabelScopeNoReuse AutoGeneratedDomainNameLabelScope = "NoReuse" + AutoGeneratedDomainNameLabelScopeResourceGroupReuse AutoGeneratedDomainNameLabelScope = "ResourceGroupReuse" + AutoGeneratedDomainNameLabelScopeSubscriptionReuse AutoGeneratedDomainNameLabelScope = "SubscriptionReuse" + AutoGeneratedDomainNameLabelScopeTenantReuse AutoGeneratedDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForAutoGeneratedDomainNameLabelScope() []string { + return []string{ + string(AutoGeneratedDomainNameLabelScopeNoReuse), + string(AutoGeneratedDomainNameLabelScopeResourceGroupReuse), + string(AutoGeneratedDomainNameLabelScopeSubscriptionReuse), + string(AutoGeneratedDomainNameLabelScopeTenantReuse), + } +} + +func (s *AutoGeneratedDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoGeneratedDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoGeneratedDomainNameLabelScope(input string) (*AutoGeneratedDomainNameLabelScope, error) { + vals := map[string]AutoGeneratedDomainNameLabelScope{ + "noreuse": AutoGeneratedDomainNameLabelScopeNoReuse, + "resourcegroupreuse": AutoGeneratedDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": AutoGeneratedDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": AutoGeneratedDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoGeneratedDomainNameLabelScope(input) + return &out, nil +} + +type CloudHsmClusterSkuFamily string + +const ( + CloudHsmClusterSkuFamilyB CloudHsmClusterSkuFamily = "B" +) + +func PossibleValuesForCloudHsmClusterSkuFamily() []string { + return []string{ + string(CloudHsmClusterSkuFamilyB), + } +} + +func (s *CloudHsmClusterSkuFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudHsmClusterSkuFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudHsmClusterSkuFamily(input string) (*CloudHsmClusterSkuFamily, error) { + vals := map[string]CloudHsmClusterSkuFamily{ + "b": CloudHsmClusterSkuFamilyB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudHsmClusterSkuFamily(input) + return &out, nil +} + +type CloudHsmClusterSkuName string + +const ( + CloudHsmClusterSkuNameStandardBOne CloudHsmClusterSkuName = "Standard_B1" + CloudHsmClusterSkuNameStandardBOneZero CloudHsmClusterSkuName = "Standard B10" +) + +func PossibleValuesForCloudHsmClusterSkuName() []string { + return []string{ + string(CloudHsmClusterSkuNameStandardBOne), + string(CloudHsmClusterSkuNameStandardBOneZero), + } +} + +func (s *CloudHsmClusterSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudHsmClusterSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudHsmClusterSkuName(input string) (*CloudHsmClusterSkuName, error) { + vals := map[string]CloudHsmClusterSkuName{ + "standard_b1": CloudHsmClusterSkuNameStandardBOne, + "standard b10": CloudHsmClusterSkuNameStandardBOneZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudHsmClusterSkuName(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCanceled PrivateEndpointConnectionProvisioningState = "Canceled" + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateInternalError PrivateEndpointConnectionProvisioningState = "InternalError" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" + PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCanceled), + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateInternalError), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + string(PrivateEndpointConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "canceled": PrivateEndpointConnectionProvisioningStateCanceled, + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "internalerror": PrivateEndpointConnectionProvisioningStateInternalError, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + "updating": PrivateEndpointConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + } +} + +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/method_cloudhsmclusterslistbysubscription.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/method_cloudhsmclusterslistbysubscription.go new file mode 100644 index 00000000000..be4d7e23f19 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/method_cloudhsmclusterslistbysubscription.go @@ -0,0 +1,106 @@ +package cloudhsmclustergetbysubscription + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClustersListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CloudHsmCluster +} + +type CloudHsmClustersListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []CloudHsmCluster +} + +type CloudHsmClustersListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *CloudHsmClustersListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// CloudHsmClustersListBySubscription ... +func (c CloudHSMClusterGetBySubscriptionClient) CloudHsmClustersListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result CloudHsmClustersListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &CloudHsmClustersListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CloudHsmCluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CloudHsmClustersListBySubscriptionComplete retrieves all the results into a single object +func (c CloudHSMClusterGetBySubscriptionClient) CloudHsmClustersListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (CloudHsmClustersListBySubscriptionCompleteResult, error) { + return c.CloudHsmClustersListBySubscriptionCompleteMatchingPredicate(ctx, id, CloudHsmClusterOperationPredicate{}) +} + +// CloudHsmClustersListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CloudHSMClusterGetBySubscriptionClient) CloudHsmClustersListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate CloudHsmClusterOperationPredicate) (result CloudHsmClustersListBySubscriptionCompleteResult, err error) { + items := make([]CloudHsmCluster, 0) + + resp, err := c.CloudHsmClustersListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = CloudHsmClustersListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_cloudhsmcluster.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_cloudhsmcluster.go new file mode 100644 index 00000000000..82474e1aa20 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_cloudhsmcluster.go @@ -0,0 +1,21 @@ +package cloudhsmclustergetbysubscription + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmCluster struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CloudHsmClusterProperties `json:"properties,omitempty"` + Sku *CloudHsmClusterSku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_cloudhsmclusterproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_cloudhsmclusterproperties.go new file mode 100644 index 00000000000..033fe576e09 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_cloudhsmclusterproperties.go @@ -0,0 +1,14 @@ +package cloudhsmclustergetbysubscription + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterProperties struct { + ActivationState *ActivationState `json:"activationState,omitempty"` + AutoGeneratedDomainNameLabelScope *AutoGeneratedDomainNameLabelScope `json:"autoGeneratedDomainNameLabelScope,omitempty"` + Hsms *[]CloudHsmProperties `json:"hsms,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + StatusMessage *string `json:"statusMessage,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_cloudhsmclustersku.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_cloudhsmclustersku.go new file mode 100644 index 00000000000..44de1fb5308 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_cloudhsmclustersku.go @@ -0,0 +1,10 @@ +package cloudhsmclustergetbysubscription + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterSku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family CloudHsmClusterSkuFamily `json:"family"` + Name CloudHsmClusterSkuName `json:"name"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_cloudhsmproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_cloudhsmproperties.go new file mode 100644 index 00000000000..cf33c2d86a6 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_cloudhsmproperties.go @@ -0,0 +1,10 @@ +package cloudhsmclustergetbysubscription + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmProperties struct { + Fqdn *string `json:"fqdn,omitempty"` + State *string `json:"state,omitempty"` + StateMessage *string `json:"stateMessage,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_privateendpoint.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_privateendpoint.go new file mode 100644 index 00000000000..e79f1a80c7e --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_privateendpoint.go @@ -0,0 +1,8 @@ +package cloudhsmclustergetbysubscription + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_privateendpointconnection.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_privateendpointconnection.go new file mode 100644 index 00000000000..ca0e471fb42 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_privateendpointconnection.go @@ -0,0 +1,17 @@ +package cloudhsmclustergetbysubscription + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_privateendpointconnectionproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..970ca66f57b --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package cloudhsmclustergetbysubscription + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_privatelinkserviceconnectionstate.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..5346078fb1e --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package cloudhsmclustergetbysubscription + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/predicates.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/predicates.go new file mode 100644 index 00000000000..8cd6e25d19e --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/predicates.go @@ -0,0 +1,32 @@ +package cloudhsmclustergetbysubscription + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p CloudHsmClusterOperationPredicate) Matches(input CloudHsmCluster) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/version.go new file mode 100644 index 00000000000..ec9be473c25 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustergetbysubscription/version.go @@ -0,0 +1,10 @@ +package cloudhsmclustergetbysubscription + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cloudhsmclustergetbysubscription/2025-03-31" +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/README.md b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/README.md new file mode 100644 index 00000000000..57988462cc6 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget` Documentation + +The `cloudhsmclusterprivateendpointconnectionsget` SDK allows for interaction with Azure Resource Manager `hardwaresecuritymodules` (API Version `2025-03-31`). + +This readme covers example usages, but further information on [using this SDK can be 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/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget" +``` + + +### Client Initialization + +```go +client := cloudhsmclusterprivateendpointconnectionsget.NewCloudHSMClusterPrivateEndpointConnectionsGetClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CloudHSMClusterPrivateEndpointConnectionsGetClient.PrivateEndpointConnectionsListByCloudHsmCluster` + +```go +ctx := context.TODO() +id := cloudhsmclusterprivateendpointconnectionsget.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +// alternatively `client.PrivateEndpointConnectionsListByCloudHsmCluster(ctx, id)` can be used to do batched pagination +items, err := client.PrivateEndpointConnectionsListByCloudHsmClusterComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/client.go new file mode 100644 index 00000000000..f0487ce8eab --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/client.go @@ -0,0 +1,26 @@ +package cloudhsmclusterprivateendpointconnectionsget + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHSMClusterPrivateEndpointConnectionsGetClient struct { + Client *resourcemanager.Client +} + +func NewCloudHSMClusterPrivateEndpointConnectionsGetClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudHSMClusterPrivateEndpointConnectionsGetClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cloudhsmclusterprivateendpointconnectionsget", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudHSMClusterPrivateEndpointConnectionsGetClient: %+v", err) + } + + return &CloudHSMClusterPrivateEndpointConnectionsGetClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/constants.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/constants.go new file mode 100644 index 00000000000..64942ac9aba --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/constants.go @@ -0,0 +1,110 @@ +package cloudhsmclusterprivateendpointconnectionsget + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCanceled PrivateEndpointConnectionProvisioningState = "Canceled" + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateInternalError PrivateEndpointConnectionProvisioningState = "InternalError" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" + PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCanceled), + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateInternalError), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + string(PrivateEndpointConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "canceled": PrivateEndpointConnectionProvisioningStateCanceled, + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "internalerror": PrivateEndpointConnectionProvisioningStateInternalError, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + "updating": PrivateEndpointConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/id_cloudhsmcluster.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/id_cloudhsmcluster.go new file mode 100644 index 00000000000..bb8f9293409 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/id_cloudhsmcluster.go @@ -0,0 +1,130 @@ +package cloudhsmclusterprivateendpointconnectionsget + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CloudHsmClusterId{}) +} + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +// CloudHsmClusterId is a struct representing the Resource ID for a Cloud Hsm Cluster +type CloudHsmClusterId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string +} + +// NewCloudHsmClusterID returns a new CloudHsmClusterId struct +func NewCloudHsmClusterID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string) CloudHsmClusterId { + return CloudHsmClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + } +} + +// ParseCloudHsmClusterID parses 'input' into a CloudHsmClusterId +func ParseCloudHsmClusterID(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudHsmClusterIDInsensitively parses 'input' case-insensitively into a CloudHsmClusterId +// note: this method should only be used for API response data and not user input +func ParseCloudHsmClusterIDInsensitively(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudHsmClusterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + return nil +} + +// ValidateCloudHsmClusterID checks that 'input' can be parsed as a Cloud Hsm Cluster ID +func ValidateCloudHsmClusterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCloudHsmClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud Hsm Cluster ID +func (id CloudHsmClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + } +} + +// String returns a human-readable description of this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + } + return fmt.Sprintf("Cloud Hsm Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/id_cloudhsmcluster_test.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/id_cloudhsmcluster_test.go new file mode 100644 index 00000000000..0b7ba19ac9c --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/id_cloudhsmcluster_test.go @@ -0,0 +1,282 @@ +package cloudhsmclusterprivateendpointconnectionsget + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +func TestNewCloudHsmClusterID(t *testing.T) { + id := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudHsmClusterName != "cloudHsmClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudHsmClusterName'", id.CloudHsmClusterName, "cloudHsmClusterName") + } +} + +func TestFormatCloudHsmClusterID(t *testing.T) { + actual := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCloudHsmClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestParseCloudHsmClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudHsmClusterName: "cLoUdHsMcLuStErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestSegmentsForCloudHsmClusterId(t *testing.T) { + segments := CloudHsmClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CloudHsmClusterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/method_privateendpointconnectionslistbycloudhsmcluster.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/method_privateendpointconnectionslistbycloudhsmcluster.go new file mode 100644 index 00000000000..1b4aff3f594 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/method_privateendpointconnectionslistbycloudhsmcluster.go @@ -0,0 +1,105 @@ +package cloudhsmclusterprivateendpointconnectionsget + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsListByCloudHsmClusterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpointConnection +} + +type PrivateEndpointConnectionsListByCloudHsmClusterCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateEndpointConnection +} + +type PrivateEndpointConnectionsListByCloudHsmClusterCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *PrivateEndpointConnectionsListByCloudHsmClusterCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// PrivateEndpointConnectionsListByCloudHsmCluster ... +func (c CloudHSMClusterPrivateEndpointConnectionsGetClient) PrivateEndpointConnectionsListByCloudHsmCluster(ctx context.Context, id CloudHsmClusterId) (result PrivateEndpointConnectionsListByCloudHsmClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &PrivateEndpointConnectionsListByCloudHsmClusterCustomPager{}, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateEndpointConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// PrivateEndpointConnectionsListByCloudHsmClusterComplete retrieves all the results into a single object +func (c CloudHSMClusterPrivateEndpointConnectionsGetClient) PrivateEndpointConnectionsListByCloudHsmClusterComplete(ctx context.Context, id CloudHsmClusterId) (PrivateEndpointConnectionsListByCloudHsmClusterCompleteResult, error) { + return c.PrivateEndpointConnectionsListByCloudHsmClusterCompleteMatchingPredicate(ctx, id, PrivateEndpointConnectionOperationPredicate{}) +} + +// PrivateEndpointConnectionsListByCloudHsmClusterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CloudHSMClusterPrivateEndpointConnectionsGetClient) PrivateEndpointConnectionsListByCloudHsmClusterCompleteMatchingPredicate(ctx context.Context, id CloudHsmClusterId, predicate PrivateEndpointConnectionOperationPredicate) (result PrivateEndpointConnectionsListByCloudHsmClusterCompleteResult, err error) { + items := make([]PrivateEndpointConnection, 0) + + resp, err := c.PrivateEndpointConnectionsListByCloudHsmCluster(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = PrivateEndpointConnectionsListByCloudHsmClusterCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/model_privateendpoint.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/model_privateendpoint.go new file mode 100644 index 00000000000..df1a4436f65 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/model_privateendpoint.go @@ -0,0 +1,8 @@ +package cloudhsmclusterprivateendpointconnectionsget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/model_privateendpointconnection.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/model_privateendpointconnection.go new file mode 100644 index 00000000000..80b84ee5483 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/model_privateendpointconnection.go @@ -0,0 +1,17 @@ +package cloudhsmclusterprivateendpointconnectionsget + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/model_privateendpointconnectionproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..54dda858028 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package cloudhsmclusterprivateendpointconnectionsget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/model_privatelinkserviceconnectionstate.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..1042e8b9b36 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package cloudhsmclusterprivateendpointconnectionsget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/predicates.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/predicates.go new file mode 100644 index 00000000000..a72c471fdd4 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/predicates.go @@ -0,0 +1,32 @@ +package cloudhsmclusterprivateendpointconnectionsget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p PrivateEndpointConnectionOperationPredicate) Matches(input PrivateEndpointConnection) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/version.go new file mode 100644 index 00000000000..fcda74e0c13 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointconnectionsget/version.go @@ -0,0 +1,10 @@ +package cloudhsmclusterprivateendpointconnectionsget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cloudhsmclusterprivateendpointconnectionsget/2025-03-31" +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/README.md b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/README.md new file mode 100644 index 00000000000..d2daa9b562c --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate` Documentation + +The `cloudhsmclusterprivateendpointcreate` SDK allows for interaction with Azure Resource Manager `hardwaresecuritymodules` (API Version `2025-03-31`). + +This readme covers example usages, but further information on [using this SDK can be 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/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate" +``` + + +### Client Initialization + +```go +client := cloudhsmclusterprivateendpointcreate.NewCloudHSMClusterPrivateEndpointCreateClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CloudHSMClusterPrivateEndpointCreateClient.CloudHsmClusterPrivateEndpointConnectionsCreate` + +```go +ctx := context.TODO() +id := cloudhsmclusterprivateendpointcreate.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName", "privateEndpointConnectionName") + +payload := cloudhsmclusterprivateendpointcreate.PrivateEndpointConnection{ + // ... +} + + +read, err := client.CloudHsmClusterPrivateEndpointConnectionsCreate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/client.go new file mode 100644 index 00000000000..3886cf7812f --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/client.go @@ -0,0 +1,26 @@ +package cloudhsmclusterprivateendpointcreate + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHSMClusterPrivateEndpointCreateClient struct { + Client *resourcemanager.Client +} + +func NewCloudHSMClusterPrivateEndpointCreateClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudHSMClusterPrivateEndpointCreateClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cloudhsmclusterprivateendpointcreate", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudHSMClusterPrivateEndpointCreateClient: %+v", err) + } + + return &CloudHSMClusterPrivateEndpointCreateClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/constants.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/constants.go new file mode 100644 index 00000000000..e9f45c063c7 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/constants.go @@ -0,0 +1,110 @@ +package cloudhsmclusterprivateendpointcreate + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCanceled PrivateEndpointConnectionProvisioningState = "Canceled" + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateInternalError PrivateEndpointConnectionProvisioningState = "InternalError" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" + PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCanceled), + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateInternalError), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + string(PrivateEndpointConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "canceled": PrivateEndpointConnectionProvisioningStateCanceled, + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "internalerror": PrivateEndpointConnectionProvisioningStateInternalError, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + "updating": PrivateEndpointConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/id_privateendpointconnection.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/id_privateendpointconnection.go new file mode 100644 index 00000000000..024c71bdc2c --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package cloudhsmclusterprivateendpointcreate + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/id_privateendpointconnection_test.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..adaf29e586c --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package cloudhsmclusterprivateendpointcreate + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName", "privateEndpointConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudHsmClusterName != "cloudHsmClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudHsmClusterName'", id.CloudHsmClusterName, "cloudHsmClusterName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudHsmClusterName: "cLoUdHsMcLuStErNaMe", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/method_cloudhsmclusterprivateendpointconnectionscreate.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/method_cloudhsmclusterprivateendpointconnectionscreate.go new file mode 100644 index 00000000000..4a9b8a1cc78 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/method_cloudhsmclusterprivateendpointconnectionscreate.go @@ -0,0 +1,57 @@ +package cloudhsmclusterprivateendpointcreate + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterPrivateEndpointConnectionsCreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// CloudHsmClusterPrivateEndpointConnectionsCreate ... +func (c CloudHSMClusterPrivateEndpointCreateClient) CloudHsmClusterPrivateEndpointConnectionsCreate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result CloudHsmClusterPrivateEndpointConnectionsCreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateEndpointConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/model_privateendpoint.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/model_privateendpoint.go new file mode 100644 index 00000000000..6c8fc436e5d --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/model_privateendpoint.go @@ -0,0 +1,8 @@ +package cloudhsmclusterprivateendpointcreate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/model_privateendpointconnection.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/model_privateendpointconnection.go new file mode 100644 index 00000000000..fba36cc4770 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/model_privateendpointconnection.go @@ -0,0 +1,17 @@ +package cloudhsmclusterprivateendpointcreate + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/model_privateendpointconnectionproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..7734d4cb6a6 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package cloudhsmclusterprivateendpointcreate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/model_privatelinkserviceconnectionstate.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..5c0108e558f --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package cloudhsmclusterprivateendpointcreate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/version.go new file mode 100644 index 00000000000..c64b8fcdb55 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointcreate/version.go @@ -0,0 +1,10 @@ +package cloudhsmclusterprivateendpointcreate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cloudhsmclusterprivateendpointcreate/2025-03-31" +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointdelete/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointdelete/client.go new file mode 100644 index 00000000000..9a04ecca1c0 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointdelete/client.go @@ -0,0 +1,26 @@ +package cloudhsmclusterprivateendpointdelete + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHSMClusterPrivateEndpointDeleteClient struct { + Client *resourcemanager.Client +} + +func NewCloudHSMClusterPrivateEndpointDeleteClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudHSMClusterPrivateEndpointDeleteClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cloudhsmclusterprivateendpointdelete", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudHSMClusterPrivateEndpointDeleteClient: %+v", err) + } + + return &CloudHSMClusterPrivateEndpointDeleteClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointdelete/id_privateendpointconnection.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointdelete/id_privateendpointconnection.go new file mode 100644 index 00000000000..9f44d09c115 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointdelete/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package cloudhsmclusterprivateendpointdelete + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointdelete/id_privateendpointconnection_test.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointdelete/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..91832191101 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointdelete/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package cloudhsmclusterprivateendpointdelete + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName", "privateEndpointConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudHsmClusterName != "cloudHsmClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudHsmClusterName'", id.CloudHsmClusterName, "cloudHsmClusterName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudHsmClusterName: "cLoUdHsMcLuStErNaMe", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointdelete/method_cloudhsmclusterprivateendpointconnectionsdelete.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointdelete/method_cloudhsmclusterprivateendpointconnectionsdelete.go new file mode 100644 index 00000000000..48ed6642425 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointdelete/method_cloudhsmclusterprivateendpointconnectionsdelete.go @@ -0,0 +1,70 @@ +package cloudhsmclusterprivateendpointdelete + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterPrivateEndpointConnectionsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CloudHsmClusterPrivateEndpointConnectionsDelete ... +func (c CloudHSMClusterPrivateEndpointDeleteClient) CloudHsmClusterPrivateEndpointConnectionsDelete(ctx context.Context, id PrivateEndpointConnectionId) (result CloudHsmClusterPrivateEndpointConnectionsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CloudHsmClusterPrivateEndpointConnectionsDeleteThenPoll performs CloudHsmClusterPrivateEndpointConnectionsDelete then polls until it's completed +func (c CloudHSMClusterPrivateEndpointDeleteClient) CloudHsmClusterPrivateEndpointConnectionsDeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.CloudHsmClusterPrivateEndpointConnectionsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing CloudHsmClusterPrivateEndpointConnectionsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CloudHsmClusterPrivateEndpointConnectionsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointdelete/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointdelete/version.go new file mode 100644 index 00000000000..73944b75b93 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointdelete/version.go @@ -0,0 +1,10 @@ +package cloudhsmclusterprivateendpointdelete + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cloudhsmclusterprivateendpointdelete/2025-03-31" +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/README.md b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/README.md new file mode 100644 index 00000000000..e7ab6724a16 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget` Documentation + +The `cloudhsmclusterprivateendpointget` SDK allows for interaction with Azure Resource Manager `hardwaresecuritymodules` (API Version `2025-03-31`). + +This readme covers example usages, but further information on [using this SDK can be 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/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget" +``` + + +### Client Initialization + +```go +client := cloudhsmclusterprivateendpointget.NewCloudHSMClusterPrivateEndpointGetClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CloudHSMClusterPrivateEndpointGetClient.CloudHsmClusterPrivateEndpointConnectionsGet` + +```go +ctx := context.TODO() +id := cloudhsmclusterprivateendpointget.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName", "privateEndpointConnectionName") + +read, err := client.CloudHsmClusterPrivateEndpointConnectionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/client.go new file mode 100644 index 00000000000..39b70c1583d --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/client.go @@ -0,0 +1,26 @@ +package cloudhsmclusterprivateendpointget + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHSMClusterPrivateEndpointGetClient struct { + Client *resourcemanager.Client +} + +func NewCloudHSMClusterPrivateEndpointGetClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudHSMClusterPrivateEndpointGetClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cloudhsmclusterprivateendpointget", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudHSMClusterPrivateEndpointGetClient: %+v", err) + } + + return &CloudHSMClusterPrivateEndpointGetClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/constants.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/constants.go new file mode 100644 index 00000000000..e02fe80858c --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/constants.go @@ -0,0 +1,110 @@ +package cloudhsmclusterprivateendpointget + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCanceled PrivateEndpointConnectionProvisioningState = "Canceled" + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateInternalError PrivateEndpointConnectionProvisioningState = "InternalError" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" + PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCanceled), + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateInternalError), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + string(PrivateEndpointConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "canceled": PrivateEndpointConnectionProvisioningStateCanceled, + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "internalerror": PrivateEndpointConnectionProvisioningStateInternalError, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + "updating": PrivateEndpointConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/id_privateendpointconnection.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/id_privateendpointconnection.go new file mode 100644 index 00000000000..7efb68deb30 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package cloudhsmclusterprivateendpointget + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/id_privateendpointconnection_test.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..e85c53bf307 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package cloudhsmclusterprivateendpointget + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName", "privateEndpointConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudHsmClusterName != "cloudHsmClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudHsmClusterName'", id.CloudHsmClusterName, "cloudHsmClusterName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudHsmClusterName: "cLoUdHsMcLuStErNaMe", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/method_cloudhsmclusterprivateendpointconnectionsget.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/method_cloudhsmclusterprivateendpointconnectionsget.go new file mode 100644 index 00000000000..31adfb98f6e --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/method_cloudhsmclusterprivateendpointconnectionsget.go @@ -0,0 +1,53 @@ +package cloudhsmclusterprivateendpointget + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterPrivateEndpointConnectionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// CloudHsmClusterPrivateEndpointConnectionsGet ... +func (c CloudHSMClusterPrivateEndpointGetClient) CloudHsmClusterPrivateEndpointConnectionsGet(ctx context.Context, id PrivateEndpointConnectionId) (result CloudHsmClusterPrivateEndpointConnectionsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateEndpointConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/model_privateendpoint.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/model_privateendpoint.go new file mode 100644 index 00000000000..9c435fce0bc --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/model_privateendpoint.go @@ -0,0 +1,8 @@ +package cloudhsmclusterprivateendpointget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/model_privateendpointconnection.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/model_privateendpointconnection.go new file mode 100644 index 00000000000..b7cef4118a8 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/model_privateendpointconnection.go @@ -0,0 +1,17 @@ +package cloudhsmclusterprivateendpointget + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/model_privateendpointconnectionproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..d6d02198956 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package cloudhsmclusterprivateendpointget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/model_privatelinkserviceconnectionstate.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..2f445483678 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package cloudhsmclusterprivateendpointget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/version.go new file mode 100644 index 00000000000..0bc3e827d9c --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivateendpointget/version.go @@ -0,0 +1,10 @@ +package cloudhsmclusterprivateendpointget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cloudhsmclusterprivateendpointget/2025-03-31" +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/README.md b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/README.md new file mode 100644 index 00000000000..6780008ee4c --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget` Documentation + +The `cloudhsmclusterprivatelinkget` SDK allows for interaction with Azure Resource Manager `hardwaresecuritymodules` (API Version `2025-03-31`). + +This readme covers example usages, but further information on [using this SDK can be 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/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget" +``` + + +### Client Initialization + +```go +client := cloudhsmclusterprivatelinkget.NewCloudHSMClusterPrivateLinkGetClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CloudHSMClusterPrivateLinkGetClient.CloudHsmClusterPrivateLinkResourcesListByCloudHsmCluster` + +```go +ctx := context.TODO() +id := cloudhsmclusterprivatelinkget.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +// alternatively `client.CloudHsmClusterPrivateLinkResourcesListByCloudHsmCluster(ctx, id)` can be used to do batched pagination +items, err := client.CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/client.go new file mode 100644 index 00000000000..5e7e616ce05 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/client.go @@ -0,0 +1,26 @@ +package cloudhsmclusterprivatelinkget + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHSMClusterPrivateLinkGetClient struct { + Client *resourcemanager.Client +} + +func NewCloudHSMClusterPrivateLinkGetClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudHSMClusterPrivateLinkGetClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cloudhsmclusterprivatelinkget", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudHSMClusterPrivateLinkGetClient: %+v", err) + } + + return &CloudHSMClusterPrivateLinkGetClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/id_cloudhsmcluster.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/id_cloudhsmcluster.go new file mode 100644 index 00000000000..bf202d2765c --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/id_cloudhsmcluster.go @@ -0,0 +1,130 @@ +package cloudhsmclusterprivatelinkget + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CloudHsmClusterId{}) +} + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +// CloudHsmClusterId is a struct representing the Resource ID for a Cloud Hsm Cluster +type CloudHsmClusterId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string +} + +// NewCloudHsmClusterID returns a new CloudHsmClusterId struct +func NewCloudHsmClusterID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string) CloudHsmClusterId { + return CloudHsmClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + } +} + +// ParseCloudHsmClusterID parses 'input' into a CloudHsmClusterId +func ParseCloudHsmClusterID(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudHsmClusterIDInsensitively parses 'input' case-insensitively into a CloudHsmClusterId +// note: this method should only be used for API response data and not user input +func ParseCloudHsmClusterIDInsensitively(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudHsmClusterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + return nil +} + +// ValidateCloudHsmClusterID checks that 'input' can be parsed as a Cloud Hsm Cluster ID +func ValidateCloudHsmClusterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCloudHsmClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud Hsm Cluster ID +func (id CloudHsmClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + } +} + +// String returns a human-readable description of this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + } + return fmt.Sprintf("Cloud Hsm Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/id_cloudhsmcluster_test.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/id_cloudhsmcluster_test.go new file mode 100644 index 00000000000..ea9c6664ec9 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/id_cloudhsmcluster_test.go @@ -0,0 +1,282 @@ +package cloudhsmclusterprivatelinkget + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +func TestNewCloudHsmClusterID(t *testing.T) { + id := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudHsmClusterName != "cloudHsmClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudHsmClusterName'", id.CloudHsmClusterName, "cloudHsmClusterName") + } +} + +func TestFormatCloudHsmClusterID(t *testing.T) { + actual := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCloudHsmClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestParseCloudHsmClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudHsmClusterName: "cLoUdHsMcLuStErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestSegmentsForCloudHsmClusterId(t *testing.T) { + segments := CloudHsmClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CloudHsmClusterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/method_cloudhsmclusterprivatelinkresourceslistbycloudhsmcluster.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/method_cloudhsmclusterprivatelinkresourceslistbycloudhsmcluster.go new file mode 100644 index 00000000000..d5b99501600 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/method_cloudhsmclusterprivatelinkresourceslistbycloudhsmcluster.go @@ -0,0 +1,105 @@ +package cloudhsmclusterprivatelinkget + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateLinkResource +} + +type CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateLinkResource +} + +type CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// CloudHsmClusterPrivateLinkResourcesListByCloudHsmCluster ... +func (c CloudHSMClusterPrivateLinkGetClient) CloudHsmClusterPrivateLinkResourcesListByCloudHsmCluster(ctx context.Context, id CloudHsmClusterId) (result CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCustomPager{}, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateLinkResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterComplete retrieves all the results into a single object +func (c CloudHSMClusterPrivateLinkGetClient) CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterComplete(ctx context.Context, id CloudHsmClusterId) (CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCompleteResult, error) { + return c.CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCompleteMatchingPredicate(ctx, id, PrivateLinkResourceOperationPredicate{}) +} + +// CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CloudHSMClusterPrivateLinkGetClient) CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCompleteMatchingPredicate(ctx context.Context, id CloudHsmClusterId, predicate PrivateLinkResourceOperationPredicate) (result CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCompleteResult, err error) { + items := make([]PrivateLinkResource, 0) + + resp, err := c.CloudHsmClusterPrivateLinkResourcesListByCloudHsmCluster(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = CloudHsmClusterPrivateLinkResourcesListByCloudHsmClusterCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/model_privatelinkresource.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/model_privatelinkresource.go new file mode 100644 index 00000000000..f9b9807b09f --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/model_privatelinkresource.go @@ -0,0 +1,16 @@ +package cloudhsmclusterprivatelinkget + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/model_privatelinkresourceproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..466651e95b5 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package cloudhsmclusterprivatelinkget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/predicates.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/predicates.go new file mode 100644 index 00000000000..7261edee266 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/predicates.go @@ -0,0 +1,27 @@ +package cloudhsmclusterprivatelinkget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PrivateLinkResourceOperationPredicate) Matches(input PrivateLinkResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/version.go new file mode 100644 index 00000000000..c7a191448ae --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterprivatelinkget/version.go @@ -0,0 +1,10 @@ +package cloudhsmclusterprivatelinkget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cloudhsmclusterprivatelinkget/2025-03-31" +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/README.md b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/README.md new file mode 100644 index 00000000000..e97198218d1 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget` Documentation + +The `cloudhsmclustersbackupoperationstatusget` SDK allows for interaction with Azure Resource Manager `hardwaresecuritymodules` (API Version `2025-03-31`). + +This readme covers example usages, but further information on [using this SDK can be 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/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget" +``` + + +### Client Initialization + +```go +client := cloudhsmclustersbackupoperationstatusget.NewCloudHSMClustersBackupOperationStatusGetClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CloudHSMClustersBackupOperationStatusGetClient.CloudHsmClusterBackupStatusGet` + +```go +ctx := context.TODO() +id := cloudhsmclustersbackupoperationstatusget.NewBackupOperationStatusID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName", "jobId") + +read, err := client.CloudHsmClusterBackupStatusGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/client.go new file mode 100644 index 00000000000..343a7ddf4e4 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/client.go @@ -0,0 +1,26 @@ +package cloudhsmclustersbackupoperationstatusget + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHSMClustersBackupOperationStatusGetClient struct { + Client *resourcemanager.Client +} + +func NewCloudHSMClustersBackupOperationStatusGetClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudHSMClustersBackupOperationStatusGetClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cloudhsmclustersbackupoperationstatusget", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudHSMClustersBackupOperationStatusGetClient: %+v", err) + } + + return &CloudHSMClustersBackupOperationStatusGetClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/constants.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/constants.go new file mode 100644 index 00000000000..3c9957d3466 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/constants.go @@ -0,0 +1,57 @@ +package cloudhsmclustersbackupoperationstatusget + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRestoreOperationStatus string + +const ( + BackupRestoreOperationStatusCancelled BackupRestoreOperationStatus = "Cancelled" + BackupRestoreOperationStatusFailed BackupRestoreOperationStatus = "Failed" + BackupRestoreOperationStatusInProgress BackupRestoreOperationStatus = "InProgress" + BackupRestoreOperationStatusSucceeded BackupRestoreOperationStatus = "Succeeded" +) + +func PossibleValuesForBackupRestoreOperationStatus() []string { + return []string{ + string(BackupRestoreOperationStatusCancelled), + string(BackupRestoreOperationStatusFailed), + string(BackupRestoreOperationStatusInProgress), + string(BackupRestoreOperationStatusSucceeded), + } +} + +func (s *BackupRestoreOperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupRestoreOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupRestoreOperationStatus(input string) (*BackupRestoreOperationStatus, error) { + vals := map[string]BackupRestoreOperationStatus{ + "cancelled": BackupRestoreOperationStatusCancelled, + "failed": BackupRestoreOperationStatusFailed, + "inprogress": BackupRestoreOperationStatusInProgress, + "succeeded": BackupRestoreOperationStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupRestoreOperationStatus(input) + return &out, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/id_backupoperationstatus.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/id_backupoperationstatus.go new file mode 100644 index 00000000000..1583376d0db --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/id_backupoperationstatus.go @@ -0,0 +1,139 @@ +package cloudhsmclustersbackupoperationstatusget + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupOperationStatusId{}) +} + +var _ resourceids.ResourceId = &BackupOperationStatusId{} + +// BackupOperationStatusId is a struct representing the Resource ID for a Backup Operation Status +type BackupOperationStatusId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string + JobId string +} + +// NewBackupOperationStatusID returns a new BackupOperationStatusId struct +func NewBackupOperationStatusID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string, jobId string) BackupOperationStatusId { + return BackupOperationStatusId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + JobId: jobId, + } +} + +// ParseBackupOperationStatusID parses 'input' into a BackupOperationStatusId +func ParseBackupOperationStatusID(input string) (*BackupOperationStatusId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupOperationStatusId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupOperationStatusId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupOperationStatusIDInsensitively parses 'input' case-insensitively into a BackupOperationStatusId +// note: this method should only be used for API response data and not user input +func ParseBackupOperationStatusIDInsensitively(input string) (*BackupOperationStatusId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupOperationStatusId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupOperationStatusId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupOperationStatusId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + if id.JobId, ok = input.Parsed["jobId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "jobId", input) + } + + return nil +} + +// ValidateBackupOperationStatusID checks that 'input' can be parsed as a Backup Operation Status ID +func ValidateBackupOperationStatusID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackupOperationStatusID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup Operation Status ID +func (id BackupOperationStatusId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s/backupOperationStatus/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName, id.JobId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup Operation Status ID +func (id BackupOperationStatusId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + resourceids.StaticSegment("staticBackupOperationStatus", "backupOperationStatus", "backupOperationStatus"), + resourceids.UserSpecifiedSegment("jobId", "jobId"), + } +} + +// String returns a human-readable description of this Backup Operation Status ID +func (id BackupOperationStatusId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + fmt.Sprintf("Job: %q", id.JobId), + } + return fmt.Sprintf("Backup Operation Status (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/id_backupoperationstatus_test.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/id_backupoperationstatus_test.go new file mode 100644 index 00000000000..91c5b1d375e --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/id_backupoperationstatus_test.go @@ -0,0 +1,327 @@ +package cloudhsmclustersbackupoperationstatusget + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupOperationStatusId{} + +func TestNewBackupOperationStatusID(t *testing.T) { + id := NewBackupOperationStatusID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName", "jobId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudHsmClusterName != "cloudHsmClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudHsmClusterName'", id.CloudHsmClusterName, "cloudHsmClusterName") + } + + if id.JobId != "jobId" { + t.Fatalf("Expected %q but got %q for Segment 'JobId'", id.JobId, "jobId") + } +} + +func TestFormatBackupOperationStatusID(t *testing.T) { + actual := NewBackupOperationStatusID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName", "jobId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/backupOperationStatus/jobId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupOperationStatusID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupOperationStatusId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/backupOperationStatus", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/backupOperationStatus/jobId", + Expected: &BackupOperationStatusId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + JobId: "jobId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/backupOperationStatus/jobId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupOperationStatusID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + if actual.JobId != v.Expected.JobId { + t.Fatalf("Expected %q but got %q for JobId", v.Expected.JobId, actual.JobId) + } + + } +} + +func TestParseBackupOperationStatusIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupOperationStatusId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/backupOperationStatus", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/bAcKuPoPeRaTiOnStAtUs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/backupOperationStatus/jobId", + Expected: &BackupOperationStatusId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + JobId: "jobId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/backupOperationStatus/jobId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/bAcKuPoPeRaTiOnStAtUs/jObId", + Expected: &BackupOperationStatusId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudHsmClusterName: "cLoUdHsMcLuStErNaMe", + JobId: "jObId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/bAcKuPoPeRaTiOnStAtUs/jObId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupOperationStatusIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + if actual.JobId != v.Expected.JobId { + t.Fatalf("Expected %q but got %q for JobId", v.Expected.JobId, actual.JobId) + } + + } +} + +func TestSegmentsForBackupOperationStatusId(t *testing.T) { + segments := BackupOperationStatusId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupOperationStatusId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/method_cloudhsmclusterbackupstatusget.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/method_cloudhsmclusterbackupstatusget.go new file mode 100644 index 00000000000..a46eadf66a1 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/method_cloudhsmclusterbackupstatusget.go @@ -0,0 +1,54 @@ +package cloudhsmclustersbackupoperationstatusget + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterBackupStatusGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupResult +} + +// CloudHsmClusterBackupStatusGet ... +func (c CloudHSMClustersBackupOperationStatusGetClient) CloudHsmClusterBackupStatusGet(ctx context.Context, id BackupOperationStatusId) (result CloudHsmClusterBackupStatusGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/model_backupresult.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/model_backupresult.go new file mode 100644 index 00000000000..569c573f74e --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/model_backupresult.go @@ -0,0 +1,8 @@ +package cloudhsmclustersbackupoperationstatusget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResult struct { + Properties *BackupResultProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/model_backupresultproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/model_backupresultproperties.go new file mode 100644 index 00000000000..1d6b5acdd37 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/model_backupresultproperties.go @@ -0,0 +1,45 @@ +package cloudhsmclustersbackupoperationstatusget + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResultProperties struct { + AzureStorageBlobContainerUri *string `json:"azureStorageBlobContainerUri,omitempty"` + BackupId *string `json:"backupId,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + JobId *string `json:"jobId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *BackupRestoreOperationStatus `json:"status,omitempty"` + StatusDetails *string `json:"statusDetails,omitempty"` +} + +func (o *BackupResultProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupResultProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *BackupResultProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupResultProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/model_erroradditionalinfo.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/model_erroradditionalinfo.go new file mode 100644 index 00000000000..e2a942c046b --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package cloudhsmclustersbackupoperationstatusget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/model_errordetail.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/model_errordetail.go new file mode 100644 index 00000000000..714bde0654b --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/model_errordetail.go @@ -0,0 +1,12 @@ +package cloudhsmclustersbackupoperationstatusget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/version.go new file mode 100644 index 00000000000..e9313b4fb1d --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersbackupoperationstatusget/version.go @@ -0,0 +1,10 @@ +package cloudhsmclustersbackupoperationstatusget + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cloudhsmclustersbackupoperationstatusget/2025-03-31" +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/README.md b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/README.md new file mode 100644 index 00000000000..7dab4f162e3 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate` Documentation + +The `cloudhsmclustersrestoreoperationcreate` SDK allows for interaction with Azure Resource Manager `hardwaresecuritymodules` (API Version `2025-03-31`). + +This readme covers example usages, but further information on [using this SDK can be 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/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate" +``` + + +### Client Initialization + +```go +client := cloudhsmclustersrestoreoperationcreate.NewCloudHSMClustersRestoreOperationCreateClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CloudHSMClustersRestoreOperationCreateClient.CloudHsmClustersRestore` + +```go +ctx := context.TODO() +id := cloudhsmclustersrestoreoperationcreate.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +payload := cloudhsmclustersrestoreoperationcreate.RestoreRequestProperties{ + // ... +} + + +if err := client.CloudHsmClustersRestoreThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/client.go new file mode 100644 index 00000000000..7660cbe0748 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/client.go @@ -0,0 +1,26 @@ +package cloudhsmclustersrestoreoperationcreate + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHSMClustersRestoreOperationCreateClient struct { + Client *resourcemanager.Client +} + +func NewCloudHSMClustersRestoreOperationCreateClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudHSMClustersRestoreOperationCreateClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cloudhsmclustersrestoreoperationcreate", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudHSMClustersRestoreOperationCreateClient: %+v", err) + } + + return &CloudHSMClustersRestoreOperationCreateClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/constants.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/constants.go new file mode 100644 index 00000000000..b82f1bc1da8 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/constants.go @@ -0,0 +1,57 @@ +package cloudhsmclustersrestoreoperationcreate + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRestoreOperationStatus string + +const ( + BackupRestoreOperationStatusCancelled BackupRestoreOperationStatus = "Cancelled" + BackupRestoreOperationStatusFailed BackupRestoreOperationStatus = "Failed" + BackupRestoreOperationStatusInProgress BackupRestoreOperationStatus = "InProgress" + BackupRestoreOperationStatusSucceeded BackupRestoreOperationStatus = "Succeeded" +) + +func PossibleValuesForBackupRestoreOperationStatus() []string { + return []string{ + string(BackupRestoreOperationStatusCancelled), + string(BackupRestoreOperationStatusFailed), + string(BackupRestoreOperationStatusInProgress), + string(BackupRestoreOperationStatusSucceeded), + } +} + +func (s *BackupRestoreOperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupRestoreOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupRestoreOperationStatus(input string) (*BackupRestoreOperationStatus, error) { + vals := map[string]BackupRestoreOperationStatus{ + "cancelled": BackupRestoreOperationStatusCancelled, + "failed": BackupRestoreOperationStatusFailed, + "inprogress": BackupRestoreOperationStatusInProgress, + "succeeded": BackupRestoreOperationStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupRestoreOperationStatus(input) + return &out, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/id_cloudhsmcluster.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/id_cloudhsmcluster.go new file mode 100644 index 00000000000..b636d691760 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/id_cloudhsmcluster.go @@ -0,0 +1,130 @@ +package cloudhsmclustersrestoreoperationcreate + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CloudHsmClusterId{}) +} + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +// CloudHsmClusterId is a struct representing the Resource ID for a Cloud Hsm Cluster +type CloudHsmClusterId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string +} + +// NewCloudHsmClusterID returns a new CloudHsmClusterId struct +func NewCloudHsmClusterID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string) CloudHsmClusterId { + return CloudHsmClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + } +} + +// ParseCloudHsmClusterID parses 'input' into a CloudHsmClusterId +func ParseCloudHsmClusterID(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudHsmClusterIDInsensitively parses 'input' case-insensitively into a CloudHsmClusterId +// note: this method should only be used for API response data and not user input +func ParseCloudHsmClusterIDInsensitively(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudHsmClusterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + return nil +} + +// ValidateCloudHsmClusterID checks that 'input' can be parsed as a Cloud Hsm Cluster ID +func ValidateCloudHsmClusterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCloudHsmClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud Hsm Cluster ID +func (id CloudHsmClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + } +} + +// String returns a human-readable description of this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + } + return fmt.Sprintf("Cloud Hsm Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/id_cloudhsmcluster_test.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/id_cloudhsmcluster_test.go new file mode 100644 index 00000000000..c5f8fbbff92 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/id_cloudhsmcluster_test.go @@ -0,0 +1,282 @@ +package cloudhsmclustersrestoreoperationcreate + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +func TestNewCloudHsmClusterID(t *testing.T) { + id := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudHsmClusterName != "cloudHsmClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudHsmClusterName'", id.CloudHsmClusterName, "cloudHsmClusterName") + } +} + +func TestFormatCloudHsmClusterID(t *testing.T) { + actual := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCloudHsmClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestParseCloudHsmClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudHsmClusterName: "cLoUdHsMcLuStErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestSegmentsForCloudHsmClusterId(t *testing.T) { + segments := CloudHsmClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CloudHsmClusterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/method_cloudhsmclustersrestore.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/method_cloudhsmclustersrestore.go new file mode 100644 index 00000000000..a47a6b4e475 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/method_cloudhsmclustersrestore.go @@ -0,0 +1,75 @@ +package cloudhsmclustersrestoreoperationcreate + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClustersRestoreOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RestoreResult +} + +// CloudHsmClustersRestore ... +func (c CloudHSMClustersRestoreOperationCreateClient) CloudHsmClustersRestore(ctx context.Context, id CloudHsmClusterId, input RestoreRequestProperties) (result CloudHsmClustersRestoreOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restore", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CloudHsmClustersRestoreThenPoll performs CloudHsmClustersRestore then polls until it's completed +func (c CloudHSMClustersRestoreOperationCreateClient) CloudHsmClustersRestoreThenPoll(ctx context.Context, id CloudHsmClusterId, input RestoreRequestProperties) error { + result, err := c.CloudHsmClustersRestore(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CloudHsmClustersRestore: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CloudHsmClustersRestore: %+v", err) + } + + return nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/model_backuprestorebaseresultproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/model_backuprestorebaseresultproperties.go new file mode 100644 index 00000000000..fbdcc09f095 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/model_backuprestorebaseresultproperties.go @@ -0,0 +1,43 @@ +package cloudhsmclustersrestoreoperationcreate + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRestoreBaseResultProperties struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + JobId *string `json:"jobId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *BackupRestoreOperationStatus `json:"status,omitempty"` + StatusDetails *string `json:"statusDetails,omitempty"` +} + +func (o *BackupRestoreBaseResultProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupRestoreBaseResultProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *BackupRestoreBaseResultProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupRestoreBaseResultProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/model_erroradditionalinfo.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/model_erroradditionalinfo.go new file mode 100644 index 00000000000..c4fe7856893 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package cloudhsmclustersrestoreoperationcreate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/model_errordetail.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/model_errordetail.go new file mode 100644 index 00000000000..38713d10806 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/model_errordetail.go @@ -0,0 +1,12 @@ +package cloudhsmclustersrestoreoperationcreate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/model_restorerequestproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/model_restorerequestproperties.go new file mode 100644 index 00000000000..89346c9d5a1 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/model_restorerequestproperties.go @@ -0,0 +1,10 @@ +package cloudhsmclustersrestoreoperationcreate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreRequestProperties struct { + AzureStorageBlobContainerUri string `json:"azureStorageBlobContainerUri"` + BackupId string `json:"backupId"` + Token *string `json:"token,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/model_restoreresult.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/model_restoreresult.go new file mode 100644 index 00000000000..4d64a0ca7fb --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/model_restoreresult.go @@ -0,0 +1,8 @@ +package cloudhsmclustersrestoreoperationcreate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreResult struct { + Properties *BackupRestoreBaseResultProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/version.go new file mode 100644 index 00000000000..f3beb57dd08 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustersrestoreoperationcreate/version.go @@ -0,0 +1,10 @@ +package cloudhsmclustersrestoreoperationcreate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cloudhsmclustersrestoreoperationcreate/2025-03-31" +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/README.md b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/README.md new file mode 100644 index 00000000000..183b9be507a --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate` Documentation + +The `cloudhsmclusterupdate` SDK allows for interaction with Azure Resource Manager `hardwaresecuritymodules` (API Version `2025-03-31`). + +This readme covers example usages, but further information on [using this SDK can be 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/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate" +``` + + +### Client Initialization + +```go +client := cloudhsmclusterupdate.NewCloudHSMClusterUpdateClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CloudHSMClusterUpdateClient.CloudHsmClustersUpdate` + +```go +ctx := context.TODO() +id := cloudhsmclusterupdate.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +payload := cloudhsmclusterupdate.CloudHsmClusterPatchParameters{ + // ... +} + + +if err := client.CloudHsmClustersUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/client.go new file mode 100644 index 00000000000..b3397f40ac4 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/client.go @@ -0,0 +1,26 @@ +package cloudhsmclusterupdate + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHSMClusterUpdateClient struct { + Client *resourcemanager.Client +} + +func NewCloudHSMClusterUpdateClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudHSMClusterUpdateClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cloudhsmclusterupdate", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudHSMClusterUpdateClient: %+v", err) + } + + return &CloudHSMClusterUpdateClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/constants.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/constants.go new file mode 100644 index 00000000000..9c5aaeeed26 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/constants.go @@ -0,0 +1,377 @@ +package cloudhsmclusterupdate + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActivationState string + +const ( + ActivationStateActive ActivationState = "Active" + ActivationStateFailed ActivationState = "Failed" + ActivationStateNotActivated ActivationState = "NotActivated" + ActivationStateNotDefined ActivationState = "NotDefined" + ActivationStateUnknown ActivationState = "Unknown" +) + +func PossibleValuesForActivationState() []string { + return []string{ + string(ActivationStateActive), + string(ActivationStateFailed), + string(ActivationStateNotActivated), + string(ActivationStateNotDefined), + string(ActivationStateUnknown), + } +} + +func (s *ActivationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActivationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseActivationState(input string) (*ActivationState, error) { + vals := map[string]ActivationState{ + "active": ActivationStateActive, + "failed": ActivationStateFailed, + "notactivated": ActivationStateNotActivated, + "notdefined": ActivationStateNotDefined, + "unknown": ActivationStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ActivationState(input) + return &out, nil +} + +type AutoGeneratedDomainNameLabelScope string + +const ( + AutoGeneratedDomainNameLabelScopeNoReuse AutoGeneratedDomainNameLabelScope = "NoReuse" + AutoGeneratedDomainNameLabelScopeResourceGroupReuse AutoGeneratedDomainNameLabelScope = "ResourceGroupReuse" + AutoGeneratedDomainNameLabelScopeSubscriptionReuse AutoGeneratedDomainNameLabelScope = "SubscriptionReuse" + AutoGeneratedDomainNameLabelScopeTenantReuse AutoGeneratedDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForAutoGeneratedDomainNameLabelScope() []string { + return []string{ + string(AutoGeneratedDomainNameLabelScopeNoReuse), + string(AutoGeneratedDomainNameLabelScopeResourceGroupReuse), + string(AutoGeneratedDomainNameLabelScopeSubscriptionReuse), + string(AutoGeneratedDomainNameLabelScopeTenantReuse), + } +} + +func (s *AutoGeneratedDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoGeneratedDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoGeneratedDomainNameLabelScope(input string) (*AutoGeneratedDomainNameLabelScope, error) { + vals := map[string]AutoGeneratedDomainNameLabelScope{ + "noreuse": AutoGeneratedDomainNameLabelScopeNoReuse, + "resourcegroupreuse": AutoGeneratedDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": AutoGeneratedDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": AutoGeneratedDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoGeneratedDomainNameLabelScope(input) + return &out, nil +} + +type CloudHsmClusterSkuFamily string + +const ( + CloudHsmClusterSkuFamilyB CloudHsmClusterSkuFamily = "B" +) + +func PossibleValuesForCloudHsmClusterSkuFamily() []string { + return []string{ + string(CloudHsmClusterSkuFamilyB), + } +} + +func (s *CloudHsmClusterSkuFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudHsmClusterSkuFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudHsmClusterSkuFamily(input string) (*CloudHsmClusterSkuFamily, error) { + vals := map[string]CloudHsmClusterSkuFamily{ + "b": CloudHsmClusterSkuFamilyB, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudHsmClusterSkuFamily(input) + return &out, nil +} + +type CloudHsmClusterSkuName string + +const ( + CloudHsmClusterSkuNameStandardBOne CloudHsmClusterSkuName = "Standard_B1" + CloudHsmClusterSkuNameStandardBOneZero CloudHsmClusterSkuName = "Standard B10" +) + +func PossibleValuesForCloudHsmClusterSkuName() []string { + return []string{ + string(CloudHsmClusterSkuNameStandardBOne), + string(CloudHsmClusterSkuNameStandardBOneZero), + } +} + +func (s *CloudHsmClusterSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloudHsmClusterSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloudHsmClusterSkuName(input string) (*CloudHsmClusterSkuName, error) { + vals := map[string]CloudHsmClusterSkuName{ + "standard_b1": CloudHsmClusterSkuNameStandardBOne, + "standard b10": CloudHsmClusterSkuNameStandardBOneZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloudHsmClusterSkuName(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCanceled PrivateEndpointConnectionProvisioningState = "Canceled" + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateInternalError PrivateEndpointConnectionProvisioningState = "InternalError" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" + PrivateEndpointConnectionProvisioningStateUpdating PrivateEndpointConnectionProvisioningState = "Updating" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCanceled), + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateInternalError), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + string(PrivateEndpointConnectionProvisioningStateUpdating), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "canceled": PrivateEndpointConnectionProvisioningStateCanceled, + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "internalerror": PrivateEndpointConnectionProvisioningStateInternalError, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + "updating": PrivateEndpointConnectionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + } +} + +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/id_cloudhsmcluster.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/id_cloudhsmcluster.go new file mode 100644 index 00000000000..9e2ddf7521d --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/id_cloudhsmcluster.go @@ -0,0 +1,130 @@ +package cloudhsmclusterupdate + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CloudHsmClusterId{}) +} + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +// CloudHsmClusterId is a struct representing the Resource ID for a Cloud Hsm Cluster +type CloudHsmClusterId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string +} + +// NewCloudHsmClusterID returns a new CloudHsmClusterId struct +func NewCloudHsmClusterID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string) CloudHsmClusterId { + return CloudHsmClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + } +} + +// ParseCloudHsmClusterID parses 'input' into a CloudHsmClusterId +func ParseCloudHsmClusterID(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudHsmClusterIDInsensitively parses 'input' case-insensitively into a CloudHsmClusterId +// note: this method should only be used for API response data and not user input +func ParseCloudHsmClusterIDInsensitively(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudHsmClusterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + return nil +} + +// ValidateCloudHsmClusterID checks that 'input' can be parsed as a Cloud Hsm Cluster ID +func ValidateCloudHsmClusterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCloudHsmClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud Hsm Cluster ID +func (id CloudHsmClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + } +} + +// String returns a human-readable description of this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + } + return fmt.Sprintf("Cloud Hsm Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/id_cloudhsmcluster_test.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/id_cloudhsmcluster_test.go new file mode 100644 index 00000000000..7c678c92d11 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/id_cloudhsmcluster_test.go @@ -0,0 +1,282 @@ +package cloudhsmclusterupdate + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +func TestNewCloudHsmClusterID(t *testing.T) { + id := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudHsmClusterName != "cloudHsmClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudHsmClusterName'", id.CloudHsmClusterName, "cloudHsmClusterName") + } +} + +func TestFormatCloudHsmClusterID(t *testing.T) { + actual := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCloudHsmClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestParseCloudHsmClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudHsmClusterName: "cLoUdHsMcLuStErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestSegmentsForCloudHsmClusterId(t *testing.T) { + segments := CloudHsmClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CloudHsmClusterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/method_cloudhsmclustersupdate.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/method_cloudhsmclustersupdate.go new file mode 100644 index 00000000000..655480ff8bf --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/method_cloudhsmclustersupdate.go @@ -0,0 +1,75 @@ +package cloudhsmclusterupdate + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClustersUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CloudHsmCluster +} + +// CloudHsmClustersUpdate ... +func (c CloudHSMClusterUpdateClient) CloudHsmClustersUpdate(ctx context.Context, id CloudHsmClusterId, input CloudHsmClusterPatchParameters) (result CloudHsmClustersUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CloudHsmClustersUpdateThenPoll performs CloudHsmClustersUpdate then polls until it's completed +func (c CloudHSMClusterUpdateClient) CloudHsmClustersUpdateThenPoll(ctx context.Context, id CloudHsmClusterId, input CloudHsmClusterPatchParameters) error { + result, err := c.CloudHsmClustersUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CloudHsmClustersUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CloudHsmClustersUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_cloudhsmcluster.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_cloudhsmcluster.go new file mode 100644 index 00000000000..7e5af38d1c6 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_cloudhsmcluster.go @@ -0,0 +1,21 @@ +package cloudhsmclusterupdate + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmCluster struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CloudHsmClusterProperties `json:"properties,omitempty"` + Sku *CloudHsmClusterSku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_cloudhsmclusterpatchparameters.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_cloudhsmclusterpatchparameters.go new file mode 100644 index 00000000000..2468c97928b --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_cloudhsmclusterpatchparameters.go @@ -0,0 +1,13 @@ +package cloudhsmclusterupdate + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterPatchParameters struct { + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_cloudhsmclusterproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_cloudhsmclusterproperties.go new file mode 100644 index 00000000000..35efaf9a1d7 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_cloudhsmclusterproperties.go @@ -0,0 +1,14 @@ +package cloudhsmclusterupdate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterProperties struct { + ActivationState *ActivationState `json:"activationState,omitempty"` + AutoGeneratedDomainNameLabelScope *AutoGeneratedDomainNameLabelScope `json:"autoGeneratedDomainNameLabelScope,omitempty"` + Hsms *[]CloudHsmProperties `json:"hsms,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + StatusMessage *string `json:"statusMessage,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_cloudhsmclustersku.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_cloudhsmclustersku.go new file mode 100644 index 00000000000..3bcda17fe1f --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_cloudhsmclustersku.go @@ -0,0 +1,10 @@ +package cloudhsmclusterupdate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterSku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family CloudHsmClusterSkuFamily `json:"family"` + Name CloudHsmClusterSkuName `json:"name"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_cloudhsmproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_cloudhsmproperties.go new file mode 100644 index 00000000000..c63bed7be37 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_cloudhsmproperties.go @@ -0,0 +1,10 @@ +package cloudhsmclusterupdate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmProperties struct { + Fqdn *string `json:"fqdn,omitempty"` + State *string `json:"state,omitempty"` + StateMessage *string `json:"stateMessage,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_privateendpoint.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_privateendpoint.go new file mode 100644 index 00000000000..d91ad83fedd --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_privateendpoint.go @@ -0,0 +1,8 @@ +package cloudhsmclusterupdate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_privateendpointconnection.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_privateendpointconnection.go new file mode 100644 index 00000000000..7bcc05a499a --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_privateendpointconnection.go @@ -0,0 +1,17 @@ +package cloudhsmclusterupdate + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_privateendpointconnectionproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..d63992a6337 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_privateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package cloudhsmclusterupdate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_privatelinkserviceconnectionstate.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..d00d72c6522 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package cloudhsmclusterupdate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/version.go new file mode 100644 index 00000000000..a61bf82c396 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclusterupdate/version.go @@ -0,0 +1,10 @@ +package cloudhsmclusterupdate + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cloudhsmclusterupdate/2025-03-31" +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/README.md b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/README.md new file mode 100644 index 00000000000..ff302f39e1b --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties` Documentation + +The `cloudhsmclustervalidatebackupproperties` SDK allows for interaction with Azure Resource Manager `hardwaresecuritymodules` (API Version `2025-03-31`). + +This readme covers example usages, but further information on [using this SDK can be 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/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties" +``` + + +### Client Initialization + +```go +client := cloudhsmclustervalidatebackupproperties.NewCloudHSMClusterValidateBackupPropertiesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CloudHSMClusterValidateBackupPropertiesClient.CloudHsmClustersValidateBackupProperties` + +```go +ctx := context.TODO() +id := cloudhsmclustervalidatebackupproperties.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +payload := cloudhsmclustervalidatebackupproperties.BackupRestoreRequestBaseProperties{ + // ... +} + + +if err := client.CloudHsmClustersValidateBackupPropertiesThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/client.go new file mode 100644 index 00000000000..2caa2733ac6 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/client.go @@ -0,0 +1,26 @@ +package cloudhsmclustervalidatebackupproperties + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHSMClusterValidateBackupPropertiesClient struct { + Client *resourcemanager.Client +} + +func NewCloudHSMClusterValidateBackupPropertiesClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudHSMClusterValidateBackupPropertiesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cloudhsmclustervalidatebackupproperties", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudHSMClusterValidateBackupPropertiesClient: %+v", err) + } + + return &CloudHSMClusterValidateBackupPropertiesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/constants.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/constants.go new file mode 100644 index 00000000000..c203fe93b97 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/constants.go @@ -0,0 +1,57 @@ +package cloudhsmclustervalidatebackupproperties + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRestoreOperationStatus string + +const ( + BackupRestoreOperationStatusCancelled BackupRestoreOperationStatus = "Cancelled" + BackupRestoreOperationStatusFailed BackupRestoreOperationStatus = "Failed" + BackupRestoreOperationStatusInProgress BackupRestoreOperationStatus = "InProgress" + BackupRestoreOperationStatusSucceeded BackupRestoreOperationStatus = "Succeeded" +) + +func PossibleValuesForBackupRestoreOperationStatus() []string { + return []string{ + string(BackupRestoreOperationStatusCancelled), + string(BackupRestoreOperationStatusFailed), + string(BackupRestoreOperationStatusInProgress), + string(BackupRestoreOperationStatusSucceeded), + } +} + +func (s *BackupRestoreOperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupRestoreOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupRestoreOperationStatus(input string) (*BackupRestoreOperationStatus, error) { + vals := map[string]BackupRestoreOperationStatus{ + "cancelled": BackupRestoreOperationStatusCancelled, + "failed": BackupRestoreOperationStatusFailed, + "inprogress": BackupRestoreOperationStatusInProgress, + "succeeded": BackupRestoreOperationStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupRestoreOperationStatus(input) + return &out, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/id_cloudhsmcluster.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/id_cloudhsmcluster.go new file mode 100644 index 00000000000..6be9685d805 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/id_cloudhsmcluster.go @@ -0,0 +1,130 @@ +package cloudhsmclustervalidatebackupproperties + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CloudHsmClusterId{}) +} + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +// CloudHsmClusterId is a struct representing the Resource ID for a Cloud Hsm Cluster +type CloudHsmClusterId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string +} + +// NewCloudHsmClusterID returns a new CloudHsmClusterId struct +func NewCloudHsmClusterID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string) CloudHsmClusterId { + return CloudHsmClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + } +} + +// ParseCloudHsmClusterID parses 'input' into a CloudHsmClusterId +func ParseCloudHsmClusterID(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudHsmClusterIDInsensitively parses 'input' case-insensitively into a CloudHsmClusterId +// note: this method should only be used for API response data and not user input +func ParseCloudHsmClusterIDInsensitively(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudHsmClusterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + return nil +} + +// ValidateCloudHsmClusterID checks that 'input' can be parsed as a Cloud Hsm Cluster ID +func ValidateCloudHsmClusterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCloudHsmClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud Hsm Cluster ID +func (id CloudHsmClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + } +} + +// String returns a human-readable description of this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + } + return fmt.Sprintf("Cloud Hsm Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/id_cloudhsmcluster_test.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/id_cloudhsmcluster_test.go new file mode 100644 index 00000000000..2a4c1af969b --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/id_cloudhsmcluster_test.go @@ -0,0 +1,282 @@ +package cloudhsmclustervalidatebackupproperties + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +func TestNewCloudHsmClusterID(t *testing.T) { + id := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudHsmClusterName != "cloudHsmClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudHsmClusterName'", id.CloudHsmClusterName, "cloudHsmClusterName") + } +} + +func TestFormatCloudHsmClusterID(t *testing.T) { + actual := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCloudHsmClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestParseCloudHsmClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudHsmClusterName: "cLoUdHsMcLuStErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestSegmentsForCloudHsmClusterId(t *testing.T) { + segments := CloudHsmClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CloudHsmClusterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/method_cloudhsmclustersvalidatebackupproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/method_cloudhsmclustersvalidatebackupproperties.go new file mode 100644 index 00000000000..531479805db --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/method_cloudhsmclustersvalidatebackupproperties.go @@ -0,0 +1,75 @@ +package cloudhsmclustervalidatebackupproperties + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClustersValidateBackupPropertiesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BackupResult +} + +// CloudHsmClustersValidateBackupProperties ... +func (c CloudHSMClusterValidateBackupPropertiesClient) CloudHsmClustersValidateBackupProperties(ctx context.Context, id CloudHsmClusterId, input BackupRestoreRequestBaseProperties) (result CloudHsmClustersValidateBackupPropertiesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validateBackupProperties", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CloudHsmClustersValidateBackupPropertiesThenPoll performs CloudHsmClustersValidateBackupProperties then polls until it's completed +func (c CloudHSMClusterValidateBackupPropertiesClient) CloudHsmClustersValidateBackupPropertiesThenPoll(ctx context.Context, id CloudHsmClusterId, input BackupRestoreRequestBaseProperties) error { + result, err := c.CloudHsmClustersValidateBackupProperties(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CloudHsmClustersValidateBackupProperties: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CloudHsmClustersValidateBackupProperties: %+v", err) + } + + return nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/model_backuprestorerequestbaseproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/model_backuprestorerequestbaseproperties.go new file mode 100644 index 00000000000..6cf20b61a1e --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/model_backuprestorerequestbaseproperties.go @@ -0,0 +1,9 @@ +package cloudhsmclustervalidatebackupproperties + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRestoreRequestBaseProperties struct { + AzureStorageBlobContainerUri string `json:"azureStorageBlobContainerUri"` + Token *string `json:"token,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/model_backupresult.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/model_backupresult.go new file mode 100644 index 00000000000..a996dda8598 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/model_backupresult.go @@ -0,0 +1,8 @@ +package cloudhsmclustervalidatebackupproperties + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResult struct { + Properties *BackupResultProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/model_backupresultproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/model_backupresultproperties.go new file mode 100644 index 00000000000..7b381f95080 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/model_backupresultproperties.go @@ -0,0 +1,45 @@ +package cloudhsmclustervalidatebackupproperties + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupResultProperties struct { + AzureStorageBlobContainerUri *string `json:"azureStorageBlobContainerUri,omitempty"` + BackupId *string `json:"backupId,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + JobId *string `json:"jobId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *BackupRestoreOperationStatus `json:"status,omitempty"` + StatusDetails *string `json:"statusDetails,omitempty"` +} + +func (o *BackupResultProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupResultProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *BackupResultProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupResultProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/model_erroradditionalinfo.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/model_erroradditionalinfo.go new file mode 100644 index 00000000000..58286327bbc --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package cloudhsmclustervalidatebackupproperties + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/model_errordetail.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/model_errordetail.go new file mode 100644 index 00000000000..9d63cf6465b --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/model_errordetail.go @@ -0,0 +1,12 @@ +package cloudhsmclustervalidatebackupproperties + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/version.go new file mode 100644 index 00000000000..e0ec45927c5 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/cloudhsmclustervalidatebackupproperties/version.go @@ -0,0 +1,10 @@ +package cloudhsmclustervalidatebackupproperties + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cloudhsmclustervalidatebackupproperties/2025-03-31" +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/README.md b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/README.md new file mode 100644 index 00000000000..949427cd964 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/README.md @@ -0,0 +1,134 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms` Documentation + +The `dedicatedhsms` SDK allows for interaction with Azure Resource Manager `hardwaresecuritymodules` (API Version `2025-03-31`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms" +``` + + +### Client Initialization + +```go +client := dedicatedhsms.NewDedicatedHsmsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DedicatedHsmsClient.DedicatedHsmCreateOrUpdate` + +```go +ctx := context.TODO() +id := dedicatedhsms.NewDedicatedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dedicatedHSMName") + +payload := dedicatedhsms.DedicatedHsm{ + // ... +} + + +if err := client.DedicatedHsmCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DedicatedHsmsClient.DedicatedHsmDelete` + +```go +ctx := context.TODO() +id := dedicatedhsms.NewDedicatedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dedicatedHSMName") + +if err := client.DedicatedHsmDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DedicatedHsmsClient.DedicatedHsmGet` + +```go +ctx := context.TODO() +id := dedicatedhsms.NewDedicatedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dedicatedHSMName") + +read, err := client.DedicatedHsmGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DedicatedHsmsClient.DedicatedHsmListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.DedicatedHsmListByResourceGroup(ctx, id, dedicatedhsms.DefaultDedicatedHsmListByResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.DedicatedHsmListByResourceGroupComplete(ctx, id, dedicatedhsms.DefaultDedicatedHsmListByResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DedicatedHsmsClient.DedicatedHsmListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.DedicatedHsmListBySubscription(ctx, id, dedicatedhsms.DefaultDedicatedHsmListBySubscriptionOperationOptions())` can be used to do batched pagination +items, err := client.DedicatedHsmListBySubscriptionComplete(ctx, id, dedicatedhsms.DefaultDedicatedHsmListBySubscriptionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DedicatedHsmsClient.DedicatedHsmListOutboundNetworkDependenciesEndpoints` + +```go +ctx := context.TODO() +id := dedicatedhsms.NewDedicatedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dedicatedHSMName") + +// alternatively `client.DedicatedHsmListOutboundNetworkDependenciesEndpoints(ctx, id)` can be used to do batched pagination +items, err := client.DedicatedHsmListOutboundNetworkDependenciesEndpointsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DedicatedHsmsClient.DedicatedHsmUpdate` + +```go +ctx := context.TODO() +id := dedicatedhsms.NewDedicatedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dedicatedHSMName") + +payload := dedicatedhsms.DedicatedHsmPatchParameters{ + // ... +} + + +if err := client.DedicatedHsmUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/client.go new file mode 100644 index 00000000000..feb05e5b6a7 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/client.go @@ -0,0 +1,26 @@ +package dedicatedhsms + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DedicatedHsmsClient struct { + Client *resourcemanager.Client +} + +func NewDedicatedHsmsClientWithBaseURI(sdkApi sdkEnv.Api) (*DedicatedHsmsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "dedicatedhsms", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DedicatedHsmsClient: %+v", err) + } + + return &DedicatedHsmsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/constants.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/constants.go new file mode 100644 index 00000000000..2b7ff4df78b --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/constants.go @@ -0,0 +1,122 @@ +package dedicatedhsms + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JsonWebKeyType string + +const ( + JsonWebKeyTypeAllocating JsonWebKeyType = "Allocating" + JsonWebKeyTypeCheckingQuota JsonWebKeyType = "CheckingQuota" + JsonWebKeyTypeConnecting JsonWebKeyType = "Connecting" + JsonWebKeyTypeDeleting JsonWebKeyType = "Deleting" + JsonWebKeyTypeFailed JsonWebKeyType = "Failed" + JsonWebKeyTypeProvisioning JsonWebKeyType = "Provisioning" + JsonWebKeyTypeSucceeded JsonWebKeyType = "Succeeded" +) + +func PossibleValuesForJsonWebKeyType() []string { + return []string{ + string(JsonWebKeyTypeAllocating), + string(JsonWebKeyTypeCheckingQuota), + string(JsonWebKeyTypeConnecting), + string(JsonWebKeyTypeDeleting), + string(JsonWebKeyTypeFailed), + string(JsonWebKeyTypeProvisioning), + string(JsonWebKeyTypeSucceeded), + } +} + +func (s *JsonWebKeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJsonWebKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseJsonWebKeyType(input string) (*JsonWebKeyType, error) { + vals := map[string]JsonWebKeyType{ + "allocating": JsonWebKeyTypeAllocating, + "checkingquota": JsonWebKeyTypeCheckingQuota, + "connecting": JsonWebKeyTypeConnecting, + "deleting": JsonWebKeyTypeDeleting, + "failed": JsonWebKeyTypeFailed, + "provisioning": JsonWebKeyTypeProvisioning, + "succeeded": JsonWebKeyTypeSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JsonWebKeyType(input) + return &out, nil +} + +type SkuName string + +const ( + SkuNamePayShieldOneZeroKLMKOneCPSSixZero SkuName = "payShield10K_LMK1_CPS60" + SkuNamePayShieldOneZeroKLMKOneCPSTwoFiveZero SkuName = "payShield10K_LMK1_CPS250" + SkuNamePayShieldOneZeroKLMKOneCPSTwoFiveZeroZero SkuName = "payShield10K_LMK1_CPS2500" + SkuNamePayShieldOneZeroKLMKTwoCPSSixZero SkuName = "payShield10K_LMK2_CPS60" + SkuNamePayShieldOneZeroKLMKTwoCPSTwoFiveZero SkuName = "payShield10K_LMK2_CPS250" + SkuNamePayShieldOneZeroKLMKTwoCPSTwoFiveZeroZero SkuName = "payShield10K_LMK2_CPS2500" + SkuNameSafeNetLunaNetworkHSMASevenNineZero SkuName = "SafeNet Luna Network HSM A790" +) + +func PossibleValuesForSkuName() []string { + return []string{ + string(SkuNamePayShieldOneZeroKLMKOneCPSSixZero), + string(SkuNamePayShieldOneZeroKLMKOneCPSTwoFiveZero), + string(SkuNamePayShieldOneZeroKLMKOneCPSTwoFiveZeroZero), + string(SkuNamePayShieldOneZeroKLMKTwoCPSSixZero), + string(SkuNamePayShieldOneZeroKLMKTwoCPSTwoFiveZero), + string(SkuNamePayShieldOneZeroKLMKTwoCPSTwoFiveZeroZero), + string(SkuNameSafeNetLunaNetworkHSMASevenNineZero), + } +} + +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuName(input string) (*SkuName, error) { + vals := map[string]SkuName{ + "payshield10k_lmk1_cps60": SkuNamePayShieldOneZeroKLMKOneCPSSixZero, + "payshield10k_lmk1_cps250": SkuNamePayShieldOneZeroKLMKOneCPSTwoFiveZero, + "payshield10k_lmk1_cps2500": SkuNamePayShieldOneZeroKLMKOneCPSTwoFiveZeroZero, + "payshield10k_lmk2_cps60": SkuNamePayShieldOneZeroKLMKTwoCPSSixZero, + "payshield10k_lmk2_cps250": SkuNamePayShieldOneZeroKLMKTwoCPSTwoFiveZero, + "payshield10k_lmk2_cps2500": SkuNamePayShieldOneZeroKLMKTwoCPSTwoFiveZeroZero, + "safenet luna network hsm a790": SkuNameSafeNetLunaNetworkHSMASevenNineZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuName(input) + return &out, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/id_dedicatedhsm.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/id_dedicatedhsm.go new file mode 100644 index 00000000000..1e87a60246a --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/id_dedicatedhsm.go @@ -0,0 +1,130 @@ +package dedicatedhsms + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DedicatedHSMId{}) +} + +var _ resourceids.ResourceId = &DedicatedHSMId{} + +// DedicatedHSMId is a struct representing the Resource ID for a Dedicated H S M +type DedicatedHSMId struct { + SubscriptionId string + ResourceGroupName string + DedicatedHSMName string +} + +// NewDedicatedHSMID returns a new DedicatedHSMId struct +func NewDedicatedHSMID(subscriptionId string, resourceGroupName string, dedicatedHSMName string) DedicatedHSMId { + return DedicatedHSMId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DedicatedHSMName: dedicatedHSMName, + } +} + +// ParseDedicatedHSMID parses 'input' into a DedicatedHSMId +func ParseDedicatedHSMID(input string) (*DedicatedHSMId, error) { + parser := resourceids.NewParserFromResourceIdType(&DedicatedHSMId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DedicatedHSMId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDedicatedHSMIDInsensitively parses 'input' case-insensitively into a DedicatedHSMId +// note: this method should only be used for API response data and not user input +func ParseDedicatedHSMIDInsensitively(input string) (*DedicatedHSMId, error) { + parser := resourceids.NewParserFromResourceIdType(&DedicatedHSMId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DedicatedHSMId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DedicatedHSMId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.DedicatedHSMName, ok = input.Parsed["dedicatedHSMName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dedicatedHSMName", input) + } + + return nil +} + +// ValidateDedicatedHSMID checks that 'input' can be parsed as a Dedicated H S M ID +func ValidateDedicatedHSMID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDedicatedHSMID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Dedicated H S M ID +func (id DedicatedHSMId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DedicatedHSMName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Dedicated H S M ID +func (id DedicatedHSMId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticDedicatedHSMs", "dedicatedHSMs", "dedicatedHSMs"), + resourceids.UserSpecifiedSegment("dedicatedHSMName", "dedicatedHSMName"), + } +} + +// String returns a human-readable description of this Dedicated H S M ID +func (id DedicatedHSMId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Dedicated H S M Name: %q", id.DedicatedHSMName), + } + return fmt.Sprintf("Dedicated H S M (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/id_dedicatedhsm_test.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/id_dedicatedhsm_test.go new file mode 100644 index 00000000000..e18c39e3359 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/id_dedicatedhsm_test.go @@ -0,0 +1,282 @@ +package dedicatedhsms + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DedicatedHSMId{} + +func TestNewDedicatedHSMID(t *testing.T) { + id := NewDedicatedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dedicatedHSMName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.DedicatedHSMName != "dedicatedHSMName" { + t.Fatalf("Expected %q but got %q for Segment 'DedicatedHSMName'", id.DedicatedHSMName, "dedicatedHSMName") + } +} + +func TestFormatDedicatedHSMID(t *testing.T) { + actual := NewDedicatedHSMID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dedicatedHSMName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/dedicatedHSMName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDedicatedHSMID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DedicatedHSMId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/dedicatedHSMName", + Expected: &DedicatedHSMId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DedicatedHSMName: "dedicatedHSMName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/dedicatedHSMName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDedicatedHSMID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DedicatedHSMName != v.Expected.DedicatedHSMName { + t.Fatalf("Expected %q but got %q for DedicatedHSMName", v.Expected.DedicatedHSMName, actual.DedicatedHSMName) + } + + } +} + +func TestParseDedicatedHSMIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DedicatedHSMId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/dEdIcAtEdHsMs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/dedicatedHSMName", + Expected: &DedicatedHSMId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DedicatedHSMName: "dedicatedHSMName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs/dedicatedHSMName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/dEdIcAtEdHsMs/dEdIcAtEdHsMnAmE", + Expected: &DedicatedHSMId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DedicatedHSMName: "dEdIcAtEdHsMnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/dEdIcAtEdHsMs/dEdIcAtEdHsMnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDedicatedHSMIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DedicatedHSMName != v.Expected.DedicatedHSMName { + t.Fatalf("Expected %q but got %q for DedicatedHSMName", v.Expected.DedicatedHSMName, actual.DedicatedHSMName) + } + + } +} + +func TestSegmentsForDedicatedHSMId(t *testing.T) { + segments := DedicatedHSMId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DedicatedHSMId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmcreateorupdate.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmcreateorupdate.go new file mode 100644 index 00000000000..10b4f7e1f69 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmcreateorupdate.go @@ -0,0 +1,75 @@ +package dedicatedhsms + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DedicatedHsmCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DedicatedHsm +} + +// DedicatedHsmCreateOrUpdate ... +func (c DedicatedHsmsClient) DedicatedHsmCreateOrUpdate(ctx context.Context, id DedicatedHSMId, input DedicatedHsm) (result DedicatedHsmCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DedicatedHsmCreateOrUpdateThenPoll performs DedicatedHsmCreateOrUpdate then polls until it's completed +func (c DedicatedHsmsClient) DedicatedHsmCreateOrUpdateThenPoll(ctx context.Context, id DedicatedHSMId, input DedicatedHsm) error { + result, err := c.DedicatedHsmCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DedicatedHsmCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DedicatedHsmCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmdelete.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmdelete.go new file mode 100644 index 00000000000..cc47cb963f3 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmdelete.go @@ -0,0 +1,70 @@ +package dedicatedhsms + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DedicatedHsmDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DedicatedHsmDelete ... +func (c DedicatedHsmsClient) DedicatedHsmDelete(ctx context.Context, id DedicatedHSMId) (result DedicatedHsmDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DedicatedHsmDeleteThenPoll performs DedicatedHsmDelete then polls until it's completed +func (c DedicatedHsmsClient) DedicatedHsmDeleteThenPoll(ctx context.Context, id DedicatedHSMId) error { + result, err := c.DedicatedHsmDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing DedicatedHsmDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DedicatedHsmDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmget.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmget.go new file mode 100644 index 00000000000..6c7b39a8d55 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmget.go @@ -0,0 +1,53 @@ +package dedicatedhsms + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DedicatedHsmGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DedicatedHsm +} + +// DedicatedHsmGet ... +func (c DedicatedHsmsClient) DedicatedHsmGet(ctx context.Context, id DedicatedHSMId) (result DedicatedHsmGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DedicatedHsm + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmlistbyresourcegroup.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmlistbyresourcegroup.go new file mode 100644 index 00000000000..95c1c48ce73 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmlistbyresourcegroup.go @@ -0,0 +1,135 @@ +package dedicatedhsms + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DedicatedHsmListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DedicatedHsm +} + +type DedicatedHsmListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []DedicatedHsm +} + +type DedicatedHsmListByResourceGroupOperationOptions struct { + Top *int64 +} + +func DefaultDedicatedHsmListByResourceGroupOperationOptions() DedicatedHsmListByResourceGroupOperationOptions { + return DedicatedHsmListByResourceGroupOperationOptions{} +} + +func (o DedicatedHsmListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DedicatedHsmListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DedicatedHsmListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type DedicatedHsmListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *DedicatedHsmListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// DedicatedHsmListByResourceGroup ... +func (c DedicatedHsmsClient) DedicatedHsmListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options DedicatedHsmListByResourceGroupOperationOptions) (result DedicatedHsmListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &DedicatedHsmListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DedicatedHsm `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// DedicatedHsmListByResourceGroupComplete retrieves all the results into a single object +func (c DedicatedHsmsClient) DedicatedHsmListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options DedicatedHsmListByResourceGroupOperationOptions) (DedicatedHsmListByResourceGroupCompleteResult, error) { + return c.DedicatedHsmListByResourceGroupCompleteMatchingPredicate(ctx, id, options, DedicatedHsmOperationPredicate{}) +} + +// DedicatedHsmListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DedicatedHsmsClient) DedicatedHsmListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options DedicatedHsmListByResourceGroupOperationOptions, predicate DedicatedHsmOperationPredicate) (result DedicatedHsmListByResourceGroupCompleteResult, err error) { + items := make([]DedicatedHsm, 0) + + resp, err := c.DedicatedHsmListByResourceGroup(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = DedicatedHsmListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmlistbysubscription.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmlistbysubscription.go new file mode 100644 index 00000000000..d4df6ae7c14 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmlistbysubscription.go @@ -0,0 +1,135 @@ +package dedicatedhsms + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DedicatedHsmListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DedicatedHsm +} + +type DedicatedHsmListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []DedicatedHsm +} + +type DedicatedHsmListBySubscriptionOperationOptions struct { + Top *int64 +} + +func DefaultDedicatedHsmListBySubscriptionOperationOptions() DedicatedHsmListBySubscriptionOperationOptions { + return DedicatedHsmListBySubscriptionOperationOptions{} +} + +func (o DedicatedHsmListBySubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DedicatedHsmListBySubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DedicatedHsmListBySubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type DedicatedHsmListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *DedicatedHsmListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// DedicatedHsmListBySubscription ... +func (c DedicatedHsmsClient) DedicatedHsmListBySubscription(ctx context.Context, id commonids.SubscriptionId, options DedicatedHsmListBySubscriptionOperationOptions) (result DedicatedHsmListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &DedicatedHsmListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.HardwareSecurityModules/dedicatedHSMs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DedicatedHsm `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// DedicatedHsmListBySubscriptionComplete retrieves all the results into a single object +func (c DedicatedHsmsClient) DedicatedHsmListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options DedicatedHsmListBySubscriptionOperationOptions) (DedicatedHsmListBySubscriptionCompleteResult, error) { + return c.DedicatedHsmListBySubscriptionCompleteMatchingPredicate(ctx, id, options, DedicatedHsmOperationPredicate{}) +} + +// DedicatedHsmListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DedicatedHsmsClient) DedicatedHsmListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options DedicatedHsmListBySubscriptionOperationOptions, predicate DedicatedHsmOperationPredicate) (result DedicatedHsmListBySubscriptionCompleteResult, err error) { + items := make([]DedicatedHsm, 0) + + resp, err := c.DedicatedHsmListBySubscription(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = DedicatedHsmListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmlistoutboundnetworkdependenciesendpoints.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmlistoutboundnetworkdependenciesendpoints.go new file mode 100644 index 00000000000..855995e3819 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmlistoutboundnetworkdependenciesendpoints.go @@ -0,0 +1,105 @@ +package dedicatedhsms + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DedicatedHsmListOutboundNetworkDependenciesEndpointsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OutboundEnvironmentEndpoint +} + +type DedicatedHsmListOutboundNetworkDependenciesEndpointsCompleteResult struct { + LatestHttpResponse *http.Response + Items []OutboundEnvironmentEndpoint +} + +type DedicatedHsmListOutboundNetworkDependenciesEndpointsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *DedicatedHsmListOutboundNetworkDependenciesEndpointsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// DedicatedHsmListOutboundNetworkDependenciesEndpoints ... +func (c DedicatedHsmsClient) DedicatedHsmListOutboundNetworkDependenciesEndpoints(ctx context.Context, id DedicatedHSMId) (result DedicatedHsmListOutboundNetworkDependenciesEndpointsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &DedicatedHsmListOutboundNetworkDependenciesEndpointsCustomPager{}, + Path: fmt.Sprintf("%s/outboundNetworkDependenciesEndpoints", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]OutboundEnvironmentEndpoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// DedicatedHsmListOutboundNetworkDependenciesEndpointsComplete retrieves all the results into a single object +func (c DedicatedHsmsClient) DedicatedHsmListOutboundNetworkDependenciesEndpointsComplete(ctx context.Context, id DedicatedHSMId) (DedicatedHsmListOutboundNetworkDependenciesEndpointsCompleteResult, error) { + return c.DedicatedHsmListOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx, id, OutboundEnvironmentEndpointOperationPredicate{}) +} + +// DedicatedHsmListOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DedicatedHsmsClient) DedicatedHsmListOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx context.Context, id DedicatedHSMId, predicate OutboundEnvironmentEndpointOperationPredicate) (result DedicatedHsmListOutboundNetworkDependenciesEndpointsCompleteResult, err error) { + items := make([]OutboundEnvironmentEndpoint, 0) + + resp, err := c.DedicatedHsmListOutboundNetworkDependenciesEndpoints(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = DedicatedHsmListOutboundNetworkDependenciesEndpointsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmupdate.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmupdate.go new file mode 100644 index 00000000000..c9b29847fdd --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/method_dedicatedhsmupdate.go @@ -0,0 +1,75 @@ +package dedicatedhsms + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DedicatedHsmUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DedicatedHsm +} + +// DedicatedHsmUpdate ... +func (c DedicatedHsmsClient) DedicatedHsmUpdate(ctx context.Context, id DedicatedHSMId, input DedicatedHsmPatchParameters) (result DedicatedHsmUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DedicatedHsmUpdateThenPoll performs DedicatedHsmUpdate then polls until it's completed +func (c DedicatedHsmsClient) DedicatedHsmUpdateThenPoll(ctx context.Context, id DedicatedHSMId, input DedicatedHsmPatchParameters) error { + result, err := c.DedicatedHsmUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DedicatedHsmUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DedicatedHsmUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_apientityreference.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_apientityreference.go new file mode 100644 index 00000000000..ff6761462cb --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_apientityreference.go @@ -0,0 +1,8 @@ +package dedicatedhsms + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiEntityReference struct { + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_dedicatedhsm.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_dedicatedhsm.go new file mode 100644 index 00000000000..f711df73695 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_dedicatedhsm.go @@ -0,0 +1,21 @@ +package dedicatedhsms + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DedicatedHsm struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties DedicatedHsmProperties `json:"properties"` + Sku Sku `json:"sku"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_dedicatedhsmpatchparameters.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_dedicatedhsmpatchparameters.go new file mode 100644 index 00000000000..86d8d0a762b --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_dedicatedhsmpatchparameters.go @@ -0,0 +1,8 @@ +package dedicatedhsms + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DedicatedHsmPatchParameters struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_dedicatedhsmproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_dedicatedhsmproperties.go new file mode 100644 index 00000000000..089c6740f27 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_dedicatedhsmproperties.go @@ -0,0 +1,12 @@ +package dedicatedhsms + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DedicatedHsmProperties struct { + ManagementNetworkProfile *NetworkProfile `json:"managementNetworkProfile,omitempty"` + NetworkProfile *NetworkProfile `json:"networkProfile,omitempty"` + ProvisioningState *JsonWebKeyType `json:"provisioningState,omitempty"` + StampId *string `json:"stampId,omitempty"` + StatusMessage *string `json:"statusMessage,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_endpointdependency.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_endpointdependency.go new file mode 100644 index 00000000000..8d0101e5200 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_endpointdependency.go @@ -0,0 +1,9 @@ +package dedicatedhsms + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointDependency struct { + DomainName *string `json:"domainName,omitempty"` + EndpointDetails *[]EndpointDetail `json:"endpointDetails,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_endpointdetail.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_endpointdetail.go new file mode 100644 index 00000000000..981bf57daeb --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_endpointdetail.go @@ -0,0 +1,11 @@ +package dedicatedhsms + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointDetail struct { + Description *string `json:"description,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *string `json:"protocol,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_networkinterface.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_networkinterface.go new file mode 100644 index 00000000000..a6c81cb896d --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_networkinterface.go @@ -0,0 +1,9 @@ +package dedicatedhsms + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + PrivateIPAddress *string `json:"privateIpAddress,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_networkprofile.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_networkprofile.go new file mode 100644 index 00000000000..ad833cee5f1 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_networkprofile.go @@ -0,0 +1,9 @@ +package dedicatedhsms + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkProfile struct { + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + Subnet *ApiEntityReference `json:"subnet,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_outboundenvironmentendpoint.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_outboundenvironmentendpoint.go new file mode 100644 index 00000000000..2da670f790a --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_outboundenvironmentendpoint.go @@ -0,0 +1,9 @@ +package dedicatedhsms + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundEnvironmentEndpoint struct { + Category *string `json:"category,omitempty"` + Endpoints *[]EndpointDependency `json:"endpoints,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_sku.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_sku.go new file mode 100644 index 00000000000..5ca103935da --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/model_sku.go @@ -0,0 +1,8 @@ +package dedicatedhsms + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Name *SkuName `json:"name,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/predicates.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/predicates.go new file mode 100644 index 00000000000..a732c07c71d --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/predicates.go @@ -0,0 +1,45 @@ +package dedicatedhsms + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DedicatedHsmOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p DedicatedHsmOperationPredicate) Matches(input DedicatedHsm) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type OutboundEnvironmentEndpointOperationPredicate struct { + Category *string +} + +func (p OutboundEnvironmentEndpointOperationPredicate) Matches(input OutboundEnvironmentEndpoint) bool { + + if p.Category != nil && (input.Category == nil || *p.Category != *input.Category) { + return false + } + + return true +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/version.go new file mode 100644 index 00000000000..22bfa1241d5 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/dedicatedhsms/version.go @@ -0,0 +1,10 @@ +package dedicatedhsms + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/dedicatedhsms/2025-03-31" +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/README.md b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/README.md new file mode 100644 index 00000000000..047a8c9a437 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus` Documentation + +The `returnsrestoreoperationstatus` SDK allows for interaction with Azure Resource Manager `hardwaresecuritymodules` (API Version `2025-03-31`). + +This readme covers example usages, but further information on [using this SDK can be 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/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus" +``` + + +### Client Initialization + +```go +client := returnsrestoreoperationstatus.NewReturnsRestoreOperationStatusClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReturnsRestoreOperationStatusClient.CloudHsmClusterRestoreStatusGet` + +```go +ctx := context.TODO() +id := returnsrestoreoperationstatus.NewRestoreOperationStatusID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName", "jobId") + +read, err := client.CloudHsmClusterRestoreStatusGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/client.go new file mode 100644 index 00000000000..55b2d9487b6 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/client.go @@ -0,0 +1,26 @@ +package returnsrestoreoperationstatus + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReturnsRestoreOperationStatusClient struct { + Client *resourcemanager.Client +} + +func NewReturnsRestoreOperationStatusClientWithBaseURI(sdkApi sdkEnv.Api) (*ReturnsRestoreOperationStatusClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "returnsrestoreoperationstatus", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReturnsRestoreOperationStatusClient: %+v", err) + } + + return &ReturnsRestoreOperationStatusClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/constants.go b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/constants.go new file mode 100644 index 00000000000..0de188943ed --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/constants.go @@ -0,0 +1,57 @@ +package returnsrestoreoperationstatus + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRestoreOperationStatus string + +const ( + BackupRestoreOperationStatusCancelled BackupRestoreOperationStatus = "Cancelled" + BackupRestoreOperationStatusFailed BackupRestoreOperationStatus = "Failed" + BackupRestoreOperationStatusInProgress BackupRestoreOperationStatus = "InProgress" + BackupRestoreOperationStatusSucceeded BackupRestoreOperationStatus = "Succeeded" +) + +func PossibleValuesForBackupRestoreOperationStatus() []string { + return []string{ + string(BackupRestoreOperationStatusCancelled), + string(BackupRestoreOperationStatusFailed), + string(BackupRestoreOperationStatusInProgress), + string(BackupRestoreOperationStatusSucceeded), + } +} + +func (s *BackupRestoreOperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupRestoreOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupRestoreOperationStatus(input string) (*BackupRestoreOperationStatus, error) { + vals := map[string]BackupRestoreOperationStatus{ + "cancelled": BackupRestoreOperationStatusCancelled, + "failed": BackupRestoreOperationStatusFailed, + "inprogress": BackupRestoreOperationStatusInProgress, + "succeeded": BackupRestoreOperationStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupRestoreOperationStatus(input) + return &out, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/id_restoreoperationstatus.go b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/id_restoreoperationstatus.go new file mode 100644 index 00000000000..152d6564876 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/id_restoreoperationstatus.go @@ -0,0 +1,139 @@ +package returnsrestoreoperationstatus + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RestoreOperationStatusId{}) +} + +var _ resourceids.ResourceId = &RestoreOperationStatusId{} + +// RestoreOperationStatusId is a struct representing the Resource ID for a Restore Operation Status +type RestoreOperationStatusId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string + JobId string +} + +// NewRestoreOperationStatusID returns a new RestoreOperationStatusId struct +func NewRestoreOperationStatusID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string, jobId string) RestoreOperationStatusId { + return RestoreOperationStatusId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + JobId: jobId, + } +} + +// ParseRestoreOperationStatusID parses 'input' into a RestoreOperationStatusId +func ParseRestoreOperationStatusID(input string) (*RestoreOperationStatusId, error) { + parser := resourceids.NewParserFromResourceIdType(&RestoreOperationStatusId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RestoreOperationStatusId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRestoreOperationStatusIDInsensitively parses 'input' case-insensitively into a RestoreOperationStatusId +// note: this method should only be used for API response data and not user input +func ParseRestoreOperationStatusIDInsensitively(input string) (*RestoreOperationStatusId, error) { + parser := resourceids.NewParserFromResourceIdType(&RestoreOperationStatusId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RestoreOperationStatusId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RestoreOperationStatusId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + if id.JobId, ok = input.Parsed["jobId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "jobId", input) + } + + return nil +} + +// ValidateRestoreOperationStatusID checks that 'input' can be parsed as a Restore Operation Status ID +func ValidateRestoreOperationStatusID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRestoreOperationStatusID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Restore Operation Status ID +func (id RestoreOperationStatusId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s/restoreOperationStatus/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName, id.JobId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Restore Operation Status ID +func (id RestoreOperationStatusId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + resourceids.StaticSegment("staticRestoreOperationStatus", "restoreOperationStatus", "restoreOperationStatus"), + resourceids.UserSpecifiedSegment("jobId", "jobId"), + } +} + +// String returns a human-readable description of this Restore Operation Status ID +func (id RestoreOperationStatusId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + fmt.Sprintf("Job: %q", id.JobId), + } + return fmt.Sprintf("Restore Operation Status (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/id_restoreoperationstatus_test.go b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/id_restoreoperationstatus_test.go new file mode 100644 index 00000000000..674e2c58f65 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/id_restoreoperationstatus_test.go @@ -0,0 +1,327 @@ +package returnsrestoreoperationstatus + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RestoreOperationStatusId{} + +func TestNewRestoreOperationStatusID(t *testing.T) { + id := NewRestoreOperationStatusID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName", "jobId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudHsmClusterName != "cloudHsmClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudHsmClusterName'", id.CloudHsmClusterName, "cloudHsmClusterName") + } + + if id.JobId != "jobId" { + t.Fatalf("Expected %q but got %q for Segment 'JobId'", id.JobId, "jobId") + } +} + +func TestFormatRestoreOperationStatusID(t *testing.T) { + actual := NewRestoreOperationStatusID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName", "jobId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/restoreOperationStatus/jobId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRestoreOperationStatusID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RestoreOperationStatusId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/restoreOperationStatus", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/restoreOperationStatus/jobId", + Expected: &RestoreOperationStatusId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + JobId: "jobId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/restoreOperationStatus/jobId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRestoreOperationStatusID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + if actual.JobId != v.Expected.JobId { + t.Fatalf("Expected %q but got %q for JobId", v.Expected.JobId, actual.JobId) + } + + } +} + +func TestParseRestoreOperationStatusIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RestoreOperationStatusId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/restoreOperationStatus", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/rEsToReOpErAtIoNsTaTuS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/restoreOperationStatus/jobId", + Expected: &RestoreOperationStatusId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + JobId: "jobId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/restoreOperationStatus/jobId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/rEsToReOpErAtIoNsTaTuS/jObId", + Expected: &RestoreOperationStatusId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudHsmClusterName: "cLoUdHsMcLuStErNaMe", + JobId: "jObId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/rEsToReOpErAtIoNsTaTuS/jObId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRestoreOperationStatusIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + if actual.JobId != v.Expected.JobId { + t.Fatalf("Expected %q but got %q for JobId", v.Expected.JobId, actual.JobId) + } + + } +} + +func TestSegmentsForRestoreOperationStatusId(t *testing.T) { + segments := RestoreOperationStatusId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RestoreOperationStatusId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/method_cloudhsmclusterrestorestatusget.go b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/method_cloudhsmclusterrestorestatusget.go new file mode 100644 index 00000000000..f2ce3630e05 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/method_cloudhsmclusterrestorestatusget.go @@ -0,0 +1,54 @@ +package returnsrestoreoperationstatus + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClusterRestoreStatusGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestoreResult +} + +// CloudHsmClusterRestoreStatusGet ... +func (c ReturnsRestoreOperationStatusClient) CloudHsmClusterRestoreStatusGet(ctx context.Context, id RestoreOperationStatusId) (result CloudHsmClusterRestoreStatusGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RestoreResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/model_backuprestorebaseresultproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/model_backuprestorebaseresultproperties.go new file mode 100644 index 00000000000..1f863d855a9 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/model_backuprestorebaseresultproperties.go @@ -0,0 +1,43 @@ +package returnsrestoreoperationstatus + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRestoreBaseResultProperties struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + JobId *string `json:"jobId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *BackupRestoreOperationStatus `json:"status,omitempty"` + StatusDetails *string `json:"statusDetails,omitempty"` +} + +func (o *BackupRestoreBaseResultProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupRestoreBaseResultProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *BackupRestoreBaseResultProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupRestoreBaseResultProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/model_erroradditionalinfo.go b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/model_erroradditionalinfo.go new file mode 100644 index 00000000000..6a00bf86024 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package returnsrestoreoperationstatus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/model_errordetail.go b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/model_errordetail.go new file mode 100644 index 00000000000..3ef7b12ee48 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/model_errordetail.go @@ -0,0 +1,12 @@ +package returnsrestoreoperationstatus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/model_restoreresult.go b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/model_restoreresult.go new file mode 100644 index 00000000000..d4d5648d961 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/model_restoreresult.go @@ -0,0 +1,8 @@ +package returnsrestoreoperationstatus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreResult struct { + Properties *BackupRestoreBaseResultProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/version.go new file mode 100644 index 00000000000..de6a0b57b25 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/returnsrestoreoperationstatus/version.go @@ -0,0 +1,10 @@ +package returnsrestoreoperationstatus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/returnsrestoreoperationstatus/2025-03-31" +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/README.md b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/README.md new file mode 100644 index 00000000000..83cf7f0f84b --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties` Documentation + +The `validatecloudhsmclusterrestoreproperties` SDK allows for interaction with Azure Resource Manager `hardwaresecuritymodules` (API Version `2025-03-31`). + +This readme covers example usages, but further information on [using this SDK can be 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/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties" +``` + + +### Client Initialization + +```go +client := validatecloudhsmclusterrestoreproperties.NewValidateCloudHSMClusterRestorePropertiesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ValidateCloudHSMClusterRestorePropertiesClient.CloudHsmClustersValidateRestoreProperties` + +```go +ctx := context.TODO() +id := validatecloudhsmclusterrestoreproperties.NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + +payload := validatecloudhsmclusterrestoreproperties.RestoreRequestProperties{ + // ... +} + + +if err := client.CloudHsmClustersValidateRestorePropertiesThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/client.go b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/client.go new file mode 100644 index 00000000000..92172b1be6d --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/client.go @@ -0,0 +1,26 @@ +package validatecloudhsmclusterrestoreproperties + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateCloudHSMClusterRestorePropertiesClient struct { + Client *resourcemanager.Client +} + +func NewValidateCloudHSMClusterRestorePropertiesClientWithBaseURI(sdkApi sdkEnv.Api) (*ValidateCloudHSMClusterRestorePropertiesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "validatecloudhsmclusterrestoreproperties", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ValidateCloudHSMClusterRestorePropertiesClient: %+v", err) + } + + return &ValidateCloudHSMClusterRestorePropertiesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/constants.go b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/constants.go new file mode 100644 index 00000000000..d79331c6195 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/constants.go @@ -0,0 +1,57 @@ +package validatecloudhsmclusterrestoreproperties + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRestoreOperationStatus string + +const ( + BackupRestoreOperationStatusCancelled BackupRestoreOperationStatus = "Cancelled" + BackupRestoreOperationStatusFailed BackupRestoreOperationStatus = "Failed" + BackupRestoreOperationStatusInProgress BackupRestoreOperationStatus = "InProgress" + BackupRestoreOperationStatusSucceeded BackupRestoreOperationStatus = "Succeeded" +) + +func PossibleValuesForBackupRestoreOperationStatus() []string { + return []string{ + string(BackupRestoreOperationStatusCancelled), + string(BackupRestoreOperationStatusFailed), + string(BackupRestoreOperationStatusInProgress), + string(BackupRestoreOperationStatusSucceeded), + } +} + +func (s *BackupRestoreOperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupRestoreOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupRestoreOperationStatus(input string) (*BackupRestoreOperationStatus, error) { + vals := map[string]BackupRestoreOperationStatus{ + "cancelled": BackupRestoreOperationStatusCancelled, + "failed": BackupRestoreOperationStatusFailed, + "inprogress": BackupRestoreOperationStatusInProgress, + "succeeded": BackupRestoreOperationStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupRestoreOperationStatus(input) + return &out, nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/id_cloudhsmcluster.go b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/id_cloudhsmcluster.go new file mode 100644 index 00000000000..3329e98073e --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/id_cloudhsmcluster.go @@ -0,0 +1,130 @@ +package validatecloudhsmclusterrestoreproperties + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CloudHsmClusterId{}) +} + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +// CloudHsmClusterId is a struct representing the Resource ID for a Cloud Hsm Cluster +type CloudHsmClusterId struct { + SubscriptionId string + ResourceGroupName string + CloudHsmClusterName string +} + +// NewCloudHsmClusterID returns a new CloudHsmClusterId struct +func NewCloudHsmClusterID(subscriptionId string, resourceGroupName string, cloudHsmClusterName string) CloudHsmClusterId { + return CloudHsmClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudHsmClusterName: cloudHsmClusterName, + } +} + +// ParseCloudHsmClusterID parses 'input' into a CloudHsmClusterId +func ParseCloudHsmClusterID(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudHsmClusterIDInsensitively parses 'input' case-insensitively into a CloudHsmClusterId +// note: this method should only be used for API response data and not user input +func ParseCloudHsmClusterIDInsensitively(input string) (*CloudHsmClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudHsmClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudHsmClusterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudHsmClusterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudHsmClusterName, ok = input.Parsed["cloudHsmClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudHsmClusterName", input) + } + + return nil +} + +// ValidateCloudHsmClusterID checks that 'input' can be parsed as a Cloud Hsm Cluster ID +func ValidateCloudHsmClusterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCloudHsmClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud Hsm Cluster ID +func (id CloudHsmClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudHsmClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftHardwareSecurityModules", "Microsoft.HardwareSecurityModules", "Microsoft.HardwareSecurityModules"), + resourceids.StaticSegment("staticCloudHsmClusters", "cloudHsmClusters", "cloudHsmClusters"), + resourceids.UserSpecifiedSegment("cloudHsmClusterName", "cloudHsmClusterName"), + } +} + +// String returns a human-readable description of this Cloud Hsm Cluster ID +func (id CloudHsmClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Hsm Cluster Name: %q", id.CloudHsmClusterName), + } + return fmt.Sprintf("Cloud Hsm Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/id_cloudhsmcluster_test.go b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/id_cloudhsmcluster_test.go new file mode 100644 index 00000000000..d0d09c910a2 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/id_cloudhsmcluster_test.go @@ -0,0 +1,282 @@ +package validatecloudhsmclusterrestoreproperties + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CloudHsmClusterId{} + +func TestNewCloudHsmClusterID(t *testing.T) { + id := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudHsmClusterName != "cloudHsmClusterName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudHsmClusterName'", id.CloudHsmClusterName, "cloudHsmClusterName") + } +} + +func TestFormatCloudHsmClusterID(t *testing.T) { + actual := NewCloudHsmClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudHsmClusterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCloudHsmClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestParseCloudHsmClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudHsmClusterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudHsmClusterName: "cloudHsmClusterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.HardwareSecurityModules/cloudHsmClusters/cloudHsmClusterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe", + Expected: &CloudHsmClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudHsmClusterName: "cLoUdHsMcLuStErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.hArDwArEsEcUrItYmOdUlEs/cLoUdHsMcLuStErS/cLoUdHsMcLuStErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudHsmClusterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudHsmClusterName != v.Expected.CloudHsmClusterName { + t.Fatalf("Expected %q but got %q for CloudHsmClusterName", v.Expected.CloudHsmClusterName, actual.CloudHsmClusterName) + } + + } +} + +func TestSegmentsForCloudHsmClusterId(t *testing.T) { + segments := CloudHsmClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CloudHsmClusterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/method_cloudhsmclustersvalidaterestoreproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/method_cloudhsmclustersvalidaterestoreproperties.go new file mode 100644 index 00000000000..60935082c3d --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/method_cloudhsmclustersvalidaterestoreproperties.go @@ -0,0 +1,75 @@ +package validatecloudhsmclusterrestoreproperties + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudHsmClustersValidateRestorePropertiesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RestoreResult +} + +// CloudHsmClustersValidateRestoreProperties ... +func (c ValidateCloudHSMClusterRestorePropertiesClient) CloudHsmClustersValidateRestoreProperties(ctx context.Context, id CloudHsmClusterId, input RestoreRequestProperties) (result CloudHsmClustersValidateRestorePropertiesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validateRestoreProperties", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CloudHsmClustersValidateRestorePropertiesThenPoll performs CloudHsmClustersValidateRestoreProperties then polls until it's completed +func (c ValidateCloudHSMClusterRestorePropertiesClient) CloudHsmClustersValidateRestorePropertiesThenPoll(ctx context.Context, id CloudHsmClusterId, input RestoreRequestProperties) error { + result, err := c.CloudHsmClustersValidateRestoreProperties(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CloudHsmClustersValidateRestoreProperties: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CloudHsmClustersValidateRestoreProperties: %+v", err) + } + + return nil +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/model_backuprestorebaseresultproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/model_backuprestorebaseresultproperties.go new file mode 100644 index 00000000000..76404456bc9 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/model_backuprestorebaseresultproperties.go @@ -0,0 +1,43 @@ +package validatecloudhsmclusterrestoreproperties + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRestoreBaseResultProperties struct { + EndTime *string `json:"endTime,omitempty"` + Error *ErrorDetail `json:"error,omitempty"` + JobId *string `json:"jobId,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *BackupRestoreOperationStatus `json:"status,omitempty"` + StatusDetails *string `json:"statusDetails,omitempty"` +} + +func (o *BackupRestoreBaseResultProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupRestoreBaseResultProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *BackupRestoreBaseResultProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupRestoreBaseResultProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/model_erroradditionalinfo.go b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/model_erroradditionalinfo.go new file mode 100644 index 00000000000..cbba0db703d --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package validatecloudhsmclusterrestoreproperties + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/model_errordetail.go b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/model_errordetail.go new file mode 100644 index 00000000000..663ac27c0c7 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/model_errordetail.go @@ -0,0 +1,12 @@ +package validatecloudhsmclusterrestoreproperties + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/model_restorerequestproperties.go b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/model_restorerequestproperties.go new file mode 100644 index 00000000000..fa0a71b53ad --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/model_restorerequestproperties.go @@ -0,0 +1,10 @@ +package validatecloudhsmclusterrestoreproperties + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreRequestProperties struct { + AzureStorageBlobContainerUri string `json:"azureStorageBlobContainerUri"` + BackupId string `json:"backupId"` + Token *string `json:"token,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/model_restoreresult.go b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/model_restoreresult.go new file mode 100644 index 00000000000..7d54380a91e --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/model_restoreresult.go @@ -0,0 +1,8 @@ +package validatecloudhsmclusterrestoreproperties + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreResult struct { + Properties *BackupRestoreBaseResultProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/version.go b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/version.go new file mode 100644 index 00000000000..ac78b948ec3 --- /dev/null +++ b/resource-manager/hardwaresecuritymodules/2025-03-31/validatecloudhsmclusterrestoreproperties/version.go @@ -0,0 +1,10 @@ +package validatecloudhsmclusterrestoreproperties + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-03-31" + +func userAgent() string { + return "hashicorp/go-azure-sdk/validatecloudhsmclusterrestoreproperties/2025-03-31" +} diff --git a/resource-manager/network/2024-05-01/networkmanageractiveconfigurations/constants.go b/resource-manager/network/2024-05-01/networkmanageractiveconfigurations/constants.go index c9291fb2fab..793caeabedc 100644 --- a/resource-manager/network/2024-05-01/networkmanageractiveconfigurations/constants.go +++ b/resource-manager/network/2024-05-01/networkmanageractiveconfigurations/constants.go @@ -138,6 +138,8 @@ func parseGroupMemberType(input string) (*GroupMemberType, error) { type ProvisioningState string const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" ProvisioningStateDeleting ProvisioningState = "Deleting" ProvisioningStateFailed ProvisioningState = "Failed" ProvisioningStateSucceeded ProvisioningState = "Succeeded" @@ -146,6 +148,8 @@ const ( func PossibleValuesForProvisioningState() []string { return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), string(ProvisioningStateDeleting), string(ProvisioningStateFailed), string(ProvisioningStateSucceeded), @@ -168,6 +172,8 @@ func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, "deleting": ProvisioningStateDeleting, "failed": ProvisioningStateFailed, "succeeded": ProvisioningStateSucceeded, diff --git a/resource-manager/network/2024-05-01/networkmanageractiveconnectivityconfigurations/constants.go b/resource-manager/network/2024-05-01/networkmanageractiveconnectivityconfigurations/constants.go index 642ecd4a0bd..6f3a6c4f554 100644 --- a/resource-manager/network/2024-05-01/networkmanageractiveconnectivityconfigurations/constants.go +++ b/resource-manager/network/2024-05-01/networkmanageractiveconnectivityconfigurations/constants.go @@ -217,6 +217,8 @@ func parseIsGlobal(input string) (*IsGlobal, error) { type ProvisioningState string const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" ProvisioningStateDeleting ProvisioningState = "Deleting" ProvisioningStateFailed ProvisioningState = "Failed" ProvisioningStateSucceeded ProvisioningState = "Succeeded" @@ -225,6 +227,8 @@ const ( func PossibleValuesForProvisioningState() []string { return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), string(ProvisioningStateDeleting), string(ProvisioningStateFailed), string(ProvisioningStateSucceeded), @@ -247,6 +251,8 @@ func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { func parseProvisioningState(input string) (*ProvisioningState, error) { vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, "deleting": ProvisioningStateDeleting, "failed": ProvisioningStateFailed, "succeeded": ProvisioningStateSucceeded, diff --git a/resource-manager/network/2024-07-01/adminrulecollections/README.md b/resource-manager/network/2024-07-01/adminrulecollections/README.md new file mode 100644 index 00000000000..6f71cefaf03 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrulecollections/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/adminrulecollections` Documentation + +The `adminrulecollections` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/adminrulecollections" +``` + + +### Client Initialization + +```go +client := adminrulecollections.NewAdminRuleCollectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AdminRuleCollectionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := adminrulecollections.NewSecurityAdminConfigurationRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName", "ruleCollectionName") + +payload := adminrulecollections.AdminRuleCollection{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AdminRuleCollectionsClient.Delete` + +```go +ctx := context.TODO() +id := adminrulecollections.NewSecurityAdminConfigurationRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName", "ruleCollectionName") + +if err := client.DeleteThenPoll(ctx, id, adminrulecollections.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `AdminRuleCollectionsClient.Get` + +```go +ctx := context.TODO() +id := adminrulecollections.NewSecurityAdminConfigurationRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName", "ruleCollectionName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AdminRuleCollectionsClient.List` + +```go +ctx := context.TODO() +id := adminrulecollections.NewSecurityAdminConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName") + +// alternatively `client.List(ctx, id, adminrulecollections.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, adminrulecollections.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/adminrulecollections/client.go b/resource-manager/network/2024-07-01/adminrulecollections/client.go new file mode 100644 index 00000000000..a0e144b1d96 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrulecollections/client.go @@ -0,0 +1,26 @@ +package adminrulecollections + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdminRuleCollectionsClient struct { + Client *resourcemanager.Client +} + +func NewAdminRuleCollectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*AdminRuleCollectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "adminrulecollections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AdminRuleCollectionsClient: %+v", err) + } + + return &AdminRuleCollectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/adminrulecollections/constants.go b/resource-manager/network/2024-07-01/adminrulecollections/constants.go new file mode 100644 index 00000000000..3ed50c565e3 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrulecollections/constants.go @@ -0,0 +1,63 @@ +package adminrulecollections + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/adminrulecollections/id_securityadminconfiguration.go b/resource-manager/network/2024-07-01/adminrulecollections/id_securityadminconfiguration.go new file mode 100644 index 00000000000..193fa95d9b5 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrulecollections/id_securityadminconfiguration.go @@ -0,0 +1,139 @@ +package adminrulecollections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SecurityAdminConfigurationId{}) +} + +var _ resourceids.ResourceId = &SecurityAdminConfigurationId{} + +// SecurityAdminConfigurationId is a struct representing the Resource ID for a Security Admin Configuration +type SecurityAdminConfigurationId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + SecurityAdminConfigurationName string +} + +// NewSecurityAdminConfigurationID returns a new SecurityAdminConfigurationId struct +func NewSecurityAdminConfigurationID(subscriptionId string, resourceGroupName string, networkManagerName string, securityAdminConfigurationName string) SecurityAdminConfigurationId { + return SecurityAdminConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + SecurityAdminConfigurationName: securityAdminConfigurationName, + } +} + +// ParseSecurityAdminConfigurationID parses 'input' into a SecurityAdminConfigurationId +func ParseSecurityAdminConfigurationID(input string) (*SecurityAdminConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityAdminConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityAdminConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSecurityAdminConfigurationIDInsensitively parses 'input' case-insensitively into a SecurityAdminConfigurationId +// note: this method should only be used for API response data and not user input +func ParseSecurityAdminConfigurationIDInsensitively(input string) (*SecurityAdminConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityAdminConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityAdminConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SecurityAdminConfigurationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.SecurityAdminConfigurationName, ok = input.Parsed["securityAdminConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "securityAdminConfigurationName", input) + } + + return nil +} + +// ValidateSecurityAdminConfigurationID checks that 'input' can be parsed as a Security Admin Configuration ID +func ValidateSecurityAdminConfigurationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSecurityAdminConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Security Admin Configuration ID +func (id SecurityAdminConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/securityAdminConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.SecurityAdminConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Security Admin Configuration ID +func (id SecurityAdminConfigurationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticSecurityAdminConfigurations", "securityAdminConfigurations", "securityAdminConfigurations"), + resourceids.UserSpecifiedSegment("securityAdminConfigurationName", "securityAdminConfigurationName"), + } +} + +// String returns a human-readable description of this Security Admin Configuration ID +func (id SecurityAdminConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Security Admin Configuration Name: %q", id.SecurityAdminConfigurationName), + } + return fmt.Sprintf("Security Admin Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/adminrulecollections/id_securityadminconfiguration_test.go b/resource-manager/network/2024-07-01/adminrulecollections/id_securityadminconfiguration_test.go new file mode 100644 index 00000000000..aa4f07d225f --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrulecollections/id_securityadminconfiguration_test.go @@ -0,0 +1,327 @@ +package adminrulecollections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SecurityAdminConfigurationId{} + +func TestNewSecurityAdminConfigurationID(t *testing.T) { + id := NewSecurityAdminConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.SecurityAdminConfigurationName != "securityAdminConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'SecurityAdminConfigurationName'", id.SecurityAdminConfigurationName, "securityAdminConfigurationName") + } +} + +func TestFormatSecurityAdminConfigurationID(t *testing.T) { + actual := NewSecurityAdminConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSecurityAdminConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityAdminConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName", + Expected: &SecurityAdminConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityAdminConfigurationName: "securityAdminConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityAdminConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityAdminConfigurationName != v.Expected.SecurityAdminConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityAdminConfigurationName", v.Expected.SecurityAdminConfigurationName, actual.SecurityAdminConfigurationName) + } + + } +} + +func TestParseSecurityAdminConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityAdminConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName", + Expected: &SecurityAdminConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityAdminConfigurationName: "securityAdminConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE", + Expected: &SecurityAdminConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + SecurityAdminConfigurationName: "sEcUrItYaDmInCoNfIgUrAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityAdminConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityAdminConfigurationName != v.Expected.SecurityAdminConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityAdminConfigurationName", v.Expected.SecurityAdminConfigurationName, actual.SecurityAdminConfigurationName) + } + + } +} + +func TestSegmentsForSecurityAdminConfigurationId(t *testing.T) { + segments := SecurityAdminConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SecurityAdminConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/adminrulecollections/id_securityadminconfigurationrulecollection.go b/resource-manager/network/2024-07-01/adminrulecollections/id_securityadminconfigurationrulecollection.go new file mode 100644 index 00000000000..543fa58afbe --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrulecollections/id_securityadminconfigurationrulecollection.go @@ -0,0 +1,148 @@ +package adminrulecollections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SecurityAdminConfigurationRuleCollectionId{}) +} + +var _ resourceids.ResourceId = &SecurityAdminConfigurationRuleCollectionId{} + +// SecurityAdminConfigurationRuleCollectionId is a struct representing the Resource ID for a Security Admin Configuration Rule Collection +type SecurityAdminConfigurationRuleCollectionId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + SecurityAdminConfigurationName string + RuleCollectionName string +} + +// NewSecurityAdminConfigurationRuleCollectionID returns a new SecurityAdminConfigurationRuleCollectionId struct +func NewSecurityAdminConfigurationRuleCollectionID(subscriptionId string, resourceGroupName string, networkManagerName string, securityAdminConfigurationName string, ruleCollectionName string) SecurityAdminConfigurationRuleCollectionId { + return SecurityAdminConfigurationRuleCollectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + SecurityAdminConfigurationName: securityAdminConfigurationName, + RuleCollectionName: ruleCollectionName, + } +} + +// ParseSecurityAdminConfigurationRuleCollectionID parses 'input' into a SecurityAdminConfigurationRuleCollectionId +func ParseSecurityAdminConfigurationRuleCollectionID(input string) (*SecurityAdminConfigurationRuleCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityAdminConfigurationRuleCollectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityAdminConfigurationRuleCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSecurityAdminConfigurationRuleCollectionIDInsensitively parses 'input' case-insensitively into a SecurityAdminConfigurationRuleCollectionId +// note: this method should only be used for API response data and not user input +func ParseSecurityAdminConfigurationRuleCollectionIDInsensitively(input string) (*SecurityAdminConfigurationRuleCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityAdminConfigurationRuleCollectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityAdminConfigurationRuleCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SecurityAdminConfigurationRuleCollectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.SecurityAdminConfigurationName, ok = input.Parsed["securityAdminConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "securityAdminConfigurationName", input) + } + + if id.RuleCollectionName, ok = input.Parsed["ruleCollectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleCollectionName", input) + } + + return nil +} + +// ValidateSecurityAdminConfigurationRuleCollectionID checks that 'input' can be parsed as a Security Admin Configuration Rule Collection ID +func ValidateSecurityAdminConfigurationRuleCollectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSecurityAdminConfigurationRuleCollectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Security Admin Configuration Rule Collection ID +func (id SecurityAdminConfigurationRuleCollectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/securityAdminConfigurations/%s/ruleCollections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.SecurityAdminConfigurationName, id.RuleCollectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Security Admin Configuration Rule Collection ID +func (id SecurityAdminConfigurationRuleCollectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticSecurityAdminConfigurations", "securityAdminConfigurations", "securityAdminConfigurations"), + resourceids.UserSpecifiedSegment("securityAdminConfigurationName", "securityAdminConfigurationName"), + resourceids.StaticSegment("staticRuleCollections", "ruleCollections", "ruleCollections"), + resourceids.UserSpecifiedSegment("ruleCollectionName", "ruleCollectionName"), + } +} + +// String returns a human-readable description of this Security Admin Configuration Rule Collection ID +func (id SecurityAdminConfigurationRuleCollectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Security Admin Configuration Name: %q", id.SecurityAdminConfigurationName), + fmt.Sprintf("Rule Collection Name: %q", id.RuleCollectionName), + } + return fmt.Sprintf("Security Admin Configuration Rule Collection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/adminrulecollections/id_securityadminconfigurationrulecollection_test.go b/resource-manager/network/2024-07-01/adminrulecollections/id_securityadminconfigurationrulecollection_test.go new file mode 100644 index 00000000000..ee1465b82db --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrulecollections/id_securityadminconfigurationrulecollection_test.go @@ -0,0 +1,372 @@ +package adminrulecollections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SecurityAdminConfigurationRuleCollectionId{} + +func TestNewSecurityAdminConfigurationRuleCollectionID(t *testing.T) { + id := NewSecurityAdminConfigurationRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName", "ruleCollectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.SecurityAdminConfigurationName != "securityAdminConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'SecurityAdminConfigurationName'", id.SecurityAdminConfigurationName, "securityAdminConfigurationName") + } + + if id.RuleCollectionName != "ruleCollectionName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleCollectionName'", id.RuleCollectionName, "ruleCollectionName") + } +} + +func TestFormatSecurityAdminConfigurationRuleCollectionID(t *testing.T) { + actual := NewSecurityAdminConfigurationRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName", "ruleCollectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSecurityAdminConfigurationRuleCollectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityAdminConfigurationRuleCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName", + Expected: &SecurityAdminConfigurationRuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityAdminConfigurationName: "securityAdminConfigurationName", + RuleCollectionName: "ruleCollectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityAdminConfigurationRuleCollectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityAdminConfigurationName != v.Expected.SecurityAdminConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityAdminConfigurationName", v.Expected.SecurityAdminConfigurationName, actual.SecurityAdminConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + } +} + +func TestParseSecurityAdminConfigurationRuleCollectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityAdminConfigurationRuleCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName", + Expected: &SecurityAdminConfigurationRuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityAdminConfigurationName: "securityAdminConfigurationName", + RuleCollectionName: "ruleCollectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE", + Expected: &SecurityAdminConfigurationRuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + SecurityAdminConfigurationName: "sEcUrItYaDmInCoNfIgUrAtIoNnAmE", + RuleCollectionName: "rUlEcOlLeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityAdminConfigurationRuleCollectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityAdminConfigurationName != v.Expected.SecurityAdminConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityAdminConfigurationName", v.Expected.SecurityAdminConfigurationName, actual.SecurityAdminConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + } +} + +func TestSegmentsForSecurityAdminConfigurationRuleCollectionId(t *testing.T) { + segments := SecurityAdminConfigurationRuleCollectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SecurityAdminConfigurationRuleCollectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/adminrulecollections/method_createorupdate.go b/resource-manager/network/2024-07-01/adminrulecollections/method_createorupdate.go new file mode 100644 index 00000000000..aa29bb56031 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrulecollections/method_createorupdate.go @@ -0,0 +1,58 @@ +package adminrulecollections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AdminRuleCollection +} + +// CreateOrUpdate ... +func (c AdminRuleCollectionsClient) CreateOrUpdate(ctx context.Context, id SecurityAdminConfigurationRuleCollectionId, input AdminRuleCollection) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AdminRuleCollection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/adminrulecollections/method_delete.go b/resource-manager/network/2024-07-01/adminrulecollections/method_delete.go new file mode 100644 index 00000000000..cb7d683e73a --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrulecollections/method_delete.go @@ -0,0 +1,100 @@ +package adminrulecollections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c AdminRuleCollectionsClient) Delete(ctx context.Context, id SecurityAdminConfigurationRuleCollectionId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c AdminRuleCollectionsClient) DeleteThenPoll(ctx context.Context, id SecurityAdminConfigurationRuleCollectionId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/adminrulecollections/method_get.go b/resource-manager/network/2024-07-01/adminrulecollections/method_get.go new file mode 100644 index 00000000000..4f1440daece --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrulecollections/method_get.go @@ -0,0 +1,53 @@ +package adminrulecollections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AdminRuleCollection +} + +// Get ... +func (c AdminRuleCollectionsClient) Get(ctx context.Context, id SecurityAdminConfigurationRuleCollectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AdminRuleCollection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/adminrulecollections/method_list.go b/resource-manager/network/2024-07-01/adminrulecollections/method_list.go new file mode 100644 index 00000000000..2ef5b46d0a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrulecollections/method_list.go @@ -0,0 +1,134 @@ +package adminrulecollections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AdminRuleCollection +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AdminRuleCollection +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c AdminRuleCollectionsClient) List(ctx context.Context, id SecurityAdminConfigurationId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/ruleCollections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AdminRuleCollection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AdminRuleCollectionsClient) ListComplete(ctx context.Context, id SecurityAdminConfigurationId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, AdminRuleCollectionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AdminRuleCollectionsClient) ListCompleteMatchingPredicate(ctx context.Context, id SecurityAdminConfigurationId, options ListOperationOptions, predicate AdminRuleCollectionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AdminRuleCollection, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/adminrulecollections/model_adminrulecollection.go b/resource-manager/network/2024-07-01/adminrulecollections/model_adminrulecollection.go new file mode 100644 index 00000000000..aea91d2ba70 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrulecollections/model_adminrulecollection.go @@ -0,0 +1,17 @@ +package adminrulecollections + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdminRuleCollection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AdminRuleCollectionPropertiesFormat `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/adminrulecollections/model_adminrulecollectionpropertiesformat.go b/resource-manager/network/2024-07-01/adminrulecollections/model_adminrulecollectionpropertiesformat.go new file mode 100644 index 00000000000..43e02d8ca9c --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrulecollections/model_adminrulecollectionpropertiesformat.go @@ -0,0 +1,11 @@ +package adminrulecollections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdminRuleCollectionPropertiesFormat struct { + AppliesToGroups []NetworkManagerSecurityGroupItem `json:"appliesToGroups"` + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/adminrulecollections/model_networkmanagersecuritygroupitem.go b/resource-manager/network/2024-07-01/adminrulecollections/model_networkmanagersecuritygroupitem.go new file mode 100644 index 00000000000..ce59c38f4fd --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrulecollections/model_networkmanagersecuritygroupitem.go @@ -0,0 +1,8 @@ +package adminrulecollections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerSecurityGroupItem struct { + NetworkGroupId string `json:"networkGroupId"` +} diff --git a/resource-manager/network/2024-07-01/adminrulecollections/predicates.go b/resource-manager/network/2024-07-01/adminrulecollections/predicates.go new file mode 100644 index 00000000000..67b37b95643 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrulecollections/predicates.go @@ -0,0 +1,32 @@ +package adminrulecollections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdminRuleCollectionOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p AdminRuleCollectionOperationPredicate) Matches(input AdminRuleCollection) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/adminrulecollections/version.go b/resource-manager/network/2024-07-01/adminrulecollections/version.go new file mode 100644 index 00000000000..a5f1bf17b0c --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrulecollections/version.go @@ -0,0 +1,10 @@ +package adminrulecollections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/adminrulecollections/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/adminrules/README.md b/resource-manager/network/2024-07-01/adminrules/README.md new file mode 100644 index 00000000000..dfe354852a5 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/adminrules` Documentation + +The `adminrules` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/adminrules" +``` + + +### Client Initialization + +```go +client := adminrules.NewAdminRulesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AdminRulesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := adminrules.NewSecurityAdminConfigurationRuleCollectionRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName", "ruleCollectionName", "ruleName") + +payload := adminrules.BaseAdminRule{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AdminRulesClient.Delete` + +```go +ctx := context.TODO() +id := adminrules.NewSecurityAdminConfigurationRuleCollectionRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName", "ruleCollectionName", "ruleName") + +if err := client.DeleteThenPoll(ctx, id, adminrules.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `AdminRulesClient.Get` + +```go +ctx := context.TODO() +id := adminrules.NewSecurityAdminConfigurationRuleCollectionRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName", "ruleCollectionName", "ruleName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AdminRulesClient.List` + +```go +ctx := context.TODO() +id := adminrules.NewSecurityAdminConfigurationRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName", "ruleCollectionName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/adminrules/client.go b/resource-manager/network/2024-07-01/adminrules/client.go new file mode 100644 index 00000000000..811271711b6 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/client.go @@ -0,0 +1,26 @@ +package adminrules + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdminRulesClient struct { + Client *resourcemanager.Client +} + +func NewAdminRulesClientWithBaseURI(sdkApi sdkEnv.Api) (*AdminRulesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "adminrules", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AdminRulesClient: %+v", err) + } + + return &AdminRulesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/adminrules/constants.go b/resource-manager/network/2024-07-01/adminrules/constants.go new file mode 100644 index 00000000000..4b50249b0af --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/constants.go @@ -0,0 +1,286 @@ +package adminrules + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressPrefixType string + +const ( + AddressPrefixTypeIPPrefix AddressPrefixType = "IPPrefix" + AddressPrefixTypeNetworkGroup AddressPrefixType = "NetworkGroup" + AddressPrefixTypeServiceTag AddressPrefixType = "ServiceTag" +) + +func PossibleValuesForAddressPrefixType() []string { + return []string{ + string(AddressPrefixTypeIPPrefix), + string(AddressPrefixTypeNetworkGroup), + string(AddressPrefixTypeServiceTag), + } +} + +func (s *AddressPrefixType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAddressPrefixType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAddressPrefixType(input string) (*AddressPrefixType, error) { + vals := map[string]AddressPrefixType{ + "ipprefix": AddressPrefixTypeIPPrefix, + "networkgroup": AddressPrefixTypeNetworkGroup, + "servicetag": AddressPrefixTypeServiceTag, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AddressPrefixType(input) + return &out, nil +} + +type AdminRuleKind string + +const ( + AdminRuleKindCustom AdminRuleKind = "Custom" + AdminRuleKindDefault AdminRuleKind = "Default" +) + +func PossibleValuesForAdminRuleKind() []string { + return []string{ + string(AdminRuleKindCustom), + string(AdminRuleKindDefault), + } +} + +func (s *AdminRuleKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAdminRuleKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAdminRuleKind(input string) (*AdminRuleKind, error) { + vals := map[string]AdminRuleKind{ + "custom": AdminRuleKindCustom, + "default": AdminRuleKindDefault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AdminRuleKind(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SecurityConfigurationRuleAccess string + +const ( + SecurityConfigurationRuleAccessAllow SecurityConfigurationRuleAccess = "Allow" + SecurityConfigurationRuleAccessAlwaysAllow SecurityConfigurationRuleAccess = "AlwaysAllow" + SecurityConfigurationRuleAccessDeny SecurityConfigurationRuleAccess = "Deny" +) + +func PossibleValuesForSecurityConfigurationRuleAccess() []string { + return []string{ + string(SecurityConfigurationRuleAccessAllow), + string(SecurityConfigurationRuleAccessAlwaysAllow), + string(SecurityConfigurationRuleAccessDeny), + } +} + +func (s *SecurityConfigurationRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityConfigurationRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityConfigurationRuleAccess(input string) (*SecurityConfigurationRuleAccess, error) { + vals := map[string]SecurityConfigurationRuleAccess{ + "allow": SecurityConfigurationRuleAccessAllow, + "alwaysallow": SecurityConfigurationRuleAccessAlwaysAllow, + "deny": SecurityConfigurationRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityConfigurationRuleAccess(input) + return &out, nil +} + +type SecurityConfigurationRuleDirection string + +const ( + SecurityConfigurationRuleDirectionInbound SecurityConfigurationRuleDirection = "Inbound" + SecurityConfigurationRuleDirectionOutbound SecurityConfigurationRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityConfigurationRuleDirection() []string { + return []string{ + string(SecurityConfigurationRuleDirectionInbound), + string(SecurityConfigurationRuleDirectionOutbound), + } +} + +func (s *SecurityConfigurationRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityConfigurationRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityConfigurationRuleDirection(input string) (*SecurityConfigurationRuleDirection, error) { + vals := map[string]SecurityConfigurationRuleDirection{ + "inbound": SecurityConfigurationRuleDirectionInbound, + "outbound": SecurityConfigurationRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityConfigurationRuleDirection(input) + return &out, nil +} + +type SecurityConfigurationRuleProtocol string + +const ( + SecurityConfigurationRuleProtocolAh SecurityConfigurationRuleProtocol = "Ah" + SecurityConfigurationRuleProtocolAny SecurityConfigurationRuleProtocol = "Any" + SecurityConfigurationRuleProtocolEsp SecurityConfigurationRuleProtocol = "Esp" + SecurityConfigurationRuleProtocolIcmp SecurityConfigurationRuleProtocol = "Icmp" + SecurityConfigurationRuleProtocolTcp SecurityConfigurationRuleProtocol = "Tcp" + SecurityConfigurationRuleProtocolUdp SecurityConfigurationRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityConfigurationRuleProtocol() []string { + return []string{ + string(SecurityConfigurationRuleProtocolAh), + string(SecurityConfigurationRuleProtocolAny), + string(SecurityConfigurationRuleProtocolEsp), + string(SecurityConfigurationRuleProtocolIcmp), + string(SecurityConfigurationRuleProtocolTcp), + string(SecurityConfigurationRuleProtocolUdp), + } +} + +func (s *SecurityConfigurationRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityConfigurationRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityConfigurationRuleProtocol(input string) (*SecurityConfigurationRuleProtocol, error) { + vals := map[string]SecurityConfigurationRuleProtocol{ + "ah": SecurityConfigurationRuleProtocolAh, + "any": SecurityConfigurationRuleProtocolAny, + "esp": SecurityConfigurationRuleProtocolEsp, + "icmp": SecurityConfigurationRuleProtocolIcmp, + "tcp": SecurityConfigurationRuleProtocolTcp, + "udp": SecurityConfigurationRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityConfigurationRuleProtocol(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/adminrules/id_securityadminconfigurationrulecollection.go b/resource-manager/network/2024-07-01/adminrules/id_securityadminconfigurationrulecollection.go new file mode 100644 index 00000000000..cc58659b878 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/id_securityadminconfigurationrulecollection.go @@ -0,0 +1,148 @@ +package adminrules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SecurityAdminConfigurationRuleCollectionId{}) +} + +var _ resourceids.ResourceId = &SecurityAdminConfigurationRuleCollectionId{} + +// SecurityAdminConfigurationRuleCollectionId is a struct representing the Resource ID for a Security Admin Configuration Rule Collection +type SecurityAdminConfigurationRuleCollectionId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + SecurityAdminConfigurationName string + RuleCollectionName string +} + +// NewSecurityAdminConfigurationRuleCollectionID returns a new SecurityAdminConfigurationRuleCollectionId struct +func NewSecurityAdminConfigurationRuleCollectionID(subscriptionId string, resourceGroupName string, networkManagerName string, securityAdminConfigurationName string, ruleCollectionName string) SecurityAdminConfigurationRuleCollectionId { + return SecurityAdminConfigurationRuleCollectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + SecurityAdminConfigurationName: securityAdminConfigurationName, + RuleCollectionName: ruleCollectionName, + } +} + +// ParseSecurityAdminConfigurationRuleCollectionID parses 'input' into a SecurityAdminConfigurationRuleCollectionId +func ParseSecurityAdminConfigurationRuleCollectionID(input string) (*SecurityAdminConfigurationRuleCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityAdminConfigurationRuleCollectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityAdminConfigurationRuleCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSecurityAdminConfigurationRuleCollectionIDInsensitively parses 'input' case-insensitively into a SecurityAdminConfigurationRuleCollectionId +// note: this method should only be used for API response data and not user input +func ParseSecurityAdminConfigurationRuleCollectionIDInsensitively(input string) (*SecurityAdminConfigurationRuleCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityAdminConfigurationRuleCollectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityAdminConfigurationRuleCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SecurityAdminConfigurationRuleCollectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.SecurityAdminConfigurationName, ok = input.Parsed["securityAdminConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "securityAdminConfigurationName", input) + } + + if id.RuleCollectionName, ok = input.Parsed["ruleCollectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleCollectionName", input) + } + + return nil +} + +// ValidateSecurityAdminConfigurationRuleCollectionID checks that 'input' can be parsed as a Security Admin Configuration Rule Collection ID +func ValidateSecurityAdminConfigurationRuleCollectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSecurityAdminConfigurationRuleCollectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Security Admin Configuration Rule Collection ID +func (id SecurityAdminConfigurationRuleCollectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/securityAdminConfigurations/%s/ruleCollections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.SecurityAdminConfigurationName, id.RuleCollectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Security Admin Configuration Rule Collection ID +func (id SecurityAdminConfigurationRuleCollectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticSecurityAdminConfigurations", "securityAdminConfigurations", "securityAdminConfigurations"), + resourceids.UserSpecifiedSegment("securityAdminConfigurationName", "securityAdminConfigurationName"), + resourceids.StaticSegment("staticRuleCollections", "ruleCollections", "ruleCollections"), + resourceids.UserSpecifiedSegment("ruleCollectionName", "ruleCollectionName"), + } +} + +// String returns a human-readable description of this Security Admin Configuration Rule Collection ID +func (id SecurityAdminConfigurationRuleCollectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Security Admin Configuration Name: %q", id.SecurityAdminConfigurationName), + fmt.Sprintf("Rule Collection Name: %q", id.RuleCollectionName), + } + return fmt.Sprintf("Security Admin Configuration Rule Collection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/adminrules/id_securityadminconfigurationrulecollection_test.go b/resource-manager/network/2024-07-01/adminrules/id_securityadminconfigurationrulecollection_test.go new file mode 100644 index 00000000000..b1132297b80 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/id_securityadminconfigurationrulecollection_test.go @@ -0,0 +1,372 @@ +package adminrules + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SecurityAdminConfigurationRuleCollectionId{} + +func TestNewSecurityAdminConfigurationRuleCollectionID(t *testing.T) { + id := NewSecurityAdminConfigurationRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName", "ruleCollectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.SecurityAdminConfigurationName != "securityAdminConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'SecurityAdminConfigurationName'", id.SecurityAdminConfigurationName, "securityAdminConfigurationName") + } + + if id.RuleCollectionName != "ruleCollectionName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleCollectionName'", id.RuleCollectionName, "ruleCollectionName") + } +} + +func TestFormatSecurityAdminConfigurationRuleCollectionID(t *testing.T) { + actual := NewSecurityAdminConfigurationRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName", "ruleCollectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSecurityAdminConfigurationRuleCollectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityAdminConfigurationRuleCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName", + Expected: &SecurityAdminConfigurationRuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityAdminConfigurationName: "securityAdminConfigurationName", + RuleCollectionName: "ruleCollectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityAdminConfigurationRuleCollectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityAdminConfigurationName != v.Expected.SecurityAdminConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityAdminConfigurationName", v.Expected.SecurityAdminConfigurationName, actual.SecurityAdminConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + } +} + +func TestParseSecurityAdminConfigurationRuleCollectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityAdminConfigurationRuleCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName", + Expected: &SecurityAdminConfigurationRuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityAdminConfigurationName: "securityAdminConfigurationName", + RuleCollectionName: "ruleCollectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE", + Expected: &SecurityAdminConfigurationRuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + SecurityAdminConfigurationName: "sEcUrItYaDmInCoNfIgUrAtIoNnAmE", + RuleCollectionName: "rUlEcOlLeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityAdminConfigurationRuleCollectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityAdminConfigurationName != v.Expected.SecurityAdminConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityAdminConfigurationName", v.Expected.SecurityAdminConfigurationName, actual.SecurityAdminConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + } +} + +func TestSegmentsForSecurityAdminConfigurationRuleCollectionId(t *testing.T) { + segments := SecurityAdminConfigurationRuleCollectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SecurityAdminConfigurationRuleCollectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/adminrules/id_securityadminconfigurationrulecollectionrule.go b/resource-manager/network/2024-07-01/adminrules/id_securityadminconfigurationrulecollectionrule.go new file mode 100644 index 00000000000..9ff1e96755d --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/id_securityadminconfigurationrulecollectionrule.go @@ -0,0 +1,157 @@ +package adminrules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SecurityAdminConfigurationRuleCollectionRuleId{}) +} + +var _ resourceids.ResourceId = &SecurityAdminConfigurationRuleCollectionRuleId{} + +// SecurityAdminConfigurationRuleCollectionRuleId is a struct representing the Resource ID for a Security Admin Configuration Rule Collection Rule +type SecurityAdminConfigurationRuleCollectionRuleId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + SecurityAdminConfigurationName string + RuleCollectionName string + RuleName string +} + +// NewSecurityAdminConfigurationRuleCollectionRuleID returns a new SecurityAdminConfigurationRuleCollectionRuleId struct +func NewSecurityAdminConfigurationRuleCollectionRuleID(subscriptionId string, resourceGroupName string, networkManagerName string, securityAdminConfigurationName string, ruleCollectionName string, ruleName string) SecurityAdminConfigurationRuleCollectionRuleId { + return SecurityAdminConfigurationRuleCollectionRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + SecurityAdminConfigurationName: securityAdminConfigurationName, + RuleCollectionName: ruleCollectionName, + RuleName: ruleName, + } +} + +// ParseSecurityAdminConfigurationRuleCollectionRuleID parses 'input' into a SecurityAdminConfigurationRuleCollectionRuleId +func ParseSecurityAdminConfigurationRuleCollectionRuleID(input string) (*SecurityAdminConfigurationRuleCollectionRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityAdminConfigurationRuleCollectionRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityAdminConfigurationRuleCollectionRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSecurityAdminConfigurationRuleCollectionRuleIDInsensitively parses 'input' case-insensitively into a SecurityAdminConfigurationRuleCollectionRuleId +// note: this method should only be used for API response data and not user input +func ParseSecurityAdminConfigurationRuleCollectionRuleIDInsensitively(input string) (*SecurityAdminConfigurationRuleCollectionRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityAdminConfigurationRuleCollectionRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityAdminConfigurationRuleCollectionRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SecurityAdminConfigurationRuleCollectionRuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.SecurityAdminConfigurationName, ok = input.Parsed["securityAdminConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "securityAdminConfigurationName", input) + } + + if id.RuleCollectionName, ok = input.Parsed["ruleCollectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleCollectionName", input) + } + + if id.RuleName, ok = input.Parsed["ruleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleName", input) + } + + return nil +} + +// ValidateSecurityAdminConfigurationRuleCollectionRuleID checks that 'input' can be parsed as a Security Admin Configuration Rule Collection Rule ID +func ValidateSecurityAdminConfigurationRuleCollectionRuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSecurityAdminConfigurationRuleCollectionRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Security Admin Configuration Rule Collection Rule ID +func (id SecurityAdminConfigurationRuleCollectionRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/securityAdminConfigurations/%s/ruleCollections/%s/rules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.SecurityAdminConfigurationName, id.RuleCollectionName, id.RuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Security Admin Configuration Rule Collection Rule ID +func (id SecurityAdminConfigurationRuleCollectionRuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticSecurityAdminConfigurations", "securityAdminConfigurations", "securityAdminConfigurations"), + resourceids.UserSpecifiedSegment("securityAdminConfigurationName", "securityAdminConfigurationName"), + resourceids.StaticSegment("staticRuleCollections", "ruleCollections", "ruleCollections"), + resourceids.UserSpecifiedSegment("ruleCollectionName", "ruleCollectionName"), + resourceids.StaticSegment("staticRules", "rules", "rules"), + resourceids.UserSpecifiedSegment("ruleName", "ruleName"), + } +} + +// String returns a human-readable description of this Security Admin Configuration Rule Collection Rule ID +func (id SecurityAdminConfigurationRuleCollectionRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Security Admin Configuration Name: %q", id.SecurityAdminConfigurationName), + fmt.Sprintf("Rule Collection Name: %q", id.RuleCollectionName), + fmt.Sprintf("Rule Name: %q", id.RuleName), + } + return fmt.Sprintf("Security Admin Configuration Rule Collection Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/adminrules/id_securityadminconfigurationrulecollectionrule_test.go b/resource-manager/network/2024-07-01/adminrules/id_securityadminconfigurationrulecollectionrule_test.go new file mode 100644 index 00000000000..5aa722a6158 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/id_securityadminconfigurationrulecollectionrule_test.go @@ -0,0 +1,417 @@ +package adminrules + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SecurityAdminConfigurationRuleCollectionRuleId{} + +func TestNewSecurityAdminConfigurationRuleCollectionRuleID(t *testing.T) { + id := NewSecurityAdminConfigurationRuleCollectionRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName", "ruleCollectionName", "ruleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.SecurityAdminConfigurationName != "securityAdminConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'SecurityAdminConfigurationName'", id.SecurityAdminConfigurationName, "securityAdminConfigurationName") + } + + if id.RuleCollectionName != "ruleCollectionName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleCollectionName'", id.RuleCollectionName, "ruleCollectionName") + } + + if id.RuleName != "ruleName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleName'", id.RuleName, "ruleName") + } +} + +func TestFormatSecurityAdminConfigurationRuleCollectionRuleID(t *testing.T) { + actual := NewSecurityAdminConfigurationRuleCollectionRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName", "ruleCollectionName", "ruleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName/rules/ruleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSecurityAdminConfigurationRuleCollectionRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityAdminConfigurationRuleCollectionRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName/rules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName/rules/ruleName", + Expected: &SecurityAdminConfigurationRuleCollectionRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityAdminConfigurationName: "securityAdminConfigurationName", + RuleCollectionName: "ruleCollectionName", + RuleName: "ruleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName/rules/ruleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityAdminConfigurationRuleCollectionRuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityAdminConfigurationName != v.Expected.SecurityAdminConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityAdminConfigurationName", v.Expected.SecurityAdminConfigurationName, actual.SecurityAdminConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + if actual.RuleName != v.Expected.RuleName { + t.Fatalf("Expected %q but got %q for RuleName", v.Expected.RuleName, actual.RuleName) + } + + } +} + +func TestParseSecurityAdminConfigurationRuleCollectionRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityAdminConfigurationRuleCollectionRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName/rules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE/rUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName/rules/ruleName", + Expected: &SecurityAdminConfigurationRuleCollectionRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityAdminConfigurationName: "securityAdminConfigurationName", + RuleCollectionName: "ruleCollectionName", + RuleName: "ruleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/ruleCollections/ruleCollectionName/rules/ruleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE/rUlEs/rUlEnAmE", + Expected: &SecurityAdminConfigurationRuleCollectionRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + SecurityAdminConfigurationName: "sEcUrItYaDmInCoNfIgUrAtIoNnAmE", + RuleCollectionName: "rUlEcOlLeCtIoNnAmE", + RuleName: "rUlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE/rUlEs/rUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityAdminConfigurationRuleCollectionRuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityAdminConfigurationName != v.Expected.SecurityAdminConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityAdminConfigurationName", v.Expected.SecurityAdminConfigurationName, actual.SecurityAdminConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + if actual.RuleName != v.Expected.RuleName { + t.Fatalf("Expected %q but got %q for RuleName", v.Expected.RuleName, actual.RuleName) + } + + } +} + +func TestSegmentsForSecurityAdminConfigurationRuleCollectionRuleId(t *testing.T) { + segments := SecurityAdminConfigurationRuleCollectionRuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SecurityAdminConfigurationRuleCollectionRuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/adminrules/method_createorupdate.go b/resource-manager/network/2024-07-01/adminrules/method_createorupdate.go new file mode 100644 index 00000000000..ab848b3599e --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/method_createorupdate.go @@ -0,0 +1,63 @@ +package adminrules + +import ( + "context" + "encoding/json" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model BaseAdminRule +} + +// CreateOrUpdate ... +func (c AdminRulesClient) CreateOrUpdate(ctx context.Context, id SecurityAdminConfigurationRuleCollectionRuleId, input BaseAdminRule) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var respObj json.RawMessage + if err = resp.Unmarshal(&respObj); err != nil { + return + } + model, err := UnmarshalBaseAdminRuleImplementation(respObj) + if err != nil { + return + } + result.Model = model + + return +} diff --git a/resource-manager/network/2024-07-01/adminrules/method_delete.go b/resource-manager/network/2024-07-01/adminrules/method_delete.go new file mode 100644 index 00000000000..fed9fcb5238 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/method_delete.go @@ -0,0 +1,100 @@ +package adminrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c AdminRulesClient) Delete(ctx context.Context, id SecurityAdminConfigurationRuleCollectionRuleId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c AdminRulesClient) DeleteThenPoll(ctx context.Context, id SecurityAdminConfigurationRuleCollectionRuleId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/adminrules/method_get.go b/resource-manager/network/2024-07-01/adminrules/method_get.go new file mode 100644 index 00000000000..5373d7e1d2b --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/method_get.go @@ -0,0 +1,58 @@ +package adminrules + +import ( + "context" + "encoding/json" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model BaseAdminRule +} + +// Get ... +func (c AdminRulesClient) Get(ctx context.Context, id SecurityAdminConfigurationRuleCollectionRuleId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var respObj json.RawMessage + if err = resp.Unmarshal(&respObj); err != nil { + return + } + model, err := UnmarshalBaseAdminRuleImplementation(respObj) + if err != nil { + return + } + result.Model = model + + return +} diff --git a/resource-manager/network/2024-07-01/adminrules/method_list.go b/resource-manager/network/2024-07-01/adminrules/method_list.go new file mode 100644 index 00000000000..1ae59bc1088 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/method_list.go @@ -0,0 +1,117 @@ +package adminrules + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BaseAdminRule +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []BaseAdminRule +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c AdminRulesClient) List(ctx context.Context, id SecurityAdminConfigurationRuleCollectionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/rules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]json.RawMessage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + temp := make([]BaseAdminRule, 0) + if values.Values != nil { + for i, v := range *values.Values { + val, err := UnmarshalBaseAdminRuleImplementation(v) + if err != nil { + err = fmt.Errorf("unmarshalling item %d for BaseAdminRule (%q): %+v", i, v, err) + return result, err + } + temp = append(temp, val) + } + } + result.Model = &temp + + return +} + +// ListComplete retrieves all the results into a single object +func (c AdminRulesClient) ListComplete(ctx context.Context, id SecurityAdminConfigurationRuleCollectionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, BaseAdminRuleOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AdminRulesClient) ListCompleteMatchingPredicate(ctx context.Context, id SecurityAdminConfigurationRuleCollectionId, predicate BaseAdminRuleOperationPredicate) (result ListCompleteResult, err error) { + items := make([]BaseAdminRule, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/adminrules/model_addressprefixitem.go b/resource-manager/network/2024-07-01/adminrules/model_addressprefixitem.go new file mode 100644 index 00000000000..223aec22448 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/model_addressprefixitem.go @@ -0,0 +1,9 @@ +package adminrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressPrefixItem struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixType *AddressPrefixType `json:"addressPrefixType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/adminrules/model_adminpropertiesformat.go b/resource-manager/network/2024-07-01/adminrules/model_adminpropertiesformat.go new file mode 100644 index 00000000000..a0e21af6c0d --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/model_adminpropertiesformat.go @@ -0,0 +1,18 @@ +package adminrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdminPropertiesFormat struct { + Access SecurityConfigurationRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Destinations *[]AddressPrefixItem `json:"destinations,omitempty"` + Direction SecurityConfigurationRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityConfigurationRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` + Sources *[]AddressPrefixItem `json:"sources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/adminrules/model_adminrule.go b/resource-manager/network/2024-07-01/adminrules/model_adminrule.go new file mode 100644 index 00000000000..74d9a7cd9c1 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/model_adminrule.go @@ -0,0 +1,62 @@ +package adminrules + +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. + +var _ BaseAdminRule = AdminRule{} + +type AdminRule struct { + Properties *AdminPropertiesFormat `json:"properties,omitempty"` + + // Fields inherited from BaseAdminRule + + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind AdminRuleKind `json:"kind"` + Name *string `json:"name,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} + +func (s AdminRule) BaseAdminRule() BaseBaseAdminRuleImpl { + return BaseBaseAdminRuleImpl{ + Etag: s.Etag, + Id: s.Id, + Kind: s.Kind, + Name: s.Name, + SystemData: s.SystemData, + Type: s.Type, + } +} + +var _ json.Marshaler = AdminRule{} + +func (s AdminRule) MarshalJSON() ([]byte, error) { + type wrapper AdminRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AdminRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AdminRule: %+v", err) + } + + decoded["kind"] = "Custom" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AdminRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/network/2024-07-01/adminrules/model_baseadminrule.go b/resource-manager/network/2024-07-01/adminrules/model_baseadminrule.go new file mode 100644 index 00000000000..ed6bfa3adb9 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/model_baseadminrule.go @@ -0,0 +1,90 @@ +package adminrules + +import ( + "encoding/json" + "fmt" + "strings" + + "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 BaseAdminRule interface { + BaseAdminRule() BaseBaseAdminRuleImpl +} + +var _ BaseAdminRule = BaseBaseAdminRuleImpl{} + +type BaseBaseAdminRuleImpl struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind AdminRuleKind `json:"kind"` + Name *string `json:"name,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} + +func (s BaseBaseAdminRuleImpl) BaseAdminRule() BaseBaseAdminRuleImpl { + return s +} + +var _ BaseAdminRule = RawBaseAdminRuleImpl{} + +// RawBaseAdminRuleImpl 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 RawBaseAdminRuleImpl struct { + baseAdminRule BaseBaseAdminRuleImpl + Type string + Values map[string]interface{} +} + +func (s RawBaseAdminRuleImpl) BaseAdminRule() BaseBaseAdminRuleImpl { + return s.baseAdminRule +} + +func UnmarshalBaseAdminRuleImplementation(input []byte) (BaseAdminRule, 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 BaseAdminRule into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["kind"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Custom") { + var out AdminRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AdminRule: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Default") { + var out DefaultAdminRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DefaultAdminRule: %+v", err) + } + return out, nil + } + + var parent BaseBaseAdminRuleImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseBaseAdminRuleImpl: %+v", err) + } + + return RawBaseAdminRuleImpl{ + baseAdminRule: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/network/2024-07-01/adminrules/model_defaultadminpropertiesformat.go b/resource-manager/network/2024-07-01/adminrules/model_defaultadminpropertiesformat.go new file mode 100644 index 00000000000..a8242069c88 --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/model_defaultadminpropertiesformat.go @@ -0,0 +1,19 @@ +package adminrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DefaultAdminPropertiesFormat struct { + Access *SecurityConfigurationRuleAccess `json:"access,omitempty"` + Description *string `json:"description,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Destinations *[]AddressPrefixItem `json:"destinations,omitempty"` + Direction *SecurityConfigurationRuleDirection `json:"direction,omitempty"` + Flag *string `json:"flag,omitempty"` + Priority *int64 `json:"priority,omitempty"` + Protocol *SecurityConfigurationRuleProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` + Sources *[]AddressPrefixItem `json:"sources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/adminrules/model_defaultadminrule.go b/resource-manager/network/2024-07-01/adminrules/model_defaultadminrule.go new file mode 100644 index 00000000000..3695c8332dc --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/model_defaultadminrule.go @@ -0,0 +1,62 @@ +package adminrules + +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. + +var _ BaseAdminRule = DefaultAdminRule{} + +type DefaultAdminRule struct { + Properties *DefaultAdminPropertiesFormat `json:"properties,omitempty"` + + // Fields inherited from BaseAdminRule + + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind AdminRuleKind `json:"kind"` + Name *string `json:"name,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} + +func (s DefaultAdminRule) BaseAdminRule() BaseBaseAdminRuleImpl { + return BaseBaseAdminRuleImpl{ + Etag: s.Etag, + Id: s.Id, + Kind: s.Kind, + Name: s.Name, + SystemData: s.SystemData, + Type: s.Type, + } +} + +var _ json.Marshaler = DefaultAdminRule{} + +func (s DefaultAdminRule) MarshalJSON() ([]byte, error) { + type wrapper DefaultAdminRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DefaultAdminRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DefaultAdminRule: %+v", err) + } + + decoded["kind"] = "Default" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DefaultAdminRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/network/2024-07-01/adminrules/predicates.go b/resource-manager/network/2024-07-01/adminrules/predicates.go new file mode 100644 index 00000000000..f594b9ac1be --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/predicates.go @@ -0,0 +1,12 @@ +package adminrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BaseAdminRuleOperationPredicate struct { +} + +func (p BaseAdminRuleOperationPredicate) Matches(input BaseAdminRule) bool { + + return true +} diff --git a/resource-manager/network/2024-07-01/adminrules/version.go b/resource-manager/network/2024-07-01/adminrules/version.go new file mode 100644 index 00000000000..84656791f1b --- /dev/null +++ b/resource-manager/network/2024-07-01/adminrules/version.go @@ -0,0 +1,10 @@ +package adminrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/adminrules/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/README.md b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/README.md new file mode 100644 index 00000000000..4047567efdb --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections` Documentation + +The `applicationgatewayprivateendpointconnections` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections" +``` + + +### Client Initialization + +```go +client := applicationgatewayprivateendpointconnections.NewApplicationGatewayPrivateEndpointConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ApplicationGatewayPrivateEndpointConnectionsClient.Delete` + +```go +ctx := context.TODO() +id := applicationgatewayprivateendpointconnections.NewApplicationGatewayPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName", "privateEndpointConnectionName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ApplicationGatewayPrivateEndpointConnectionsClient.Get` + +```go +ctx := context.TODO() +id := applicationgatewayprivateendpointconnections.NewApplicationGatewayPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName", "privateEndpointConnectionName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationGatewayPrivateEndpointConnectionsClient.List` + +```go +ctx := context.TODO() +id := applicationgatewayprivateendpointconnections.NewApplicationGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ApplicationGatewayPrivateEndpointConnectionsClient.Update` + +```go +ctx := context.TODO() +id := applicationgatewayprivateendpointconnections.NewApplicationGatewayPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName", "privateEndpointConnectionName") + +payload := applicationgatewayprivateendpointconnections.ApplicationGatewayPrivateEndpointConnection{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/client.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/client.go new file mode 100644 index 00000000000..2218d4c59f1 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/client.go @@ -0,0 +1,26 @@ +package applicationgatewayprivateendpointconnections + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateEndpointConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewApplicationGatewayPrivateEndpointConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationGatewayPrivateEndpointConnectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "applicationgatewayprivateendpointconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApplicationGatewayPrivateEndpointConnectionsClient: %+v", err) + } + + return &ApplicationGatewayPrivateEndpointConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/constants.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/constants.go new file mode 100644 index 00000000000..90ac499eb41 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/constants.go @@ -0,0 +1,1204 @@ +package applicationgatewayprivateendpointconnections + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/id_applicationgateway.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/id_applicationgateway.go new file mode 100644 index 00000000000..c8739b388e8 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/id_applicationgateway.go @@ -0,0 +1,130 @@ +package applicationgatewayprivateendpointconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ApplicationGatewayId{}) +} + +var _ resourceids.ResourceId = &ApplicationGatewayId{} + +// ApplicationGatewayId is a struct representing the Resource ID for a Application Gateway +type ApplicationGatewayId struct { + SubscriptionId string + ResourceGroupName string + ApplicationGatewayName string +} + +// NewApplicationGatewayID returns a new ApplicationGatewayId struct +func NewApplicationGatewayID(subscriptionId string, resourceGroupName string, applicationGatewayName string) ApplicationGatewayId { + return ApplicationGatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ApplicationGatewayName: applicationGatewayName, + } +} + +// ParseApplicationGatewayID parses 'input' into a ApplicationGatewayId +func ParseApplicationGatewayID(input string) (*ApplicationGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApplicationGatewayIDInsensitively parses 'input' case-insensitively into a ApplicationGatewayId +// note: this method should only be used for API response data and not user input +func ParseApplicationGatewayIDInsensitively(input string) (*ApplicationGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApplicationGatewayId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ApplicationGatewayName, ok = input.Parsed["applicationGatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationGatewayName", input) + } + + return nil +} + +// ValidateApplicationGatewayID checks that 'input' can be parsed as a Application Gateway ID +func ValidateApplicationGatewayID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseApplicationGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Application Gateway ID +func (id ApplicationGatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/applicationGateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ApplicationGatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Application Gateway ID +func (id ApplicationGatewayId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticApplicationGateways", "applicationGateways", "applicationGateways"), + resourceids.UserSpecifiedSegment("applicationGatewayName", "applicationGatewayName"), + } +} + +// String returns a human-readable description of this Application Gateway ID +func (id ApplicationGatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Application Gateway Name: %q", id.ApplicationGatewayName), + } + return fmt.Sprintf("Application Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/id_applicationgateway_test.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/id_applicationgateway_test.go new file mode 100644 index 00000000000..8c11c5189d1 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/id_applicationgateway_test.go @@ -0,0 +1,282 @@ +package applicationgatewayprivateendpointconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ApplicationGatewayId{} + +func TestNewApplicationGatewayID(t *testing.T) { + id := NewApplicationGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ApplicationGatewayName != "applicationGatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationGatewayName'", id.ApplicationGatewayName, "applicationGatewayName") + } +} + +func TestFormatApplicationGatewayID(t *testing.T) { + actual := NewApplicationGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApplicationGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName", + Expected: &ApplicationGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGatewayName: "applicationGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGatewayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGatewayName != v.Expected.ApplicationGatewayName { + t.Fatalf("Expected %q but got %q for ApplicationGatewayName", v.Expected.ApplicationGatewayName, actual.ApplicationGatewayName) + } + + } +} + +func TestParseApplicationGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName", + Expected: &ApplicationGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGatewayName: "applicationGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYs/aPpLiCaTiOnGaTeWaYnAmE", + Expected: &ApplicationGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ApplicationGatewayName: "aPpLiCaTiOnGaTeWaYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYs/aPpLiCaTiOnGaTeWaYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGatewayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGatewayName != v.Expected.ApplicationGatewayName { + t.Fatalf("Expected %q but got %q for ApplicationGatewayName", v.Expected.ApplicationGatewayName, actual.ApplicationGatewayName) + } + + } +} + +func TestSegmentsForApplicationGatewayId(t *testing.T) { + segments := ApplicationGatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApplicationGatewayId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/id_applicationgatewayprivateendpointconnection.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/id_applicationgatewayprivateendpointconnection.go new file mode 100644 index 00000000000..5fdf773f215 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/id_applicationgatewayprivateendpointconnection.go @@ -0,0 +1,139 @@ +package applicationgatewayprivateendpointconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ApplicationGatewayPrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &ApplicationGatewayPrivateEndpointConnectionId{} + +// ApplicationGatewayPrivateEndpointConnectionId is a struct representing the Resource ID for a Application Gateway Private Endpoint Connection +type ApplicationGatewayPrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + ApplicationGatewayName string + PrivateEndpointConnectionName string +} + +// NewApplicationGatewayPrivateEndpointConnectionID returns a new ApplicationGatewayPrivateEndpointConnectionId struct +func NewApplicationGatewayPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, applicationGatewayName string, privateEndpointConnectionName string) ApplicationGatewayPrivateEndpointConnectionId { + return ApplicationGatewayPrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ApplicationGatewayName: applicationGatewayName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParseApplicationGatewayPrivateEndpointConnectionID parses 'input' into a ApplicationGatewayPrivateEndpointConnectionId +func ParseApplicationGatewayPrivateEndpointConnectionID(input string) (*ApplicationGatewayPrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGatewayPrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGatewayPrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApplicationGatewayPrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a ApplicationGatewayPrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParseApplicationGatewayPrivateEndpointConnectionIDInsensitively(input string) (*ApplicationGatewayPrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGatewayPrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGatewayPrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApplicationGatewayPrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ApplicationGatewayName, ok = input.Parsed["applicationGatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationGatewayName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidateApplicationGatewayPrivateEndpointConnectionID checks that 'input' can be parsed as a Application Gateway Private Endpoint Connection ID +func ValidateApplicationGatewayPrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseApplicationGatewayPrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Application Gateway Private Endpoint Connection ID +func (id ApplicationGatewayPrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/applicationGateways/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ApplicationGatewayName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Application Gateway Private Endpoint Connection ID +func (id ApplicationGatewayPrivateEndpointConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticApplicationGateways", "applicationGateways", "applicationGateways"), + resourceids.UserSpecifiedSegment("applicationGatewayName", "applicationGatewayName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Application Gateway Private Endpoint Connection ID +func (id ApplicationGatewayPrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Application Gateway Name: %q", id.ApplicationGatewayName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Application Gateway Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/id_applicationgatewayprivateendpointconnection_test.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/id_applicationgatewayprivateendpointconnection_test.go new file mode 100644 index 00000000000..41f023a4a31 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/id_applicationgatewayprivateendpointconnection_test.go @@ -0,0 +1,327 @@ +package applicationgatewayprivateendpointconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ApplicationGatewayPrivateEndpointConnectionId{} + +func TestNewApplicationGatewayPrivateEndpointConnectionID(t *testing.T) { + id := NewApplicationGatewayPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName", "privateEndpointConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ApplicationGatewayName != "applicationGatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationGatewayName'", id.ApplicationGatewayName, "applicationGatewayName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatApplicationGatewayPrivateEndpointConnectionID(t *testing.T) { + actual := NewApplicationGatewayPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApplicationGatewayPrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGatewayPrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &ApplicationGatewayPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGatewayName: "applicationGatewayName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGatewayPrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGatewayName != v.Expected.ApplicationGatewayName { + t.Fatalf("Expected %q but got %q for ApplicationGatewayName", v.Expected.ApplicationGatewayName, actual.ApplicationGatewayName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParseApplicationGatewayPrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGatewayPrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYs/aPpLiCaTiOnGaTeWaYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYs/aPpLiCaTiOnGaTeWaYnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &ApplicationGatewayPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGatewayName: "applicationGatewayName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYs/aPpLiCaTiOnGaTeWaYnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &ApplicationGatewayPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ApplicationGatewayName: "aPpLiCaTiOnGaTeWaYnAmE", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYs/aPpLiCaTiOnGaTeWaYnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGatewayPrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGatewayName != v.Expected.ApplicationGatewayName { + t.Fatalf("Expected %q but got %q for ApplicationGatewayName", v.Expected.ApplicationGatewayName, actual.ApplicationGatewayName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForApplicationGatewayPrivateEndpointConnectionId(t *testing.T) { + segments := ApplicationGatewayPrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApplicationGatewayPrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/method_delete.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/method_delete.go new file mode 100644 index 00000000000..8a25d1654cc --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/method_delete.go @@ -0,0 +1,71 @@ +package applicationgatewayprivateendpointconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ApplicationGatewayPrivateEndpointConnectionsClient) Delete(ctx context.Context, id ApplicationGatewayPrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ApplicationGatewayPrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id ApplicationGatewayPrivateEndpointConnectionId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/method_get.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/method_get.go new file mode 100644 index 00000000000..dace2e6df65 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/method_get.go @@ -0,0 +1,53 @@ +package applicationgatewayprivateendpointconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationGatewayPrivateEndpointConnection +} + +// Get ... +func (c ApplicationGatewayPrivateEndpointConnectionsClient) Get(ctx context.Context, id ApplicationGatewayPrivateEndpointConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApplicationGatewayPrivateEndpointConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/method_list.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/method_list.go new file mode 100644 index 00000000000..595ab9b2ec1 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/method_list.go @@ -0,0 +1,105 @@ +package applicationgatewayprivateendpointconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationGatewayPrivateEndpointConnection +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationGatewayPrivateEndpointConnection +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ApplicationGatewayPrivateEndpointConnectionsClient) List(ctx context.Context, id ApplicationGatewayId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApplicationGatewayPrivateEndpointConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ApplicationGatewayPrivateEndpointConnectionsClient) ListComplete(ctx context.Context, id ApplicationGatewayId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ApplicationGatewayPrivateEndpointConnectionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationGatewayPrivateEndpointConnectionsClient) ListCompleteMatchingPredicate(ctx context.Context, id ApplicationGatewayId, predicate ApplicationGatewayPrivateEndpointConnectionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ApplicationGatewayPrivateEndpointConnection, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/method_update.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/method_update.go new file mode 100644 index 00000000000..394f02e54dd --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/method_update.go @@ -0,0 +1,75 @@ +package applicationgatewayprivateendpointconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationGatewayPrivateEndpointConnection +} + +// Update ... +func (c ApplicationGatewayPrivateEndpointConnectionsClient) Update(ctx context.Context, id ApplicationGatewayPrivateEndpointConnectionId, input ApplicationGatewayPrivateEndpointConnection) (result UpdateOperationResponse, 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 +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c ApplicationGatewayPrivateEndpointConnectionsClient) UpdateThenPoll(ctx context.Context, id ApplicationGatewayPrivateEndpointConnectionId, input ApplicationGatewayPrivateEndpointConnection) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..19262bd584a --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..049337217fe --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..508dc9994b4 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..89d75010a65 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..5d46fc4d14d --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewayprivateendpointconnection.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewayprivateendpointconnection.go new file mode 100644 index 00000000000..899ea09f853 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewayprivateendpointconnection.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayPrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewayprivateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewayprivateendpointconnectionproperties.go new file mode 100644 index 00000000000..19f24417e8b --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationgatewayprivateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..6cfad393dcc --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..f494b4f811b --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_backendaddresspool.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_backendaddresspool.go new file mode 100644 index 00000000000..f5906c781bd --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..d3eb3749cba --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..0e7c2876d57 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ddossettings.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ddossettings.go new file mode 100644 index 00000000000..84bb3713a5f --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ddossettings.go @@ -0,0 +1,9 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_delegation.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_delegation.go new file mode 100644 index 00000000000..db8d3269de6 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_delegation.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_flowlog.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_flowlog.go new file mode 100644 index 00000000000..1222520d55a --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_flowlog.go @@ -0,0 +1,19 @@ +package applicationgatewayprivateendpointconnections + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_flowlogformatparameters.go new file mode 100644 index 00000000000..0b6831f6fa6 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..4081ff94415 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_frontendipconfiguration.go new file mode 100644 index 00000000000..5d4f44391e7 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package applicationgatewayprivateendpointconnections + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..f8184b617b0 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..d1d69ce0587 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_inboundnatrule.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_inboundnatrule.go new file mode 100644 index 00000000000..a9b0e096bd3 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..30f69829656 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..188bd1aa9db --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..eb41e849d6f --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipconfiguration.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipconfiguration.go new file mode 100644 index 00000000000..38591b7aaa2 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..a118ebdd4e1 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..75728fa1ebe --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..b2f70477897 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_iptag.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_iptag.go new file mode 100644 index 00000000000..c1aef66c21f --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_iptag.go @@ -0,0 +1,9 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..7c55794d5db --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..786682fa462 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_natgateway.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_natgateway.go new file mode 100644 index 00000000000..f7258d97962 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_natgateway.go @@ -0,0 +1,20 @@ +package applicationgatewayprivateendpointconnections + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..a995398f3c9 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_natgatewaysku.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_natgatewaysku.go new file mode 100644 index 00000000000..17af8527640 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_natruleportmapping.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_natruleportmapping.go new file mode 100644 index 00000000000..d1f6b522fcc --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterface.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterface.go new file mode 100644 index 00000000000..27dd4a4a08a --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterface.go @@ -0,0 +1,19 @@ +package applicationgatewayprivateendpointconnections + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..6b7723bb374 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..5b9d0f918bf --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..fc79de05a6f --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..3bc2704b42e --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..2e0d32652eb --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..54a119f8358 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..2812f9ea959 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networksecuritygroup.go new file mode 100644 index 00000000000..cb2c6128022 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..2ec03e22f7c --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpoint.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpoint.go new file mode 100644 index 00000000000..c59c28f78d1 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpoint.go @@ -0,0 +1,19 @@ +package applicationgatewayprivateendpointconnections + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpointconnection.go new file mode 100644 index 00000000000..ad89494737c --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..f1877976742 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..bd3c50f01ac --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..f3ec0dcc86e --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpointproperties.go new file mode 100644 index 00000000000..d7be5354bcd --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkservice.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkservice.go new file mode 100644 index 00000000000..78a6c7ebba8 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package applicationgatewayprivateendpointconnections + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..5cc8a8e4dbf --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..461fb1081a9 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..6be96efd9df --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..3c19c2d4de4 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..c81dae99663 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..8578a51238a --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_publicipaddress.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_publicipaddress.go new file mode 100644 index 00000000000..e89345d55bc --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_publicipaddress.go @@ -0,0 +1,22 @@ +package applicationgatewayprivateendpointconnections + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..38e3265c5cf --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..f699284c895 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_publicipaddresssku.go new file mode 100644 index 00000000000..b74d0311a75 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_resourcenavigationlink.go new file mode 100644 index 00000000000..0274f951e3c --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..4182988a892 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_resourceset.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_resourceset.go new file mode 100644 index 00000000000..075d9853046 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_resourceset.go @@ -0,0 +1,8 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..2b030c17554 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_route.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_route.go new file mode 100644 index 00000000000..939f9379822 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_route.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_routepropertiesformat.go new file mode 100644 index 00000000000..4afa3c6bed4 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_routetable.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_routetable.go new file mode 100644 index 00000000000..8a1cf00052b --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_routetable.go @@ -0,0 +1,14 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..c3a2020ea09 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_securityrule.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_securityrule.go new file mode 100644 index 00000000000..e892509d682 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_securityrule.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..ad268f42e3d --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceassociationlink.go new file mode 100644 index 00000000000..208a786f7a0 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..eaf8e403c15 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..a8da5cf7bca --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..0871d765423 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..9051f5afd03 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..c8f3720498a --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..27a0c5e36ce --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..5deea5147b0 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_subnet.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_subnet.go new file mode 100644 index 00000000000..315bdbd9d59 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_subnet.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..3267f5d2d1c --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_subresource.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_subresource.go new file mode 100644 index 00000000000..7cea1d49c02 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_subresource.go @@ -0,0 +1,8 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..860948a52b3 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..92e4c14749f --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_virtualnetworktap.go new file mode 100644 index 00000000000..7c49436256c --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..131405acb48 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/predicates.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/predicates.go new file mode 100644 index 00000000000..46757c5239b --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/predicates.go @@ -0,0 +1,32 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateEndpointConnectionOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p ApplicationGatewayPrivateEndpointConnectionOperationPredicate) Matches(input ApplicationGatewayPrivateEndpointConnection) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/version.go b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/version.go new file mode 100644 index 00000000000..24641c469f8 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections/version.go @@ -0,0 +1,10 @@ +package applicationgatewayprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/applicationgatewayprivateendpointconnections/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/README.md b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/README.md new file mode 100644 index 00000000000..b4cd74f1457 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources` Documentation + +The `applicationgatewayprivatelinkresources` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources" +``` + + +### Client Initialization + +```go +client := applicationgatewayprivatelinkresources.NewApplicationGatewayPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ApplicationGatewayPrivateLinkResourcesClient.List` + +```go +ctx := context.TODO() +id := applicationgatewayprivatelinkresources.NewApplicationGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/client.go b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/client.go new file mode 100644 index 00000000000..81bc1b2fb1d --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/client.go @@ -0,0 +1,26 @@ +package applicationgatewayprivatelinkresources + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateLinkResourcesClient struct { + Client *resourcemanager.Client +} + +func NewApplicationGatewayPrivateLinkResourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationGatewayPrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "applicationgatewayprivatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApplicationGatewayPrivateLinkResourcesClient: %+v", err) + } + + return &ApplicationGatewayPrivateLinkResourcesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/id_applicationgateway.go b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/id_applicationgateway.go new file mode 100644 index 00000000000..365cb9522ea --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/id_applicationgateway.go @@ -0,0 +1,130 @@ +package applicationgatewayprivatelinkresources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ApplicationGatewayId{}) +} + +var _ resourceids.ResourceId = &ApplicationGatewayId{} + +// ApplicationGatewayId is a struct representing the Resource ID for a Application Gateway +type ApplicationGatewayId struct { + SubscriptionId string + ResourceGroupName string + ApplicationGatewayName string +} + +// NewApplicationGatewayID returns a new ApplicationGatewayId struct +func NewApplicationGatewayID(subscriptionId string, resourceGroupName string, applicationGatewayName string) ApplicationGatewayId { + return ApplicationGatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ApplicationGatewayName: applicationGatewayName, + } +} + +// ParseApplicationGatewayID parses 'input' into a ApplicationGatewayId +func ParseApplicationGatewayID(input string) (*ApplicationGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApplicationGatewayIDInsensitively parses 'input' case-insensitively into a ApplicationGatewayId +// note: this method should only be used for API response data and not user input +func ParseApplicationGatewayIDInsensitively(input string) (*ApplicationGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApplicationGatewayId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ApplicationGatewayName, ok = input.Parsed["applicationGatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationGatewayName", input) + } + + return nil +} + +// ValidateApplicationGatewayID checks that 'input' can be parsed as a Application Gateway ID +func ValidateApplicationGatewayID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseApplicationGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Application Gateway ID +func (id ApplicationGatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/applicationGateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ApplicationGatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Application Gateway ID +func (id ApplicationGatewayId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticApplicationGateways", "applicationGateways", "applicationGateways"), + resourceids.UserSpecifiedSegment("applicationGatewayName", "applicationGatewayName"), + } +} + +// String returns a human-readable description of this Application Gateway ID +func (id ApplicationGatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Application Gateway Name: %q", id.ApplicationGatewayName), + } + return fmt.Sprintf("Application Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/id_applicationgateway_test.go b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/id_applicationgateway_test.go new file mode 100644 index 00000000000..39e5fc1b92c --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/id_applicationgateway_test.go @@ -0,0 +1,282 @@ +package applicationgatewayprivatelinkresources + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ApplicationGatewayId{} + +func TestNewApplicationGatewayID(t *testing.T) { + id := NewApplicationGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ApplicationGatewayName != "applicationGatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationGatewayName'", id.ApplicationGatewayName, "applicationGatewayName") + } +} + +func TestFormatApplicationGatewayID(t *testing.T) { + actual := NewApplicationGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApplicationGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName", + Expected: &ApplicationGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGatewayName: "applicationGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGatewayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGatewayName != v.Expected.ApplicationGatewayName { + t.Fatalf("Expected %q but got %q for ApplicationGatewayName", v.Expected.ApplicationGatewayName, actual.ApplicationGatewayName) + } + + } +} + +func TestParseApplicationGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName", + Expected: &ApplicationGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGatewayName: "applicationGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYs/aPpLiCaTiOnGaTeWaYnAmE", + Expected: &ApplicationGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ApplicationGatewayName: "aPpLiCaTiOnGaTeWaYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYs/aPpLiCaTiOnGaTeWaYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGatewayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGatewayName != v.Expected.ApplicationGatewayName { + t.Fatalf("Expected %q but got %q for ApplicationGatewayName", v.Expected.ApplicationGatewayName, actual.ApplicationGatewayName) + } + + } +} + +func TestSegmentsForApplicationGatewayId(t *testing.T) { + segments := ApplicationGatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApplicationGatewayId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/method_list.go b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/method_list.go new file mode 100644 index 00000000000..ab3dbda73fe --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/method_list.go @@ -0,0 +1,105 @@ +package applicationgatewayprivatelinkresources + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationGatewayPrivateLinkResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationGatewayPrivateLinkResource +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ApplicationGatewayPrivateLinkResourcesClient) List(ctx context.Context, id ApplicationGatewayId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApplicationGatewayPrivateLinkResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ApplicationGatewayPrivateLinkResourcesClient) ListComplete(ctx context.Context, id ApplicationGatewayId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ApplicationGatewayPrivateLinkResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationGatewayPrivateLinkResourcesClient) ListCompleteMatchingPredicate(ctx context.Context, id ApplicationGatewayId, predicate ApplicationGatewayPrivateLinkResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ApplicationGatewayPrivateLinkResource, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/model_applicationgatewayprivatelinkresource.go b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/model_applicationgatewayprivatelinkresource.go new file mode 100644 index 00000000000..c3c4b5afa06 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/model_applicationgatewayprivatelinkresource.go @@ -0,0 +1,12 @@ +package applicationgatewayprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateLinkResource struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayPrivateLinkResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/model_applicationgatewayprivatelinkresourceproperties.go b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/model_applicationgatewayprivatelinkresourceproperties.go new file mode 100644 index 00000000000..0f4b9748324 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/model_applicationgatewayprivatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package applicationgatewayprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/predicates.go b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/predicates.go new file mode 100644 index 00000000000..e93c21bb751 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/predicates.go @@ -0,0 +1,32 @@ +package applicationgatewayprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateLinkResourceOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p ApplicationGatewayPrivateLinkResourceOperationPredicate) Matches(input ApplicationGatewayPrivateLinkResource) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/version.go b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/version.go new file mode 100644 index 00000000000..4c0166d85d6 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources/version.go @@ -0,0 +1,10 @@ +package applicationgatewayprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/applicationgatewayprivatelinkresources/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/README.md b/resource-manager/network/2024-07-01/applicationgateways/README.md new file mode 100644 index 00000000000..241f12f457c --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/README.md @@ -0,0 +1,287 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/applicationgateways` Documentation + +The `applicationgateways` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/applicationgateways" +``` + + +### Client Initialization + +```go +client := applicationgateways.NewApplicationGatewaysClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ApplicationGatewaysClient.BackendHealth` + +```go +ctx := context.TODO() +id := applicationgateways.NewApplicationGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName") + +if err := client.BackendHealthThenPoll(ctx, id, applicationgateways.DefaultBackendHealthOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `ApplicationGatewaysClient.BackendHealthOnDemand` + +```go +ctx := context.TODO() +id := applicationgateways.NewApplicationGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName") + +payload := applicationgateways.ApplicationGatewayOnDemandProbe{ + // ... +} + + +if err := client.BackendHealthOnDemandThenPoll(ctx, id, payload, applicationgateways.DefaultBackendHealthOnDemandOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `ApplicationGatewaysClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := applicationgateways.NewApplicationGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName") + +payload := applicationgateways.ApplicationGateway{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ApplicationGatewaysClient.Delete` + +```go +ctx := context.TODO() +id := applicationgateways.NewApplicationGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ApplicationGatewaysClient.Get` + +```go +ctx := context.TODO() +id := applicationgateways.NewApplicationGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationGatewaysClient.GetSslPredefinedPolicy` + +```go +ctx := context.TODO() +id := applicationgateways.NewPredefinedPolicyID("12345678-1234-9876-4563-123456789012", "predefinedPolicyName") + +read, err := client.GetSslPredefinedPolicy(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationGatewaysClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ApplicationGatewaysClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ApplicationGatewaysClient.ListAvailableRequestHeaders` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.ListAvailableRequestHeaders(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationGatewaysClient.ListAvailableResponseHeaders` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.ListAvailableResponseHeaders(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationGatewaysClient.ListAvailableServerVariables` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.ListAvailableServerVariables(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationGatewaysClient.ListAvailableSslOptions` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.ListAvailableSslOptions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationGatewaysClient.ListAvailableSslPredefinedPolicies` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAvailableSslPredefinedPolicies(ctx, id)` can be used to do batched pagination +items, err := client.ListAvailableSslPredefinedPoliciesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ApplicationGatewaysClient.ListAvailableWafRuleSets` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.ListAvailableWafRuleSets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationGatewaysClient.Start` + +```go +ctx := context.TODO() +id := applicationgateways.NewApplicationGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName") + +if err := client.StartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ApplicationGatewaysClient.Stop` + +```go +ctx := context.TODO() +id := applicationgateways.NewApplicationGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName") + +if err := client.StopThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ApplicationGatewaysClient.UpdateTags` + +```go +ctx := context.TODO() +id := applicationgateways.NewApplicationGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName") + +payload := applicationgateways.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/applicationgateways/client.go b/resource-manager/network/2024-07-01/applicationgateways/client.go new file mode 100644 index 00000000000..3cd17d71726 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/client.go @@ -0,0 +1,26 @@ +package applicationgateways + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewaysClient struct { + Client *resourcemanager.Client +} + +func NewApplicationGatewaysClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationGatewaysClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "applicationgateways", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApplicationGatewaysClient: %+v", err) + } + + return &ApplicationGatewaysClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/constants.go b/resource-manager/network/2024-07-01/applicationgateways/constants.go new file mode 100644 index 00000000000..3328234c5fd --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/constants.go @@ -0,0 +1,2260 @@ +package applicationgateways + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendHealthServerHealth string + +const ( + ApplicationGatewayBackendHealthServerHealthDown ApplicationGatewayBackendHealthServerHealth = "Down" + ApplicationGatewayBackendHealthServerHealthDraining ApplicationGatewayBackendHealthServerHealth = "Draining" + ApplicationGatewayBackendHealthServerHealthPartial ApplicationGatewayBackendHealthServerHealth = "Partial" + ApplicationGatewayBackendHealthServerHealthUnknown ApplicationGatewayBackendHealthServerHealth = "Unknown" + ApplicationGatewayBackendHealthServerHealthUp ApplicationGatewayBackendHealthServerHealth = "Up" +) + +func PossibleValuesForApplicationGatewayBackendHealthServerHealth() []string { + return []string{ + string(ApplicationGatewayBackendHealthServerHealthDown), + string(ApplicationGatewayBackendHealthServerHealthDraining), + string(ApplicationGatewayBackendHealthServerHealthPartial), + string(ApplicationGatewayBackendHealthServerHealthUnknown), + string(ApplicationGatewayBackendHealthServerHealthUp), + } +} + +func (s *ApplicationGatewayBackendHealthServerHealth) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayBackendHealthServerHealth(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayBackendHealthServerHealth(input string) (*ApplicationGatewayBackendHealthServerHealth, error) { + vals := map[string]ApplicationGatewayBackendHealthServerHealth{ + "down": ApplicationGatewayBackendHealthServerHealthDown, + "draining": ApplicationGatewayBackendHealthServerHealthDraining, + "partial": ApplicationGatewayBackendHealthServerHealthPartial, + "unknown": ApplicationGatewayBackendHealthServerHealthUnknown, + "up": ApplicationGatewayBackendHealthServerHealthUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayBackendHealthServerHealth(input) + return &out, nil +} + +type ApplicationGatewayClientRevocationOptions string + +const ( + ApplicationGatewayClientRevocationOptionsNone ApplicationGatewayClientRevocationOptions = "None" + ApplicationGatewayClientRevocationOptionsOCSP ApplicationGatewayClientRevocationOptions = "OCSP" +) + +func PossibleValuesForApplicationGatewayClientRevocationOptions() []string { + return []string{ + string(ApplicationGatewayClientRevocationOptionsNone), + string(ApplicationGatewayClientRevocationOptionsOCSP), + } +} + +func (s *ApplicationGatewayClientRevocationOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayClientRevocationOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayClientRevocationOptions(input string) (*ApplicationGatewayClientRevocationOptions, error) { + vals := map[string]ApplicationGatewayClientRevocationOptions{ + "none": ApplicationGatewayClientRevocationOptionsNone, + "ocsp": ApplicationGatewayClientRevocationOptionsOCSP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayClientRevocationOptions(input) + return &out, nil +} + +type ApplicationGatewayCookieBasedAffinity string + +const ( + ApplicationGatewayCookieBasedAffinityDisabled ApplicationGatewayCookieBasedAffinity = "Disabled" + ApplicationGatewayCookieBasedAffinityEnabled ApplicationGatewayCookieBasedAffinity = "Enabled" +) + +func PossibleValuesForApplicationGatewayCookieBasedAffinity() []string { + return []string{ + string(ApplicationGatewayCookieBasedAffinityDisabled), + string(ApplicationGatewayCookieBasedAffinityEnabled), + } +} + +func (s *ApplicationGatewayCookieBasedAffinity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayCookieBasedAffinity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayCookieBasedAffinity(input string) (*ApplicationGatewayCookieBasedAffinity, error) { + vals := map[string]ApplicationGatewayCookieBasedAffinity{ + "disabled": ApplicationGatewayCookieBasedAffinityDisabled, + "enabled": ApplicationGatewayCookieBasedAffinityEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayCookieBasedAffinity(input) + return &out, nil +} + +type ApplicationGatewayCustomErrorStatusCode string + +const ( + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveHundred ApplicationGatewayCustomErrorStatusCode = "HttpStatus500" + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroFour ApplicationGatewayCustomErrorStatusCode = "HttpStatus504" + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroThree ApplicationGatewayCustomErrorStatusCode = "HttpStatus503" + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroTwo ApplicationGatewayCustomErrorStatusCode = "HttpStatus502" + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourHundred ApplicationGatewayCustomErrorStatusCode = "HttpStatus400" + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroEight ApplicationGatewayCustomErrorStatusCode = "HttpStatus408" + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroFive ApplicationGatewayCustomErrorStatusCode = "HttpStatus405" + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroFour ApplicationGatewayCustomErrorStatusCode = "HttpStatus404" + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroThree ApplicationGatewayCustomErrorStatusCode = "HttpStatus403" +) + +func PossibleValuesForApplicationGatewayCustomErrorStatusCode() []string { + return []string{ + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveHundred), + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroFour), + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroThree), + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroTwo), + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourHundred), + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroEight), + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroFive), + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroFour), + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroThree), + } +} + +func (s *ApplicationGatewayCustomErrorStatusCode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayCustomErrorStatusCode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayCustomErrorStatusCode(input string) (*ApplicationGatewayCustomErrorStatusCode, error) { + vals := map[string]ApplicationGatewayCustomErrorStatusCode{ + "httpstatus500": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveHundred, + "httpstatus504": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroFour, + "httpstatus503": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroThree, + "httpstatus502": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroTwo, + "httpstatus400": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourHundred, + "httpstatus408": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroEight, + "httpstatus405": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroFive, + "httpstatus404": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroFour, + "httpstatus403": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayCustomErrorStatusCode(input) + return &out, nil +} + +type ApplicationGatewayFirewallMode string + +const ( + ApplicationGatewayFirewallModeDetection ApplicationGatewayFirewallMode = "Detection" + ApplicationGatewayFirewallModePrevention ApplicationGatewayFirewallMode = "Prevention" +) + +func PossibleValuesForApplicationGatewayFirewallMode() []string { + return []string{ + string(ApplicationGatewayFirewallModeDetection), + string(ApplicationGatewayFirewallModePrevention), + } +} + +func (s *ApplicationGatewayFirewallMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayFirewallMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayFirewallMode(input string) (*ApplicationGatewayFirewallMode, error) { + vals := map[string]ApplicationGatewayFirewallMode{ + "detection": ApplicationGatewayFirewallModeDetection, + "prevention": ApplicationGatewayFirewallModePrevention, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayFirewallMode(input) + return &out, nil +} + +type ApplicationGatewayLoadDistributionAlgorithm string + +const ( + ApplicationGatewayLoadDistributionAlgorithmIPHash ApplicationGatewayLoadDistributionAlgorithm = "IpHash" + ApplicationGatewayLoadDistributionAlgorithmLeastConnections ApplicationGatewayLoadDistributionAlgorithm = "LeastConnections" + ApplicationGatewayLoadDistributionAlgorithmRoundRobin ApplicationGatewayLoadDistributionAlgorithm = "RoundRobin" +) + +func PossibleValuesForApplicationGatewayLoadDistributionAlgorithm() []string { + return []string{ + string(ApplicationGatewayLoadDistributionAlgorithmIPHash), + string(ApplicationGatewayLoadDistributionAlgorithmLeastConnections), + string(ApplicationGatewayLoadDistributionAlgorithmRoundRobin), + } +} + +func (s *ApplicationGatewayLoadDistributionAlgorithm) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayLoadDistributionAlgorithm(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayLoadDistributionAlgorithm(input string) (*ApplicationGatewayLoadDistributionAlgorithm, error) { + vals := map[string]ApplicationGatewayLoadDistributionAlgorithm{ + "iphash": ApplicationGatewayLoadDistributionAlgorithmIPHash, + "leastconnections": ApplicationGatewayLoadDistributionAlgorithmLeastConnections, + "roundrobin": ApplicationGatewayLoadDistributionAlgorithmRoundRobin, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayLoadDistributionAlgorithm(input) + return &out, nil +} + +type ApplicationGatewayOperationalState string + +const ( + ApplicationGatewayOperationalStateRunning ApplicationGatewayOperationalState = "Running" + ApplicationGatewayOperationalStateStarting ApplicationGatewayOperationalState = "Starting" + ApplicationGatewayOperationalStateStopped ApplicationGatewayOperationalState = "Stopped" + ApplicationGatewayOperationalStateStopping ApplicationGatewayOperationalState = "Stopping" +) + +func PossibleValuesForApplicationGatewayOperationalState() []string { + return []string{ + string(ApplicationGatewayOperationalStateRunning), + string(ApplicationGatewayOperationalStateStarting), + string(ApplicationGatewayOperationalStateStopped), + string(ApplicationGatewayOperationalStateStopping), + } +} + +func (s *ApplicationGatewayOperationalState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayOperationalState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayOperationalState(input string) (*ApplicationGatewayOperationalState, error) { + vals := map[string]ApplicationGatewayOperationalState{ + "running": ApplicationGatewayOperationalStateRunning, + "starting": ApplicationGatewayOperationalStateStarting, + "stopped": ApplicationGatewayOperationalStateStopped, + "stopping": ApplicationGatewayOperationalStateStopping, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayOperationalState(input) + return &out, nil +} + +type ApplicationGatewayProtocol string + +const ( + ApplicationGatewayProtocolHTTP ApplicationGatewayProtocol = "Http" + ApplicationGatewayProtocolHTTPS ApplicationGatewayProtocol = "Https" + ApplicationGatewayProtocolTcp ApplicationGatewayProtocol = "Tcp" + ApplicationGatewayProtocolTls ApplicationGatewayProtocol = "Tls" +) + +func PossibleValuesForApplicationGatewayProtocol() []string { + return []string{ + string(ApplicationGatewayProtocolHTTP), + string(ApplicationGatewayProtocolHTTPS), + string(ApplicationGatewayProtocolTcp), + string(ApplicationGatewayProtocolTls), + } +} + +func (s *ApplicationGatewayProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayProtocol(input string) (*ApplicationGatewayProtocol, error) { + vals := map[string]ApplicationGatewayProtocol{ + "http": ApplicationGatewayProtocolHTTP, + "https": ApplicationGatewayProtocolHTTPS, + "tcp": ApplicationGatewayProtocolTcp, + "tls": ApplicationGatewayProtocolTls, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayProtocol(input) + return &out, nil +} + +type ApplicationGatewayRedirectType string + +const ( + ApplicationGatewayRedirectTypeFound ApplicationGatewayRedirectType = "Found" + ApplicationGatewayRedirectTypePermanent ApplicationGatewayRedirectType = "Permanent" + ApplicationGatewayRedirectTypeSeeOther ApplicationGatewayRedirectType = "SeeOther" + ApplicationGatewayRedirectTypeTemporary ApplicationGatewayRedirectType = "Temporary" +) + +func PossibleValuesForApplicationGatewayRedirectType() []string { + return []string{ + string(ApplicationGatewayRedirectTypeFound), + string(ApplicationGatewayRedirectTypePermanent), + string(ApplicationGatewayRedirectTypeSeeOther), + string(ApplicationGatewayRedirectTypeTemporary), + } +} + +func (s *ApplicationGatewayRedirectType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayRedirectType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayRedirectType(input string) (*ApplicationGatewayRedirectType, error) { + vals := map[string]ApplicationGatewayRedirectType{ + "found": ApplicationGatewayRedirectTypeFound, + "permanent": ApplicationGatewayRedirectTypePermanent, + "seeother": ApplicationGatewayRedirectTypeSeeOther, + "temporary": ApplicationGatewayRedirectTypeTemporary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayRedirectType(input) + return &out, nil +} + +type ApplicationGatewayRequestRoutingRuleType string + +const ( + ApplicationGatewayRequestRoutingRuleTypeBasic ApplicationGatewayRequestRoutingRuleType = "Basic" + ApplicationGatewayRequestRoutingRuleTypePathBasedRouting ApplicationGatewayRequestRoutingRuleType = "PathBasedRouting" +) + +func PossibleValuesForApplicationGatewayRequestRoutingRuleType() []string { + return []string{ + string(ApplicationGatewayRequestRoutingRuleTypeBasic), + string(ApplicationGatewayRequestRoutingRuleTypePathBasedRouting), + } +} + +func (s *ApplicationGatewayRequestRoutingRuleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayRequestRoutingRuleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayRequestRoutingRuleType(input string) (*ApplicationGatewayRequestRoutingRuleType, error) { + vals := map[string]ApplicationGatewayRequestRoutingRuleType{ + "basic": ApplicationGatewayRequestRoutingRuleTypeBasic, + "pathbasedrouting": ApplicationGatewayRequestRoutingRuleTypePathBasedRouting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayRequestRoutingRuleType(input) + return &out, nil +} + +type ApplicationGatewaySkuFamily string + +const ( + ApplicationGatewaySkuFamilyGenerationOne ApplicationGatewaySkuFamily = "Generation_1" + ApplicationGatewaySkuFamilyGenerationTwo ApplicationGatewaySkuFamily = "Generation_2" +) + +func PossibleValuesForApplicationGatewaySkuFamily() []string { + return []string{ + string(ApplicationGatewaySkuFamilyGenerationOne), + string(ApplicationGatewaySkuFamilyGenerationTwo), + } +} + +func (s *ApplicationGatewaySkuFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewaySkuFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewaySkuFamily(input string) (*ApplicationGatewaySkuFamily, error) { + vals := map[string]ApplicationGatewaySkuFamily{ + "generation_1": ApplicationGatewaySkuFamilyGenerationOne, + "generation_2": ApplicationGatewaySkuFamilyGenerationTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewaySkuFamily(input) + return &out, nil +} + +type ApplicationGatewaySkuName string + +const ( + ApplicationGatewaySkuNameBasic ApplicationGatewaySkuName = "Basic" + ApplicationGatewaySkuNameStandardLarge ApplicationGatewaySkuName = "Standard_Large" + ApplicationGatewaySkuNameStandardMedium ApplicationGatewaySkuName = "Standard_Medium" + ApplicationGatewaySkuNameStandardSmall ApplicationGatewaySkuName = "Standard_Small" + ApplicationGatewaySkuNameStandardVTwo ApplicationGatewaySkuName = "Standard_v2" + ApplicationGatewaySkuNameWAFLarge ApplicationGatewaySkuName = "WAF_Large" + ApplicationGatewaySkuNameWAFMedium ApplicationGatewaySkuName = "WAF_Medium" + ApplicationGatewaySkuNameWAFVTwo ApplicationGatewaySkuName = "WAF_v2" +) + +func PossibleValuesForApplicationGatewaySkuName() []string { + return []string{ + string(ApplicationGatewaySkuNameBasic), + string(ApplicationGatewaySkuNameStandardLarge), + string(ApplicationGatewaySkuNameStandardMedium), + string(ApplicationGatewaySkuNameStandardSmall), + string(ApplicationGatewaySkuNameStandardVTwo), + string(ApplicationGatewaySkuNameWAFLarge), + string(ApplicationGatewaySkuNameWAFMedium), + string(ApplicationGatewaySkuNameWAFVTwo), + } +} + +func (s *ApplicationGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewaySkuName(input string) (*ApplicationGatewaySkuName, error) { + vals := map[string]ApplicationGatewaySkuName{ + "basic": ApplicationGatewaySkuNameBasic, + "standard_large": ApplicationGatewaySkuNameStandardLarge, + "standard_medium": ApplicationGatewaySkuNameStandardMedium, + "standard_small": ApplicationGatewaySkuNameStandardSmall, + "standard_v2": ApplicationGatewaySkuNameStandardVTwo, + "waf_large": ApplicationGatewaySkuNameWAFLarge, + "waf_medium": ApplicationGatewaySkuNameWAFMedium, + "waf_v2": ApplicationGatewaySkuNameWAFVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewaySkuName(input) + return &out, nil +} + +type ApplicationGatewaySslCipherSuite string + +const ( + ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESOneTwoEightCBCSHA ApplicationGatewaySslCipherSuite = "TLS_DHE_DSS_WITH_AES_128_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESOneTwoEightCBCSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256" + ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESTwoFiveSixCBCSHA ApplicationGatewaySslCipherSuite = "TLS_DHE_DSS_WITH_AES_256_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESTwoFiveSixCBCSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256" + ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHThreeDESEDECBCSHA ApplicationGatewaySslCipherSuite = "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESOneTwoEightCBCSHA ApplicationGatewaySslCipherSuite = "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" + ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESTwoFiveSixCBCSHA ApplicationGatewaySslCipherSuite = "TLS_DHE_RSA_WITH_AES_256_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour ApplicationGatewaySslCipherSuite = "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384" + ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightCBCSHA ApplicationGatewaySslCipherSuite = "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" + ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" + ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixCBCSHA ApplicationGatewaySslCipherSuite = "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixCBCSHAThreeEightFour ApplicationGatewaySslCipherSuite = "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384" + ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour ApplicationGatewaySslCipherSuite = "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" + ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightCBCSHA ApplicationGatewaySslCipherSuite = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" + ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" + ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixCBCSHA ApplicationGatewaySslCipherSuite = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour ApplicationGatewaySslCipherSuite = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" + ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour ApplicationGatewaySslCipherSuite = "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" + ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightCBCSHA ApplicationGatewaySslCipherSuite = "TLS_RSA_WITH_AES_128_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_RSA_WITH_AES_128_CBC_SHA256" + ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_RSA_WITH_AES_128_GCM_SHA256" + ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixCBCSHA ApplicationGatewaySslCipherSuite = "TLS_RSA_WITH_AES_256_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_RSA_WITH_AES_256_CBC_SHA256" + ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour ApplicationGatewaySslCipherSuite = "TLS_RSA_WITH_AES_256_GCM_SHA384" + ApplicationGatewaySslCipherSuiteTLSRSAWITHThreeDESEDECBCSHA ApplicationGatewaySslCipherSuite = "TLS_RSA_WITH_3DES_EDE_CBC_SHA" +) + +func PossibleValuesForApplicationGatewaySslCipherSuite() []string { + return []string{ + string(ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESOneTwoEightCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESOneTwoEightCBCSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESTwoFiveSixCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESTwoFiveSixCBCSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHThreeDESEDECBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESOneTwoEightCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESTwoFiveSixCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixCBCSHAThreeEightFour), + string(ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour), + string(ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(ApplicationGatewaySslCipherSuiteTLSRSAWITHThreeDESEDECBCSHA), + } +} + +func (s *ApplicationGatewaySslCipherSuite) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewaySslCipherSuite(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewaySslCipherSuite(input string) (*ApplicationGatewaySslCipherSuite, error) { + vals := map[string]ApplicationGatewaySslCipherSuite{ + "tls_dhe_dss_with_aes_128_cbc_sha": ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESOneTwoEightCBCSHA, + "tls_dhe_dss_with_aes_128_cbc_sha256": ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_dhe_dss_with_aes_256_cbc_sha": ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESTwoFiveSixCBCSHA, + "tls_dhe_dss_with_aes_256_cbc_sha256": ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESTwoFiveSixCBCSHATwoFiveSix, + "tls_dhe_dss_with_3des_ede_cbc_sha": ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHThreeDESEDECBCSHA, + "tls_dhe_rsa_with_aes_128_cbc_sha": ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESOneTwoEightCBCSHA, + "tls_dhe_rsa_with_aes_128_gcm_sha256": ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_dhe_rsa_with_aes_256_cbc_sha": ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESTwoFiveSixCBCSHA, + "tls_dhe_rsa_with_aes_256_gcm_sha384": ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_ecdsa_with_aes_128_cbc_sha": ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightCBCSHA, + "tls_ecdhe_ecdsa_with_aes_128_cbc_sha256": ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_128_gcm_sha256": ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_256_cbc_sha": ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixCBCSHA, + "tls_ecdhe_ecdsa_with_aes_256_cbc_sha384": ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixCBCSHAThreeEightFour, + "tls_ecdhe_ecdsa_with_aes_256_gcm_sha384": ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_128_cbc_sha": ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightCBCSHA, + "tls_ecdhe_rsa_with_aes_128_cbc_sha256": ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_128_gcm_sha256": ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_256_cbc_sha": ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixCBCSHA, + "tls_ecdhe_rsa_with_aes_256_cbc_sha384": ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_256_gcm_sha384": ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_rsa_with_aes_128_cbc_sha": ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightCBCSHA, + "tls_rsa_with_aes_128_cbc_sha256": ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_rsa_with_aes_128_gcm_sha256": ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_rsa_with_aes_256_cbc_sha": ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixCBCSHA, + "tls_rsa_with_aes_256_cbc_sha256": ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix, + "tls_rsa_with_aes_256_gcm_sha384": ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_rsa_with_3des_ede_cbc_sha": ApplicationGatewaySslCipherSuiteTLSRSAWITHThreeDESEDECBCSHA, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewaySslCipherSuite(input) + return &out, nil +} + +type ApplicationGatewaySslPolicyName string + +const ( + ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneFiveZeroFiveZeroOne ApplicationGatewaySslPolicyName = "AppGwSslPolicy20150501" + ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneSevenZeroFourZeroOne ApplicationGatewaySslPolicyName = "AppGwSslPolicy20170401" + ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneSevenZeroFourZeroOneS ApplicationGatewaySslPolicyName = "AppGwSslPolicy20170401S" + ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroTwoTwoZeroOneZeroOne ApplicationGatewaySslPolicyName = "AppGwSslPolicy20220101" + ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroTwoTwoZeroOneZeroOneS ApplicationGatewaySslPolicyName = "AppGwSslPolicy20220101S" +) + +func PossibleValuesForApplicationGatewaySslPolicyName() []string { + return []string{ + string(ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneFiveZeroFiveZeroOne), + string(ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneSevenZeroFourZeroOne), + string(ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneSevenZeroFourZeroOneS), + string(ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroTwoTwoZeroOneZeroOne), + string(ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroTwoTwoZeroOneZeroOneS), + } +} + +func (s *ApplicationGatewaySslPolicyName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewaySslPolicyName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewaySslPolicyName(input string) (*ApplicationGatewaySslPolicyName, error) { + vals := map[string]ApplicationGatewaySslPolicyName{ + "appgwsslpolicy20150501": ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneFiveZeroFiveZeroOne, + "appgwsslpolicy20170401": ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneSevenZeroFourZeroOne, + "appgwsslpolicy20170401s": ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneSevenZeroFourZeroOneS, + "appgwsslpolicy20220101": ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroTwoTwoZeroOneZeroOne, + "appgwsslpolicy20220101s": ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroTwoTwoZeroOneZeroOneS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewaySslPolicyName(input) + return &out, nil +} + +type ApplicationGatewaySslPolicyType string + +const ( + ApplicationGatewaySslPolicyTypeCustom ApplicationGatewaySslPolicyType = "Custom" + ApplicationGatewaySslPolicyTypeCustomVTwo ApplicationGatewaySslPolicyType = "CustomV2" + ApplicationGatewaySslPolicyTypePredefined ApplicationGatewaySslPolicyType = "Predefined" +) + +func PossibleValuesForApplicationGatewaySslPolicyType() []string { + return []string{ + string(ApplicationGatewaySslPolicyTypeCustom), + string(ApplicationGatewaySslPolicyTypeCustomVTwo), + string(ApplicationGatewaySslPolicyTypePredefined), + } +} + +func (s *ApplicationGatewaySslPolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewaySslPolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewaySslPolicyType(input string) (*ApplicationGatewaySslPolicyType, error) { + vals := map[string]ApplicationGatewaySslPolicyType{ + "custom": ApplicationGatewaySslPolicyTypeCustom, + "customv2": ApplicationGatewaySslPolicyTypeCustomVTwo, + "predefined": ApplicationGatewaySslPolicyTypePredefined, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewaySslPolicyType(input) + return &out, nil +} + +type ApplicationGatewaySslProtocol string + +const ( + ApplicationGatewaySslProtocolTLSvOneOne ApplicationGatewaySslProtocol = "TLSv1_1" + ApplicationGatewaySslProtocolTLSvOneThree ApplicationGatewaySslProtocol = "TLSv1_3" + ApplicationGatewaySslProtocolTLSvOneTwo ApplicationGatewaySslProtocol = "TLSv1_2" + ApplicationGatewaySslProtocolTLSvOneZero ApplicationGatewaySslProtocol = "TLSv1_0" +) + +func PossibleValuesForApplicationGatewaySslProtocol() []string { + return []string{ + string(ApplicationGatewaySslProtocolTLSvOneOne), + string(ApplicationGatewaySslProtocolTLSvOneThree), + string(ApplicationGatewaySslProtocolTLSvOneTwo), + string(ApplicationGatewaySslProtocolTLSvOneZero), + } +} + +func (s *ApplicationGatewaySslProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewaySslProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewaySslProtocol(input string) (*ApplicationGatewaySslProtocol, error) { + vals := map[string]ApplicationGatewaySslProtocol{ + "tlsv1_1": ApplicationGatewaySslProtocolTLSvOneOne, + "tlsv1_3": ApplicationGatewaySslProtocolTLSvOneThree, + "tlsv1_2": ApplicationGatewaySslProtocolTLSvOneTwo, + "tlsv1_0": ApplicationGatewaySslProtocolTLSvOneZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewaySslProtocol(input) + return &out, nil +} + +type ApplicationGatewayTier string + +const ( + ApplicationGatewayTierBasic ApplicationGatewayTier = "Basic" + ApplicationGatewayTierStandard ApplicationGatewayTier = "Standard" + ApplicationGatewayTierStandardVTwo ApplicationGatewayTier = "Standard_v2" + ApplicationGatewayTierWAF ApplicationGatewayTier = "WAF" + ApplicationGatewayTierWAFVTwo ApplicationGatewayTier = "WAF_v2" +) + +func PossibleValuesForApplicationGatewayTier() []string { + return []string{ + string(ApplicationGatewayTierBasic), + string(ApplicationGatewayTierStandard), + string(ApplicationGatewayTierStandardVTwo), + string(ApplicationGatewayTierWAF), + string(ApplicationGatewayTierWAFVTwo), + } +} + +func (s *ApplicationGatewayTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayTier(input string) (*ApplicationGatewayTier, error) { + vals := map[string]ApplicationGatewayTier{ + "basic": ApplicationGatewayTierBasic, + "standard": ApplicationGatewayTierStandard, + "standard_v2": ApplicationGatewayTierStandardVTwo, + "waf": ApplicationGatewayTierWAF, + "waf_v2": ApplicationGatewayTierWAFVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayTier(input) + return &out, nil +} + +type ApplicationGatewayTierTypes string + +const ( + ApplicationGatewayTierTypesStandard ApplicationGatewayTierTypes = "Standard" + ApplicationGatewayTierTypesStandardVTwo ApplicationGatewayTierTypes = "Standard_v2" + ApplicationGatewayTierTypesWAF ApplicationGatewayTierTypes = "WAF" + ApplicationGatewayTierTypesWAFVTwo ApplicationGatewayTierTypes = "WAF_v2" +) + +func PossibleValuesForApplicationGatewayTierTypes() []string { + return []string{ + string(ApplicationGatewayTierTypesStandard), + string(ApplicationGatewayTierTypesStandardVTwo), + string(ApplicationGatewayTierTypesWAF), + string(ApplicationGatewayTierTypesWAFVTwo), + } +} + +func (s *ApplicationGatewayTierTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayTierTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayTierTypes(input string) (*ApplicationGatewayTierTypes, error) { + vals := map[string]ApplicationGatewayTierTypes{ + "standard": ApplicationGatewayTierTypesStandard, + "standard_v2": ApplicationGatewayTierTypesStandardVTwo, + "waf": ApplicationGatewayTierTypesWAF, + "waf_v2": ApplicationGatewayTierTypesWAFVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayTierTypes(input) + return &out, nil +} + +type ApplicationGatewayWafRuleActionTypes string + +const ( + ApplicationGatewayWafRuleActionTypesAllow ApplicationGatewayWafRuleActionTypes = "Allow" + ApplicationGatewayWafRuleActionTypesAnomalyScoring ApplicationGatewayWafRuleActionTypes = "AnomalyScoring" + ApplicationGatewayWafRuleActionTypesBlock ApplicationGatewayWafRuleActionTypes = "Block" + ApplicationGatewayWafRuleActionTypesLog ApplicationGatewayWafRuleActionTypes = "Log" + ApplicationGatewayWafRuleActionTypesNone ApplicationGatewayWafRuleActionTypes = "None" +) + +func PossibleValuesForApplicationGatewayWafRuleActionTypes() []string { + return []string{ + string(ApplicationGatewayWafRuleActionTypesAllow), + string(ApplicationGatewayWafRuleActionTypesAnomalyScoring), + string(ApplicationGatewayWafRuleActionTypesBlock), + string(ApplicationGatewayWafRuleActionTypesLog), + string(ApplicationGatewayWafRuleActionTypesNone), + } +} + +func (s *ApplicationGatewayWafRuleActionTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayWafRuleActionTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayWafRuleActionTypes(input string) (*ApplicationGatewayWafRuleActionTypes, error) { + vals := map[string]ApplicationGatewayWafRuleActionTypes{ + "allow": ApplicationGatewayWafRuleActionTypesAllow, + "anomalyscoring": ApplicationGatewayWafRuleActionTypesAnomalyScoring, + "block": ApplicationGatewayWafRuleActionTypesBlock, + "log": ApplicationGatewayWafRuleActionTypesLog, + "none": ApplicationGatewayWafRuleActionTypesNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayWafRuleActionTypes(input) + return &out, nil +} + +type ApplicationGatewayWafRuleSensitivityTypes string + +const ( + ApplicationGatewayWafRuleSensitivityTypesHigh ApplicationGatewayWafRuleSensitivityTypes = "High" + ApplicationGatewayWafRuleSensitivityTypesLow ApplicationGatewayWafRuleSensitivityTypes = "Low" + ApplicationGatewayWafRuleSensitivityTypesMedium ApplicationGatewayWafRuleSensitivityTypes = "Medium" + ApplicationGatewayWafRuleSensitivityTypesNone ApplicationGatewayWafRuleSensitivityTypes = "None" +) + +func PossibleValuesForApplicationGatewayWafRuleSensitivityTypes() []string { + return []string{ + string(ApplicationGatewayWafRuleSensitivityTypesHigh), + string(ApplicationGatewayWafRuleSensitivityTypesLow), + string(ApplicationGatewayWafRuleSensitivityTypesMedium), + string(ApplicationGatewayWafRuleSensitivityTypesNone), + } +} + +func (s *ApplicationGatewayWafRuleSensitivityTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayWafRuleSensitivityTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayWafRuleSensitivityTypes(input string) (*ApplicationGatewayWafRuleSensitivityTypes, error) { + vals := map[string]ApplicationGatewayWafRuleSensitivityTypes{ + "high": ApplicationGatewayWafRuleSensitivityTypesHigh, + "low": ApplicationGatewayWafRuleSensitivityTypesLow, + "medium": ApplicationGatewayWafRuleSensitivityTypesMedium, + "none": ApplicationGatewayWafRuleSensitivityTypesNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayWafRuleSensitivityTypes(input) + return &out, nil +} + +type ApplicationGatewayWafRuleStateTypes string + +const ( + ApplicationGatewayWafRuleStateTypesDisabled ApplicationGatewayWafRuleStateTypes = "Disabled" + ApplicationGatewayWafRuleStateTypesEnabled ApplicationGatewayWafRuleStateTypes = "Enabled" +) + +func PossibleValuesForApplicationGatewayWafRuleStateTypes() []string { + return []string{ + string(ApplicationGatewayWafRuleStateTypesDisabled), + string(ApplicationGatewayWafRuleStateTypesEnabled), + } +} + +func (s *ApplicationGatewayWafRuleStateTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayWafRuleStateTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayWafRuleStateTypes(input string) (*ApplicationGatewayWafRuleStateTypes, error) { + vals := map[string]ApplicationGatewayWafRuleStateTypes{ + "disabled": ApplicationGatewayWafRuleStateTypesDisabled, + "enabled": ApplicationGatewayWafRuleStateTypesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayWafRuleStateTypes(input) + return &out, nil +} + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/id_applicationgateway.go b/resource-manager/network/2024-07-01/applicationgateways/id_applicationgateway.go new file mode 100644 index 00000000000..90637014b69 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/id_applicationgateway.go @@ -0,0 +1,130 @@ +package applicationgateways + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ApplicationGatewayId{}) +} + +var _ resourceids.ResourceId = &ApplicationGatewayId{} + +// ApplicationGatewayId is a struct representing the Resource ID for a Application Gateway +type ApplicationGatewayId struct { + SubscriptionId string + ResourceGroupName string + ApplicationGatewayName string +} + +// NewApplicationGatewayID returns a new ApplicationGatewayId struct +func NewApplicationGatewayID(subscriptionId string, resourceGroupName string, applicationGatewayName string) ApplicationGatewayId { + return ApplicationGatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ApplicationGatewayName: applicationGatewayName, + } +} + +// ParseApplicationGatewayID parses 'input' into a ApplicationGatewayId +func ParseApplicationGatewayID(input string) (*ApplicationGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApplicationGatewayIDInsensitively parses 'input' case-insensitively into a ApplicationGatewayId +// note: this method should only be used for API response data and not user input +func ParseApplicationGatewayIDInsensitively(input string) (*ApplicationGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApplicationGatewayId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ApplicationGatewayName, ok = input.Parsed["applicationGatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationGatewayName", input) + } + + return nil +} + +// ValidateApplicationGatewayID checks that 'input' can be parsed as a Application Gateway ID +func ValidateApplicationGatewayID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseApplicationGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Application Gateway ID +func (id ApplicationGatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/applicationGateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ApplicationGatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Application Gateway ID +func (id ApplicationGatewayId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticApplicationGateways", "applicationGateways", "applicationGateways"), + resourceids.UserSpecifiedSegment("applicationGatewayName", "applicationGatewayName"), + } +} + +// String returns a human-readable description of this Application Gateway ID +func (id ApplicationGatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Application Gateway Name: %q", id.ApplicationGatewayName), + } + return fmt.Sprintf("Application Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/id_applicationgateway_test.go b/resource-manager/network/2024-07-01/applicationgateways/id_applicationgateway_test.go new file mode 100644 index 00000000000..58dbc7b0f5a --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/id_applicationgateway_test.go @@ -0,0 +1,282 @@ +package applicationgateways + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ApplicationGatewayId{} + +func TestNewApplicationGatewayID(t *testing.T) { + id := NewApplicationGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ApplicationGatewayName != "applicationGatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationGatewayName'", id.ApplicationGatewayName, "applicationGatewayName") + } +} + +func TestFormatApplicationGatewayID(t *testing.T) { + actual := NewApplicationGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApplicationGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName", + Expected: &ApplicationGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGatewayName: "applicationGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGatewayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGatewayName != v.Expected.ApplicationGatewayName { + t.Fatalf("Expected %q but got %q for ApplicationGatewayName", v.Expected.ApplicationGatewayName, actual.ApplicationGatewayName) + } + + } +} + +func TestParseApplicationGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName", + Expected: &ApplicationGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGatewayName: "applicationGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGateways/applicationGatewayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYs/aPpLiCaTiOnGaTeWaYnAmE", + Expected: &ApplicationGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ApplicationGatewayName: "aPpLiCaTiOnGaTeWaYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYs/aPpLiCaTiOnGaTeWaYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGatewayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGatewayName != v.Expected.ApplicationGatewayName { + t.Fatalf("Expected %q but got %q for ApplicationGatewayName", v.Expected.ApplicationGatewayName, actual.ApplicationGatewayName) + } + + } +} + +func TestSegmentsForApplicationGatewayId(t *testing.T) { + segments := ApplicationGatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApplicationGatewayId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/id_predefinedpolicy.go b/resource-manager/network/2024-07-01/applicationgateways/id_predefinedpolicy.go new file mode 100644 index 00000000000..098e66be9e4 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/id_predefinedpolicy.go @@ -0,0 +1,123 @@ +package applicationgateways + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PredefinedPolicyId{}) +} + +var _ resourceids.ResourceId = &PredefinedPolicyId{} + +// PredefinedPolicyId is a struct representing the Resource ID for a Predefined Policy +type PredefinedPolicyId struct { + SubscriptionId string + PredefinedPolicyName string +} + +// NewPredefinedPolicyID returns a new PredefinedPolicyId struct +func NewPredefinedPolicyID(subscriptionId string, predefinedPolicyName string) PredefinedPolicyId { + return PredefinedPolicyId{ + SubscriptionId: subscriptionId, + PredefinedPolicyName: predefinedPolicyName, + } +} + +// ParsePredefinedPolicyID parses 'input' into a PredefinedPolicyId +func ParsePredefinedPolicyID(input string) (*PredefinedPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&PredefinedPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PredefinedPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePredefinedPolicyIDInsensitively parses 'input' case-insensitively into a PredefinedPolicyId +// note: this method should only be used for API response data and not user input +func ParsePredefinedPolicyIDInsensitively(input string) (*PredefinedPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&PredefinedPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PredefinedPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PredefinedPolicyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.PredefinedPolicyName, ok = input.Parsed["predefinedPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "predefinedPolicyName", input) + } + + return nil +} + +// ValidatePredefinedPolicyID checks that 'input' can be parsed as a Predefined Policy ID +func ValidatePredefinedPolicyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePredefinedPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Predefined Policy ID +func (id PredefinedPolicyId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Network/applicationGatewayAvailableSslOptions/default/predefinedPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.PredefinedPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Predefined Policy ID +func (id PredefinedPolicyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticApplicationGatewayAvailableSslOptions", "applicationGatewayAvailableSslOptions", "applicationGatewayAvailableSslOptions"), + resourceids.StaticSegment("staticDefault", "default", "default"), + resourceids.StaticSegment("staticPredefinedPolicies", "predefinedPolicies", "predefinedPolicies"), + resourceids.UserSpecifiedSegment("predefinedPolicyName", "predefinedPolicyName"), + } +} + +// String returns a human-readable description of this Predefined Policy ID +func (id PredefinedPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Predefined Policy Name: %q", id.PredefinedPolicyName), + } + return fmt.Sprintf("Predefined Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/id_predefinedpolicy_test.go b/resource-manager/network/2024-07-01/applicationgateways/id_predefinedpolicy_test.go new file mode 100644 index 00000000000..013bf65b5b5 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/id_predefinedpolicy_test.go @@ -0,0 +1,267 @@ +package applicationgateways + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PredefinedPolicyId{} + +func TestNewPredefinedPolicyID(t *testing.T) { + id := NewPredefinedPolicyID("12345678-1234-9876-4563-123456789012", "predefinedPolicyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.PredefinedPolicyName != "predefinedPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'PredefinedPolicyName'", id.PredefinedPolicyName, "predefinedPolicyName") + } +} + +func TestFormatPredefinedPolicyID(t *testing.T) { + actual := NewPredefinedPolicyID("12345678-1234-9876-4563-123456789012", "predefinedPolicyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/applicationGatewayAvailableSslOptions/default/predefinedPolicies/predefinedPolicyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePredefinedPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PredefinedPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/applicationGatewayAvailableSslOptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/applicationGatewayAvailableSslOptions/default", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/applicationGatewayAvailableSslOptions/default/predefinedPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/applicationGatewayAvailableSslOptions/default/predefinedPolicies/predefinedPolicyName", + Expected: &PredefinedPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PredefinedPolicyName: "predefinedPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/applicationGatewayAvailableSslOptions/default/predefinedPolicies/predefinedPolicyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePredefinedPolicyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.PredefinedPolicyName != v.Expected.PredefinedPolicyName { + t.Fatalf("Expected %q but got %q for PredefinedPolicyName", v.Expected.PredefinedPolicyName, actual.PredefinedPolicyName) + } + + } +} + +func TestParsePredefinedPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PredefinedPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/applicationGatewayAvailableSslOptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYaVaIlAbLeSsLoPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/applicationGatewayAvailableSslOptions/default", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYaVaIlAbLeSsLoPtIoNs/dEfAuLt", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/applicationGatewayAvailableSslOptions/default/predefinedPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYaVaIlAbLeSsLoPtIoNs/dEfAuLt/pReDeFiNeDpOlIcIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/applicationGatewayAvailableSslOptions/default/predefinedPolicies/predefinedPolicyName", + Expected: &PredefinedPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PredefinedPolicyName: "predefinedPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/applicationGatewayAvailableSslOptions/default/predefinedPolicies/predefinedPolicyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYaVaIlAbLeSsLoPtIoNs/dEfAuLt/pReDeFiNeDpOlIcIeS/pReDeFiNeDpOlIcYnAmE", + Expected: &PredefinedPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + PredefinedPolicyName: "pReDeFiNeDpOlIcYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYaVaIlAbLeSsLoPtIoNs/dEfAuLt/pReDeFiNeDpOlIcIeS/pReDeFiNeDpOlIcYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePredefinedPolicyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.PredefinedPolicyName != v.Expected.PredefinedPolicyName { + t.Fatalf("Expected %q but got %q for PredefinedPolicyName", v.Expected.PredefinedPolicyName, actual.PredefinedPolicyName) + } + + } +} + +func TestSegmentsForPredefinedPolicyId(t *testing.T) { + segments := PredefinedPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PredefinedPolicyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/method_backendhealth.go b/resource-manager/network/2024-07-01/applicationgateways/method_backendhealth.go new file mode 100644 index 00000000000..2ab399ab3f9 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/method_backendhealth.go @@ -0,0 +1,100 @@ +package applicationgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendHealthOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationGatewayBackendHealth +} + +type BackendHealthOperationOptions struct { + Expand *string +} + +func DefaultBackendHealthOperationOptions() BackendHealthOperationOptions { + return BackendHealthOperationOptions{} +} + +func (o BackendHealthOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o BackendHealthOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o BackendHealthOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// BackendHealth ... +func (c ApplicationGatewaysClient) BackendHealth(ctx context.Context, id ApplicationGatewayId, options BackendHealthOperationOptions) (result BackendHealthOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/backendhealth", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// BackendHealthThenPoll performs BackendHealth then polls until it's completed +func (c ApplicationGatewaysClient) BackendHealthThenPoll(ctx context.Context, id ApplicationGatewayId, options BackendHealthOperationOptions) error { + result, err := c.BackendHealth(ctx, id, options) + if err != nil { + return fmt.Errorf("performing BackendHealth: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BackendHealth: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/method_backendhealthondemand.go b/resource-manager/network/2024-07-01/applicationgateways/method_backendhealthondemand.go new file mode 100644 index 00000000000..a22fd7135ce --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/method_backendhealthondemand.go @@ -0,0 +1,104 @@ +package applicationgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendHealthOnDemandOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationGatewayBackendHealthOnDemand +} + +type BackendHealthOnDemandOperationOptions struct { + Expand *string +} + +func DefaultBackendHealthOnDemandOperationOptions() BackendHealthOnDemandOperationOptions { + return BackendHealthOnDemandOperationOptions{} +} + +func (o BackendHealthOnDemandOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o BackendHealthOnDemandOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o BackendHealthOnDemandOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// BackendHealthOnDemand ... +func (c ApplicationGatewaysClient) BackendHealthOnDemand(ctx context.Context, id ApplicationGatewayId, input ApplicationGatewayOnDemandProbe, options BackendHealthOnDemandOperationOptions) (result BackendHealthOnDemandOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/getBackendHealthOnDemand", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// BackendHealthOnDemandThenPoll performs BackendHealthOnDemand then polls until it's completed +func (c ApplicationGatewaysClient) BackendHealthOnDemandThenPoll(ctx context.Context, id ApplicationGatewayId, input ApplicationGatewayOnDemandProbe, options BackendHealthOnDemandOperationOptions) error { + result, err := c.BackendHealthOnDemand(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing BackendHealthOnDemand: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after BackendHealthOnDemand: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/method_createorupdate.go b/resource-manager/network/2024-07-01/applicationgateways/method_createorupdate.go new file mode 100644 index 00000000000..66330483b32 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/method_createorupdate.go @@ -0,0 +1,75 @@ +package applicationgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationGateway +} + +// CreateOrUpdate ... +func (c ApplicationGatewaysClient) CreateOrUpdate(ctx context.Context, id ApplicationGatewayId, input ApplicationGateway) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ApplicationGatewaysClient) CreateOrUpdateThenPoll(ctx context.Context, id ApplicationGatewayId, input ApplicationGateway) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/method_delete.go b/resource-manager/network/2024-07-01/applicationgateways/method_delete.go new file mode 100644 index 00000000000..6769fa69c24 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/method_delete.go @@ -0,0 +1,71 @@ +package applicationgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ApplicationGatewaysClient) Delete(ctx context.Context, id ApplicationGatewayId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ApplicationGatewaysClient) DeleteThenPoll(ctx context.Context, id ApplicationGatewayId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/method_get.go b/resource-manager/network/2024-07-01/applicationgateways/method_get.go new file mode 100644 index 00000000000..c25227f49ca --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/method_get.go @@ -0,0 +1,53 @@ +package applicationgateways + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationGateway +} + +// Get ... +func (c ApplicationGatewaysClient) Get(ctx context.Context, id ApplicationGatewayId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApplicationGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/method_getsslpredefinedpolicy.go b/resource-manager/network/2024-07-01/applicationgateways/method_getsslpredefinedpolicy.go new file mode 100644 index 00000000000..d42b5d2730e --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/method_getsslpredefinedpolicy.go @@ -0,0 +1,53 @@ +package applicationgateways + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSslPredefinedPolicyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationGatewaySslPredefinedPolicy +} + +// GetSslPredefinedPolicy ... +func (c ApplicationGatewaysClient) GetSslPredefinedPolicy(ctx context.Context, id PredefinedPolicyId) (result GetSslPredefinedPolicyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApplicationGatewaySslPredefinedPolicy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/method_list.go b/resource-manager/network/2024-07-01/applicationgateways/method_list.go new file mode 100644 index 00000000000..5993122f77d --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/method_list.go @@ -0,0 +1,106 @@ +package applicationgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationGateway +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationGateway +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ApplicationGatewaysClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/applicationGateways", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApplicationGateway `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ApplicationGatewaysClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ApplicationGatewayOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationGatewaysClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ApplicationGatewayOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ApplicationGateway, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/method_listall.go b/resource-manager/network/2024-07-01/applicationgateways/method_listall.go new file mode 100644 index 00000000000..2339a539153 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/method_listall.go @@ -0,0 +1,106 @@ +package applicationgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationGateway +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationGateway +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c ApplicationGatewaysClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/applicationGateways", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApplicationGateway `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c ApplicationGatewaysClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, ApplicationGatewayOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationGatewaysClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ApplicationGatewayOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]ApplicationGateway, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/method_listavailablerequestheaders.go b/resource-manager/network/2024-07-01/applicationgateways/method_listavailablerequestheaders.go new file mode 100644 index 00000000000..8132f0945cf --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/method_listavailablerequestheaders.go @@ -0,0 +1,55 @@ +package applicationgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAvailableRequestHeadersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]string +} + +// ListAvailableRequestHeaders ... +func (c ApplicationGatewaysClient) ListAvailableRequestHeaders(ctx context.Context, id commonids.SubscriptionId) (result ListAvailableRequestHeadersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/applicationGatewayAvailableRequestHeaders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []string + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/method_listavailableresponseheaders.go b/resource-manager/network/2024-07-01/applicationgateways/method_listavailableresponseheaders.go new file mode 100644 index 00000000000..89bdb636e2e --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/method_listavailableresponseheaders.go @@ -0,0 +1,55 @@ +package applicationgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAvailableResponseHeadersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]string +} + +// ListAvailableResponseHeaders ... +func (c ApplicationGatewaysClient) ListAvailableResponseHeaders(ctx context.Context, id commonids.SubscriptionId) (result ListAvailableResponseHeadersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/applicationGatewayAvailableResponseHeaders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []string + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/method_listavailableservervariables.go b/resource-manager/network/2024-07-01/applicationgateways/method_listavailableservervariables.go new file mode 100644 index 00000000000..f2a0d8c4b79 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/method_listavailableservervariables.go @@ -0,0 +1,55 @@ +package applicationgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAvailableServerVariablesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]string +} + +// ListAvailableServerVariables ... +func (c ApplicationGatewaysClient) ListAvailableServerVariables(ctx context.Context, id commonids.SubscriptionId) (result ListAvailableServerVariablesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/applicationGatewayAvailableServerVariables", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []string + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/method_listavailablessloptions.go b/resource-manager/network/2024-07-01/applicationgateways/method_listavailablessloptions.go new file mode 100644 index 00000000000..f446cd3730a --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/method_listavailablessloptions.go @@ -0,0 +1,55 @@ +package applicationgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAvailableSslOptionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationGatewayAvailableSslOptions +} + +// ListAvailableSslOptions ... +func (c ApplicationGatewaysClient) ListAvailableSslOptions(ctx context.Context, id commonids.SubscriptionId) (result ListAvailableSslOptionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/applicationGatewayAvailableSslOptions/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApplicationGatewayAvailableSslOptions + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/method_listavailablesslpredefinedpolicies.go b/resource-manager/network/2024-07-01/applicationgateways/method_listavailablesslpredefinedpolicies.go new file mode 100644 index 00000000000..60e04b841d4 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/method_listavailablesslpredefinedpolicies.go @@ -0,0 +1,106 @@ +package applicationgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAvailableSslPredefinedPoliciesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationGatewaySslPredefinedPolicy +} + +type ListAvailableSslPredefinedPoliciesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationGatewaySslPredefinedPolicy +} + +type ListAvailableSslPredefinedPoliciesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAvailableSslPredefinedPoliciesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAvailableSslPredefinedPolicies ... +func (c ApplicationGatewaysClient) ListAvailableSslPredefinedPolicies(ctx context.Context, id commonids.SubscriptionId) (result ListAvailableSslPredefinedPoliciesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAvailableSslPredefinedPoliciesCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/applicationGatewayAvailableSslOptions/default/predefinedPolicies", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApplicationGatewaySslPredefinedPolicy `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAvailableSslPredefinedPoliciesComplete retrieves all the results into a single object +func (c ApplicationGatewaysClient) ListAvailableSslPredefinedPoliciesComplete(ctx context.Context, id commonids.SubscriptionId) (ListAvailableSslPredefinedPoliciesCompleteResult, error) { + return c.ListAvailableSslPredefinedPoliciesCompleteMatchingPredicate(ctx, id, ApplicationGatewaySslPredefinedPolicyOperationPredicate{}) +} + +// ListAvailableSslPredefinedPoliciesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationGatewaysClient) ListAvailableSslPredefinedPoliciesCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ApplicationGatewaySslPredefinedPolicyOperationPredicate) (result ListAvailableSslPredefinedPoliciesCompleteResult, err error) { + items := make([]ApplicationGatewaySslPredefinedPolicy, 0) + + resp, err := c.ListAvailableSslPredefinedPolicies(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAvailableSslPredefinedPoliciesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/method_listavailablewafrulesets.go b/resource-manager/network/2024-07-01/applicationgateways/method_listavailablewafrulesets.go new file mode 100644 index 00000000000..ee2a21477a5 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/method_listavailablewafrulesets.go @@ -0,0 +1,55 @@ +package applicationgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAvailableWafRuleSetsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationGatewayAvailableWafRuleSetsResult +} + +// ListAvailableWafRuleSets ... +func (c ApplicationGatewaysClient) ListAvailableWafRuleSets(ctx context.Context, id commonids.SubscriptionId) (result ListAvailableWafRuleSetsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/applicationGatewayAvailableWafRuleSets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApplicationGatewayAvailableWafRuleSetsResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/method_start.go b/resource-manager/network/2024-07-01/applicationgateways/method_start.go new file mode 100644 index 00000000000..828fc60cb3c --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/method_start.go @@ -0,0 +1,70 @@ +package applicationgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Start ... +func (c ApplicationGatewaysClient) Start(ctx context.Context, id ApplicationGatewayId) (result StartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StartThenPoll performs Start then polls until it's completed +func (c ApplicationGatewaysClient) StartThenPoll(ctx context.Context, id ApplicationGatewayId) error { + result, err := c.Start(ctx, id) + if err != nil { + return fmt.Errorf("performing Start: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Start: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/method_stop.go b/resource-manager/network/2024-07-01/applicationgateways/method_stop.go new file mode 100644 index 00000000000..75b68cdf697 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/method_stop.go @@ -0,0 +1,70 @@ +package applicationgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Stop ... +func (c ApplicationGatewaysClient) Stop(ctx context.Context, id ApplicationGatewayId) (result StopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StopThenPoll performs Stop then polls until it's completed +func (c ApplicationGatewaysClient) StopThenPoll(ctx context.Context, id ApplicationGatewayId) error { + result, err := c.Stop(ctx, id) + if err != nil { + return fmt.Errorf("performing Stop: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Stop: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/method_updatetags.go b/resource-manager/network/2024-07-01/applicationgateways/method_updatetags.go new file mode 100644 index 00000000000..875c2ce138d --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/method_updatetags.go @@ -0,0 +1,57 @@ +package applicationgateways + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationGateway +} + +// UpdateTags ... +func (c ApplicationGatewaysClient) UpdateTags(ctx context.Context, id ApplicationGatewayId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApplicationGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgateway.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgateway.go new file mode 100644 index 00000000000..26c26a88927 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgateway.go @@ -0,0 +1,21 @@ +package applicationgateways + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayauthenticationcertificate.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayauthenticationcertificate.go new file mode 100644 index 00000000000..21a1fec007f --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayauthenticationcertificate.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayAuthenticationCertificate struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayAuthenticationCertificatePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayauthenticationcertificatepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayauthenticationcertificatepropertiesformat.go new file mode 100644 index 00000000000..37f5189d68a --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayauthenticationcertificatepropertiesformat.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayAuthenticationCertificatePropertiesFormat struct { + Data *string `json:"data,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayautoscaleconfiguration.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayautoscaleconfiguration.go new file mode 100644 index 00000000000..e8f13521e07 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayautoscaleconfiguration.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayAutoscaleConfiguration struct { + MaxCapacity *int64 `json:"maxCapacity,omitempty"` + MinCapacity int64 `json:"minCapacity"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayavailablessloptions.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayavailablessloptions.go new file mode 100644 index 00000000000..18677bfa9ad --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayavailablessloptions.go @@ -0,0 +1,13 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayAvailableSslOptions struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayAvailableSslOptionsPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayavailablessloptionspropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayavailablessloptionspropertiesformat.go new file mode 100644 index 00000000000..552b956629b --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayavailablessloptionspropertiesformat.go @@ -0,0 +1,11 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayAvailableSslOptionsPropertiesFormat struct { + AvailableCipherSuites *[]ApplicationGatewaySslCipherSuite `json:"availableCipherSuites,omitempty"` + AvailableProtocols *[]ApplicationGatewaySslProtocol `json:"availableProtocols,omitempty"` + DefaultPolicy *ApplicationGatewaySslPolicyName `json:"defaultPolicy,omitempty"` + PredefinedPolicies *[]SubResource `json:"predefinedPolicies,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayavailablewafrulesetsresult.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayavailablewafrulesetsresult.go new file mode 100644 index 00000000000..b960a888077 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayavailablewafrulesetsresult.go @@ -0,0 +1,8 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayAvailableWafRuleSetsResult struct { + Value *[]ApplicationGatewayFirewallRuleSet `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..9245b4581ff --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..e62cc5f5a6a --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..92e4b6fcae0 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhealth.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhealth.go new file mode 100644 index 00000000000..b8439220957 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhealth.go @@ -0,0 +1,8 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendHealth struct { + BackendAddressPools *[]ApplicationGatewayBackendHealthPool `json:"backendAddressPools,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhealthhttpsettings.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhealthhttpsettings.go new file mode 100644 index 00000000000..00f4c87c142 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhealthhttpsettings.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendHealthHTTPSettings struct { + BackendHTTPSettings *ApplicationGatewayBackendHTTPSettings `json:"backendHttpSettings,omitempty"` + Servers *[]ApplicationGatewayBackendHealthServer `json:"servers,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhealthondemand.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhealthondemand.go new file mode 100644 index 00000000000..3bf6d17e80c --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhealthondemand.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendHealthOnDemand struct { + BackendAddressPool *ApplicationGatewayBackendAddressPool `json:"backendAddressPool,omitempty"` + BackendHealthHTTPSettings *ApplicationGatewayBackendHealthHTTPSettings `json:"backendHealthHttpSettings,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhealthpool.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhealthpool.go new file mode 100644 index 00000000000..b32fffdf614 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhealthpool.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendHealthPool struct { + BackendAddressPool *ApplicationGatewayBackendAddressPool `json:"backendAddressPool,omitempty"` + BackendHTTPSettingsCollection *[]ApplicationGatewayBackendHealthHTTPSettings `json:"backendHttpSettingsCollection,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhealthserver.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhealthserver.go new file mode 100644 index 00000000000..c11aed154b2 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhealthserver.go @@ -0,0 +1,11 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendHealthServer struct { + Address *string `json:"address,omitempty"` + Health *ApplicationGatewayBackendHealthServerHealth `json:"health,omitempty"` + HealthProbeLog *string `json:"healthProbeLog,omitempty"` + IPConfiguration *NetworkInterfaceIPConfiguration `json:"ipConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhttpsettings.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhttpsettings.go new file mode 100644 index 00000000000..7cfbecd3506 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhttpsettings.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendHTTPSettings struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendHTTPSettingsPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhttpsettingspropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhttpsettingspropertiesformat.go new file mode 100644 index 00000000000..68ccfd35301 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendhttpsettingspropertiesformat.go @@ -0,0 +1,21 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendHTTPSettingsPropertiesFormat struct { + AffinityCookieName *string `json:"affinityCookieName,omitempty"` + AuthenticationCertificates *[]SubResource `json:"authenticationCertificates,omitempty"` + ConnectionDraining *ApplicationGatewayConnectionDraining `json:"connectionDraining,omitempty"` + CookieBasedAffinity *ApplicationGatewayCookieBasedAffinity `json:"cookieBasedAffinity,omitempty"` + HostName *string `json:"hostName,omitempty"` + Path *string `json:"path,omitempty"` + PickHostNameFromBackendAddress *bool `json:"pickHostNameFromBackendAddress,omitempty"` + Port *int64 `json:"port,omitempty"` + Probe *SubResource `json:"probe,omitempty"` + ProbeEnabled *bool `json:"probeEnabled,omitempty"` + Protocol *ApplicationGatewayProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestTimeout *int64 `json:"requestTimeout,omitempty"` + TrustedRootCertificates *[]SubResource `json:"trustedRootCertificates,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendsettings.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendsettings.go new file mode 100644 index 00000000000..435626e7296 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendsettings.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendSettings struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendSettingsPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendsettingspropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendsettingspropertiesformat.go new file mode 100644 index 00000000000..5d5c1275f2e --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaybackendsettingspropertiesformat.go @@ -0,0 +1,15 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendSettingsPropertiesFormat struct { + HostName *string `json:"hostName,omitempty"` + PickHostNameFromBackendAddress *bool `json:"pickHostNameFromBackendAddress,omitempty"` + Port *int64 `json:"port,omitempty"` + Probe *SubResource `json:"probe,omitempty"` + Protocol *ApplicationGatewayProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Timeout *int64 `json:"timeout,omitempty"` + TrustedRootCertificates *[]SubResource `json:"trustedRootCertificates,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayclientauthconfiguration.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayclientauthconfiguration.go new file mode 100644 index 00000000000..7be179f89f0 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayclientauthconfiguration.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayClientAuthConfiguration struct { + VerifyClientCertIssuerDN *bool `json:"verifyClientCertIssuerDN,omitempty"` + VerifyClientRevocation *ApplicationGatewayClientRevocationOptions `json:"verifyClientRevocation,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayconnectiondraining.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayconnectiondraining.go new file mode 100644 index 00000000000..f40777a88f8 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayconnectiondraining.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayConnectionDraining struct { + DrainTimeoutInSec int64 `json:"drainTimeoutInSec"` + Enabled bool `json:"enabled"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaycustomerror.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaycustomerror.go new file mode 100644 index 00000000000..8b0e5fb8d20 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaycustomerror.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayCustomError struct { + CustomErrorPageURL *string `json:"customErrorPageUrl,omitempty"` + StatusCode *ApplicationGatewayCustomErrorStatusCode `json:"statusCode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewalldisabledrulegroup.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewalldisabledrulegroup.go new file mode 100644 index 00000000000..30534c50f52 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewalldisabledrulegroup.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFirewallDisabledRuleGroup struct { + RuleGroupName string `json:"ruleGroupName"` + Rules *[]int64 `json:"rules,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewallexclusion.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewallexclusion.go new file mode 100644 index 00000000000..77bfe2cf65c --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewallexclusion.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFirewallExclusion struct { + MatchVariable string `json:"matchVariable"` + Selector string `json:"selector"` + SelectorMatchOperator string `json:"selectorMatchOperator"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewallrule.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewallrule.go new file mode 100644 index 00000000000..3e364fe77a2 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewallrule.go @@ -0,0 +1,13 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFirewallRule struct { + Action *ApplicationGatewayWafRuleActionTypes `json:"action,omitempty"` + Description *string `json:"description,omitempty"` + RuleId int64 `json:"ruleId"` + RuleIdString *string `json:"ruleIdString,omitempty"` + Sensitivity *ApplicationGatewayWafRuleSensitivityTypes `json:"sensitivity,omitempty"` + State *ApplicationGatewayWafRuleStateTypes `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewallrulegroup.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewallrulegroup.go new file mode 100644 index 00000000000..06c7cbffb38 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewallrulegroup.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFirewallRuleGroup struct { + Description *string `json:"description,omitempty"` + RuleGroupName string `json:"ruleGroupName"` + Rules []ApplicationGatewayFirewallRule `json:"rules"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewallruleset.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewallruleset.go new file mode 100644 index 00000000000..3eb74351624 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewallruleset.go @@ -0,0 +1,13 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFirewallRuleSet struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayFirewallRuleSetPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewallrulesetpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewallrulesetpropertiesformat.go new file mode 100644 index 00000000000..f0bd967c325 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfirewallrulesetpropertiesformat.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFirewallRuleSetPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RuleGroups []ApplicationGatewayFirewallRuleGroup `json:"ruleGroups"` + RuleSetType string `json:"ruleSetType"` + RuleSetVersion string `json:"ruleSetVersion"` + Tiers *[]ApplicationGatewayTierTypes `json:"tiers,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfrontendipconfiguration.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfrontendipconfiguration.go new file mode 100644 index 00000000000..16f3a44fe68 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfrontendipconfiguration.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayFrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfrontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfrontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..45f83bbaa11 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfrontendipconfigurationpropertiesformat.go @@ -0,0 +1,13 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFrontendIPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConfiguration *SubResource `json:"privateLinkConfiguration,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *SubResource `json:"publicIPAddress,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfrontendport.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfrontendport.go new file mode 100644 index 00000000000..9b3c8763e01 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfrontendport.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFrontendPort struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayFrontendPortPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfrontendportpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfrontendportpropertiesformat.go new file mode 100644 index 00000000000..a9399610b8b --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayfrontendportpropertiesformat.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFrontendPortPropertiesFormat struct { + Port *int64 `json:"port,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayglobalconfiguration.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayglobalconfiguration.go new file mode 100644 index 00000000000..8f031b6ad38 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayglobalconfiguration.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayGlobalConfiguration struct { + EnableRequestBuffering *bool `json:"enableRequestBuffering,omitempty"` + EnableResponseBuffering *bool `json:"enableResponseBuffering,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayheaderconfiguration.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayheaderconfiguration.go new file mode 100644 index 00000000000..a7a9580c702 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayheaderconfiguration.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayHeaderConfiguration struct { + HeaderName *string `json:"headerName,omitempty"` + HeaderValue *string `json:"headerValue,omitempty"` + HeaderValueMatcher *HeaderValueMatcher `json:"headerValueMatcher,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayhttplistener.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayhttplistener.go new file mode 100644 index 00000000000..457c3af7d7b --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayhttplistener.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayHTTPListener struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayHTTPListenerPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayhttplistenerpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayhttplistenerpropertiesformat.go new file mode 100644 index 00000000000..7d3436f6186 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayhttplistenerpropertiesformat.go @@ -0,0 +1,18 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayHTTPListenerPropertiesFormat struct { + CustomErrorConfigurations *[]ApplicationGatewayCustomError `json:"customErrorConfigurations,omitempty"` + FirewallPolicy *SubResource `json:"firewallPolicy,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *SubResource `json:"frontendPort,omitempty"` + HostName *string `json:"hostName,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + Protocol *ApplicationGatewayProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequireServerNameIndication *bool `json:"requireServerNameIndication,omitempty"` + SslCertificate *SubResource `json:"sslCertificate,omitempty"` + SslProfile *SubResource `json:"sslProfile,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..7b513c56359 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..67b2b22486e --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaylistener.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaylistener.go new file mode 100644 index 00000000000..eb251dad173 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaylistener.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayListener struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayListenerPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaylistenerpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaylistenerpropertiesformat.go new file mode 100644 index 00000000000..96c7728780d --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaylistenerpropertiesformat.go @@ -0,0 +1,14 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayListenerPropertiesFormat struct { + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *SubResource `json:"frontendPort,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + Protocol *ApplicationGatewayProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SslCertificate *SubResource `json:"sslCertificate,omitempty"` + SslProfile *SubResource `json:"sslProfile,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayloaddistributionpolicy.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayloaddistributionpolicy.go new file mode 100644 index 00000000000..9c07ad54259 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayloaddistributionpolicy.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayLoadDistributionPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayLoadDistributionPolicyPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayloaddistributionpolicypropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayloaddistributionpolicypropertiesformat.go new file mode 100644 index 00000000000..9ae762454d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayloaddistributionpolicypropertiesformat.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayLoadDistributionPolicyPropertiesFormat struct { + LoadDistributionAlgorithm *ApplicationGatewayLoadDistributionAlgorithm `json:"loadDistributionAlgorithm,omitempty"` + LoadDistributionTargets *[]ApplicationGatewayLoadDistributionTarget `json:"loadDistributionTargets,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayloaddistributiontarget.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayloaddistributiontarget.go new file mode 100644 index 00000000000..5db29bd27a5 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayloaddistributiontarget.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayLoadDistributionTarget struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayLoadDistributionTargetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayloaddistributiontargetpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayloaddistributiontargetpropertiesformat.go new file mode 100644 index 00000000000..cd785c4126e --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayloaddistributiontargetpropertiesformat.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayLoadDistributionTargetPropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + WeightPerServer *int64 `json:"weightPerServer,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayondemandprobe.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayondemandprobe.go new file mode 100644 index 00000000000..6ee19e174e2 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayondemandprobe.go @@ -0,0 +1,15 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayOnDemandProbe struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendHTTPSettings *SubResource `json:"backendHttpSettings,omitempty"` + Host *string `json:"host,omitempty"` + Match *ApplicationGatewayProbeHealthResponseMatch `json:"match,omitempty"` + Path *string `json:"path,omitempty"` + PickHostNameFromBackendHTTPSettings *bool `json:"pickHostNameFromBackendHttpSettings,omitempty"` + Protocol *ApplicationGatewayProtocol `json:"protocol,omitempty"` + Timeout *int64 `json:"timeout,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaypathrule.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaypathrule.go new file mode 100644 index 00000000000..ae684eb5860 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaypathrule.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPathRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayPathRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaypathrulepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaypathrulepropertiesformat.go new file mode 100644 index 00000000000..c0586444c85 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaypathrulepropertiesformat.go @@ -0,0 +1,15 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPathRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendHTTPSettings *SubResource `json:"backendHttpSettings,omitempty"` + FirewallPolicy *SubResource `json:"firewallPolicy,omitempty"` + LoadDistributionPolicy *SubResource `json:"loadDistributionPolicy,omitempty"` + Paths *[]string `json:"paths,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RedirectConfiguration *SubResource `json:"redirectConfiguration,omitempty"` + RewriteRuleSet *SubResource `json:"rewriteRuleSet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivateendpointconnection.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivateendpointconnection.go new file mode 100644 index 00000000000..8099219aff4 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivateendpointconnection.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayPrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivateendpointconnectionproperties.go new file mode 100644 index 00000000000..400c841d704 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivatelinkconfiguration.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivatelinkconfiguration.go new file mode 100644 index 00000000000..1997234fb4d --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivatelinkconfiguration.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateLinkConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayPrivateLinkConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivatelinkconfigurationproperties.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivatelinkconfigurationproperties.go new file mode 100644 index 00000000000..b86b3f17014 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivatelinkconfigurationproperties.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateLinkConfigurationProperties struct { + IPConfigurations *[]ApplicationGatewayPrivateLinkIPConfiguration `json:"ipConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivatelinkipconfiguration.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivatelinkipconfiguration.go new file mode 100644 index 00000000000..ad8bfa28be7 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivatelinkipconfiguration.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateLinkIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayPrivateLinkIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivatelinkipconfigurationproperties.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivatelinkipconfigurationproperties.go new file mode 100644 index 00000000000..b2d2b2af23a --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprivatelinkipconfigurationproperties.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateLinkIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprobe.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprobe.go new file mode 100644 index 00000000000..9b27b4f7133 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprobe.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayProbe struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayProbePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprobehealthresponsematch.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprobehealthresponsematch.go new file mode 100644 index 00000000000..68ccf1eaaaf --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprobehealthresponsematch.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayProbeHealthResponseMatch struct { + Body *string `json:"body,omitempty"` + StatusCodes *[]string `json:"statusCodes,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprobepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprobepropertiesformat.go new file mode 100644 index 00000000000..dab5ee7ae23 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayprobepropertiesformat.go @@ -0,0 +1,19 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayProbePropertiesFormat struct { + Host *string `json:"host,omitempty"` + Interval *int64 `json:"interval,omitempty"` + Match *ApplicationGatewayProbeHealthResponseMatch `json:"match,omitempty"` + MinServers *int64 `json:"minServers,omitempty"` + Path *string `json:"path,omitempty"` + PickHostNameFromBackendHTTPSettings *bool `json:"pickHostNameFromBackendHttpSettings,omitempty"` + PickHostNameFromBackendSettings *bool `json:"pickHostNameFromBackendSettings,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *ApplicationGatewayProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Timeout *int64 `json:"timeout,omitempty"` + UnhealthyThreshold *int64 `json:"unhealthyThreshold,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaypropertiesformat.go new file mode 100644 index 00000000000..4e54c939bcb --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaypropertiesformat.go @@ -0,0 +1,43 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPropertiesFormat struct { + AuthenticationCertificates *[]ApplicationGatewayAuthenticationCertificate `json:"authenticationCertificates,omitempty"` + AutoscaleConfiguration *ApplicationGatewayAutoscaleConfiguration `json:"autoscaleConfiguration,omitempty"` + BackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"backendAddressPools,omitempty"` + BackendHTTPSettingsCollection *[]ApplicationGatewayBackendHTTPSettings `json:"backendHttpSettingsCollection,omitempty"` + BackendSettingsCollection *[]ApplicationGatewayBackendSettings `json:"backendSettingsCollection,omitempty"` + CustomErrorConfigurations *[]ApplicationGatewayCustomError `json:"customErrorConfigurations,omitempty"` + DefaultPredefinedSslPolicy *ApplicationGatewaySslPolicyName `json:"defaultPredefinedSslPolicy,omitempty"` + EnableFips *bool `json:"enableFips,omitempty"` + EnableHTTP2 *bool `json:"enableHttp2,omitempty"` + FirewallPolicy *SubResource `json:"firewallPolicy,omitempty"` + ForceFirewallPolicyAssociation *bool `json:"forceFirewallPolicyAssociation,omitempty"` + FrontendIPConfigurations *[]ApplicationGatewayFrontendIPConfiguration `json:"frontendIPConfigurations,omitempty"` + FrontendPorts *[]ApplicationGatewayFrontendPort `json:"frontendPorts,omitempty"` + GatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"gatewayIPConfigurations,omitempty"` + GlobalConfiguration *ApplicationGatewayGlobalConfiguration `json:"globalConfiguration,omitempty"` + HTTPListeners *[]ApplicationGatewayHTTPListener `json:"httpListeners,omitempty"` + Listeners *[]ApplicationGatewayListener `json:"listeners,omitempty"` + LoadDistributionPolicies *[]ApplicationGatewayLoadDistributionPolicy `json:"loadDistributionPolicies,omitempty"` + OperationalState *ApplicationGatewayOperationalState `json:"operationalState,omitempty"` + PrivateEndpointConnections *[]ApplicationGatewayPrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + PrivateLinkConfigurations *[]ApplicationGatewayPrivateLinkConfiguration `json:"privateLinkConfigurations,omitempty"` + Probes *[]ApplicationGatewayProbe `json:"probes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RedirectConfigurations *[]ApplicationGatewayRedirectConfiguration `json:"redirectConfigurations,omitempty"` + RequestRoutingRules *[]ApplicationGatewayRequestRoutingRule `json:"requestRoutingRules,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + RewriteRuleSets *[]ApplicationGatewayRewriteRuleSet `json:"rewriteRuleSets,omitempty"` + RoutingRules *[]ApplicationGatewayRoutingRule `json:"routingRules,omitempty"` + Sku *ApplicationGatewaySku `json:"sku,omitempty"` + SslCertificates *[]ApplicationGatewaySslCertificate `json:"sslCertificates,omitempty"` + SslPolicy *ApplicationGatewaySslPolicy `json:"sslPolicy,omitempty"` + SslProfiles *[]ApplicationGatewaySslProfile `json:"sslProfiles,omitempty"` + TrustedClientCertificates *[]ApplicationGatewayTrustedClientCertificate `json:"trustedClientCertificates,omitempty"` + TrustedRootCertificates *[]ApplicationGatewayTrustedRootCertificate `json:"trustedRootCertificates,omitempty"` + UrlPathMaps *[]ApplicationGatewayURLPathMap `json:"urlPathMaps,omitempty"` + WebApplicationFirewallConfiguration *ApplicationGatewayWebApplicationFirewallConfiguration `json:"webApplicationFirewallConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayredirectconfiguration.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayredirectconfiguration.go new file mode 100644 index 00000000000..99a2df5f0de --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayredirectconfiguration.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRedirectConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayRedirectConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayredirectconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayredirectconfigurationpropertiesformat.go new file mode 100644 index 00000000000..b629d49b411 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayredirectconfigurationpropertiesformat.go @@ -0,0 +1,15 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRedirectConfigurationPropertiesFormat struct { + IncludePath *bool `json:"includePath,omitempty"` + IncludeQueryString *bool `json:"includeQueryString,omitempty"` + PathRules *[]SubResource `json:"pathRules,omitempty"` + RedirectType *ApplicationGatewayRedirectType `json:"redirectType,omitempty"` + RequestRoutingRules *[]SubResource `json:"requestRoutingRules,omitempty"` + TargetListener *SubResource `json:"targetListener,omitempty"` + TargetURL *string `json:"targetUrl,omitempty"` + UrlPathMaps *[]SubResource `json:"urlPathMaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrequestroutingrule.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrequestroutingrule.go new file mode 100644 index 00000000000..8968674820d --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrequestroutingrule.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRequestRoutingRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayRequestRoutingRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrequestroutingrulepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrequestroutingrulepropertiesformat.go new file mode 100644 index 00000000000..d7ab0f3f4d9 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrequestroutingrulepropertiesformat.go @@ -0,0 +1,17 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRequestRoutingRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendHTTPSettings *SubResource `json:"backendHttpSettings,omitempty"` + HTTPListener *SubResource `json:"httpListener,omitempty"` + LoadDistributionPolicy *SubResource `json:"loadDistributionPolicy,omitempty"` + Priority *int64 `json:"priority,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RedirectConfiguration *SubResource `json:"redirectConfiguration,omitempty"` + RewriteRuleSet *SubResource `json:"rewriteRuleSet,omitempty"` + RuleType *ApplicationGatewayRequestRoutingRuleType `json:"ruleType,omitempty"` + UrlPathMap *SubResource `json:"urlPathMap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrewriterule.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrewriterule.go new file mode 100644 index 00000000000..6ce3b9a1f5d --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrewriterule.go @@ -0,0 +1,11 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRewriteRule struct { + ActionSet *ApplicationGatewayRewriteRuleActionSet `json:"actionSet,omitempty"` + Conditions *[]ApplicationGatewayRewriteRuleCondition `json:"conditions,omitempty"` + Name *string `json:"name,omitempty"` + RuleSequence *int64 `json:"ruleSequence,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrewriteruleactionset.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrewriteruleactionset.go new file mode 100644 index 00000000000..c46a7bd6d6c --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrewriteruleactionset.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRewriteRuleActionSet struct { + RequestHeaderConfigurations *[]ApplicationGatewayHeaderConfiguration `json:"requestHeaderConfigurations,omitempty"` + ResponseHeaderConfigurations *[]ApplicationGatewayHeaderConfiguration `json:"responseHeaderConfigurations,omitempty"` + UrlConfiguration *ApplicationGatewayURLConfiguration `json:"urlConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrewriterulecondition.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrewriterulecondition.go new file mode 100644 index 00000000000..c7e6af3b85a --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrewriterulecondition.go @@ -0,0 +1,11 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRewriteRuleCondition struct { + IgnoreCase *bool `json:"ignoreCase,omitempty"` + Negate *bool `json:"negate,omitempty"` + Pattern *string `json:"pattern,omitempty"` + Variable *string `json:"variable,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrewriteruleset.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrewriteruleset.go new file mode 100644 index 00000000000..571e9038508 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrewriteruleset.go @@ -0,0 +1,11 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRewriteRuleSet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayRewriteRuleSetPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrewriterulesetpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrewriterulesetpropertiesformat.go new file mode 100644 index 00000000000..031206c13ce --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayrewriterulesetpropertiesformat.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRewriteRuleSetPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RewriteRules *[]ApplicationGatewayRewriteRule `json:"rewriteRules,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayroutingrule.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayroutingrule.go new file mode 100644 index 00000000000..448709de6b4 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayroutingrule.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRoutingRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayRoutingRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayroutingrulepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayroutingrulepropertiesformat.go new file mode 100644 index 00000000000..5be00552534 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayroutingrulepropertiesformat.go @@ -0,0 +1,13 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRoutingRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendSettings *SubResource `json:"backendSettings,omitempty"` + Listener *SubResource `json:"listener,omitempty"` + Priority int64 `json:"priority"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RuleType *ApplicationGatewayRequestRoutingRuleType `json:"ruleType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysku.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysku.go new file mode 100644 index 00000000000..461f2f965a6 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysku.go @@ -0,0 +1,11 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewaySku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *ApplicationGatewaySkuFamily `json:"family,omitempty"` + Name *ApplicationGatewaySkuName `json:"name,omitempty"` + Tier *ApplicationGatewayTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslcertificate.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslcertificate.go new file mode 100644 index 00000000000..1f589867862 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslcertificate.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewaySslCertificate struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewaySslCertificatePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslcertificatepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslcertificatepropertiesformat.go new file mode 100644 index 00000000000..1c92efb93bd --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslcertificatepropertiesformat.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewaySslCertificatePropertiesFormat struct { + Data *string `json:"data,omitempty"` + KeyVaultSecretId *string `json:"keyVaultSecretId,omitempty"` + Password *string `json:"password,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicCertData *string `json:"publicCertData,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslpolicy.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslpolicy.go new file mode 100644 index 00000000000..be42ac49a18 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslpolicy.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewaySslPolicy struct { + CipherSuites *[]ApplicationGatewaySslCipherSuite `json:"cipherSuites,omitempty"` + DisabledSslProtocols *[]ApplicationGatewaySslProtocol `json:"disabledSslProtocols,omitempty"` + MinProtocolVersion *ApplicationGatewaySslProtocol `json:"minProtocolVersion,omitempty"` + PolicyName *ApplicationGatewaySslPolicyName `json:"policyName,omitempty"` + PolicyType *ApplicationGatewaySslPolicyType `json:"policyType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslpredefinedpolicy.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslpredefinedpolicy.go new file mode 100644 index 00000000000..a7932dc66db --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslpredefinedpolicy.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewaySslPredefinedPolicy struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewaySslPredefinedPolicyPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslpredefinedpolicypropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslpredefinedpolicypropertiesformat.go new file mode 100644 index 00000000000..15702750dea --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslpredefinedpolicypropertiesformat.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewaySslPredefinedPolicyPropertiesFormat struct { + CipherSuites *[]ApplicationGatewaySslCipherSuite `json:"cipherSuites,omitempty"` + MinProtocolVersion *ApplicationGatewaySslProtocol `json:"minProtocolVersion,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslprofile.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslprofile.go new file mode 100644 index 00000000000..609877668f8 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslprofile.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewaySslProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewaySslProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslprofilepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslprofilepropertiesformat.go new file mode 100644 index 00000000000..a7c5ae2c883 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaysslprofilepropertiesformat.go @@ -0,0 +1,11 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewaySslProfilePropertiesFormat struct { + ClientAuthConfiguration *ApplicationGatewayClientAuthConfiguration `json:"clientAuthConfiguration,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SslPolicy *ApplicationGatewaySslPolicy `json:"sslPolicy,omitempty"` + TrustedClientCertificates *[]SubResource `json:"trustedClientCertificates,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaytrustedclientcertificate.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaytrustedclientcertificate.go new file mode 100644 index 00000000000..731b46860d7 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaytrustedclientcertificate.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayTrustedClientCertificate struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayTrustedClientCertificatePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaytrustedclientcertificatepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaytrustedclientcertificatepropertiesformat.go new file mode 100644 index 00000000000..67b5d91461d --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaytrustedclientcertificatepropertiesformat.go @@ -0,0 +1,11 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayTrustedClientCertificatePropertiesFormat struct { + ClientCertIssuerDN *string `json:"clientCertIssuerDN,omitempty"` + Data *string `json:"data,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ValidatedCertData *string `json:"validatedCertData,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaytrustedrootcertificate.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaytrustedrootcertificate.go new file mode 100644 index 00000000000..12343718b35 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaytrustedrootcertificate.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayTrustedRootCertificate struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayTrustedRootCertificatePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaytrustedrootcertificatepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaytrustedrootcertificatepropertiesformat.go new file mode 100644 index 00000000000..7aeb8e0a84e --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaytrustedrootcertificatepropertiesformat.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayTrustedRootCertificatePropertiesFormat struct { + Data *string `json:"data,omitempty"` + KeyVaultSecretId *string `json:"keyVaultSecretId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayurlconfiguration.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayurlconfiguration.go new file mode 100644 index 00000000000..9c77d1808a2 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayurlconfiguration.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayURLConfiguration struct { + ModifiedPath *string `json:"modifiedPath,omitempty"` + ModifiedQueryString *string `json:"modifiedQueryString,omitempty"` + Reroute *bool `json:"reroute,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayurlpathmap.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayurlpathmap.go new file mode 100644 index 00000000000..9ca546cb957 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayurlpathmap.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayURLPathMap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayURLPathMapPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayurlpathmappropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayurlpathmappropertiesformat.go new file mode 100644 index 00000000000..9c00ae43cdf --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewayurlpathmappropertiesformat.go @@ -0,0 +1,14 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayURLPathMapPropertiesFormat struct { + DefaultBackendAddressPool *SubResource `json:"defaultBackendAddressPool,omitempty"` + DefaultBackendHTTPSettings *SubResource `json:"defaultBackendHttpSettings,omitempty"` + DefaultLoadDistributionPolicy *SubResource `json:"defaultLoadDistributionPolicy,omitempty"` + DefaultRedirectConfiguration *SubResource `json:"defaultRedirectConfiguration,omitempty"` + DefaultRewriteRuleSet *SubResource `json:"defaultRewriteRuleSet,omitempty"` + PathRules *[]ApplicationGatewayPathRule `json:"pathRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaywebapplicationfirewallconfiguration.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaywebapplicationfirewallconfiguration.go new file mode 100644 index 00000000000..561512df449 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationgatewaywebapplicationfirewallconfiguration.go @@ -0,0 +1,17 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayWebApplicationFirewallConfiguration struct { + DisabledRuleGroups *[]ApplicationGatewayFirewallDisabledRuleGroup `json:"disabledRuleGroups,omitempty"` + Enabled bool `json:"enabled"` + Exclusions *[]ApplicationGatewayFirewallExclusion `json:"exclusions,omitempty"` + FileUploadLimitInMb *int64 `json:"fileUploadLimitInMb,omitempty"` + FirewallMode ApplicationGatewayFirewallMode `json:"firewallMode"` + MaxRequestBodySize *int64 `json:"maxRequestBodySize,omitempty"` + MaxRequestBodySizeInKb *int64 `json:"maxRequestBodySizeInKb,omitempty"` + RequestBodyCheck *bool `json:"requestBodyCheck,omitempty"` + RuleSetType string `json:"ruleSetType"` + RuleSetVersion string `json:"ruleSetVersion"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..71e4f60a5a0 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..c8593cff776 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_backendaddresspool.go b/resource-manager/network/2024-07-01/applicationgateways/model_backendaddresspool.go new file mode 100644 index 00000000000..1a7d2037c67 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..74aca7bc73d --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..821207ea54b --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_ddossettings.go b/resource-manager/network/2024-07-01/applicationgateways/model_ddossettings.go new file mode 100644 index 00000000000..afe28edd8fc --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_ddossettings.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_delegation.go b/resource-manager/network/2024-07-01/applicationgateways/model_delegation.go new file mode 100644 index 00000000000..dde48e048ee --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_delegation.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_flowlog.go b/resource-manager/network/2024-07-01/applicationgateways/model_flowlog.go new file mode 100644 index 00000000000..af3968a2f68 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_flowlog.go @@ -0,0 +1,19 @@ +package applicationgateways + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/applicationgateways/model_flowlogformatparameters.go new file mode 100644 index 00000000000..79d541b9318 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..a180a38c6fb --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/applicationgateways/model_frontendipconfiguration.go new file mode 100644 index 00000000000..6af1ef34991 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package applicationgateways + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..dfcbf3e5aca --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/applicationgateways/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..81f73592309 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_headervaluematcher.go b/resource-manager/network/2024-07-01/applicationgateways/model_headervaluematcher.go new file mode 100644 index 00000000000..5c2f77f54e2 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_headervaluematcher.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HeaderValueMatcher struct { + IgnoreCase *bool `json:"ignoreCase,omitempty"` + Negate *bool `json:"negate,omitempty"` + Pattern *string `json:"pattern,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_inboundnatrule.go b/resource-manager/network/2024-07-01/applicationgateways/model_inboundnatrule.go new file mode 100644 index 00000000000..e8326d63cdd --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..e68b37342b3 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/applicationgateways/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..9419ecd70ea --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/applicationgateways/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..98c76b46142 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_ipconfiguration.go b/resource-manager/network/2024-07-01/applicationgateways/model_ipconfiguration.go new file mode 100644 index 00000000000..3035f84c596 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/applicationgateways/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..edb884d2718 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..1c6df0dcda2 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..5de8de82f9e --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_iptag.go b/resource-manager/network/2024-07-01/applicationgateways/model_iptag.go new file mode 100644 index 00000000000..e423a8c0593 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_iptag.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/applicationgateways/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..a4bb848daa5 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..ab1822cd6b6 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_natgateway.go b/resource-manager/network/2024-07-01/applicationgateways/model_natgateway.go new file mode 100644 index 00000000000..eb51b102cad --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_natgateway.go @@ -0,0 +1,20 @@ +package applicationgateways + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..c84930f5fb1 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_natgatewaysku.go b/resource-manager/network/2024-07-01/applicationgateways/model_natgatewaysku.go new file mode 100644 index 00000000000..54ee08d2498 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_natruleportmapping.go b/resource-manager/network/2024-07-01/applicationgateways/model_natruleportmapping.go new file mode 100644 index 00000000000..1ca2ef21443 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_networkinterface.go b/resource-manager/network/2024-07-01/applicationgateways/model_networkinterface.go new file mode 100644 index 00000000000..73b1cb41a52 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_networkinterface.go @@ -0,0 +1,19 @@ +package applicationgateways + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..92961ce7d04 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..1be55bfe469 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..fed49bbe9de --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..452ec816a20 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..4f745902d21 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..8dc17186426 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..199c278ace0 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/applicationgateways/model_networksecuritygroup.go new file mode 100644 index 00000000000..14268c44ed0 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..e16fb5f6fb3 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_privateendpoint.go b/resource-manager/network/2024-07-01/applicationgateways/model_privateendpoint.go new file mode 100644 index 00000000000..4ec26559664 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_privateendpoint.go @@ -0,0 +1,19 @@ +package applicationgateways + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/applicationgateways/model_privateendpointconnection.go new file mode 100644 index 00000000000..72911c666f8 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/applicationgateways/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..baec08812d8 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/applicationgateways/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..7cae9c3cf71 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/applicationgateways/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..f1f5adead63 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/applicationgateways/model_privateendpointproperties.go new file mode 100644 index 00000000000..832b7f18a5d --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkservice.go b/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkservice.go new file mode 100644 index 00000000000..238c6ee31c6 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package applicationgateways + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..ee88d81eb06 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..26b1b21ad32 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..2d2970905b0 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..18d6fcdf24d --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..02fc04bab97 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..545a2473e0f --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_publicipaddress.go b/resource-manager/network/2024-07-01/applicationgateways/model_publicipaddress.go new file mode 100644 index 00000000000..c17efae3e57 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_publicipaddress.go @@ -0,0 +1,22 @@ +package applicationgateways + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/applicationgateways/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..4aeba6f0581 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..d714bdf3daa --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/applicationgateways/model_publicipaddresssku.go new file mode 100644 index 00000000000..976ba6d175a --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/applicationgateways/model_resourcenavigationlink.go new file mode 100644 index 00000000000..0aeedfe5241 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..540e9b96c41 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_resourceset.go b/resource-manager/network/2024-07-01/applicationgateways/model_resourceset.go new file mode 100644 index 00000000000..05c6f87a097 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_resourceset.go @@ -0,0 +1,8 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/applicationgateways/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..aed6889cbab --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_route.go b/resource-manager/network/2024-07-01/applicationgateways/model_route.go new file mode 100644 index 00000000000..8b16e63b0d4 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_route.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_routepropertiesformat.go new file mode 100644 index 00000000000..e5c5f698874 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_routetable.go b/resource-manager/network/2024-07-01/applicationgateways/model_routetable.go new file mode 100644 index 00000000000..6b3d63e8b6c --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_routetable.go @@ -0,0 +1,14 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..af2c694b5db --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_securityrule.go b/resource-manager/network/2024-07-01/applicationgateways/model_securityrule.go new file mode 100644 index 00000000000..ef187da7432 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_securityrule.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..c96607c5d20 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/applicationgateways/model_serviceassociationlink.go new file mode 100644 index 00000000000..fcd770e8b43 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..74146988caf --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..508b02893d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/applicationgateways/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..3c9d04af717 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/applicationgateways/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..3c52f56e9ea --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..0ccd3a839f3 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..edd49bd36a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..651b33530e8 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_subnet.go b/resource-manager/network/2024-07-01/applicationgateways/model_subnet.go new file mode 100644 index 00000000000..9bad3a3150c --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_subnet.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..44be8579151 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_subresource.go b/resource-manager/network/2024-07-01/applicationgateways/model_subresource.go new file mode 100644 index 00000000000..5e7297f22b2 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_subresource.go @@ -0,0 +1,8 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_tagsobject.go b/resource-manager/network/2024-07-01/applicationgateways/model_tagsobject.go new file mode 100644 index 00000000000..d5962ed5647 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_tagsobject.go @@ -0,0 +1,8 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/applicationgateways/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..65767115778 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/applicationgateways/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..b9b39e7b346 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/applicationgateways/model_virtualnetworktap.go new file mode 100644 index 00000000000..610065f3a8a --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/applicationgateways/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..a7db53f1629 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/predicates.go b/resource-manager/network/2024-07-01/applicationgateways/predicates.go new file mode 100644 index 00000000000..c51e6f7b000 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/predicates.go @@ -0,0 +1,55 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ApplicationGatewayOperationPredicate) Matches(input ApplicationGateway) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type ApplicationGatewaySslPredefinedPolicyOperationPredicate struct { + Id *string + Name *string +} + +func (p ApplicationGatewaySslPredefinedPolicyOperationPredicate) Matches(input ApplicationGatewaySslPredefinedPolicy) 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 + } + + return true +} diff --git a/resource-manager/network/2024-07-01/applicationgateways/version.go b/resource-manager/network/2024-07-01/applicationgateways/version.go new file mode 100644 index 00000000000..d6afa7550c2 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgateways/version.go @@ -0,0 +1,10 @@ +package applicationgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/applicationgateways/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/README.md b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/README.md new file mode 100644 index 00000000000..fd6d3637564 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests` Documentation + +The `applicationgatewaywafdynamicmanifests` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests" +``` + + +### Client Initialization + +```go +client := applicationgatewaywafdynamicmanifests.NewApplicationGatewayWafDynamicManifestsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ApplicationGatewayWafDynamicManifestsClient.DefaultGet` + +```go +ctx := context.TODO() +id := applicationgatewaywafdynamicmanifests.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +read, err := client.DefaultGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationGatewayWafDynamicManifestsClient.Get` + +```go +ctx := context.TODO() +id := applicationgatewaywafdynamicmanifests.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.Get(ctx, id)` can be used to do batched pagination +items, err := client.GetComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/client.go b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/client.go new file mode 100644 index 00000000000..c8cf9d79e64 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/client.go @@ -0,0 +1,26 @@ +package applicationgatewaywafdynamicmanifests + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayWafDynamicManifestsClient struct { + Client *resourcemanager.Client +} + +func NewApplicationGatewayWafDynamicManifestsClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationGatewayWafDynamicManifestsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "applicationgatewaywafdynamicmanifests", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApplicationGatewayWafDynamicManifestsClient: %+v", err) + } + + return &ApplicationGatewayWafDynamicManifestsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/constants.go b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/constants.go new file mode 100644 index 00000000000..40d85530d24 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/constants.go @@ -0,0 +1,242 @@ +package applicationgatewaywafdynamicmanifests + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRuleSetStatusOptions string + +const ( + ApplicationGatewayRuleSetStatusOptionsDeprecated ApplicationGatewayRuleSetStatusOptions = "Deprecated" + ApplicationGatewayRuleSetStatusOptionsGA ApplicationGatewayRuleSetStatusOptions = "GA" + ApplicationGatewayRuleSetStatusOptionsPreview ApplicationGatewayRuleSetStatusOptions = "Preview" + ApplicationGatewayRuleSetStatusOptionsSupported ApplicationGatewayRuleSetStatusOptions = "Supported" +) + +func PossibleValuesForApplicationGatewayRuleSetStatusOptions() []string { + return []string{ + string(ApplicationGatewayRuleSetStatusOptionsDeprecated), + string(ApplicationGatewayRuleSetStatusOptionsGA), + string(ApplicationGatewayRuleSetStatusOptionsPreview), + string(ApplicationGatewayRuleSetStatusOptionsSupported), + } +} + +func (s *ApplicationGatewayRuleSetStatusOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayRuleSetStatusOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayRuleSetStatusOptions(input string) (*ApplicationGatewayRuleSetStatusOptions, error) { + vals := map[string]ApplicationGatewayRuleSetStatusOptions{ + "deprecated": ApplicationGatewayRuleSetStatusOptionsDeprecated, + "ga": ApplicationGatewayRuleSetStatusOptionsGA, + "preview": ApplicationGatewayRuleSetStatusOptionsPreview, + "supported": ApplicationGatewayRuleSetStatusOptionsSupported, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayRuleSetStatusOptions(input) + return &out, nil +} + +type ApplicationGatewayTierTypes string + +const ( + ApplicationGatewayTierTypesStandard ApplicationGatewayTierTypes = "Standard" + ApplicationGatewayTierTypesStandardVTwo ApplicationGatewayTierTypes = "Standard_v2" + ApplicationGatewayTierTypesWAF ApplicationGatewayTierTypes = "WAF" + ApplicationGatewayTierTypesWAFVTwo ApplicationGatewayTierTypes = "WAF_v2" +) + +func PossibleValuesForApplicationGatewayTierTypes() []string { + return []string{ + string(ApplicationGatewayTierTypesStandard), + string(ApplicationGatewayTierTypesStandardVTwo), + string(ApplicationGatewayTierTypesWAF), + string(ApplicationGatewayTierTypesWAFVTwo), + } +} + +func (s *ApplicationGatewayTierTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayTierTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayTierTypes(input string) (*ApplicationGatewayTierTypes, error) { + vals := map[string]ApplicationGatewayTierTypes{ + "standard": ApplicationGatewayTierTypesStandard, + "standard_v2": ApplicationGatewayTierTypesStandardVTwo, + "waf": ApplicationGatewayTierTypesWAF, + "waf_v2": ApplicationGatewayTierTypesWAFVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayTierTypes(input) + return &out, nil +} + +type ApplicationGatewayWafRuleActionTypes string + +const ( + ApplicationGatewayWafRuleActionTypesAllow ApplicationGatewayWafRuleActionTypes = "Allow" + ApplicationGatewayWafRuleActionTypesAnomalyScoring ApplicationGatewayWafRuleActionTypes = "AnomalyScoring" + ApplicationGatewayWafRuleActionTypesBlock ApplicationGatewayWafRuleActionTypes = "Block" + ApplicationGatewayWafRuleActionTypesLog ApplicationGatewayWafRuleActionTypes = "Log" + ApplicationGatewayWafRuleActionTypesNone ApplicationGatewayWafRuleActionTypes = "None" +) + +func PossibleValuesForApplicationGatewayWafRuleActionTypes() []string { + return []string{ + string(ApplicationGatewayWafRuleActionTypesAllow), + string(ApplicationGatewayWafRuleActionTypesAnomalyScoring), + string(ApplicationGatewayWafRuleActionTypesBlock), + string(ApplicationGatewayWafRuleActionTypesLog), + string(ApplicationGatewayWafRuleActionTypesNone), + } +} + +func (s *ApplicationGatewayWafRuleActionTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayWafRuleActionTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayWafRuleActionTypes(input string) (*ApplicationGatewayWafRuleActionTypes, error) { + vals := map[string]ApplicationGatewayWafRuleActionTypes{ + "allow": ApplicationGatewayWafRuleActionTypesAllow, + "anomalyscoring": ApplicationGatewayWafRuleActionTypesAnomalyScoring, + "block": ApplicationGatewayWafRuleActionTypesBlock, + "log": ApplicationGatewayWafRuleActionTypesLog, + "none": ApplicationGatewayWafRuleActionTypesNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayWafRuleActionTypes(input) + return &out, nil +} + +type ApplicationGatewayWafRuleSensitivityTypes string + +const ( + ApplicationGatewayWafRuleSensitivityTypesHigh ApplicationGatewayWafRuleSensitivityTypes = "High" + ApplicationGatewayWafRuleSensitivityTypesLow ApplicationGatewayWafRuleSensitivityTypes = "Low" + ApplicationGatewayWafRuleSensitivityTypesMedium ApplicationGatewayWafRuleSensitivityTypes = "Medium" + ApplicationGatewayWafRuleSensitivityTypesNone ApplicationGatewayWafRuleSensitivityTypes = "None" +) + +func PossibleValuesForApplicationGatewayWafRuleSensitivityTypes() []string { + return []string{ + string(ApplicationGatewayWafRuleSensitivityTypesHigh), + string(ApplicationGatewayWafRuleSensitivityTypesLow), + string(ApplicationGatewayWafRuleSensitivityTypesMedium), + string(ApplicationGatewayWafRuleSensitivityTypesNone), + } +} + +func (s *ApplicationGatewayWafRuleSensitivityTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayWafRuleSensitivityTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayWafRuleSensitivityTypes(input string) (*ApplicationGatewayWafRuleSensitivityTypes, error) { + vals := map[string]ApplicationGatewayWafRuleSensitivityTypes{ + "high": ApplicationGatewayWafRuleSensitivityTypesHigh, + "low": ApplicationGatewayWafRuleSensitivityTypesLow, + "medium": ApplicationGatewayWafRuleSensitivityTypesMedium, + "none": ApplicationGatewayWafRuleSensitivityTypesNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayWafRuleSensitivityTypes(input) + return &out, nil +} + +type ApplicationGatewayWafRuleStateTypes string + +const ( + ApplicationGatewayWafRuleStateTypesDisabled ApplicationGatewayWafRuleStateTypes = "Disabled" + ApplicationGatewayWafRuleStateTypesEnabled ApplicationGatewayWafRuleStateTypes = "Enabled" +) + +func PossibleValuesForApplicationGatewayWafRuleStateTypes() []string { + return []string{ + string(ApplicationGatewayWafRuleStateTypesDisabled), + string(ApplicationGatewayWafRuleStateTypesEnabled), + } +} + +func (s *ApplicationGatewayWafRuleStateTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayWafRuleStateTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayWafRuleStateTypes(input string) (*ApplicationGatewayWafRuleStateTypes, error) { + vals := map[string]ApplicationGatewayWafRuleStateTypes{ + "disabled": ApplicationGatewayWafRuleStateTypesDisabled, + "enabled": ApplicationGatewayWafRuleStateTypesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayWafRuleStateTypes(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/id_location.go b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/id_location.go new file mode 100644 index 00000000000..3d179e08bf0 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/id_location.go @@ -0,0 +1,121 @@ +package applicationgatewaywafdynamicmanifests + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Network/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/id_location_test.go b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/id_location_test.go new file mode 100644 index 00000000000..3989d8a5132 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/id_location_test.go @@ -0,0 +1,237 @@ +package applicationgatewaywafdynamicmanifests + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/method_defaultget.go b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/method_defaultget.go new file mode 100644 index 00000000000..41ec3674d2f --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/method_defaultget.go @@ -0,0 +1,54 @@ +package applicationgatewaywafdynamicmanifests + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DefaultGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationGatewayWafDynamicManifestResult +} + +// DefaultGet ... +func (c ApplicationGatewayWafDynamicManifestsClient) DefaultGet(ctx context.Context, id LocationId) (result DefaultGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/applicationGatewayWafDynamicManifests/dafault", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApplicationGatewayWafDynamicManifestResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/method_get.go b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/method_get.go new file mode 100644 index 00000000000..4f7a0478f78 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/method_get.go @@ -0,0 +1,105 @@ +package applicationgatewaywafdynamicmanifests + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationGatewayWafDynamicManifestResult +} + +type GetCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationGatewayWafDynamicManifestResult +} + +type GetCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// Get ... +func (c ApplicationGatewayWafDynamicManifestsClient) Get(ctx context.Context, id LocationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetCustomPager{}, + Path: fmt.Sprintf("%s/applicationGatewayWafDynamicManifests", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApplicationGatewayWafDynamicManifestResult `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetComplete retrieves all the results into a single object +func (c ApplicationGatewayWafDynamicManifestsClient) GetComplete(ctx context.Context, id LocationId) (GetCompleteResult, error) { + return c.GetCompleteMatchingPredicate(ctx, id, ApplicationGatewayWafDynamicManifestResultOperationPredicate{}) +} + +// GetCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationGatewayWafDynamicManifestsClient) GetCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate ApplicationGatewayWafDynamicManifestResultOperationPredicate) (result GetCompleteResult, err error) { + items := make([]ApplicationGatewayWafDynamicManifestResult, 0) + + resp, err := c.Get(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_applicationgatewayfirewallmanifestruleset.go b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_applicationgatewayfirewallmanifestruleset.go new file mode 100644 index 00000000000..401a87a86a8 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_applicationgatewayfirewallmanifestruleset.go @@ -0,0 +1,12 @@ +package applicationgatewaywafdynamicmanifests + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFirewallManifestRuleSet struct { + RuleGroups []ApplicationGatewayFirewallRuleGroup `json:"ruleGroups"` + RuleSetType string `json:"ruleSetType"` + RuleSetVersion string `json:"ruleSetVersion"` + Status *ApplicationGatewayRuleSetStatusOptions `json:"status,omitempty"` + Tiers *[]ApplicationGatewayTierTypes `json:"tiers,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_applicationgatewayfirewallrule.go b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_applicationgatewayfirewallrule.go new file mode 100644 index 00000000000..30a847539f1 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_applicationgatewayfirewallrule.go @@ -0,0 +1,13 @@ +package applicationgatewaywafdynamicmanifests + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFirewallRule struct { + Action *ApplicationGatewayWafRuleActionTypes `json:"action,omitempty"` + Description *string `json:"description,omitempty"` + RuleId int64 `json:"ruleId"` + RuleIdString *string `json:"ruleIdString,omitempty"` + Sensitivity *ApplicationGatewayWafRuleSensitivityTypes `json:"sensitivity,omitempty"` + State *ApplicationGatewayWafRuleStateTypes `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_applicationgatewayfirewallrulegroup.go b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_applicationgatewayfirewallrulegroup.go new file mode 100644 index 00000000000..f9aefdfc147 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_applicationgatewayfirewallrulegroup.go @@ -0,0 +1,10 @@ +package applicationgatewaywafdynamicmanifests + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFirewallRuleGroup struct { + Description *string `json:"description,omitempty"` + RuleGroupName string `json:"ruleGroupName"` + Rules []ApplicationGatewayFirewallRule `json:"rules"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_applicationgatewaywafdynamicmanifestpropertiesresult.go b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_applicationgatewaywafdynamicmanifestpropertiesresult.go new file mode 100644 index 00000000000..d68d61add58 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_applicationgatewaywafdynamicmanifestpropertiesresult.go @@ -0,0 +1,9 @@ +package applicationgatewaywafdynamicmanifests + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayWafDynamicManifestPropertiesResult struct { + AvailableRuleSets *[]ApplicationGatewayFirewallManifestRuleSet `json:"availableRuleSets,omitempty"` + DefaultRuleSet *DefaultRuleSetPropertyFormat `json:"defaultRuleSet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_applicationgatewaywafdynamicmanifestresult.go b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_applicationgatewaywafdynamicmanifestresult.go new file mode 100644 index 00000000000..763ec4aad23 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_applicationgatewaywafdynamicmanifestresult.go @@ -0,0 +1,11 @@ +package applicationgatewaywafdynamicmanifests + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayWafDynamicManifestResult struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayWafDynamicManifestPropertiesResult `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_defaultrulesetpropertyformat.go b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_defaultrulesetpropertyformat.go new file mode 100644 index 00000000000..b69c307217f --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/model_defaultrulesetpropertyformat.go @@ -0,0 +1,9 @@ +package applicationgatewaywafdynamicmanifests + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DefaultRuleSetPropertyFormat struct { + RuleSetType *string `json:"ruleSetType,omitempty"` + RuleSetVersion *string `json:"ruleSetVersion,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/predicates.go b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/predicates.go new file mode 100644 index 00000000000..9714d21637e --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/predicates.go @@ -0,0 +1,27 @@ +package applicationgatewaywafdynamicmanifests + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayWafDynamicManifestResultOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ApplicationGatewayWafDynamicManifestResultOperationPredicate) Matches(input ApplicationGatewayWafDynamicManifestResult) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/version.go b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/version.go new file mode 100644 index 00000000000..c5a5c79ed5b --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests/version.go @@ -0,0 +1,10 @@ +package applicationgatewaywafdynamicmanifests + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/applicationgatewaywafdynamicmanifests/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/applicationsecuritygroups/README.md b/resource-manager/network/2024-07-01/applicationsecuritygroups/README.md new file mode 100644 index 00000000000..3225df4be86 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationsecuritygroups/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/applicationsecuritygroups` Documentation + +The `applicationsecuritygroups` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/applicationsecuritygroups" +``` + + +### Client Initialization + +```go +client := applicationsecuritygroups.NewApplicationSecurityGroupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ApplicationSecurityGroupsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := applicationsecuritygroups.NewApplicationSecurityGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationSecurityGroupName") + +payload := applicationsecuritygroups.ApplicationSecurityGroup{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ApplicationSecurityGroupsClient.Delete` + +```go +ctx := context.TODO() +id := applicationsecuritygroups.NewApplicationSecurityGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationSecurityGroupName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ApplicationSecurityGroupsClient.Get` + +```go +ctx := context.TODO() +id := applicationsecuritygroups.NewApplicationSecurityGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationSecurityGroupName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ApplicationSecurityGroupsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ApplicationSecurityGroupsClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ApplicationSecurityGroupsClient.UpdateTags` + +```go +ctx := context.TODO() +id := applicationsecuritygroups.NewApplicationSecurityGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationSecurityGroupName") + +payload := applicationsecuritygroups.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/applicationsecuritygroups/client.go b/resource-manager/network/2024-07-01/applicationsecuritygroups/client.go new file mode 100644 index 00000000000..81de33d92a0 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationsecuritygroups/client.go @@ -0,0 +1,26 @@ +package applicationsecuritygroups + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupsClient struct { + Client *resourcemanager.Client +} + +func NewApplicationSecurityGroupsClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationSecurityGroupsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "applicationsecuritygroups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ApplicationSecurityGroupsClient: %+v", err) + } + + return &ApplicationSecurityGroupsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/applicationsecuritygroups/constants.go b/resource-manager/network/2024-07-01/applicationsecuritygroups/constants.go new file mode 100644 index 00000000000..a226eb6274e --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationsecuritygroups/constants.go @@ -0,0 +1,57 @@ +package applicationsecuritygroups + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/applicationsecuritygroups/id_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/applicationsecuritygroups/id_applicationsecuritygroup.go new file mode 100644 index 00000000000..65cacde62c9 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationsecuritygroups/id_applicationsecuritygroup.go @@ -0,0 +1,130 @@ +package applicationsecuritygroups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ApplicationSecurityGroupId{}) +} + +var _ resourceids.ResourceId = &ApplicationSecurityGroupId{} + +// ApplicationSecurityGroupId is a struct representing the Resource ID for a Application Security Group +type ApplicationSecurityGroupId struct { + SubscriptionId string + ResourceGroupName string + ApplicationSecurityGroupName string +} + +// NewApplicationSecurityGroupID returns a new ApplicationSecurityGroupId struct +func NewApplicationSecurityGroupID(subscriptionId string, resourceGroupName string, applicationSecurityGroupName string) ApplicationSecurityGroupId { + return ApplicationSecurityGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ApplicationSecurityGroupName: applicationSecurityGroupName, + } +} + +// ParseApplicationSecurityGroupID parses 'input' into a ApplicationSecurityGroupId +func ParseApplicationSecurityGroupID(input string) (*ApplicationSecurityGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationSecurityGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationSecurityGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApplicationSecurityGroupIDInsensitively parses 'input' case-insensitively into a ApplicationSecurityGroupId +// note: this method should only be used for API response data and not user input +func ParseApplicationSecurityGroupIDInsensitively(input string) (*ApplicationSecurityGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationSecurityGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationSecurityGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApplicationSecurityGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ApplicationSecurityGroupName, ok = input.Parsed["applicationSecurityGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationSecurityGroupName", input) + } + + return nil +} + +// ValidateApplicationSecurityGroupID checks that 'input' can be parsed as a Application Security Group ID +func ValidateApplicationSecurityGroupID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseApplicationSecurityGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Application Security Group ID +func (id ApplicationSecurityGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/applicationSecurityGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ApplicationSecurityGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Application Security Group ID +func (id ApplicationSecurityGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticApplicationSecurityGroups", "applicationSecurityGroups", "applicationSecurityGroups"), + resourceids.UserSpecifiedSegment("applicationSecurityGroupName", "applicationSecurityGroupName"), + } +} + +// String returns a human-readable description of this Application Security Group ID +func (id ApplicationSecurityGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Application Security Group Name: %q", id.ApplicationSecurityGroupName), + } + return fmt.Sprintf("Application Security Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/applicationsecuritygroups/id_applicationsecuritygroup_test.go b/resource-manager/network/2024-07-01/applicationsecuritygroups/id_applicationsecuritygroup_test.go new file mode 100644 index 00000000000..01691330fab --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationsecuritygroups/id_applicationsecuritygroup_test.go @@ -0,0 +1,282 @@ +package applicationsecuritygroups + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ApplicationSecurityGroupId{} + +func TestNewApplicationSecurityGroupID(t *testing.T) { + id := NewApplicationSecurityGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationSecurityGroupName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ApplicationSecurityGroupName != "applicationSecurityGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationSecurityGroupName'", id.ApplicationSecurityGroupName, "applicationSecurityGroupName") + } +} + +func TestFormatApplicationSecurityGroupID(t *testing.T) { + actual := NewApplicationSecurityGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationSecurityGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationSecurityGroups/applicationSecurityGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApplicationSecurityGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationSecurityGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationSecurityGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationSecurityGroups/applicationSecurityGroupName", + Expected: &ApplicationSecurityGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationSecurityGroupName: "applicationSecurityGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationSecurityGroups/applicationSecurityGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationSecurityGroupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationSecurityGroupName != v.Expected.ApplicationSecurityGroupName { + t.Fatalf("Expected %q but got %q for ApplicationSecurityGroupName", v.Expected.ApplicationSecurityGroupName, actual.ApplicationSecurityGroupName) + } + + } +} + +func TestParseApplicationSecurityGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationSecurityGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationSecurityGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnSeCuRiTyGrOuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationSecurityGroups/applicationSecurityGroupName", + Expected: &ApplicationSecurityGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationSecurityGroupName: "applicationSecurityGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationSecurityGroups/applicationSecurityGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnSeCuRiTyGrOuPs/aPpLiCaTiOnSeCuRiTyGrOuPnAmE", + Expected: &ApplicationSecurityGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ApplicationSecurityGroupName: "aPpLiCaTiOnSeCuRiTyGrOuPnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnSeCuRiTyGrOuPs/aPpLiCaTiOnSeCuRiTyGrOuPnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationSecurityGroupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationSecurityGroupName != v.Expected.ApplicationSecurityGroupName { + t.Fatalf("Expected %q but got %q for ApplicationSecurityGroupName", v.Expected.ApplicationSecurityGroupName, actual.ApplicationSecurityGroupName) + } + + } +} + +func TestSegmentsForApplicationSecurityGroupId(t *testing.T) { + segments := ApplicationSecurityGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApplicationSecurityGroupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/applicationsecuritygroups/method_createorupdate.go b/resource-manager/network/2024-07-01/applicationsecuritygroups/method_createorupdate.go new file mode 100644 index 00000000000..f2b60b46a6a --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationsecuritygroups/method_createorupdate.go @@ -0,0 +1,75 @@ +package applicationsecuritygroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationSecurityGroup +} + +// CreateOrUpdate ... +func (c ApplicationSecurityGroupsClient) CreateOrUpdate(ctx context.Context, id ApplicationSecurityGroupId, input ApplicationSecurityGroup) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ApplicationSecurityGroupsClient) CreateOrUpdateThenPoll(ctx context.Context, id ApplicationSecurityGroupId, input ApplicationSecurityGroup) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/applicationsecuritygroups/method_delete.go b/resource-manager/network/2024-07-01/applicationsecuritygroups/method_delete.go new file mode 100644 index 00000000000..6d16cb628e3 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationsecuritygroups/method_delete.go @@ -0,0 +1,71 @@ +package applicationsecuritygroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ApplicationSecurityGroupsClient) Delete(ctx context.Context, id ApplicationSecurityGroupId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ApplicationSecurityGroupsClient) DeleteThenPoll(ctx context.Context, id ApplicationSecurityGroupId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/applicationsecuritygroups/method_get.go b/resource-manager/network/2024-07-01/applicationsecuritygroups/method_get.go new file mode 100644 index 00000000000..88fdcf2df15 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationsecuritygroups/method_get.go @@ -0,0 +1,53 @@ +package applicationsecuritygroups + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationSecurityGroup +} + +// Get ... +func (c ApplicationSecurityGroupsClient) Get(ctx context.Context, id ApplicationSecurityGroupId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApplicationSecurityGroup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/applicationsecuritygroups/method_list.go b/resource-manager/network/2024-07-01/applicationsecuritygroups/method_list.go new file mode 100644 index 00000000000..1e8cc5c05eb --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationsecuritygroups/method_list.go @@ -0,0 +1,106 @@ +package applicationsecuritygroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationSecurityGroup +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationSecurityGroup +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ApplicationSecurityGroupsClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/applicationSecurityGroups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApplicationSecurityGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ApplicationSecurityGroupsClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ApplicationSecurityGroupOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationSecurityGroupsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ApplicationSecurityGroupOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ApplicationSecurityGroup, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/applicationsecuritygroups/method_listall.go b/resource-manager/network/2024-07-01/applicationsecuritygroups/method_listall.go new file mode 100644 index 00000000000..b0f38c737fa --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationsecuritygroups/method_listall.go @@ -0,0 +1,106 @@ +package applicationsecuritygroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationSecurityGroup +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationSecurityGroup +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c ApplicationSecurityGroupsClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/applicationSecurityGroups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApplicationSecurityGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c ApplicationSecurityGroupsClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, ApplicationSecurityGroupOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ApplicationSecurityGroupsClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ApplicationSecurityGroupOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]ApplicationSecurityGroup, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/applicationsecuritygroups/method_updatetags.go b/resource-manager/network/2024-07-01/applicationsecuritygroups/method_updatetags.go new file mode 100644 index 00000000000..3337e0dc239 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationsecuritygroups/method_updatetags.go @@ -0,0 +1,57 @@ +package applicationsecuritygroups + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApplicationSecurityGroup +} + +// UpdateTags ... +func (c ApplicationSecurityGroupsClient) UpdateTags(ctx context.Context, id ApplicationSecurityGroupId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApplicationSecurityGroup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/applicationsecuritygroups/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/applicationsecuritygroups/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..56c89e2151e --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationsecuritygroups/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package applicationsecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationsecuritygroups/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/applicationsecuritygroups/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..c54772935da --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationsecuritygroups/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package applicationsecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationsecuritygroups/model_tagsobject.go b/resource-manager/network/2024-07-01/applicationsecuritygroups/model_tagsobject.go new file mode 100644 index 00000000000..b945e6c9cdf --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationsecuritygroups/model_tagsobject.go @@ -0,0 +1,8 @@ +package applicationsecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/applicationsecuritygroups/predicates.go b/resource-manager/network/2024-07-01/applicationsecuritygroups/predicates.go new file mode 100644 index 00000000000..6ea534ecd89 --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationsecuritygroups/predicates.go @@ -0,0 +1,37 @@ +package applicationsecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ApplicationSecurityGroupOperationPredicate) Matches(input ApplicationSecurityGroup) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/applicationsecuritygroups/version.go b/resource-manager/network/2024-07-01/applicationsecuritygroups/version.go new file mode 100644 index 00000000000..60cdef068cd --- /dev/null +++ b/resource-manager/network/2024-07-01/applicationsecuritygroups/version.go @@ -0,0 +1,10 @@ +package applicationsecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/applicationsecuritygroups/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/availabledelegations/README.md b/resource-manager/network/2024-07-01/availabledelegations/README.md new file mode 100644 index 00000000000..64d7349ab5b --- /dev/null +++ b/resource-manager/network/2024-07-01/availabledelegations/README.md @@ -0,0 +1,54 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/availabledelegations` Documentation + +The `availabledelegations` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/availabledelegations" +``` + + +### Client Initialization + +```go +client := availabledelegations.NewAvailableDelegationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AvailableDelegationsClient.AvailableDelegationsList` + +```go +ctx := context.TODO() +id := availabledelegations.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.AvailableDelegationsList(ctx, id)` can be used to do batched pagination +items, err := client.AvailableDelegationsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AvailableDelegationsClient.AvailableResourceGroupDelegationsList` + +```go +ctx := context.TODO() +id := availabledelegations.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationName") + +// alternatively `client.AvailableResourceGroupDelegationsList(ctx, id)` can be used to do batched pagination +items, err := client.AvailableResourceGroupDelegationsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/availabledelegations/client.go b/resource-manager/network/2024-07-01/availabledelegations/client.go new file mode 100644 index 00000000000..2b7153e2c60 --- /dev/null +++ b/resource-manager/network/2024-07-01/availabledelegations/client.go @@ -0,0 +1,26 @@ +package availabledelegations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableDelegationsClient struct { + Client *resourcemanager.Client +} + +func NewAvailableDelegationsClientWithBaseURI(sdkApi sdkEnv.Api) (*AvailableDelegationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "availabledelegations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AvailableDelegationsClient: %+v", err) + } + + return &AvailableDelegationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/availabledelegations/id_location.go b/resource-manager/network/2024-07-01/availabledelegations/id_location.go new file mode 100644 index 00000000000..e6387e4fdeb --- /dev/null +++ b/resource-manager/network/2024-07-01/availabledelegations/id_location.go @@ -0,0 +1,121 @@ +package availabledelegations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Network/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/availabledelegations/id_location_test.go b/resource-manager/network/2024-07-01/availabledelegations/id_location_test.go new file mode 100644 index 00000000000..8d0352c08ff --- /dev/null +++ b/resource-manager/network/2024-07-01/availabledelegations/id_location_test.go @@ -0,0 +1,237 @@ +package availabledelegations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/availabledelegations/id_providerlocation.go b/resource-manager/network/2024-07-01/availabledelegations/id_providerlocation.go new file mode 100644 index 00000000000..1e3b30f4431 --- /dev/null +++ b/resource-manager/network/2024-07-01/availabledelegations/id_providerlocation.go @@ -0,0 +1,130 @@ +package availabledelegations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + ResourceGroupName string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, resourceGroupName string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/availabledelegations/id_providerlocation_test.go b/resource-manager/network/2024-07-01/availabledelegations/id_providerlocation_test.go new file mode 100644 index 00000000000..e24c8def247 --- /dev/null +++ b/resource-manager/network/2024-07-01/availabledelegations/id_providerlocation_test.go @@ -0,0 +1,282 @@ +package availabledelegations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/availabledelegations/method_availabledelegationslist.go b/resource-manager/network/2024-07-01/availabledelegations/method_availabledelegationslist.go new file mode 100644 index 00000000000..e9a70f09fbc --- /dev/null +++ b/resource-manager/network/2024-07-01/availabledelegations/method_availabledelegationslist.go @@ -0,0 +1,105 @@ +package availabledelegations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableDelegationsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AvailableDelegation +} + +type AvailableDelegationsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AvailableDelegation +} + +type AvailableDelegationsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *AvailableDelegationsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// AvailableDelegationsList ... +func (c AvailableDelegationsClient) AvailableDelegationsList(ctx context.Context, id LocationId) (result AvailableDelegationsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &AvailableDelegationsListCustomPager{}, + Path: fmt.Sprintf("%s/availableDelegations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AvailableDelegation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// AvailableDelegationsListComplete retrieves all the results into a single object +func (c AvailableDelegationsClient) AvailableDelegationsListComplete(ctx context.Context, id LocationId) (AvailableDelegationsListCompleteResult, error) { + return c.AvailableDelegationsListCompleteMatchingPredicate(ctx, id, AvailableDelegationOperationPredicate{}) +} + +// AvailableDelegationsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AvailableDelegationsClient) AvailableDelegationsListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate AvailableDelegationOperationPredicate) (result AvailableDelegationsListCompleteResult, err error) { + items := make([]AvailableDelegation, 0) + + resp, err := c.AvailableDelegationsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = AvailableDelegationsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/availabledelegations/method_availableresourcegroupdelegationslist.go b/resource-manager/network/2024-07-01/availabledelegations/method_availableresourcegroupdelegationslist.go new file mode 100644 index 00000000000..1663af9f165 --- /dev/null +++ b/resource-manager/network/2024-07-01/availabledelegations/method_availableresourcegroupdelegationslist.go @@ -0,0 +1,105 @@ +package availabledelegations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableResourceGroupDelegationsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AvailableDelegation +} + +type AvailableResourceGroupDelegationsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AvailableDelegation +} + +type AvailableResourceGroupDelegationsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *AvailableResourceGroupDelegationsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// AvailableResourceGroupDelegationsList ... +func (c AvailableDelegationsClient) AvailableResourceGroupDelegationsList(ctx context.Context, id ProviderLocationId) (result AvailableResourceGroupDelegationsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &AvailableResourceGroupDelegationsListCustomPager{}, + Path: fmt.Sprintf("%s/availableDelegations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AvailableDelegation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// AvailableResourceGroupDelegationsListComplete retrieves all the results into a single object +func (c AvailableDelegationsClient) AvailableResourceGroupDelegationsListComplete(ctx context.Context, id ProviderLocationId) (AvailableResourceGroupDelegationsListCompleteResult, error) { + return c.AvailableResourceGroupDelegationsListCompleteMatchingPredicate(ctx, id, AvailableDelegationOperationPredicate{}) +} + +// AvailableResourceGroupDelegationsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AvailableDelegationsClient) AvailableResourceGroupDelegationsListCompleteMatchingPredicate(ctx context.Context, id ProviderLocationId, predicate AvailableDelegationOperationPredicate) (result AvailableResourceGroupDelegationsListCompleteResult, err error) { + items := make([]AvailableDelegation, 0) + + resp, err := c.AvailableResourceGroupDelegationsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = AvailableResourceGroupDelegationsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/availabledelegations/model_availabledelegation.go b/resource-manager/network/2024-07-01/availabledelegations/model_availabledelegation.go new file mode 100644 index 00000000000..0fa5dba60d1 --- /dev/null +++ b/resource-manager/network/2024-07-01/availabledelegations/model_availabledelegation.go @@ -0,0 +1,12 @@ +package availabledelegations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableDelegation struct { + Actions *[]string `json:"actions,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/availabledelegations/predicates.go b/resource-manager/network/2024-07-01/availabledelegations/predicates.go new file mode 100644 index 00000000000..caf6b904077 --- /dev/null +++ b/resource-manager/network/2024-07-01/availabledelegations/predicates.go @@ -0,0 +1,32 @@ +package availabledelegations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableDelegationOperationPredicate struct { + Id *string + Name *string + ServiceName *string + Type *string +} + +func (p AvailableDelegationOperationPredicate) Matches(input AvailableDelegation) 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.ServiceName != nil && (input.ServiceName == nil || *p.ServiceName != *input.ServiceName) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/availabledelegations/version.go b/resource-manager/network/2024-07-01/availabledelegations/version.go new file mode 100644 index 00000000000..39e12ee090c --- /dev/null +++ b/resource-manager/network/2024-07-01/availabledelegations/version.go @@ -0,0 +1,10 @@ +package availabledelegations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/availabledelegations/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/availableservicealiases/README.md b/resource-manager/network/2024-07-01/availableservicealiases/README.md new file mode 100644 index 00000000000..ccde2182715 --- /dev/null +++ b/resource-manager/network/2024-07-01/availableservicealiases/README.md @@ -0,0 +1,54 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/availableservicealiases` Documentation + +The `availableservicealiases` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/availableservicealiases" +``` + + +### Client Initialization + +```go +client := availableservicealiases.NewAvailableServiceAliasesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AvailableServiceAliasesClient.List` + +```go +ctx := context.TODO() +id := availableservicealiases.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AvailableServiceAliasesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := availableservicealiases.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationName") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/availableservicealiases/client.go b/resource-manager/network/2024-07-01/availableservicealiases/client.go new file mode 100644 index 00000000000..5f9e19acaa8 --- /dev/null +++ b/resource-manager/network/2024-07-01/availableservicealiases/client.go @@ -0,0 +1,26 @@ +package availableservicealiases + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableServiceAliasesClient struct { + Client *resourcemanager.Client +} + +func NewAvailableServiceAliasesClientWithBaseURI(sdkApi sdkEnv.Api) (*AvailableServiceAliasesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "availableservicealiases", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AvailableServiceAliasesClient: %+v", err) + } + + return &AvailableServiceAliasesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/availableservicealiases/id_location.go b/resource-manager/network/2024-07-01/availableservicealiases/id_location.go new file mode 100644 index 00000000000..b531d5a4bb7 --- /dev/null +++ b/resource-manager/network/2024-07-01/availableservicealiases/id_location.go @@ -0,0 +1,121 @@ +package availableservicealiases + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Network/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/availableservicealiases/id_location_test.go b/resource-manager/network/2024-07-01/availableservicealiases/id_location_test.go new file mode 100644 index 00000000000..995b5cfad7f --- /dev/null +++ b/resource-manager/network/2024-07-01/availableservicealiases/id_location_test.go @@ -0,0 +1,237 @@ +package availableservicealiases + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/availableservicealiases/id_providerlocation.go b/resource-manager/network/2024-07-01/availableservicealiases/id_providerlocation.go new file mode 100644 index 00000000000..6c961f76bc1 --- /dev/null +++ b/resource-manager/network/2024-07-01/availableservicealiases/id_providerlocation.go @@ -0,0 +1,130 @@ +package availableservicealiases + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + ResourceGroupName string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, resourceGroupName string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/availableservicealiases/id_providerlocation_test.go b/resource-manager/network/2024-07-01/availableservicealiases/id_providerlocation_test.go new file mode 100644 index 00000000000..d6526faaf37 --- /dev/null +++ b/resource-manager/network/2024-07-01/availableservicealiases/id_providerlocation_test.go @@ -0,0 +1,282 @@ +package availableservicealiases + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/availableservicealiases/method_list.go b/resource-manager/network/2024-07-01/availableservicealiases/method_list.go new file mode 100644 index 00000000000..702ae41758c --- /dev/null +++ b/resource-manager/network/2024-07-01/availableservicealiases/method_list.go @@ -0,0 +1,105 @@ +package availableservicealiases + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AvailableServiceAlias +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AvailableServiceAlias +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c AvailableServiceAliasesClient) List(ctx context.Context, id LocationId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/availableServiceAliases", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AvailableServiceAlias `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AvailableServiceAliasesClient) ListComplete(ctx context.Context, id LocationId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AvailableServiceAliasOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AvailableServiceAliasesClient) ListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate AvailableServiceAliasOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AvailableServiceAlias, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/availableservicealiases/method_listbyresourcegroup.go b/resource-manager/network/2024-07-01/availableservicealiases/method_listbyresourcegroup.go new file mode 100644 index 00000000000..0f1856bad3f --- /dev/null +++ b/resource-manager/network/2024-07-01/availableservicealiases/method_listbyresourcegroup.go @@ -0,0 +1,105 @@ +package availableservicealiases + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AvailableServiceAlias +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AvailableServiceAlias +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c AvailableServiceAliasesClient) ListByResourceGroup(ctx context.Context, id ProviderLocationId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/availableServiceAliases", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AvailableServiceAlias `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AvailableServiceAliasesClient) ListByResourceGroupComplete(ctx context.Context, id ProviderLocationId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AvailableServiceAliasOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AvailableServiceAliasesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id ProviderLocationId, predicate AvailableServiceAliasOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AvailableServiceAlias, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/availableservicealiases/model_availableservicealias.go b/resource-manager/network/2024-07-01/availableservicealiases/model_availableservicealias.go new file mode 100644 index 00000000000..b5f6cfd263b --- /dev/null +++ b/resource-manager/network/2024-07-01/availableservicealiases/model_availableservicealias.go @@ -0,0 +1,11 @@ +package availableservicealiases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableServiceAlias struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/availableservicealiases/predicates.go b/resource-manager/network/2024-07-01/availableservicealiases/predicates.go new file mode 100644 index 00000000000..afe2abff9ab --- /dev/null +++ b/resource-manager/network/2024-07-01/availableservicealiases/predicates.go @@ -0,0 +1,32 @@ +package availableservicealiases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableServiceAliasOperationPredicate struct { + Id *string + Name *string + ResourceName *string + Type *string +} + +func (p AvailableServiceAliasOperationPredicate) Matches(input AvailableServiceAlias) 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.ResourceName != nil && (input.ResourceName == nil || *p.ResourceName != *input.ResourceName) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/availableservicealiases/version.go b/resource-manager/network/2024-07-01/availableservicealiases/version.go new file mode 100644 index 00000000000..38793bca5a7 --- /dev/null +++ b/resource-manager/network/2024-07-01/availableservicealiases/version.go @@ -0,0 +1,10 @@ +package availableservicealiases + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/availableservicealiases/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/README.md b/resource-manager/network/2024-07-01/azurefirewalls/README.md new file mode 100644 index 00000000000..c6d6e1ab9ae --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/README.md @@ -0,0 +1,146 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/azurefirewalls` Documentation + +The `azurefirewalls` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/azurefirewalls" +``` + + +### Client Initialization + +```go +client := azurefirewalls.NewAzureFirewallsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AzureFirewallsClient.AzureFirewallsListLearnedPrefixes` + +```go +ctx := context.TODO() +id := azurefirewalls.NewAzureFirewallID("12345678-1234-9876-4563-123456789012", "example-resource-group", "azureFirewallName") + +if err := client.AzureFirewallsListLearnedPrefixesThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AzureFirewallsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := azurefirewalls.NewAzureFirewallID("12345678-1234-9876-4563-123456789012", "example-resource-group", "azureFirewallName") + +payload := azurefirewalls.AzureFirewall{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AzureFirewallsClient.Delete` + +```go +ctx := context.TODO() +id := azurefirewalls.NewAzureFirewallID("12345678-1234-9876-4563-123456789012", "example-resource-group", "azureFirewallName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AzureFirewallsClient.Get` + +```go +ctx := context.TODO() +id := azurefirewalls.NewAzureFirewallID("12345678-1234-9876-4563-123456789012", "example-resource-group", "azureFirewallName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AzureFirewallsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AzureFirewallsClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AzureFirewallsClient.PacketCapture` + +```go +ctx := context.TODO() +id := azurefirewalls.NewAzureFirewallID("12345678-1234-9876-4563-123456789012", "example-resource-group", "azureFirewallName") + +payload := azurefirewalls.FirewallPacketCaptureParameters{ + // ... +} + + +if err := client.PacketCaptureThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AzureFirewallsClient.UpdateTags` + +```go +ctx := context.TODO() +id := azurefirewalls.NewAzureFirewallID("12345678-1234-9876-4563-123456789012", "example-resource-group", "azureFirewallName") + +payload := azurefirewalls.TagsObject{ + // ... +} + + +if err := client.UpdateTagsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/network/2024-07-01/azurefirewalls/client.go b/resource-manager/network/2024-07-01/azurefirewalls/client.go new file mode 100644 index 00000000000..02df961b70b --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/client.go @@ -0,0 +1,26 @@ +package azurefirewalls + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallsClient struct { + Client *resourcemanager.Client +} + +func NewAzureFirewallsClientWithBaseURI(sdkApi sdkEnv.Api) (*AzureFirewallsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "azurefirewalls", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AzureFirewallsClient: %+v", err) + } + + return &AzureFirewallsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/constants.go b/resource-manager/network/2024-07-01/azurefirewalls/constants.go new file mode 100644 index 00000000000..d7a3af8fb71 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/constants.go @@ -0,0 +1,412 @@ +package azurefirewalls + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallApplicationRuleProtocolType string + +const ( + AzureFirewallApplicationRuleProtocolTypeHTTP AzureFirewallApplicationRuleProtocolType = "Http" + AzureFirewallApplicationRuleProtocolTypeHTTPS AzureFirewallApplicationRuleProtocolType = "Https" + AzureFirewallApplicationRuleProtocolTypeMssql AzureFirewallApplicationRuleProtocolType = "Mssql" +) + +func PossibleValuesForAzureFirewallApplicationRuleProtocolType() []string { + return []string{ + string(AzureFirewallApplicationRuleProtocolTypeHTTP), + string(AzureFirewallApplicationRuleProtocolTypeHTTPS), + string(AzureFirewallApplicationRuleProtocolTypeMssql), + } +} + +func (s *AzureFirewallApplicationRuleProtocolType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureFirewallApplicationRuleProtocolType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureFirewallApplicationRuleProtocolType(input string) (*AzureFirewallApplicationRuleProtocolType, error) { + vals := map[string]AzureFirewallApplicationRuleProtocolType{ + "http": AzureFirewallApplicationRuleProtocolTypeHTTP, + "https": AzureFirewallApplicationRuleProtocolTypeHTTPS, + "mssql": AzureFirewallApplicationRuleProtocolTypeMssql, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureFirewallApplicationRuleProtocolType(input) + return &out, nil +} + +type AzureFirewallNatRCActionType string + +const ( + AzureFirewallNatRCActionTypeDnat AzureFirewallNatRCActionType = "Dnat" + AzureFirewallNatRCActionTypeSnat AzureFirewallNatRCActionType = "Snat" +) + +func PossibleValuesForAzureFirewallNatRCActionType() []string { + return []string{ + string(AzureFirewallNatRCActionTypeDnat), + string(AzureFirewallNatRCActionTypeSnat), + } +} + +func (s *AzureFirewallNatRCActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureFirewallNatRCActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureFirewallNatRCActionType(input string) (*AzureFirewallNatRCActionType, error) { + vals := map[string]AzureFirewallNatRCActionType{ + "dnat": AzureFirewallNatRCActionTypeDnat, + "snat": AzureFirewallNatRCActionTypeSnat, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureFirewallNatRCActionType(input) + return &out, nil +} + +type AzureFirewallNetworkRuleProtocol string + +const ( + AzureFirewallNetworkRuleProtocolAny AzureFirewallNetworkRuleProtocol = "Any" + AzureFirewallNetworkRuleProtocolICMP AzureFirewallNetworkRuleProtocol = "ICMP" + AzureFirewallNetworkRuleProtocolTCP AzureFirewallNetworkRuleProtocol = "TCP" + AzureFirewallNetworkRuleProtocolUDP AzureFirewallNetworkRuleProtocol = "UDP" +) + +func PossibleValuesForAzureFirewallNetworkRuleProtocol() []string { + return []string{ + string(AzureFirewallNetworkRuleProtocolAny), + string(AzureFirewallNetworkRuleProtocolICMP), + string(AzureFirewallNetworkRuleProtocolTCP), + string(AzureFirewallNetworkRuleProtocolUDP), + } +} + +func (s *AzureFirewallNetworkRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureFirewallNetworkRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureFirewallNetworkRuleProtocol(input string) (*AzureFirewallNetworkRuleProtocol, error) { + vals := map[string]AzureFirewallNetworkRuleProtocol{ + "any": AzureFirewallNetworkRuleProtocolAny, + "icmp": AzureFirewallNetworkRuleProtocolICMP, + "tcp": AzureFirewallNetworkRuleProtocolTCP, + "udp": AzureFirewallNetworkRuleProtocolUDP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureFirewallNetworkRuleProtocol(input) + return &out, nil +} + +type AzureFirewallPacketCaptureFlagsType string + +const ( + AzureFirewallPacketCaptureFlagsTypeAck AzureFirewallPacketCaptureFlagsType = "ack" + AzureFirewallPacketCaptureFlagsTypeFin AzureFirewallPacketCaptureFlagsType = "fin" + AzureFirewallPacketCaptureFlagsTypePush AzureFirewallPacketCaptureFlagsType = "push" + AzureFirewallPacketCaptureFlagsTypeRst AzureFirewallPacketCaptureFlagsType = "rst" + AzureFirewallPacketCaptureFlagsTypeSyn AzureFirewallPacketCaptureFlagsType = "syn" + AzureFirewallPacketCaptureFlagsTypeUrg AzureFirewallPacketCaptureFlagsType = "urg" +) + +func PossibleValuesForAzureFirewallPacketCaptureFlagsType() []string { + return []string{ + string(AzureFirewallPacketCaptureFlagsTypeAck), + string(AzureFirewallPacketCaptureFlagsTypeFin), + string(AzureFirewallPacketCaptureFlagsTypePush), + string(AzureFirewallPacketCaptureFlagsTypeRst), + string(AzureFirewallPacketCaptureFlagsTypeSyn), + string(AzureFirewallPacketCaptureFlagsTypeUrg), + } +} + +func (s *AzureFirewallPacketCaptureFlagsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureFirewallPacketCaptureFlagsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureFirewallPacketCaptureFlagsType(input string) (*AzureFirewallPacketCaptureFlagsType, error) { + vals := map[string]AzureFirewallPacketCaptureFlagsType{ + "ack": AzureFirewallPacketCaptureFlagsTypeAck, + "fin": AzureFirewallPacketCaptureFlagsTypeFin, + "push": AzureFirewallPacketCaptureFlagsTypePush, + "rst": AzureFirewallPacketCaptureFlagsTypeRst, + "syn": AzureFirewallPacketCaptureFlagsTypeSyn, + "urg": AzureFirewallPacketCaptureFlagsTypeUrg, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureFirewallPacketCaptureFlagsType(input) + return &out, nil +} + +type AzureFirewallRCActionType string + +const ( + AzureFirewallRCActionTypeAllow AzureFirewallRCActionType = "Allow" + AzureFirewallRCActionTypeDeny AzureFirewallRCActionType = "Deny" +) + +func PossibleValuesForAzureFirewallRCActionType() []string { + return []string{ + string(AzureFirewallRCActionTypeAllow), + string(AzureFirewallRCActionTypeDeny), + } +} + +func (s *AzureFirewallRCActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureFirewallRCActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureFirewallRCActionType(input string) (*AzureFirewallRCActionType, error) { + vals := map[string]AzureFirewallRCActionType{ + "allow": AzureFirewallRCActionTypeAllow, + "deny": AzureFirewallRCActionTypeDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureFirewallRCActionType(input) + return &out, nil +} + +type AzureFirewallSkuName string + +const ( + AzureFirewallSkuNameAZFWHub AzureFirewallSkuName = "AZFW_Hub" + AzureFirewallSkuNameAZFWVNet AzureFirewallSkuName = "AZFW_VNet" +) + +func PossibleValuesForAzureFirewallSkuName() []string { + return []string{ + string(AzureFirewallSkuNameAZFWHub), + string(AzureFirewallSkuNameAZFWVNet), + } +} + +func (s *AzureFirewallSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureFirewallSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureFirewallSkuName(input string) (*AzureFirewallSkuName, error) { + vals := map[string]AzureFirewallSkuName{ + "azfw_hub": AzureFirewallSkuNameAZFWHub, + "azfw_vnet": AzureFirewallSkuNameAZFWVNet, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureFirewallSkuName(input) + return &out, nil +} + +type AzureFirewallSkuTier string + +const ( + AzureFirewallSkuTierBasic AzureFirewallSkuTier = "Basic" + AzureFirewallSkuTierPremium AzureFirewallSkuTier = "Premium" + AzureFirewallSkuTierStandard AzureFirewallSkuTier = "Standard" +) + +func PossibleValuesForAzureFirewallSkuTier() []string { + return []string{ + string(AzureFirewallSkuTierBasic), + string(AzureFirewallSkuTierPremium), + string(AzureFirewallSkuTierStandard), + } +} + +func (s *AzureFirewallSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureFirewallSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureFirewallSkuTier(input string) (*AzureFirewallSkuTier, error) { + vals := map[string]AzureFirewallSkuTier{ + "basic": AzureFirewallSkuTierBasic, + "premium": AzureFirewallSkuTierPremium, + "standard": AzureFirewallSkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureFirewallSkuTier(input) + return &out, nil +} + +type AzureFirewallThreatIntelMode string + +const ( + AzureFirewallThreatIntelModeAlert AzureFirewallThreatIntelMode = "Alert" + AzureFirewallThreatIntelModeDeny AzureFirewallThreatIntelMode = "Deny" + AzureFirewallThreatIntelModeOff AzureFirewallThreatIntelMode = "Off" +) + +func PossibleValuesForAzureFirewallThreatIntelMode() []string { + return []string{ + string(AzureFirewallThreatIntelModeAlert), + string(AzureFirewallThreatIntelModeDeny), + string(AzureFirewallThreatIntelModeOff), + } +} + +func (s *AzureFirewallThreatIntelMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureFirewallThreatIntelMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureFirewallThreatIntelMode(input string) (*AzureFirewallThreatIntelMode, error) { + vals := map[string]AzureFirewallThreatIntelMode{ + "alert": AzureFirewallThreatIntelModeAlert, + "deny": AzureFirewallThreatIntelModeDeny, + "off": AzureFirewallThreatIntelModeOff, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureFirewallThreatIntelMode(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/id_azurefirewall.go b/resource-manager/network/2024-07-01/azurefirewalls/id_azurefirewall.go new file mode 100644 index 00000000000..5c55ccb6a6a --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/id_azurefirewall.go @@ -0,0 +1,130 @@ +package azurefirewalls + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AzureFirewallId{}) +} + +var _ resourceids.ResourceId = &AzureFirewallId{} + +// AzureFirewallId is a struct representing the Resource ID for a Azure Firewall +type AzureFirewallId struct { + SubscriptionId string + ResourceGroupName string + AzureFirewallName string +} + +// NewAzureFirewallID returns a new AzureFirewallId struct +func NewAzureFirewallID(subscriptionId string, resourceGroupName string, azureFirewallName string) AzureFirewallId { + return AzureFirewallId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AzureFirewallName: azureFirewallName, + } +} + +// ParseAzureFirewallID parses 'input' into a AzureFirewallId +func ParseAzureFirewallID(input string) (*AzureFirewallId, error) { + parser := resourceids.NewParserFromResourceIdType(&AzureFirewallId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AzureFirewallId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAzureFirewallIDInsensitively parses 'input' case-insensitively into a AzureFirewallId +// note: this method should only be used for API response data and not user input +func ParseAzureFirewallIDInsensitively(input string) (*AzureFirewallId, error) { + parser := resourceids.NewParserFromResourceIdType(&AzureFirewallId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AzureFirewallId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AzureFirewallId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.AzureFirewallName, ok = input.Parsed["azureFirewallName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "azureFirewallName", input) + } + + return nil +} + +// ValidateAzureFirewallID checks that 'input' can be parsed as a Azure Firewall ID +func ValidateAzureFirewallID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseAzureFirewallID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Azure Firewall ID +func (id AzureFirewallId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/azureFirewalls/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AzureFirewallName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Azure Firewall ID +func (id AzureFirewallId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticAzureFirewalls", "azureFirewalls", "azureFirewalls"), + resourceids.UserSpecifiedSegment("azureFirewallName", "azureFirewallName"), + } +} + +// String returns a human-readable description of this Azure Firewall ID +func (id AzureFirewallId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Azure Firewall Name: %q", id.AzureFirewallName), + } + return fmt.Sprintf("Azure Firewall (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/id_azurefirewall_test.go b/resource-manager/network/2024-07-01/azurefirewalls/id_azurefirewall_test.go new file mode 100644 index 00000000000..edaefaab1ce --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/id_azurefirewall_test.go @@ -0,0 +1,282 @@ +package azurefirewalls + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AzureFirewallId{} + +func TestNewAzureFirewallID(t *testing.T) { + id := NewAzureFirewallID("12345678-1234-9876-4563-123456789012", "example-resource-group", "azureFirewallName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.AzureFirewallName != "azureFirewallName" { + t.Fatalf("Expected %q but got %q for Segment 'AzureFirewallName'", id.AzureFirewallName, "azureFirewallName") + } +} + +func TestFormatAzureFirewallID(t *testing.T) { + actual := NewAzureFirewallID("12345678-1234-9876-4563-123456789012", "example-resource-group", "azureFirewallName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/azureFirewalls/azureFirewallName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAzureFirewallID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AzureFirewallId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/azureFirewalls", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/azureFirewalls/azureFirewallName", + Expected: &AzureFirewallId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AzureFirewallName: "azureFirewallName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/azureFirewalls/azureFirewallName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAzureFirewallID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.AzureFirewallName != v.Expected.AzureFirewallName { + t.Fatalf("Expected %q but got %q for AzureFirewallName", v.Expected.AzureFirewallName, actual.AzureFirewallName) + } + + } +} + +func TestParseAzureFirewallIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AzureFirewallId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/azureFirewalls", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aZuReFiReWaLlS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/azureFirewalls/azureFirewallName", + Expected: &AzureFirewallId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + AzureFirewallName: "azureFirewallName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/azureFirewalls/azureFirewallName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aZuReFiReWaLlS/aZuReFiReWaLlNaMe", + Expected: &AzureFirewallId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + AzureFirewallName: "aZuReFiReWaLlNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aZuReFiReWaLlS/aZuReFiReWaLlNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAzureFirewallIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.AzureFirewallName != v.Expected.AzureFirewallName { + t.Fatalf("Expected %q but got %q for AzureFirewallName", v.Expected.AzureFirewallName, actual.AzureFirewallName) + } + + } +} + +func TestSegmentsForAzureFirewallId(t *testing.T) { + segments := AzureFirewallId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AzureFirewallId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/method_azurefirewallslistlearnedprefixes.go b/resource-manager/network/2024-07-01/azurefirewalls/method_azurefirewallslistlearnedprefixes.go new file mode 100644 index 00000000000..79c6c0ccfd6 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/method_azurefirewallslistlearnedprefixes.go @@ -0,0 +1,71 @@ +package azurefirewalls + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallsListLearnedPrefixesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *IPPrefixesList +} + +// AzureFirewallsListLearnedPrefixes ... +func (c AzureFirewallsClient) AzureFirewallsListLearnedPrefixes(ctx context.Context, id AzureFirewallId) (result AzureFirewallsListLearnedPrefixesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/learnedIPPrefixes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// AzureFirewallsListLearnedPrefixesThenPoll performs AzureFirewallsListLearnedPrefixes then polls until it's completed +func (c AzureFirewallsClient) AzureFirewallsListLearnedPrefixesThenPoll(ctx context.Context, id AzureFirewallId) error { + result, err := c.AzureFirewallsListLearnedPrefixes(ctx, id) + if err != nil { + return fmt.Errorf("performing AzureFirewallsListLearnedPrefixes: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AzureFirewallsListLearnedPrefixes: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/method_createorupdate.go b/resource-manager/network/2024-07-01/azurefirewalls/method_createorupdate.go new file mode 100644 index 00000000000..fdd7520026c --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/method_createorupdate.go @@ -0,0 +1,75 @@ +package azurefirewalls + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AzureFirewall +} + +// CreateOrUpdate ... +func (c AzureFirewallsClient) CreateOrUpdate(ctx context.Context, id AzureFirewallId, input AzureFirewall) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AzureFirewallsClient) CreateOrUpdateThenPoll(ctx context.Context, id AzureFirewallId, input AzureFirewall) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/method_delete.go b/resource-manager/network/2024-07-01/azurefirewalls/method_delete.go new file mode 100644 index 00000000000..04fddc41723 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/method_delete.go @@ -0,0 +1,71 @@ +package azurefirewalls + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c AzureFirewallsClient) Delete(ctx context.Context, id AzureFirewallId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c AzureFirewallsClient) DeleteThenPoll(ctx context.Context, id AzureFirewallId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/method_get.go b/resource-manager/network/2024-07-01/azurefirewalls/method_get.go new file mode 100644 index 00000000000..e9802794921 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/method_get.go @@ -0,0 +1,53 @@ +package azurefirewalls + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureFirewall +} + +// Get ... +func (c AzureFirewallsClient) Get(ctx context.Context, id AzureFirewallId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AzureFirewall + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/method_list.go b/resource-manager/network/2024-07-01/azurefirewalls/method_list.go new file mode 100644 index 00000000000..305a4b553ef --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/method_list.go @@ -0,0 +1,106 @@ +package azurefirewalls + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AzureFirewall +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AzureFirewall +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c AzureFirewallsClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/azureFirewalls", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AzureFirewall `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AzureFirewallsClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AzureFirewallOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AzureFirewallsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AzureFirewallOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AzureFirewall, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/method_listall.go b/resource-manager/network/2024-07-01/azurefirewalls/method_listall.go new file mode 100644 index 00000000000..be602f8bbd5 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/method_listall.go @@ -0,0 +1,106 @@ +package azurefirewalls + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AzureFirewall +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []AzureFirewall +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c AzureFirewallsClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/azureFirewalls", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AzureFirewall `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c AzureFirewallsClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, AzureFirewallOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AzureFirewallsClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AzureFirewallOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]AzureFirewall, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/method_packetcapture.go b/resource-manager/network/2024-07-01/azurefirewalls/method_packetcapture.go new file mode 100644 index 00000000000..a2b211da6c7 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/method_packetcapture.go @@ -0,0 +1,73 @@ +package azurefirewalls + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCaptureOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// PacketCapture ... +func (c AzureFirewallsClient) PacketCapture(ctx context.Context, id AzureFirewallId, input FirewallPacketCaptureParameters) (result PacketCaptureOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/packetCapture", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PacketCaptureThenPoll performs PacketCapture then polls until it's completed +func (c AzureFirewallsClient) PacketCaptureThenPoll(ctx context.Context, id AzureFirewallId, input FirewallPacketCaptureParameters) error { + result, err := c.PacketCapture(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PacketCapture: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PacketCapture: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/method_updatetags.go b/resource-manager/network/2024-07-01/azurefirewalls/method_updatetags.go new file mode 100644 index 00000000000..1d404977af9 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/method_updatetags.go @@ -0,0 +1,75 @@ +package azurefirewalls + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AzureFirewall +} + +// UpdateTags ... +func (c AzureFirewallsClient) UpdateTags(ctx context.Context, id AzureFirewallId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateTagsThenPoll performs UpdateTags then polls until it's completed +func (c AzureFirewallsClient) UpdateTagsThenPoll(ctx context.Context, id AzureFirewallId, input TagsObject) error { + result, err := c.UpdateTags(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UpdateTags: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpdateTags: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewall.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewall.go new file mode 100644 index 00000000000..da4d4ccf5f7 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewall.go @@ -0,0 +1,19 @@ +package azurefirewalls + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewall struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AzureFirewallPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallapplicationrule.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallapplicationrule.go new file mode 100644 index 00000000000..c74f6235d09 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallapplicationrule.go @@ -0,0 +1,14 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallApplicationRule struct { + Description *string `json:"description,omitempty"` + FqdnTags *[]string `json:"fqdnTags,omitempty"` + Name *string `json:"name,omitempty"` + Protocols *[]AzureFirewallApplicationRuleProtocol `json:"protocols,omitempty"` + SourceAddresses *[]string `json:"sourceAddresses,omitempty"` + SourceIPGroups *[]string `json:"sourceIpGroups,omitempty"` + TargetFqdns *[]string `json:"targetFqdns,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallapplicationrulecollection.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallapplicationrulecollection.go new file mode 100644 index 00000000000..0307e6e7b33 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallapplicationrulecollection.go @@ -0,0 +1,11 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallApplicationRuleCollection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AzureFirewallApplicationRuleCollectionPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallapplicationrulecollectionpropertiesformat.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallapplicationrulecollectionpropertiesformat.go new file mode 100644 index 00000000000..bd5d09f330d --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallapplicationrulecollectionpropertiesformat.go @@ -0,0 +1,11 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallApplicationRuleCollectionPropertiesFormat struct { + Action *AzureFirewallRCAction `json:"action,omitempty"` + Priority *int64 `json:"priority,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Rules *[]AzureFirewallApplicationRule `json:"rules,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallapplicationruleprotocol.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallapplicationruleprotocol.go new file mode 100644 index 00000000000..8ea63b2ef92 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallapplicationruleprotocol.go @@ -0,0 +1,9 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallApplicationRuleProtocol struct { + Port *int64 `json:"port,omitempty"` + ProtocolType *AzureFirewallApplicationRuleProtocolType `json:"protocolType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallautoscaleconfiguration.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallautoscaleconfiguration.go new file mode 100644 index 00000000000..39e71317305 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallautoscaleconfiguration.go @@ -0,0 +1,9 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallAutoscaleConfiguration struct { + MaxCapacity *int64 `json:"maxCapacity,omitempty"` + MinCapacity *int64 `json:"minCapacity,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallipconfiguration.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallipconfiguration.go new file mode 100644 index 00000000000..3456ba0b1ad --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallipconfiguration.go @@ -0,0 +1,12 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AzureFirewallIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..cca79069337 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallipconfigurationpropertiesformat.go @@ -0,0 +1,11 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallIPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *SubResource `json:"publicIPAddress,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallipgroups.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallipgroups.go new file mode 100644 index 00000000000..e26c8540a65 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallipgroups.go @@ -0,0 +1,9 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallIPGroups struct { + ChangeNumber *string `json:"changeNumber,omitempty"` + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnatrcaction.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnatrcaction.go new file mode 100644 index 00000000000..9c9250aef39 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnatrcaction.go @@ -0,0 +1,8 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallNatRCAction struct { + Type *AzureFirewallNatRCActionType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnatrule.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnatrule.go new file mode 100644 index 00000000000..70c0d009eab --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnatrule.go @@ -0,0 +1,17 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallNatRule struct { + Description *string `json:"description,omitempty"` + DestinationAddresses *[]string `json:"destinationAddresses,omitempty"` + DestinationPorts *[]string `json:"destinationPorts,omitempty"` + Name *string `json:"name,omitempty"` + Protocols *[]AzureFirewallNetworkRuleProtocol `json:"protocols,omitempty"` + SourceAddresses *[]string `json:"sourceAddresses,omitempty"` + SourceIPGroups *[]string `json:"sourceIpGroups,omitempty"` + TranslatedAddress *string `json:"translatedAddress,omitempty"` + TranslatedFqdn *string `json:"translatedFqdn,omitempty"` + TranslatedPort *string `json:"translatedPort,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnatrulecollection.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnatrulecollection.go new file mode 100644 index 00000000000..d06cf19e359 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnatrulecollection.go @@ -0,0 +1,11 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallNatRuleCollection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AzureFirewallNatRuleCollectionProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnatrulecollectionproperties.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnatrulecollectionproperties.go new file mode 100644 index 00000000000..774ac6902bc --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnatrulecollectionproperties.go @@ -0,0 +1,11 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallNatRuleCollectionProperties struct { + Action *AzureFirewallNatRCAction `json:"action,omitempty"` + Priority *int64 `json:"priority,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Rules *[]AzureFirewallNatRule `json:"rules,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnetworkrule.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnetworkrule.go new file mode 100644 index 00000000000..6833c1f7509 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnetworkrule.go @@ -0,0 +1,16 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallNetworkRule struct { + Description *string `json:"description,omitempty"` + DestinationAddresses *[]string `json:"destinationAddresses,omitempty"` + DestinationFqdns *[]string `json:"destinationFqdns,omitempty"` + DestinationIPGroups *[]string `json:"destinationIpGroups,omitempty"` + DestinationPorts *[]string `json:"destinationPorts,omitempty"` + Name *string `json:"name,omitempty"` + Protocols *[]AzureFirewallNetworkRuleProtocol `json:"protocols,omitempty"` + SourceAddresses *[]string `json:"sourceAddresses,omitempty"` + SourceIPGroups *[]string `json:"sourceIpGroups,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnetworkrulecollection.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnetworkrulecollection.go new file mode 100644 index 00000000000..ea5f2ba0d2b --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnetworkrulecollection.go @@ -0,0 +1,11 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallNetworkRuleCollection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AzureFirewallNetworkRuleCollectionPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnetworkrulecollectionpropertiesformat.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnetworkrulecollectionpropertiesformat.go new file mode 100644 index 00000000000..be71e063370 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallnetworkrulecollectionpropertiesformat.go @@ -0,0 +1,11 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallNetworkRuleCollectionPropertiesFormat struct { + Action *AzureFirewallRCAction `json:"action,omitempty"` + Priority *int64 `json:"priority,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Rules *[]AzureFirewallNetworkRule `json:"rules,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallpacketcaptureflags.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallpacketcaptureflags.go new file mode 100644 index 00000000000..edcc08e5590 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallpacketcaptureflags.go @@ -0,0 +1,8 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallPacketCaptureFlags struct { + Type *AzureFirewallPacketCaptureFlagsType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallpacketcapturerule.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallpacketcapturerule.go new file mode 100644 index 00000000000..4d9921e3243 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallpacketcapturerule.go @@ -0,0 +1,10 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallPacketCaptureRule struct { + DestinationPorts *[]string `json:"destinationPorts,omitempty"` + Destinations *[]string `json:"destinations,omitempty"` + Sources *[]string `json:"sources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallpropertiesformat.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallpropertiesformat.go new file mode 100644 index 00000000000..61ffc25c585 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallpropertiesformat.go @@ -0,0 +1,21 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallPropertiesFormat struct { + AdditionalProperties *map[string]string `json:"additionalProperties,omitempty"` + ApplicationRuleCollections *[]AzureFirewallApplicationRuleCollection `json:"applicationRuleCollections,omitempty"` + AutoscaleConfiguration *AzureFirewallAutoscaleConfiguration `json:"autoscaleConfiguration,omitempty"` + FirewallPolicy *SubResource `json:"firewallPolicy,omitempty"` + HubIPAddresses *HubIPAddresses `json:"hubIPAddresses,omitempty"` + IPConfigurations *[]AzureFirewallIPConfiguration `json:"ipConfigurations,omitempty"` + IPGroups *[]AzureFirewallIPGroups `json:"ipGroups,omitempty"` + ManagementIPConfiguration *AzureFirewallIPConfiguration `json:"managementIpConfiguration,omitempty"` + NatRuleCollections *[]AzureFirewallNatRuleCollection `json:"natRuleCollections,omitempty"` + NetworkRuleCollections *[]AzureFirewallNetworkRuleCollection `json:"networkRuleCollections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Sku *AzureFirewallSku `json:"sku,omitempty"` + ThreatIntelMode *AzureFirewallThreatIntelMode `json:"threatIntelMode,omitempty"` + VirtualHub *SubResource `json:"virtualHub,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallpublicipaddress.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallpublicipaddress.go new file mode 100644 index 00000000000..c5dff4f3fff --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallpublicipaddress.go @@ -0,0 +1,8 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallPublicIPAddress struct { + Address *string `json:"address,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallrcaction.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallrcaction.go new file mode 100644 index 00000000000..752c166b62b --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallrcaction.go @@ -0,0 +1,8 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallRCAction struct { + Type *AzureFirewallRCActionType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallsku.go b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallsku.go new file mode 100644 index 00000000000..46f81c15dbc --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_azurefirewallsku.go @@ -0,0 +1,9 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallSku struct { + Name *AzureFirewallSkuName `json:"name,omitempty"` + Tier *AzureFirewallSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_firewallpacketcaptureparameters.go b/resource-manager/network/2024-07-01/azurefirewalls/model_firewallpacketcaptureparameters.go new file mode 100644 index 00000000000..0fab56fc1d5 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_firewallpacketcaptureparameters.go @@ -0,0 +1,14 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPacketCaptureParameters struct { + DurationInSeconds *int64 `json:"durationInSeconds,omitempty"` + FileName *string `json:"fileName,omitempty"` + Filters *[]AzureFirewallPacketCaptureRule `json:"filters,omitempty"` + Flags *[]AzureFirewallPacketCaptureFlags `json:"flags,omitempty"` + NumberOfPacketsToCapture *int64 `json:"numberOfPacketsToCapture,omitempty"` + Protocol *AzureFirewallNetworkRuleProtocol `json:"protocol,omitempty"` + SasURL *string `json:"sasUrl,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_hubipaddresses.go b/resource-manager/network/2024-07-01/azurefirewalls/model_hubipaddresses.go new file mode 100644 index 00000000000..2fa8e41de6b --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_hubipaddresses.go @@ -0,0 +1,9 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubIPAddresses struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PublicIPs *HubPublicIPAddresses `json:"publicIPs,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_hubpublicipaddresses.go b/resource-manager/network/2024-07-01/azurefirewalls/model_hubpublicipaddresses.go new file mode 100644 index 00000000000..48ee3132846 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_hubpublicipaddresses.go @@ -0,0 +1,9 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubPublicIPAddresses struct { + Addresses *[]AzureFirewallPublicIPAddress `json:"addresses,omitempty"` + Count *int64 `json:"count,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_ipprefixeslist.go b/resource-manager/network/2024-07-01/azurefirewalls/model_ipprefixeslist.go new file mode 100644 index 00000000000..3d2ea0d9a9e --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_ipprefixeslist.go @@ -0,0 +1,8 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPPrefixesList struct { + IPPrefixes *[]string `json:"ipPrefixes,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_subresource.go b/resource-manager/network/2024-07-01/azurefirewalls/model_subresource.go new file mode 100644 index 00000000000..3a39f2458c4 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_subresource.go @@ -0,0 +1,8 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/model_tagsobject.go b/resource-manager/network/2024-07-01/azurefirewalls/model_tagsobject.go new file mode 100644 index 00000000000..3b70ce55bcd --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/model_tagsobject.go @@ -0,0 +1,8 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/predicates.go b/resource-manager/network/2024-07-01/azurefirewalls/predicates.go new file mode 100644 index 00000000000..68ca8da5623 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/predicates.go @@ -0,0 +1,37 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureFirewallOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p AzureFirewallOperationPredicate) Matches(input AzureFirewall) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/azurefirewalls/version.go b/resource-manager/network/2024-07-01/azurefirewalls/version.go new file mode 100644 index 00000000000..042a9893745 --- /dev/null +++ b/resource-manager/network/2024-07-01/azurefirewalls/version.go @@ -0,0 +1,10 @@ +package azurefirewalls + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/azurefirewalls/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/README.md b/resource-manager/network/2024-07-01/bastionhosts/README.md new file mode 100644 index 00000000000..3bed053446d --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/README.md @@ -0,0 +1,234 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/bastionhosts` Documentation + +The `bastionhosts` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/bastionhosts" +``` + + +### Client Initialization + +```go +client := bastionhosts.NewBastionHostsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BastionHostsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := bastionhosts.NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName") + +payload := bastionhosts.BastionHost{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BastionHostsClient.Delete` + +```go +ctx := context.TODO() +id := bastionhosts.NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `BastionHostsClient.DeleteBastionShareableLink` + +```go +ctx := context.TODO() +id := bastionhosts.NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName") + +payload := bastionhosts.BastionShareableLinkListRequest{ + // ... +} + + +if err := client.DeleteBastionShareableLinkThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BastionHostsClient.DeleteBastionShareableLinkByToken` + +```go +ctx := context.TODO() +id := bastionhosts.NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName") + +payload := bastionhosts.BastionShareableLinkTokenListRequest{ + // ... +} + + +if err := client.DeleteBastionShareableLinkByTokenThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BastionHostsClient.DisconnectActiveSessions` + +```go +ctx := context.TODO() +id := bastionhosts.NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName") + +payload := bastionhosts.SessionIds{ + // ... +} + + +// alternatively `client.DisconnectActiveSessions(ctx, id, payload)` can be used to do batched pagination +items, err := client.DisconnectActiveSessionsComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `BastionHostsClient.Get` + +```go +ctx := context.TODO() +id := bastionhosts.NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BastionHostsClient.GetActiveSessions` + +```go +ctx := context.TODO() +id := bastionhosts.NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName") + +// alternatively `client.GetActiveSessions(ctx, id)` can be used to do batched pagination +items, err := client.GetActiveSessionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `BastionHostsClient.GetBastionShareableLink` + +```go +ctx := context.TODO() +id := bastionhosts.NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName") + +payload := bastionhosts.BastionShareableLinkListRequest{ + // ... +} + + +// alternatively `client.GetBastionShareableLink(ctx, id, payload)` can be used to do batched pagination +items, err := client.GetBastionShareableLinkComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `BastionHostsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `BastionHostsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `BastionHostsClient.PutBastionShareableLink` + +```go +ctx := context.TODO() +id := bastionhosts.NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName") + +payload := bastionhosts.BastionShareableLinkListRequest{ + // ... +} + + +// alternatively `client.PutBastionShareableLink(ctx, id, payload)` can be used to do batched pagination +items, err := client.PutBastionShareableLinkComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `BastionHostsClient.UpdateTags` + +```go +ctx := context.TODO() +id := bastionhosts.NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName") + +payload := bastionhosts.TagsObject{ + // ... +} + + +if err := client.UpdateTagsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/network/2024-07-01/bastionhosts/client.go b/resource-manager/network/2024-07-01/bastionhosts/client.go new file mode 100644 index 00000000000..f77ea65ff0a --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/client.go @@ -0,0 +1,26 @@ +package bastionhosts + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionHostsClient struct { + Client *resourcemanager.Client +} + +func NewBastionHostsClientWithBaseURI(sdkApi sdkEnv.Api) (*BastionHostsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "bastionhosts", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BastionHostsClient: %+v", err) + } + + return &BastionHostsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/constants.go b/resource-manager/network/2024-07-01/bastionhosts/constants.go new file mode 100644 index 00000000000..3822668195b --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/constants.go @@ -0,0 +1,186 @@ +package bastionhosts + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionConnectProtocol string + +const ( + BastionConnectProtocolRDP BastionConnectProtocol = "RDP" + BastionConnectProtocolSSH BastionConnectProtocol = "SSH" +) + +func PossibleValuesForBastionConnectProtocol() []string { + return []string{ + string(BastionConnectProtocolRDP), + string(BastionConnectProtocolSSH), + } +} + +func (s *BastionConnectProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBastionConnectProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBastionConnectProtocol(input string) (*BastionConnectProtocol, error) { + vals := map[string]BastionConnectProtocol{ + "rdp": BastionConnectProtocolRDP, + "ssh": BastionConnectProtocolSSH, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BastionConnectProtocol(input) + return &out, nil +} + +type BastionHostSkuName string + +const ( + BastionHostSkuNameBasic BastionHostSkuName = "Basic" + BastionHostSkuNameDeveloper BastionHostSkuName = "Developer" + BastionHostSkuNamePremium BastionHostSkuName = "Premium" + BastionHostSkuNameStandard BastionHostSkuName = "Standard" +) + +func PossibleValuesForBastionHostSkuName() []string { + return []string{ + string(BastionHostSkuNameBasic), + string(BastionHostSkuNameDeveloper), + string(BastionHostSkuNamePremium), + string(BastionHostSkuNameStandard), + } +} + +func (s *BastionHostSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBastionHostSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBastionHostSkuName(input string) (*BastionHostSkuName, error) { + vals := map[string]BastionHostSkuName{ + "basic": BastionHostSkuNameBasic, + "developer": BastionHostSkuNameDeveloper, + "premium": BastionHostSkuNamePremium, + "standard": BastionHostSkuNameStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BastionHostSkuName(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/id_bastionhost.go b/resource-manager/network/2024-07-01/bastionhosts/id_bastionhost.go new file mode 100644 index 00000000000..655e58ea53f --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/id_bastionhost.go @@ -0,0 +1,130 @@ +package bastionhosts + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BastionHostId{}) +} + +var _ resourceids.ResourceId = &BastionHostId{} + +// BastionHostId is a struct representing the Resource ID for a Bastion Host +type BastionHostId struct { + SubscriptionId string + ResourceGroupName string + BastionHostName string +} + +// NewBastionHostID returns a new BastionHostId struct +func NewBastionHostID(subscriptionId string, resourceGroupName string, bastionHostName string) BastionHostId { + return BastionHostId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BastionHostName: bastionHostName, + } +} + +// ParseBastionHostID parses 'input' into a BastionHostId +func ParseBastionHostID(input string) (*BastionHostId, error) { + parser := resourceids.NewParserFromResourceIdType(&BastionHostId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BastionHostId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBastionHostIDInsensitively parses 'input' case-insensitively into a BastionHostId +// note: this method should only be used for API response data and not user input +func ParseBastionHostIDInsensitively(input string) (*BastionHostId, error) { + parser := resourceids.NewParserFromResourceIdType(&BastionHostId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BastionHostId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BastionHostId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.BastionHostName, ok = input.Parsed["bastionHostName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "bastionHostName", input) + } + + return nil +} + +// ValidateBastionHostID checks that 'input' can be parsed as a Bastion Host ID +func ValidateBastionHostID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBastionHostID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Bastion Host ID +func (id BastionHostId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/bastionHosts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BastionHostName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Bastion Host ID +func (id BastionHostId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticBastionHosts", "bastionHosts", "bastionHosts"), + resourceids.UserSpecifiedSegment("bastionHostName", "bastionHostName"), + } +} + +// String returns a human-readable description of this Bastion Host ID +func (id BastionHostId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Bastion Host Name: %q", id.BastionHostName), + } + return fmt.Sprintf("Bastion Host (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/id_bastionhost_test.go b/resource-manager/network/2024-07-01/bastionhosts/id_bastionhost_test.go new file mode 100644 index 00000000000..ea56e29a730 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/id_bastionhost_test.go @@ -0,0 +1,282 @@ +package bastionhosts + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BastionHostId{} + +func TestNewBastionHostID(t *testing.T) { + id := NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.BastionHostName != "bastionHostName" { + t.Fatalf("Expected %q but got %q for Segment 'BastionHostName'", id.BastionHostName, "bastionHostName") + } +} + +func TestFormatBastionHostID(t *testing.T) { + actual := NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/bastionHosts/bastionHostName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBastionHostID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BastionHostId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/bastionHosts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/bastionHosts/bastionHostName", + Expected: &BastionHostId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BastionHostName: "bastionHostName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/bastionHosts/bastionHostName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBastionHostID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BastionHostName != v.Expected.BastionHostName { + t.Fatalf("Expected %q but got %q for BastionHostName", v.Expected.BastionHostName, actual.BastionHostName) + } + + } +} + +func TestParseBastionHostIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BastionHostId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/bastionHosts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/bAsTiOnHoStS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/bastionHosts/bastionHostName", + Expected: &BastionHostId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BastionHostName: "bastionHostName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/bastionHosts/bastionHostName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/bAsTiOnHoStS/bAsTiOnHoStNaMe", + Expected: &BastionHostId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BastionHostName: "bAsTiOnHoStNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/bAsTiOnHoStS/bAsTiOnHoStNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBastionHostIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BastionHostName != v.Expected.BastionHostName { + t.Fatalf("Expected %q but got %q for BastionHostName", v.Expected.BastionHostName, actual.BastionHostName) + } + + } +} + +func TestSegmentsForBastionHostId(t *testing.T) { + segments := BastionHostId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BastionHostId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/method_createorupdate.go b/resource-manager/network/2024-07-01/bastionhosts/method_createorupdate.go new file mode 100644 index 00000000000..fe735012d1f --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/method_createorupdate.go @@ -0,0 +1,75 @@ +package bastionhosts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BastionHost +} + +// CreateOrUpdate ... +func (c BastionHostsClient) CreateOrUpdate(ctx context.Context, id BastionHostId, input BastionHost) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c BastionHostsClient) CreateOrUpdateThenPoll(ctx context.Context, id BastionHostId, input BastionHost) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/method_delete.go b/resource-manager/network/2024-07-01/bastionhosts/method_delete.go new file mode 100644 index 00000000000..5eebbeeeed3 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/method_delete.go @@ -0,0 +1,71 @@ +package bastionhosts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c BastionHostsClient) Delete(ctx context.Context, id BastionHostId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c BastionHostsClient) DeleteThenPoll(ctx context.Context, id BastionHostId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/method_deletebastionshareablelink.go b/resource-manager/network/2024-07-01/bastionhosts/method_deletebastionshareablelink.go new file mode 100644 index 00000000000..24694223a11 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/method_deletebastionshareablelink.go @@ -0,0 +1,74 @@ +package bastionhosts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteBastionShareableLinkOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBastionShareableLink ... +func (c BastionHostsClient) DeleteBastionShareableLink(ctx context.Context, id BastionHostId, input BastionShareableLinkListRequest) (result DeleteBastionShareableLinkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deleteShareableLinks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteBastionShareableLinkThenPoll performs DeleteBastionShareableLink then polls until it's completed +func (c BastionHostsClient) DeleteBastionShareableLinkThenPoll(ctx context.Context, id BastionHostId, input BastionShareableLinkListRequest) error { + result, err := c.DeleteBastionShareableLink(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DeleteBastionShareableLink: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteBastionShareableLink: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/method_deletebastionshareablelinkbytoken.go b/resource-manager/network/2024-07-01/bastionhosts/method_deletebastionshareablelinkbytoken.go new file mode 100644 index 00000000000..dd4a99222c9 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/method_deletebastionshareablelinkbytoken.go @@ -0,0 +1,73 @@ +package bastionhosts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteBastionShareableLinkByTokenOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBastionShareableLinkByToken ... +func (c BastionHostsClient) DeleteBastionShareableLinkByToken(ctx context.Context, id BastionHostId, input BastionShareableLinkTokenListRequest) (result DeleteBastionShareableLinkByTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deleteShareableLinksByToken", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteBastionShareableLinkByTokenThenPoll performs DeleteBastionShareableLinkByToken then polls until it's completed +func (c BastionHostsClient) DeleteBastionShareableLinkByTokenThenPoll(ctx context.Context, id BastionHostId, input BastionShareableLinkTokenListRequest) error { + result, err := c.DeleteBastionShareableLinkByToken(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DeleteBastionShareableLinkByToken: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteBastionShareableLinkByToken: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/method_disconnectactivesessions.go b/resource-manager/network/2024-07-01/bastionhosts/method_disconnectactivesessions.go new file mode 100644 index 00000000000..b5bf326b6c2 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/method_disconnectactivesessions.go @@ -0,0 +1,105 @@ +package bastionhosts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DisconnectActiveSessionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BastionSessionState +} + +type DisconnectActiveSessionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []BastionSessionState +} + +type DisconnectActiveSessionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *DisconnectActiveSessionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// DisconnectActiveSessions ... +func (c BastionHostsClient) DisconnectActiveSessions(ctx context.Context, id BastionHostId, input SessionIds) (result DisconnectActiveSessionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &DisconnectActiveSessionsCustomPager{}, + Path: fmt.Sprintf("%s/disconnectActiveSessions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BastionSessionState `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// DisconnectActiveSessionsComplete retrieves all the results into a single object +func (c BastionHostsClient) DisconnectActiveSessionsComplete(ctx context.Context, id BastionHostId, input SessionIds) (DisconnectActiveSessionsCompleteResult, error) { + return c.DisconnectActiveSessionsCompleteMatchingPredicate(ctx, id, input, BastionSessionStateOperationPredicate{}) +} + +// DisconnectActiveSessionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BastionHostsClient) DisconnectActiveSessionsCompleteMatchingPredicate(ctx context.Context, id BastionHostId, input SessionIds, predicate BastionSessionStateOperationPredicate) (result DisconnectActiveSessionsCompleteResult, err error) { + items := make([]BastionSessionState, 0) + + resp, err := c.DisconnectActiveSessions(ctx, id, input) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = DisconnectActiveSessionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/method_get.go b/resource-manager/network/2024-07-01/bastionhosts/method_get.go new file mode 100644 index 00000000000..7d0d6c578df --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/method_get.go @@ -0,0 +1,53 @@ +package bastionhosts + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BastionHost +} + +// Get ... +func (c BastionHostsClient) Get(ctx context.Context, id BastionHostId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BastionHost + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/method_getactivesessions.go b/resource-manager/network/2024-07-01/bastionhosts/method_getactivesessions.go new file mode 100644 index 00000000000..ef9274ebcca --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/method_getactivesessions.go @@ -0,0 +1,89 @@ +package bastionhosts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetActiveSessionsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]BastionActiveSession +} + +type GetActiveSessionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []BastionActiveSession +} + +type GetActiveSessionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetActiveSessionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetActiveSessions ... +func (c BastionHostsClient) GetActiveSessions(ctx context.Context, id BastionHostId) (result GetActiveSessionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &GetActiveSessionsCustomPager{}, + Path: fmt.Sprintf("%s/getActiveSessions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetActiveSessionsThenPoll performs GetActiveSessions then polls until it's completed +func (c BastionHostsClient) GetActiveSessionsThenPoll(ctx context.Context, id BastionHostId) error { + result, err := c.GetActiveSessions(ctx, id) + if err != nil { + return fmt.Errorf("performing GetActiveSessions: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetActiveSessions: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/method_getbastionshareablelink.go b/resource-manager/network/2024-07-01/bastionhosts/method_getbastionshareablelink.go new file mode 100644 index 00000000000..c2598119199 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/method_getbastionshareablelink.go @@ -0,0 +1,105 @@ +package bastionhosts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBastionShareableLinkOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BastionShareableLink +} + +type GetBastionShareableLinkCompleteResult struct { + LatestHttpResponse *http.Response + Items []BastionShareableLink +} + +type GetBastionShareableLinkCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetBastionShareableLinkCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetBastionShareableLink ... +func (c BastionHostsClient) GetBastionShareableLink(ctx context.Context, id BastionHostId, input BastionShareableLinkListRequest) (result GetBastionShareableLinkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &GetBastionShareableLinkCustomPager{}, + Path: fmt.Sprintf("%s/getShareableLinks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BastionShareableLink `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetBastionShareableLinkComplete retrieves all the results into a single object +func (c BastionHostsClient) GetBastionShareableLinkComplete(ctx context.Context, id BastionHostId, input BastionShareableLinkListRequest) (GetBastionShareableLinkCompleteResult, error) { + return c.GetBastionShareableLinkCompleteMatchingPredicate(ctx, id, input, BastionShareableLinkOperationPredicate{}) +} + +// GetBastionShareableLinkCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BastionHostsClient) GetBastionShareableLinkCompleteMatchingPredicate(ctx context.Context, id BastionHostId, input BastionShareableLinkListRequest, predicate BastionShareableLinkOperationPredicate) (result GetBastionShareableLinkCompleteResult, err error) { + items := make([]BastionShareableLink, 0) + + resp, err := c.GetBastionShareableLink(ctx, id, input) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetBastionShareableLinkCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/method_list.go b/resource-manager/network/2024-07-01/bastionhosts/method_list.go new file mode 100644 index 00000000000..1503bda8513 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/method_list.go @@ -0,0 +1,106 @@ +package bastionhosts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BastionHost +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []BastionHost +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c BastionHostsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/bastionHosts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BastionHost `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c BastionHostsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, BastionHostOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BastionHostsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate BastionHostOperationPredicate) (result ListCompleteResult, err error) { + items := make([]BastionHost, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/method_listbyresourcegroup.go b/resource-manager/network/2024-07-01/bastionhosts/method_listbyresourcegroup.go new file mode 100644 index 00000000000..9be179204d2 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package bastionhosts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BastionHost +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []BastionHost +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c BastionHostsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/bastionHosts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BastionHost `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c BastionHostsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, BastionHostOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BastionHostsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate BastionHostOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]BastionHost, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/method_putbastionshareablelink.go b/resource-manager/network/2024-07-01/bastionhosts/method_putbastionshareablelink.go new file mode 100644 index 00000000000..f0a53697d66 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/method_putbastionshareablelink.go @@ -0,0 +1,93 @@ +package bastionhosts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PutBastionShareableLinkOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]BastionShareableLink +} + +type PutBastionShareableLinkCompleteResult struct { + LatestHttpResponse *http.Response + Items []BastionShareableLink +} + +type PutBastionShareableLinkCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *PutBastionShareableLinkCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// PutBastionShareableLink ... +func (c BastionHostsClient) PutBastionShareableLink(ctx context.Context, id BastionHostId, input BastionShareableLinkListRequest) (result PutBastionShareableLinkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &PutBastionShareableLinkCustomPager{}, + Path: fmt.Sprintf("%s/createShareableLinks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PutBastionShareableLinkThenPoll performs PutBastionShareableLink then polls until it's completed +func (c BastionHostsClient) PutBastionShareableLinkThenPoll(ctx context.Context, id BastionHostId, input BastionShareableLinkListRequest) error { + result, err := c.PutBastionShareableLink(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PutBastionShareableLink: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PutBastionShareableLink: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/method_updatetags.go b/resource-manager/network/2024-07-01/bastionhosts/method_updatetags.go new file mode 100644 index 00000000000..697efefb0c8 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/method_updatetags.go @@ -0,0 +1,75 @@ +package bastionhosts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BastionHost +} + +// UpdateTags ... +func (c BastionHostsClient) UpdateTags(ctx context.Context, id BastionHostId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateTagsThenPoll performs UpdateTags then polls until it's completed +func (c BastionHostsClient) UpdateTagsThenPoll(ctx context.Context, id BastionHostId, input TagsObject) error { + result, err := c.UpdateTags(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UpdateTags: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpdateTags: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/model_bastionactivesession.go b/resource-manager/network/2024-07-01/bastionhosts/model_bastionactivesession.go new file mode 100644 index 00000000000..4f5fe8c844e --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/model_bastionactivesession.go @@ -0,0 +1,18 @@ +package bastionhosts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionActiveSession struct { + Protocol *BastionConnectProtocol `json:"protocol,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + SessionDurationInMins *float64 `json:"sessionDurationInMins,omitempty"` + SessionId *string `json:"sessionId,omitempty"` + StartTime *interface{} `json:"startTime,omitempty"` + TargetHostName *string `json:"targetHostName,omitempty"` + TargetIPAddress *string `json:"targetIpAddress,omitempty"` + TargetResourceGroup *string `json:"targetResourceGroup,omitempty"` + TargetResourceId *string `json:"targetResourceId,omitempty"` + TargetSubscriptionId *string `json:"targetSubscriptionId,omitempty"` + UserName *string `json:"userName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/model_bastionhost.go b/resource-manager/network/2024-07-01/bastionhosts/model_bastionhost.go new file mode 100644 index 00000000000..cdd1feb92cf --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/model_bastionhost.go @@ -0,0 +1,20 @@ +package bastionhosts + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionHost struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BastionHostPropertiesFormat `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/model_bastionhostipconfiguration.go b/resource-manager/network/2024-07-01/bastionhosts/model_bastionhostipconfiguration.go new file mode 100644 index 00000000000..efda704773c --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/model_bastionhostipconfiguration.go @@ -0,0 +1,12 @@ +package bastionhosts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionHostIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BastionHostIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/model_bastionhostipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/bastionhosts/model_bastionhostipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..f5edc766a77 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/model_bastionhostipconfigurationpropertiesformat.go @@ -0,0 +1,11 @@ +package bastionhosts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionHostIPConfigurationPropertiesFormat struct { + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *SubResource `json:"publicIPAddress,omitempty"` + Subnet SubResource `json:"subnet"` +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/model_bastionhostpropertiesformat.go b/resource-manager/network/2024-07-01/bastionhosts/model_bastionhostpropertiesformat.go new file mode 100644 index 00000000000..c560f3add55 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/model_bastionhostpropertiesformat.go @@ -0,0 +1,21 @@ +package bastionhosts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionHostPropertiesFormat struct { + DisableCopyPaste *bool `json:"disableCopyPaste,omitempty"` + DnsName *string `json:"dnsName,omitempty"` + EnableFileCopy *bool `json:"enableFileCopy,omitempty"` + EnableIPConnect *bool `json:"enableIpConnect,omitempty"` + EnableKerberos *bool `json:"enableKerberos,omitempty"` + EnablePrivateOnlyBastion *bool `json:"enablePrivateOnlyBastion,omitempty"` + EnableSessionRecording *bool `json:"enableSessionRecording,omitempty"` + EnableShareableLink *bool `json:"enableShareableLink,omitempty"` + EnableTunneling *bool `json:"enableTunneling,omitempty"` + IPConfigurations *[]BastionHostIPConfiguration `json:"ipConfigurations,omitempty"` + NetworkAcls *BastionHostPropertiesFormatNetworkAcls `json:"networkAcls,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ScaleUnits *int64 `json:"scaleUnits,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/model_bastionhostpropertiesformatnetworkacls.go b/resource-manager/network/2024-07-01/bastionhosts/model_bastionhostpropertiesformatnetworkacls.go new file mode 100644 index 00000000000..f217ff8d9ae --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/model_bastionhostpropertiesformatnetworkacls.go @@ -0,0 +1,8 @@ +package bastionhosts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionHostPropertiesFormatNetworkAcls struct { + IPRules *[]IPRule `json:"ipRules,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/model_bastionsessionstate.go b/resource-manager/network/2024-07-01/bastionhosts/model_bastionsessionstate.go new file mode 100644 index 00000000000..f60a5f77620 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/model_bastionsessionstate.go @@ -0,0 +1,10 @@ +package bastionhosts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionSessionState struct { + Message *string `json:"message,omitempty"` + SessionId *string `json:"sessionId,omitempty"` + State *string `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/model_bastionshareablelink.go b/resource-manager/network/2024-07-01/bastionhosts/model_bastionshareablelink.go new file mode 100644 index 00000000000..4da004b8f53 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/model_bastionshareablelink.go @@ -0,0 +1,11 @@ +package bastionhosts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionShareableLink struct { + Bsl *string `json:"bsl,omitempty"` + CreatedAt *string `json:"createdAt,omitempty"` + Message *string `json:"message,omitempty"` + VM Resource `json:"vm"` +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/model_bastionshareablelinklistrequest.go b/resource-manager/network/2024-07-01/bastionhosts/model_bastionshareablelinklistrequest.go new file mode 100644 index 00000000000..925995fca64 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/model_bastionshareablelinklistrequest.go @@ -0,0 +1,8 @@ +package bastionhosts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionShareableLinkListRequest struct { + VMs *[]BastionShareableLink `json:"vms,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/model_bastionshareablelinktokenlistrequest.go b/resource-manager/network/2024-07-01/bastionhosts/model_bastionshareablelinktokenlistrequest.go new file mode 100644 index 00000000000..0b7aa54ce71 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/model_bastionshareablelinktokenlistrequest.go @@ -0,0 +1,8 @@ +package bastionhosts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionShareableLinkTokenListRequest struct { + Tokens *[]string `json:"tokens,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/model_iprule.go b/resource-manager/network/2024-07-01/bastionhosts/model_iprule.go new file mode 100644 index 00000000000..a54a84aac8e --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/model_iprule.go @@ -0,0 +1,8 @@ +package bastionhosts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPRule struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/model_resource.go b/resource-manager/network/2024-07-01/bastionhosts/model_resource.go new file mode 100644 index 00000000000..17e7756ce3c --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/model_resource.go @@ -0,0 +1,12 @@ +package bastionhosts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Resource struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/model_sessionids.go b/resource-manager/network/2024-07-01/bastionhosts/model_sessionids.go new file mode 100644 index 00000000000..a74e44a3ebd --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/model_sessionids.go @@ -0,0 +1,8 @@ +package bastionhosts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SessionIds struct { + SessionIds *[]string `json:"sessionIds,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/model_sku.go b/resource-manager/network/2024-07-01/bastionhosts/model_sku.go new file mode 100644 index 00000000000..1a8a8749a46 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/model_sku.go @@ -0,0 +1,8 @@ +package bastionhosts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Name *BastionHostSkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/model_subresource.go b/resource-manager/network/2024-07-01/bastionhosts/model_subresource.go new file mode 100644 index 00000000000..7a0a23a149a --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/model_subresource.go @@ -0,0 +1,8 @@ +package bastionhosts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/model_tagsobject.go b/resource-manager/network/2024-07-01/bastionhosts/model_tagsobject.go new file mode 100644 index 00000000000..73566b88f0b --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/model_tagsobject.go @@ -0,0 +1,8 @@ +package bastionhosts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/predicates.go b/resource-manager/network/2024-07-01/bastionhosts/predicates.go new file mode 100644 index 00000000000..3c3835a32d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/predicates.go @@ -0,0 +1,141 @@ +package bastionhosts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionActiveSessionOperationPredicate struct { + ResourceType *string + SessionDurationInMins *float64 + SessionId *string + StartTime *interface{} + TargetHostName *string + TargetIPAddress *string + TargetResourceGroup *string + TargetResourceId *string + TargetSubscriptionId *string + UserName *string +} + +func (p BastionActiveSessionOperationPredicate) Matches(input BastionActiveSession) bool { + + if p.ResourceType != nil && (input.ResourceType == nil || *p.ResourceType != *input.ResourceType) { + return false + } + + if p.SessionDurationInMins != nil && (input.SessionDurationInMins == nil || *p.SessionDurationInMins != *input.SessionDurationInMins) { + return false + } + + if p.SessionId != nil && (input.SessionId == nil || *p.SessionId != *input.SessionId) { + return false + } + + if p.StartTime != nil && (input.StartTime == nil || *p.StartTime != *input.StartTime) { + return false + } + + if p.TargetHostName != nil && (input.TargetHostName == nil || *p.TargetHostName != *input.TargetHostName) { + return false + } + + if p.TargetIPAddress != nil && (input.TargetIPAddress == nil || *p.TargetIPAddress != *input.TargetIPAddress) { + return false + } + + if p.TargetResourceGroup != nil && (input.TargetResourceGroup == nil || *p.TargetResourceGroup != *input.TargetResourceGroup) { + return false + } + + if p.TargetResourceId != nil && (input.TargetResourceId == nil || *p.TargetResourceId != *input.TargetResourceId) { + return false + } + + if p.TargetSubscriptionId != nil && (input.TargetSubscriptionId == nil || *p.TargetSubscriptionId != *input.TargetSubscriptionId) { + return false + } + + if p.UserName != nil && (input.UserName == nil || *p.UserName != *input.UserName) { + return false + } + + return true +} + +type BastionHostOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p BastionHostOperationPredicate) Matches(input BastionHost) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type BastionSessionStateOperationPredicate struct { + Message *string + SessionId *string + State *string +} + +func (p BastionSessionStateOperationPredicate) Matches(input BastionSessionState) bool { + + if p.Message != nil && (input.Message == nil || *p.Message != *input.Message) { + return false + } + + if p.SessionId != nil && (input.SessionId == nil || *p.SessionId != *input.SessionId) { + return false + } + + if p.State != nil && (input.State == nil || *p.State != *input.State) { + return false + } + + return true +} + +type BastionShareableLinkOperationPredicate struct { + Bsl *string + CreatedAt *string + Message *string +} + +func (p BastionShareableLinkOperationPredicate) Matches(input BastionShareableLink) bool { + + if p.Bsl != nil && (input.Bsl == nil || *p.Bsl != *input.Bsl) { + return false + } + + if p.CreatedAt != nil && (input.CreatedAt == nil || *p.CreatedAt != *input.CreatedAt) { + return false + } + + if p.Message != nil && (input.Message == nil || *p.Message != *input.Message) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/bastionhosts/version.go b/resource-manager/network/2024-07-01/bastionhosts/version.go new file mode 100644 index 00000000000..e37b3719dce --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionhosts/version.go @@ -0,0 +1,10 @@ +package bastionhosts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/bastionhosts/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/bastionshareablelink/README.md b/resource-manager/network/2024-07-01/bastionshareablelink/README.md new file mode 100644 index 00000000000..a9908224918 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionshareablelink/README.md @@ -0,0 +1,98 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/bastionshareablelink` Documentation + +The `bastionshareablelink` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/bastionshareablelink" +``` + + +### Client Initialization + +```go +client := bastionshareablelink.NewBastionShareableLinkClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BastionShareableLinkClient.DeleteBastionShareableLink` + +```go +ctx := context.TODO() +id := bastionshareablelink.NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName") + +payload := bastionshareablelink.BastionShareableLinkListRequest{ + // ... +} + + +if err := client.DeleteBastionShareableLinkThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BastionShareableLinkClient.DeleteBastionShareableLinkByToken` + +```go +ctx := context.TODO() +id := bastionshareablelink.NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName") + +payload := bastionshareablelink.BastionShareableLinkTokenListRequest{ + // ... +} + + +if err := client.DeleteBastionShareableLinkByTokenThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BastionShareableLinkClient.GetBastionShareableLink` + +```go +ctx := context.TODO() +id := bastionshareablelink.NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName") + +payload := bastionshareablelink.BastionShareableLinkListRequest{ + // ... +} + + +// alternatively `client.GetBastionShareableLink(ctx, id, payload)` can be used to do batched pagination +items, err := client.GetBastionShareableLinkComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `BastionShareableLinkClient.PutBastionShareableLink` + +```go +ctx := context.TODO() +id := bastionshareablelink.NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName") + +payload := bastionshareablelink.BastionShareableLinkListRequest{ + // ... +} + + +// alternatively `client.PutBastionShareableLink(ctx, id, payload)` can be used to do batched pagination +items, err := client.PutBastionShareableLinkComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/bastionshareablelink/client.go b/resource-manager/network/2024-07-01/bastionshareablelink/client.go new file mode 100644 index 00000000000..39fc8e4cbdd --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionshareablelink/client.go @@ -0,0 +1,26 @@ +package bastionshareablelink + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionShareableLinkClient struct { + Client *resourcemanager.Client +} + +func NewBastionShareableLinkClientWithBaseURI(sdkApi sdkEnv.Api) (*BastionShareableLinkClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "bastionshareablelink", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BastionShareableLinkClient: %+v", err) + } + + return &BastionShareableLinkClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/bastionshareablelink/id_bastionhost.go b/resource-manager/network/2024-07-01/bastionshareablelink/id_bastionhost.go new file mode 100644 index 00000000000..dbb59b63996 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionshareablelink/id_bastionhost.go @@ -0,0 +1,130 @@ +package bastionshareablelink + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BastionHostId{}) +} + +var _ resourceids.ResourceId = &BastionHostId{} + +// BastionHostId is a struct representing the Resource ID for a Bastion Host +type BastionHostId struct { + SubscriptionId string + ResourceGroupName string + BastionHostName string +} + +// NewBastionHostID returns a new BastionHostId struct +func NewBastionHostID(subscriptionId string, resourceGroupName string, bastionHostName string) BastionHostId { + return BastionHostId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + BastionHostName: bastionHostName, + } +} + +// ParseBastionHostID parses 'input' into a BastionHostId +func ParseBastionHostID(input string) (*BastionHostId, error) { + parser := resourceids.NewParserFromResourceIdType(&BastionHostId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BastionHostId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBastionHostIDInsensitively parses 'input' case-insensitively into a BastionHostId +// note: this method should only be used for API response data and not user input +func ParseBastionHostIDInsensitively(input string) (*BastionHostId, error) { + parser := resourceids.NewParserFromResourceIdType(&BastionHostId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BastionHostId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BastionHostId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.BastionHostName, ok = input.Parsed["bastionHostName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "bastionHostName", input) + } + + return nil +} + +// ValidateBastionHostID checks that 'input' can be parsed as a Bastion Host ID +func ValidateBastionHostID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBastionHostID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Bastion Host ID +func (id BastionHostId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/bastionHosts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.BastionHostName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Bastion Host ID +func (id BastionHostId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticBastionHosts", "bastionHosts", "bastionHosts"), + resourceids.UserSpecifiedSegment("bastionHostName", "bastionHostName"), + } +} + +// String returns a human-readable description of this Bastion Host ID +func (id BastionHostId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Bastion Host Name: %q", id.BastionHostName), + } + return fmt.Sprintf("Bastion Host (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/bastionshareablelink/id_bastionhost_test.go b/resource-manager/network/2024-07-01/bastionshareablelink/id_bastionhost_test.go new file mode 100644 index 00000000000..ebfcf72e735 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionshareablelink/id_bastionhost_test.go @@ -0,0 +1,282 @@ +package bastionshareablelink + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BastionHostId{} + +func TestNewBastionHostID(t *testing.T) { + id := NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.BastionHostName != "bastionHostName" { + t.Fatalf("Expected %q but got %q for Segment 'BastionHostName'", id.BastionHostName, "bastionHostName") + } +} + +func TestFormatBastionHostID(t *testing.T) { + actual := NewBastionHostID("12345678-1234-9876-4563-123456789012", "example-resource-group", "bastionHostName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/bastionHosts/bastionHostName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBastionHostID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BastionHostId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/bastionHosts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/bastionHosts/bastionHostName", + Expected: &BastionHostId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BastionHostName: "bastionHostName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/bastionHosts/bastionHostName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBastionHostID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BastionHostName != v.Expected.BastionHostName { + t.Fatalf("Expected %q but got %q for BastionHostName", v.Expected.BastionHostName, actual.BastionHostName) + } + + } +} + +func TestParseBastionHostIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BastionHostId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/bastionHosts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/bAsTiOnHoStS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/bastionHosts/bastionHostName", + Expected: &BastionHostId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + BastionHostName: "bastionHostName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/bastionHosts/bastionHostName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/bAsTiOnHoStS/bAsTiOnHoStNaMe", + Expected: &BastionHostId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + BastionHostName: "bAsTiOnHoStNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/bAsTiOnHoStS/bAsTiOnHoStNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBastionHostIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.BastionHostName != v.Expected.BastionHostName { + t.Fatalf("Expected %q but got %q for BastionHostName", v.Expected.BastionHostName, actual.BastionHostName) + } + + } +} + +func TestSegmentsForBastionHostId(t *testing.T) { + segments := BastionHostId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BastionHostId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/bastionshareablelink/method_deletebastionshareablelink.go b/resource-manager/network/2024-07-01/bastionshareablelink/method_deletebastionshareablelink.go new file mode 100644 index 00000000000..6b46bbc5fea --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionshareablelink/method_deletebastionshareablelink.go @@ -0,0 +1,74 @@ +package bastionshareablelink + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteBastionShareableLinkOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBastionShareableLink ... +func (c BastionShareableLinkClient) DeleteBastionShareableLink(ctx context.Context, id BastionHostId, input BastionShareableLinkListRequest) (result DeleteBastionShareableLinkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deleteShareableLinks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteBastionShareableLinkThenPoll performs DeleteBastionShareableLink then polls until it's completed +func (c BastionShareableLinkClient) DeleteBastionShareableLinkThenPoll(ctx context.Context, id BastionHostId, input BastionShareableLinkListRequest) error { + result, err := c.DeleteBastionShareableLink(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DeleteBastionShareableLink: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteBastionShareableLink: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/bastionshareablelink/method_deletebastionshareablelinkbytoken.go b/resource-manager/network/2024-07-01/bastionshareablelink/method_deletebastionshareablelinkbytoken.go new file mode 100644 index 00000000000..f2973cf1c92 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionshareablelink/method_deletebastionshareablelinkbytoken.go @@ -0,0 +1,73 @@ +package bastionshareablelink + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteBastionShareableLinkByTokenOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBastionShareableLinkByToken ... +func (c BastionShareableLinkClient) DeleteBastionShareableLinkByToken(ctx context.Context, id BastionHostId, input BastionShareableLinkTokenListRequest) (result DeleteBastionShareableLinkByTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deleteShareableLinksByToken", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteBastionShareableLinkByTokenThenPoll performs DeleteBastionShareableLinkByToken then polls until it's completed +func (c BastionShareableLinkClient) DeleteBastionShareableLinkByTokenThenPoll(ctx context.Context, id BastionHostId, input BastionShareableLinkTokenListRequest) error { + result, err := c.DeleteBastionShareableLinkByToken(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DeleteBastionShareableLinkByToken: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteBastionShareableLinkByToken: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/bastionshareablelink/method_getbastionshareablelink.go b/resource-manager/network/2024-07-01/bastionshareablelink/method_getbastionshareablelink.go new file mode 100644 index 00000000000..2c1e9c470aa --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionshareablelink/method_getbastionshareablelink.go @@ -0,0 +1,105 @@ +package bastionshareablelink + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBastionShareableLinkOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BastionShareableLink +} + +type GetBastionShareableLinkCompleteResult struct { + LatestHttpResponse *http.Response + Items []BastionShareableLink +} + +type GetBastionShareableLinkCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetBastionShareableLinkCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetBastionShareableLink ... +func (c BastionShareableLinkClient) GetBastionShareableLink(ctx context.Context, id BastionHostId, input BastionShareableLinkListRequest) (result GetBastionShareableLinkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &GetBastionShareableLinkCustomPager{}, + Path: fmt.Sprintf("%s/getShareableLinks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BastionShareableLink `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetBastionShareableLinkComplete retrieves all the results into a single object +func (c BastionShareableLinkClient) GetBastionShareableLinkComplete(ctx context.Context, id BastionHostId, input BastionShareableLinkListRequest) (GetBastionShareableLinkCompleteResult, error) { + return c.GetBastionShareableLinkCompleteMatchingPredicate(ctx, id, input, BastionShareableLinkOperationPredicate{}) +} + +// GetBastionShareableLinkCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BastionShareableLinkClient) GetBastionShareableLinkCompleteMatchingPredicate(ctx context.Context, id BastionHostId, input BastionShareableLinkListRequest, predicate BastionShareableLinkOperationPredicate) (result GetBastionShareableLinkCompleteResult, err error) { + items := make([]BastionShareableLink, 0) + + resp, err := c.GetBastionShareableLink(ctx, id, input) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetBastionShareableLinkCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/bastionshareablelink/method_putbastionshareablelink.go b/resource-manager/network/2024-07-01/bastionshareablelink/method_putbastionshareablelink.go new file mode 100644 index 00000000000..7c6c9a0cd1d --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionshareablelink/method_putbastionshareablelink.go @@ -0,0 +1,93 @@ +package bastionshareablelink + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PutBastionShareableLinkOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]BastionShareableLink +} + +type PutBastionShareableLinkCompleteResult struct { + LatestHttpResponse *http.Response + Items []BastionShareableLink +} + +type PutBastionShareableLinkCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *PutBastionShareableLinkCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// PutBastionShareableLink ... +func (c BastionShareableLinkClient) PutBastionShareableLink(ctx context.Context, id BastionHostId, input BastionShareableLinkListRequest) (result PutBastionShareableLinkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &PutBastionShareableLinkCustomPager{}, + Path: fmt.Sprintf("%s/createShareableLinks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PutBastionShareableLinkThenPoll performs PutBastionShareableLink then polls until it's completed +func (c BastionShareableLinkClient) PutBastionShareableLinkThenPoll(ctx context.Context, id BastionHostId, input BastionShareableLinkListRequest) error { + result, err := c.PutBastionShareableLink(ctx, id, input) + if err != nil { + return fmt.Errorf("performing PutBastionShareableLink: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after PutBastionShareableLink: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/bastionshareablelink/model_bastionshareablelink.go b/resource-manager/network/2024-07-01/bastionshareablelink/model_bastionshareablelink.go new file mode 100644 index 00000000000..a0bc0647825 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionshareablelink/model_bastionshareablelink.go @@ -0,0 +1,11 @@ +package bastionshareablelink + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionShareableLink struct { + Bsl *string `json:"bsl,omitempty"` + CreatedAt *string `json:"createdAt,omitempty"` + Message *string `json:"message,omitempty"` + VM Resource `json:"vm"` +} diff --git a/resource-manager/network/2024-07-01/bastionshareablelink/model_bastionshareablelinklistrequest.go b/resource-manager/network/2024-07-01/bastionshareablelink/model_bastionshareablelinklistrequest.go new file mode 100644 index 00000000000..e41fcb083d8 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionshareablelink/model_bastionshareablelinklistrequest.go @@ -0,0 +1,8 @@ +package bastionshareablelink + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionShareableLinkListRequest struct { + VMs *[]BastionShareableLink `json:"vms,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bastionshareablelink/model_bastionshareablelinktokenlistrequest.go b/resource-manager/network/2024-07-01/bastionshareablelink/model_bastionshareablelinktokenlistrequest.go new file mode 100644 index 00000000000..10d868903d8 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionshareablelink/model_bastionshareablelinktokenlistrequest.go @@ -0,0 +1,8 @@ +package bastionshareablelink + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionShareableLinkTokenListRequest struct { + Tokens *[]string `json:"tokens,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bastionshareablelink/model_resource.go b/resource-manager/network/2024-07-01/bastionshareablelink/model_resource.go new file mode 100644 index 00000000000..31d5ef85703 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionshareablelink/model_resource.go @@ -0,0 +1,12 @@ +package bastionshareablelink + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Resource struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bastionshareablelink/predicates.go b/resource-manager/network/2024-07-01/bastionshareablelink/predicates.go new file mode 100644 index 00000000000..15f07095262 --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionshareablelink/predicates.go @@ -0,0 +1,27 @@ +package bastionshareablelink + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BastionShareableLinkOperationPredicate struct { + Bsl *string + CreatedAt *string + Message *string +} + +func (p BastionShareableLinkOperationPredicate) Matches(input BastionShareableLink) bool { + + if p.Bsl != nil && (input.Bsl == nil || *p.Bsl != *input.Bsl) { + return false + } + + if p.CreatedAt != nil && (input.CreatedAt == nil || *p.CreatedAt != *input.CreatedAt) { + return false + } + + if p.Message != nil && (input.Message == nil || *p.Message != *input.Message) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/bastionshareablelink/version.go b/resource-manager/network/2024-07-01/bastionshareablelink/version.go new file mode 100644 index 00000000000..e949ef4172a --- /dev/null +++ b/resource-manager/network/2024-07-01/bastionshareablelink/version.go @@ -0,0 +1,10 @@ +package bastionshareablelink + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/bastionshareablelink/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/bgpservicecommunities/README.md b/resource-manager/network/2024-07-01/bgpservicecommunities/README.md new file mode 100644 index 00000000000..1db814957c9 --- /dev/null +++ b/resource-manager/network/2024-07-01/bgpservicecommunities/README.md @@ -0,0 +1,38 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/bgpservicecommunities` Documentation + +The `bgpservicecommunities` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/bgpservicecommunities" +``` + + +### Client Initialization + +```go +client := bgpservicecommunities.NewBgpServiceCommunitiesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BgpServiceCommunitiesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/bgpservicecommunities/client.go b/resource-manager/network/2024-07-01/bgpservicecommunities/client.go new file mode 100644 index 00000000000..0fbe7d0bd51 --- /dev/null +++ b/resource-manager/network/2024-07-01/bgpservicecommunities/client.go @@ -0,0 +1,26 @@ +package bgpservicecommunities + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BgpServiceCommunitiesClient struct { + Client *resourcemanager.Client +} + +func NewBgpServiceCommunitiesClientWithBaseURI(sdkApi sdkEnv.Api) (*BgpServiceCommunitiesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "bgpservicecommunities", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BgpServiceCommunitiesClient: %+v", err) + } + + return &BgpServiceCommunitiesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/bgpservicecommunities/method_list.go b/resource-manager/network/2024-07-01/bgpservicecommunities/method_list.go new file mode 100644 index 00000000000..633bcf897cf --- /dev/null +++ b/resource-manager/network/2024-07-01/bgpservicecommunities/method_list.go @@ -0,0 +1,106 @@ +package bgpservicecommunities + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BgpServiceCommunity +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []BgpServiceCommunity +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c BgpServiceCommunitiesClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/bgpServiceCommunities", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BgpServiceCommunity `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c BgpServiceCommunitiesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, BgpServiceCommunityOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BgpServiceCommunitiesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate BgpServiceCommunityOperationPredicate) (result ListCompleteResult, err error) { + items := make([]BgpServiceCommunity, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/bgpservicecommunities/model_bgpcommunity.go b/resource-manager/network/2024-07-01/bgpservicecommunities/model_bgpcommunity.go new file mode 100644 index 00000000000..87cd63647eb --- /dev/null +++ b/resource-manager/network/2024-07-01/bgpservicecommunities/model_bgpcommunity.go @@ -0,0 +1,13 @@ +package bgpservicecommunities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BGPCommunity struct { + CommunityName *string `json:"communityName,omitempty"` + CommunityPrefixes *[]string `json:"communityPrefixes,omitempty"` + CommunityValue *string `json:"communityValue,omitempty"` + IsAuthorizedToUse *bool `json:"isAuthorizedToUse,omitempty"` + ServiceGroup *string `json:"serviceGroup,omitempty"` + ServiceSupportedRegion *string `json:"serviceSupportedRegion,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bgpservicecommunities/model_bgpservicecommunity.go b/resource-manager/network/2024-07-01/bgpservicecommunities/model_bgpservicecommunity.go new file mode 100644 index 00000000000..0fad9ca63e5 --- /dev/null +++ b/resource-manager/network/2024-07-01/bgpservicecommunities/model_bgpservicecommunity.go @@ -0,0 +1,13 @@ +package bgpservicecommunities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BgpServiceCommunity struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BgpServiceCommunityPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bgpservicecommunities/model_bgpservicecommunitypropertiesformat.go b/resource-manager/network/2024-07-01/bgpservicecommunities/model_bgpservicecommunitypropertiesformat.go new file mode 100644 index 00000000000..5bf2c270ecc --- /dev/null +++ b/resource-manager/network/2024-07-01/bgpservicecommunities/model_bgpservicecommunitypropertiesformat.go @@ -0,0 +1,9 @@ +package bgpservicecommunities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BgpServiceCommunityPropertiesFormat struct { + BgpCommunities *[]BGPCommunity `json:"bgpCommunities,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/bgpservicecommunities/predicates.go b/resource-manager/network/2024-07-01/bgpservicecommunities/predicates.go new file mode 100644 index 00000000000..2e90f55ae55 --- /dev/null +++ b/resource-manager/network/2024-07-01/bgpservicecommunities/predicates.go @@ -0,0 +1,32 @@ +package bgpservicecommunities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BgpServiceCommunityOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p BgpServiceCommunityOperationPredicate) Matches(input BgpServiceCommunity) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/bgpservicecommunities/version.go b/resource-manager/network/2024-07-01/bgpservicecommunities/version.go new file mode 100644 index 00000000000..bcb90d0caae --- /dev/null +++ b/resource-manager/network/2024-07-01/bgpservicecommunities/version.go @@ -0,0 +1,10 @@ +package bgpservicecommunities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/bgpservicecommunities/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/checkdnsavailabilities/README.md b/resource-manager/network/2024-07-01/checkdnsavailabilities/README.md new file mode 100644 index 00000000000..572e66cf08b --- /dev/null +++ b/resource-manager/network/2024-07-01/checkdnsavailabilities/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/checkdnsavailabilities` Documentation + +The `checkdnsavailabilities` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/checkdnsavailabilities" +``` + + +### Client Initialization + +```go +client := checkdnsavailabilities.NewCheckDnsAvailabilitiesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CheckDnsAvailabilitiesClient.CheckDnsNameAvailability` + +```go +ctx := context.TODO() +id := checkdnsavailabilities.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +read, err := client.CheckDnsNameAvailability(ctx, id, checkdnsavailabilities.DefaultCheckDnsNameAvailabilityOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/checkdnsavailabilities/client.go b/resource-manager/network/2024-07-01/checkdnsavailabilities/client.go new file mode 100644 index 00000000000..3641ce2ee39 --- /dev/null +++ b/resource-manager/network/2024-07-01/checkdnsavailabilities/client.go @@ -0,0 +1,26 @@ +package checkdnsavailabilities + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckDnsAvailabilitiesClient struct { + Client *resourcemanager.Client +} + +func NewCheckDnsAvailabilitiesClientWithBaseURI(sdkApi sdkEnv.Api) (*CheckDnsAvailabilitiesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "checkdnsavailabilities", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CheckDnsAvailabilitiesClient: %+v", err) + } + + return &CheckDnsAvailabilitiesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/checkdnsavailabilities/id_location.go b/resource-manager/network/2024-07-01/checkdnsavailabilities/id_location.go new file mode 100644 index 00000000000..e9c60b3adaf --- /dev/null +++ b/resource-manager/network/2024-07-01/checkdnsavailabilities/id_location.go @@ -0,0 +1,121 @@ +package checkdnsavailabilities + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Network/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/checkdnsavailabilities/id_location_test.go b/resource-manager/network/2024-07-01/checkdnsavailabilities/id_location_test.go new file mode 100644 index 00000000000..7d13e412f40 --- /dev/null +++ b/resource-manager/network/2024-07-01/checkdnsavailabilities/id_location_test.go @@ -0,0 +1,237 @@ +package checkdnsavailabilities + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/checkdnsavailabilities/method_checkdnsnameavailability.go b/resource-manager/network/2024-07-01/checkdnsavailabilities/method_checkdnsnameavailability.go new file mode 100644 index 00000000000..aa291abadeb --- /dev/null +++ b/resource-manager/network/2024-07-01/checkdnsavailabilities/method_checkdnsnameavailability.go @@ -0,0 +1,83 @@ +package checkdnsavailabilities + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckDnsNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DnsNameAvailabilityResult +} + +type CheckDnsNameAvailabilityOperationOptions struct { + DomainNameLabel *string +} + +func DefaultCheckDnsNameAvailabilityOperationOptions() CheckDnsNameAvailabilityOperationOptions { + return CheckDnsNameAvailabilityOperationOptions{} +} + +func (o CheckDnsNameAvailabilityOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CheckDnsNameAvailabilityOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CheckDnsNameAvailabilityOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DomainNameLabel != nil { + out.Append("domainNameLabel", fmt.Sprintf("%v", *o.DomainNameLabel)) + } + return &out +} + +// CheckDnsNameAvailability ... +func (c CheckDnsAvailabilitiesClient) CheckDnsNameAvailability(ctx context.Context, id LocationId, options CheckDnsNameAvailabilityOperationOptions) (result CheckDnsNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/checkDnsNameAvailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DnsNameAvailabilityResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/checkdnsavailabilities/model_dnsnameavailabilityresult.go b/resource-manager/network/2024-07-01/checkdnsavailabilities/model_dnsnameavailabilityresult.go new file mode 100644 index 00000000000..e12398a149f --- /dev/null +++ b/resource-manager/network/2024-07-01/checkdnsavailabilities/model_dnsnameavailabilityresult.go @@ -0,0 +1,8 @@ +package checkdnsavailabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DnsNameAvailabilityResult struct { + Available *bool `json:"available,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/checkdnsavailabilities/version.go b/resource-manager/network/2024-07-01/checkdnsavailabilities/version.go new file mode 100644 index 00000000000..5bdb02d5994 --- /dev/null +++ b/resource-manager/network/2024-07-01/checkdnsavailabilities/version.go @@ -0,0 +1,10 @@ +package checkdnsavailabilities + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/checkdnsavailabilities/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/client.go b/resource-manager/network/2024-07-01/client.go new file mode 100644 index 00000000000..a9853f5f350 --- /dev/null +++ b/resource-manager/network/2024-07-01/client.go @@ -0,0 +1,1153 @@ +package v2024_07_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/adminrulecollections" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/adminrules" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/applicationgatewayprivateendpointconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/applicationgatewayprivatelinkresources" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/applicationgateways" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/applicationgatewaywafdynamicmanifests" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/applicationsecuritygroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/availabledelegations" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/availableservicealiases" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/azurefirewalls" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/bastionhosts" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/bastionshareablelink" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/bgpservicecommunities" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/checkdnsavailabilities" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/cloudservicepublicipaddresses" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/connectionmonitors" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/connectivityconfigurations" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/customipprefixes" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/ddoscustompolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/ddosprotectionplans" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/dscpconfiguration" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/dscpconfigurations" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/endpointservices" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitarptable" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitauthorizations" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitpeerings" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitroutestable" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuits" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitstats" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecrossconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutegateways" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutelinks" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteportauthorizations" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteports" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteportslocations" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteproviderports" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteserviceproviders" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/firewallpolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/flowlogs" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/ipallocations" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/ipampools" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/ipgroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/loadbalancers" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/localnetworkgateways" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/natgateways" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkgroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkinterfaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanageractiveconfigurations" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanagerconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanagers" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkprofiles" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecuritygroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterassociations" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterlinks" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterprofiles" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeters" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkvirtualappliances" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkwatchers" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/p2svpngateways" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/packetcaptures" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/privatednszonegroups" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/privateendpoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/privatelinkservices" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/publicipaddresses" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/publicipprefixes" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/reachabilityanalysisintent" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/reachabilityanalysisintents" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/reachabilityanalysisruns" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routefilterrules" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routefilters" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routes" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routetables" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routingrulecollections" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routingrules" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/scopeconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securityadminconfigurations" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securitypartnerproviders" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securityrules" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securityuserconfigurations" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securityuserrulecollections" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securityuserrules" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/serviceendpointpolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/servicetags" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/staticcidrs" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/staticmembers" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/subnets" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/trafficanalytics" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/usages" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/verifierworkspaces" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/vipswap" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualappliancesites" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualapplianceskus" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworkgateways" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworkpeerings" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworks" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworktap" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworktaps" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualrouterpeerings" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualrouters" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualwans" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/vmsspublicipaddresses" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/vpngateways" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/vpnlinkconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/vpnserverconfigurations" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/vpnsites" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/webapplicationfirewallpolicies" + "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/webcategories" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AdminRuleCollections *adminrulecollections.AdminRuleCollectionsClient + AdminRules *adminrules.AdminRulesClient + ApplicationGatewayPrivateEndpointConnections *applicationgatewayprivateendpointconnections.ApplicationGatewayPrivateEndpointConnectionsClient + ApplicationGatewayPrivateLinkResources *applicationgatewayprivatelinkresources.ApplicationGatewayPrivateLinkResourcesClient + ApplicationGatewayWafDynamicManifests *applicationgatewaywafdynamicmanifests.ApplicationGatewayWafDynamicManifestsClient + ApplicationGateways *applicationgateways.ApplicationGatewaysClient + ApplicationSecurityGroups *applicationsecuritygroups.ApplicationSecurityGroupsClient + AvailableDelegations *availabledelegations.AvailableDelegationsClient + AvailableServiceAliases *availableservicealiases.AvailableServiceAliasesClient + AzureFirewalls *azurefirewalls.AzureFirewallsClient + BastionHosts *bastionhosts.BastionHostsClient + BastionShareableLink *bastionshareablelink.BastionShareableLinkClient + BgpServiceCommunities *bgpservicecommunities.BgpServiceCommunitiesClient + CheckDnsAvailabilities *checkdnsavailabilities.CheckDnsAvailabilitiesClient + CloudServicePublicIPAddresses *cloudservicepublicipaddresses.CloudServicePublicIPAddressesClient + ConnectionMonitors *connectionmonitors.ConnectionMonitorsClient + ConnectivityConfigurations *connectivityconfigurations.ConnectivityConfigurationsClient + CustomIPPrefixes *customipprefixes.CustomIPPrefixesClient + DdosCustomPolicies *ddoscustompolicies.DdosCustomPoliciesClient + DdosProtectionPlans *ddosprotectionplans.DdosProtectionPlansClient + DscpConfiguration *dscpconfiguration.DscpConfigurationClient + DscpConfigurations *dscpconfigurations.DscpConfigurationsClient + EndpointServices *endpointservices.EndpointServicesClient + ExpressRouteCircuitArpTable *expressroutecircuitarptable.ExpressRouteCircuitArpTableClient + ExpressRouteCircuitAuthorizations *expressroutecircuitauthorizations.ExpressRouteCircuitAuthorizationsClient + ExpressRouteCircuitConnections *expressroutecircuitconnections.ExpressRouteCircuitConnectionsClient + ExpressRouteCircuitPeerings *expressroutecircuitpeerings.ExpressRouteCircuitPeeringsClient + ExpressRouteCircuitRoutesTable *expressroutecircuitroutestable.ExpressRouteCircuitRoutesTableClient + ExpressRouteCircuitRoutesTableSummary *expressroutecircuitroutestablesummary.ExpressRouteCircuitRoutesTableSummaryClient + ExpressRouteCircuitStats *expressroutecircuitstats.ExpressRouteCircuitStatsClient + ExpressRouteCircuits *expressroutecircuits.ExpressRouteCircuitsClient + ExpressRouteConnections *expressrouteconnections.ExpressRouteConnectionsClient + ExpressRouteCrossConnectionArpTable *expressroutecrossconnectionarptable.ExpressRouteCrossConnectionArpTableClient + ExpressRouteCrossConnectionPeerings *expressroutecrossconnectionpeerings.ExpressRouteCrossConnectionPeeringsClient + ExpressRouteCrossConnectionRouteTable *expressroutecrossconnectionroutetable.ExpressRouteCrossConnectionRouteTableClient + ExpressRouteCrossConnectionRouteTableSummary *expressroutecrossconnectionroutetablesummary.ExpressRouteCrossConnectionRouteTableSummaryClient + ExpressRouteCrossConnections *expressroutecrossconnections.ExpressRouteCrossConnectionsClient + ExpressRouteGateways *expressroutegateways.ExpressRouteGatewaysClient + ExpressRouteLinks *expressroutelinks.ExpressRouteLinksClient + ExpressRoutePortAuthorizations *expressrouteportauthorizations.ExpressRoutePortAuthorizationsClient + ExpressRoutePorts *expressrouteports.ExpressRoutePortsClient + ExpressRoutePortsLocations *expressrouteportslocations.ExpressRoutePortsLocationsClient + ExpressRouteProviderPorts *expressrouteproviderports.ExpressRouteProviderPortsClient + ExpressRouteServiceProviders *expressrouteserviceproviders.ExpressRouteServiceProvidersClient + FirewallPolicies *firewallpolicies.FirewallPoliciesClient + FirewallPolicyRuleCollectionGroups *firewallpolicyrulecollectiongroups.FirewallPolicyRuleCollectionGroupsClient + FlowLogs *flowlogs.FlowLogsClient + IPAllocations *ipallocations.IPAllocationsClient + IPGroups *ipgroups.IPGroupsClient + IPamPools *ipampools.IPamPoolsClient + LoadBalancers *loadbalancers.LoadBalancersClient + LocalNetworkGateways *localnetworkgateways.LocalNetworkGatewaysClient + NatGateways *natgateways.NatGatewaysClient + NetworkGroups *networkgroups.NetworkGroupsClient + NetworkInterfaces *networkinterfaces.NetworkInterfacesClient + NetworkManagerActiveConfigurations *networkmanageractiveconfigurations.NetworkManagerActiveConfigurationsClient + NetworkManagerActiveConnectivityConfigurations *networkmanageractiveconnectivityconfigurations.NetworkManagerActiveConnectivityConfigurationsClient + NetworkManagerConnections *networkmanagerconnections.NetworkManagerConnectionsClient + NetworkManagerEffectiveConnectivityConfiguration *networkmanagereffectiveconnectivityconfiguration.NetworkManagerEffectiveConnectivityConfigurationClient + NetworkManagerEffectiveSecurityAdminRules *networkmanagereffectivesecurityadminrules.NetworkManagerEffectiveSecurityAdminRulesClient + NetworkManagerRoutingConfigurations *networkmanagerroutingconfigurations.NetworkManagerRoutingConfigurationsClient + NetworkManagers *networkmanagers.NetworkManagersClient + NetworkProfiles *networkprofiles.NetworkProfilesClient + NetworkSecurityGroups *networksecuritygroups.NetworkSecurityGroupsClient + NetworkSecurityPerimeterAccessRules *networksecurityperimeteraccessrules.NetworkSecurityPerimeterAccessRulesClient + NetworkSecurityPerimeterAssociableResourceTypes *networksecurityperimeterassociableresourcetypes.NetworkSecurityPerimeterAssociableResourceTypesClient + NetworkSecurityPerimeterAssociations *networksecurityperimeterassociations.NetworkSecurityPerimeterAssociationsClient + NetworkSecurityPerimeterLinkReferences *networksecurityperimeterlinkreferences.NetworkSecurityPerimeterLinkReferencesClient + NetworkSecurityPerimeterLinks *networksecurityperimeterlinks.NetworkSecurityPerimeterLinksClient + NetworkSecurityPerimeterLoggingConfigurations *networksecurityperimeterloggingconfigurations.NetworkSecurityPerimeterLoggingConfigurationsClient + NetworkSecurityPerimeterProfiles *networksecurityperimeterprofiles.NetworkSecurityPerimeterProfilesClient + NetworkSecurityPerimeters *networksecurityperimeters.NetworkSecurityPerimetersClient + NetworkVirtualAppliances *networkvirtualappliances.NetworkVirtualAppliancesClient + NetworkWatchers *networkwatchers.NetworkWatchersClient + P2sVpnGateways *p2svpngateways.P2sVpnGatewaysClient + PacketCaptures *packetcaptures.PacketCapturesClient + PeerExpressRouteCircuitConnections *peerexpressroutecircuitconnections.PeerExpressRouteCircuitConnectionsClient + PrivateDnsZoneGroups *privatednszonegroups.PrivateDnsZoneGroupsClient + PrivateEndpoints *privateendpoints.PrivateEndpointsClient + PrivateLinkServices *privatelinkservices.PrivateLinkServicesClient + PublicIPAddresses *publicipaddresses.PublicIPAddressesClient + PublicIPPrefixes *publicipprefixes.PublicIPPrefixesClient + ReachabilityAnalysisIntent *reachabilityanalysisintent.ReachabilityAnalysisIntentClient + ReachabilityAnalysisIntents *reachabilityanalysisintents.ReachabilityAnalysisIntentsClient + ReachabilityAnalysisRuns *reachabilityanalysisruns.ReachabilityAnalysisRunsClient + RouteFilterRules *routefilterrules.RouteFilterRulesClient + RouteFilters *routefilters.RouteFiltersClient + RouteTables *routetables.RouteTablesClient + Routes *routes.RoutesClient + RoutingRuleCollections *routingrulecollections.RoutingRuleCollectionsClient + RoutingRules *routingrules.RoutingRulesClient + ScopeConnections *scopeconnections.ScopeConnectionsClient + SecurityAdminConfigurations *securityadminconfigurations.SecurityAdminConfigurationsClient + SecurityPartnerProviders *securitypartnerproviders.SecurityPartnerProvidersClient + SecurityRules *securityrules.SecurityRulesClient + SecurityUserConfigurations *securityuserconfigurations.SecurityUserConfigurationsClient + SecurityUserRuleCollections *securityuserrulecollections.SecurityUserRuleCollectionsClient + SecurityUserRules *securityuserrules.SecurityUserRulesClient + ServiceEndpointPolicies *serviceendpointpolicies.ServiceEndpointPoliciesClient + ServiceEndpointPolicyDefinitions *serviceendpointpolicydefinitions.ServiceEndpointPolicyDefinitionsClient + ServiceTags *servicetags.ServiceTagsClient + StaticCidrs *staticcidrs.StaticCidrsClient + StaticMembers *staticmembers.StaticMembersClient + Subnets *subnets.SubnetsClient + TrafficAnalytics *trafficanalytics.TrafficAnalyticsClient + Usages *usages.UsagesClient + VMSSPublicIPAddresses *vmsspublicipaddresses.VMSSPublicIPAddressesClient + VerifierWorkspaces *verifierworkspaces.VerifierWorkspacesClient + VipSwap *vipswap.VipSwapClient + VirtualApplianceSites *virtualappliancesites.VirtualApplianceSitesClient + VirtualApplianceSkus *virtualapplianceskus.VirtualApplianceSkusClient + VirtualNetworkGatewayConnections *virtualnetworkgatewayconnections.VirtualNetworkGatewayConnectionsClient + VirtualNetworkGateways *virtualnetworkgateways.VirtualNetworkGatewaysClient + VirtualNetworkPeerings *virtualnetworkpeerings.VirtualNetworkPeeringsClient + VirtualNetworkTap *virtualnetworktap.VirtualNetworkTapClient + VirtualNetworkTaps *virtualnetworktaps.VirtualNetworkTapsClient + VirtualNetworks *virtualnetworks.VirtualNetworksClient + VirtualRouterPeerings *virtualrouterpeerings.VirtualRouterPeeringsClient + VirtualRouters *virtualrouters.VirtualRoutersClient + VirtualWANs *virtualwans.VirtualWANsClient + VpnGateways *vpngateways.VpnGatewaysClient + VpnLinkConnections *vpnlinkconnections.VpnLinkConnectionsClient + VpnServerConfigurations *vpnserverconfigurations.VpnServerConfigurationsClient + VpnSites *vpnsites.VpnSitesClient + WebApplicationFirewallPolicies *webapplicationfirewallpolicies.WebApplicationFirewallPoliciesClient + WebCategories *webcategories.WebCategoriesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + adminRuleCollectionsClient, err := adminrulecollections.NewAdminRuleCollectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AdminRuleCollections client: %+v", err) + } + configureFunc(adminRuleCollectionsClient.Client) + + adminRulesClient, err := adminrules.NewAdminRulesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AdminRules client: %+v", err) + } + configureFunc(adminRulesClient.Client) + + applicationGatewayPrivateEndpointConnectionsClient, err := applicationgatewayprivateendpointconnections.NewApplicationGatewayPrivateEndpointConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ApplicationGatewayPrivateEndpointConnections client: %+v", err) + } + configureFunc(applicationGatewayPrivateEndpointConnectionsClient.Client) + + applicationGatewayPrivateLinkResourcesClient, err := applicationgatewayprivatelinkresources.NewApplicationGatewayPrivateLinkResourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ApplicationGatewayPrivateLinkResources client: %+v", err) + } + configureFunc(applicationGatewayPrivateLinkResourcesClient.Client) + + applicationGatewayWafDynamicManifestsClient, err := applicationgatewaywafdynamicmanifests.NewApplicationGatewayWafDynamicManifestsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ApplicationGatewayWafDynamicManifests client: %+v", err) + } + configureFunc(applicationGatewayWafDynamicManifestsClient.Client) + + applicationGatewaysClient, err := applicationgateways.NewApplicationGatewaysClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ApplicationGateways client: %+v", err) + } + configureFunc(applicationGatewaysClient.Client) + + applicationSecurityGroupsClient, err := applicationsecuritygroups.NewApplicationSecurityGroupsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ApplicationSecurityGroups client: %+v", err) + } + configureFunc(applicationSecurityGroupsClient.Client) + + availableDelegationsClient, err := availabledelegations.NewAvailableDelegationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AvailableDelegations client: %+v", err) + } + configureFunc(availableDelegationsClient.Client) + + availableServiceAliasesClient, err := availableservicealiases.NewAvailableServiceAliasesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AvailableServiceAliases client: %+v", err) + } + configureFunc(availableServiceAliasesClient.Client) + + azureFirewallsClient, err := azurefirewalls.NewAzureFirewallsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AzureFirewalls client: %+v", err) + } + configureFunc(azureFirewallsClient.Client) + + bastionHostsClient, err := bastionhosts.NewBastionHostsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building BastionHosts client: %+v", err) + } + configureFunc(bastionHostsClient.Client) + + bastionShareableLinkClient, err := bastionshareablelink.NewBastionShareableLinkClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building BastionShareableLink client: %+v", err) + } + configureFunc(bastionShareableLinkClient.Client) + + bgpServiceCommunitiesClient, err := bgpservicecommunities.NewBgpServiceCommunitiesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building BgpServiceCommunities client: %+v", err) + } + configureFunc(bgpServiceCommunitiesClient.Client) + + checkDnsAvailabilitiesClient, err := checkdnsavailabilities.NewCheckDnsAvailabilitiesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CheckDnsAvailabilities client: %+v", err) + } + configureFunc(checkDnsAvailabilitiesClient.Client) + + cloudServicePublicIPAddressesClient, err := cloudservicepublicipaddresses.NewCloudServicePublicIPAddressesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CloudServicePublicIPAddresses client: %+v", err) + } + configureFunc(cloudServicePublicIPAddressesClient.Client) + + connectionMonitorsClient, err := connectionmonitors.NewConnectionMonitorsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ConnectionMonitors client: %+v", err) + } + configureFunc(connectionMonitorsClient.Client) + + connectivityConfigurationsClient, err := connectivityconfigurations.NewConnectivityConfigurationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ConnectivityConfigurations client: %+v", err) + } + configureFunc(connectivityConfigurationsClient.Client) + + customIPPrefixesClient, err := customipprefixes.NewCustomIPPrefixesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CustomIPPrefixes client: %+v", err) + } + configureFunc(customIPPrefixesClient.Client) + + ddosCustomPoliciesClient, err := ddoscustompolicies.NewDdosCustomPoliciesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DdosCustomPolicies client: %+v", err) + } + configureFunc(ddosCustomPoliciesClient.Client) + + ddosProtectionPlansClient, err := ddosprotectionplans.NewDdosProtectionPlansClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DdosProtectionPlans client: %+v", err) + } + configureFunc(ddosProtectionPlansClient.Client) + + dscpConfigurationClient, err := dscpconfiguration.NewDscpConfigurationClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DscpConfiguration client: %+v", err) + } + configureFunc(dscpConfigurationClient.Client) + + dscpConfigurationsClient, err := dscpconfigurations.NewDscpConfigurationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DscpConfigurations client: %+v", err) + } + configureFunc(dscpConfigurationsClient.Client) + + endpointServicesClient, err := endpointservices.NewEndpointServicesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building EndpointServices client: %+v", err) + } + configureFunc(endpointServicesClient.Client) + + expressRouteCircuitArpTableClient, err := expressroutecircuitarptable.NewExpressRouteCircuitArpTableClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteCircuitArpTable client: %+v", err) + } + configureFunc(expressRouteCircuitArpTableClient.Client) + + expressRouteCircuitAuthorizationsClient, err := expressroutecircuitauthorizations.NewExpressRouteCircuitAuthorizationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteCircuitAuthorizations client: %+v", err) + } + configureFunc(expressRouteCircuitAuthorizationsClient.Client) + + expressRouteCircuitConnectionsClient, err := expressroutecircuitconnections.NewExpressRouteCircuitConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteCircuitConnections client: %+v", err) + } + configureFunc(expressRouteCircuitConnectionsClient.Client) + + expressRouteCircuitPeeringsClient, err := expressroutecircuitpeerings.NewExpressRouteCircuitPeeringsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteCircuitPeerings client: %+v", err) + } + configureFunc(expressRouteCircuitPeeringsClient.Client) + + expressRouteCircuitRoutesTableClient, err := expressroutecircuitroutestable.NewExpressRouteCircuitRoutesTableClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteCircuitRoutesTable client: %+v", err) + } + configureFunc(expressRouteCircuitRoutesTableClient.Client) + + expressRouteCircuitRoutesTableSummaryClient, err := expressroutecircuitroutestablesummary.NewExpressRouteCircuitRoutesTableSummaryClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteCircuitRoutesTableSummary client: %+v", err) + } + configureFunc(expressRouteCircuitRoutesTableSummaryClient.Client) + + expressRouteCircuitStatsClient, err := expressroutecircuitstats.NewExpressRouteCircuitStatsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteCircuitStats client: %+v", err) + } + configureFunc(expressRouteCircuitStatsClient.Client) + + expressRouteCircuitsClient, err := expressroutecircuits.NewExpressRouteCircuitsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteCircuits client: %+v", err) + } + configureFunc(expressRouteCircuitsClient.Client) + + expressRouteConnectionsClient, err := expressrouteconnections.NewExpressRouteConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteConnections client: %+v", err) + } + configureFunc(expressRouteConnectionsClient.Client) + + expressRouteCrossConnectionArpTableClient, err := expressroutecrossconnectionarptable.NewExpressRouteCrossConnectionArpTableClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteCrossConnectionArpTable client: %+v", err) + } + configureFunc(expressRouteCrossConnectionArpTableClient.Client) + + expressRouteCrossConnectionPeeringsClient, err := expressroutecrossconnectionpeerings.NewExpressRouteCrossConnectionPeeringsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteCrossConnectionPeerings client: %+v", err) + } + configureFunc(expressRouteCrossConnectionPeeringsClient.Client) + + expressRouteCrossConnectionRouteTableClient, err := expressroutecrossconnectionroutetable.NewExpressRouteCrossConnectionRouteTableClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteCrossConnectionRouteTable client: %+v", err) + } + configureFunc(expressRouteCrossConnectionRouteTableClient.Client) + + expressRouteCrossConnectionRouteTableSummaryClient, err := expressroutecrossconnectionroutetablesummary.NewExpressRouteCrossConnectionRouteTableSummaryClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteCrossConnectionRouteTableSummary client: %+v", err) + } + configureFunc(expressRouteCrossConnectionRouteTableSummaryClient.Client) + + expressRouteCrossConnectionsClient, err := expressroutecrossconnections.NewExpressRouteCrossConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteCrossConnections client: %+v", err) + } + configureFunc(expressRouteCrossConnectionsClient.Client) + + expressRouteGatewaysClient, err := expressroutegateways.NewExpressRouteGatewaysClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteGateways client: %+v", err) + } + configureFunc(expressRouteGatewaysClient.Client) + + expressRouteLinksClient, err := expressroutelinks.NewExpressRouteLinksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteLinks client: %+v", err) + } + configureFunc(expressRouteLinksClient.Client) + + expressRoutePortAuthorizationsClient, err := expressrouteportauthorizations.NewExpressRoutePortAuthorizationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRoutePortAuthorizations client: %+v", err) + } + configureFunc(expressRoutePortAuthorizationsClient.Client) + + expressRoutePortsClient, err := expressrouteports.NewExpressRoutePortsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRoutePorts client: %+v", err) + } + configureFunc(expressRoutePortsClient.Client) + + expressRoutePortsLocationsClient, err := expressrouteportslocations.NewExpressRoutePortsLocationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRoutePortsLocations client: %+v", err) + } + configureFunc(expressRoutePortsLocationsClient.Client) + + expressRouteProviderPortsClient, err := expressrouteproviderports.NewExpressRouteProviderPortsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteProviderPorts client: %+v", err) + } + configureFunc(expressRouteProviderPortsClient.Client) + + expressRouteServiceProvidersClient, err := expressrouteserviceproviders.NewExpressRouteServiceProvidersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ExpressRouteServiceProviders client: %+v", err) + } + configureFunc(expressRouteServiceProvidersClient.Client) + + firewallPoliciesClient, err := firewallpolicies.NewFirewallPoliciesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building FirewallPolicies client: %+v", err) + } + configureFunc(firewallPoliciesClient.Client) + + firewallPolicyRuleCollectionGroupsClient, err := firewallpolicyrulecollectiongroups.NewFirewallPolicyRuleCollectionGroupsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building FirewallPolicyRuleCollectionGroups client: %+v", err) + } + configureFunc(firewallPolicyRuleCollectionGroupsClient.Client) + + flowLogsClient, err := flowlogs.NewFlowLogsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building FlowLogs client: %+v", err) + } + configureFunc(flowLogsClient.Client) + + iPAllocationsClient, err := ipallocations.NewIPAllocationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building IPAllocations client: %+v", err) + } + configureFunc(iPAllocationsClient.Client) + + iPGroupsClient, err := ipgroups.NewIPGroupsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building IPGroups client: %+v", err) + } + configureFunc(iPGroupsClient.Client) + + iPamPoolsClient, err := ipampools.NewIPamPoolsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building IPamPools client: %+v", err) + } + configureFunc(iPamPoolsClient.Client) + + loadBalancersClient, err := loadbalancers.NewLoadBalancersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building LoadBalancers client: %+v", err) + } + configureFunc(loadBalancersClient.Client) + + localNetworkGatewaysClient, err := localnetworkgateways.NewLocalNetworkGatewaysClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building LocalNetworkGateways client: %+v", err) + } + configureFunc(localNetworkGatewaysClient.Client) + + natGatewaysClient, err := natgateways.NewNatGatewaysClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NatGateways client: %+v", err) + } + configureFunc(natGatewaysClient.Client) + + networkGroupsClient, err := networkgroups.NewNetworkGroupsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkGroups client: %+v", err) + } + configureFunc(networkGroupsClient.Client) + + networkInterfacesClient, err := networkinterfaces.NewNetworkInterfacesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkInterfaces client: %+v", err) + } + configureFunc(networkInterfacesClient.Client) + + networkManagerActiveConfigurationsClient, err := networkmanageractiveconfigurations.NewNetworkManagerActiveConfigurationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkManagerActiveConfigurations client: %+v", err) + } + configureFunc(networkManagerActiveConfigurationsClient.Client) + + networkManagerActiveConnectivityConfigurationsClient, err := networkmanageractiveconnectivityconfigurations.NewNetworkManagerActiveConnectivityConfigurationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkManagerActiveConnectivityConfigurations client: %+v", err) + } + configureFunc(networkManagerActiveConnectivityConfigurationsClient.Client) + + networkManagerConnectionsClient, err := networkmanagerconnections.NewNetworkManagerConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkManagerConnections client: %+v", err) + } + configureFunc(networkManagerConnectionsClient.Client) + + networkManagerEffectiveConnectivityConfigurationClient, err := networkmanagereffectiveconnectivityconfiguration.NewNetworkManagerEffectiveConnectivityConfigurationClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkManagerEffectiveConnectivityConfiguration client: %+v", err) + } + configureFunc(networkManagerEffectiveConnectivityConfigurationClient.Client) + + networkManagerEffectiveSecurityAdminRulesClient, err := networkmanagereffectivesecurityadminrules.NewNetworkManagerEffectiveSecurityAdminRulesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkManagerEffectiveSecurityAdminRules client: %+v", err) + } + configureFunc(networkManagerEffectiveSecurityAdminRulesClient.Client) + + networkManagerRoutingConfigurationsClient, err := networkmanagerroutingconfigurations.NewNetworkManagerRoutingConfigurationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkManagerRoutingConfigurations client: %+v", err) + } + configureFunc(networkManagerRoutingConfigurationsClient.Client) + + networkManagersClient, err := networkmanagers.NewNetworkManagersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkManagers client: %+v", err) + } + configureFunc(networkManagersClient.Client) + + networkProfilesClient, err := networkprofiles.NewNetworkProfilesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkProfiles client: %+v", err) + } + configureFunc(networkProfilesClient.Client) + + networkSecurityGroupsClient, err := networksecuritygroups.NewNetworkSecurityGroupsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkSecurityGroups client: %+v", err) + } + configureFunc(networkSecurityGroupsClient.Client) + + networkSecurityPerimeterAccessRulesClient, err := networksecurityperimeteraccessrules.NewNetworkSecurityPerimeterAccessRulesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkSecurityPerimeterAccessRules client: %+v", err) + } + configureFunc(networkSecurityPerimeterAccessRulesClient.Client) + + networkSecurityPerimeterAssociableResourceTypesClient, err := networksecurityperimeterassociableresourcetypes.NewNetworkSecurityPerimeterAssociableResourceTypesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkSecurityPerimeterAssociableResourceTypes client: %+v", err) + } + configureFunc(networkSecurityPerimeterAssociableResourceTypesClient.Client) + + networkSecurityPerimeterAssociationsClient, err := networksecurityperimeterassociations.NewNetworkSecurityPerimeterAssociationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkSecurityPerimeterAssociations client: %+v", err) + } + configureFunc(networkSecurityPerimeterAssociationsClient.Client) + + networkSecurityPerimeterLinkReferencesClient, err := networksecurityperimeterlinkreferences.NewNetworkSecurityPerimeterLinkReferencesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkSecurityPerimeterLinkReferences client: %+v", err) + } + configureFunc(networkSecurityPerimeterLinkReferencesClient.Client) + + networkSecurityPerimeterLinksClient, err := networksecurityperimeterlinks.NewNetworkSecurityPerimeterLinksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkSecurityPerimeterLinks client: %+v", err) + } + configureFunc(networkSecurityPerimeterLinksClient.Client) + + networkSecurityPerimeterLoggingConfigurationsClient, err := networksecurityperimeterloggingconfigurations.NewNetworkSecurityPerimeterLoggingConfigurationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkSecurityPerimeterLoggingConfigurations client: %+v", err) + } + configureFunc(networkSecurityPerimeterLoggingConfigurationsClient.Client) + + networkSecurityPerimeterProfilesClient, err := networksecurityperimeterprofiles.NewNetworkSecurityPerimeterProfilesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkSecurityPerimeterProfiles client: %+v", err) + } + configureFunc(networkSecurityPerimeterProfilesClient.Client) + + networkSecurityPerimetersClient, err := networksecurityperimeters.NewNetworkSecurityPerimetersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkSecurityPerimeters client: %+v", err) + } + configureFunc(networkSecurityPerimetersClient.Client) + + networkVirtualAppliancesClient, err := networkvirtualappliances.NewNetworkVirtualAppliancesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkVirtualAppliances client: %+v", err) + } + configureFunc(networkVirtualAppliancesClient.Client) + + networkWatchersClient, err := networkwatchers.NewNetworkWatchersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building NetworkWatchers client: %+v", err) + } + configureFunc(networkWatchersClient.Client) + + p2sVpnGatewaysClient, err := p2svpngateways.NewP2sVpnGatewaysClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building P2sVpnGateways client: %+v", err) + } + configureFunc(p2sVpnGatewaysClient.Client) + + packetCapturesClient, err := packetcaptures.NewPacketCapturesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PacketCaptures client: %+v", err) + } + configureFunc(packetCapturesClient.Client) + + peerExpressRouteCircuitConnectionsClient, err := peerexpressroutecircuitconnections.NewPeerExpressRouteCircuitConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PeerExpressRouteCircuitConnections client: %+v", err) + } + configureFunc(peerExpressRouteCircuitConnectionsClient.Client) + + privateDnsZoneGroupsClient, err := privatednszonegroups.NewPrivateDnsZoneGroupsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateDnsZoneGroups client: %+v", err) + } + configureFunc(privateDnsZoneGroupsClient.Client) + + privateEndpointsClient, err := privateendpoints.NewPrivateEndpointsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpoints client: %+v", err) + } + configureFunc(privateEndpointsClient.Client) + + privateLinkServicesClient, err := privatelinkservices.NewPrivateLinkServicesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateLinkServices client: %+v", err) + } + configureFunc(privateLinkServicesClient.Client) + + publicIPAddressesClient, err := publicipaddresses.NewPublicIPAddressesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PublicIPAddresses client: %+v", err) + } + configureFunc(publicIPAddressesClient.Client) + + publicIPPrefixesClient, err := publicipprefixes.NewPublicIPPrefixesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PublicIPPrefixes client: %+v", err) + } + configureFunc(publicIPPrefixesClient.Client) + + reachabilityAnalysisIntentClient, err := reachabilityanalysisintent.NewReachabilityAnalysisIntentClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReachabilityAnalysisIntent client: %+v", err) + } + configureFunc(reachabilityAnalysisIntentClient.Client) + + reachabilityAnalysisIntentsClient, err := reachabilityanalysisintents.NewReachabilityAnalysisIntentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReachabilityAnalysisIntents client: %+v", err) + } + configureFunc(reachabilityAnalysisIntentsClient.Client) + + reachabilityAnalysisRunsClient, err := reachabilityanalysisruns.NewReachabilityAnalysisRunsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ReachabilityAnalysisRuns client: %+v", err) + } + configureFunc(reachabilityAnalysisRunsClient.Client) + + routeFilterRulesClient, err := routefilterrules.NewRouteFilterRulesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building RouteFilterRules client: %+v", err) + } + configureFunc(routeFilterRulesClient.Client) + + routeFiltersClient, err := routefilters.NewRouteFiltersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building RouteFilters client: %+v", err) + } + configureFunc(routeFiltersClient.Client) + + routeTablesClient, err := routetables.NewRouteTablesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building RouteTables client: %+v", err) + } + configureFunc(routeTablesClient.Client) + + routesClient, err := routes.NewRoutesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Routes client: %+v", err) + } + configureFunc(routesClient.Client) + + routingRuleCollectionsClient, err := routingrulecollections.NewRoutingRuleCollectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building RoutingRuleCollections client: %+v", err) + } + configureFunc(routingRuleCollectionsClient.Client) + + routingRulesClient, err := routingrules.NewRoutingRulesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building RoutingRules client: %+v", err) + } + configureFunc(routingRulesClient.Client) + + scopeConnectionsClient, err := scopeconnections.NewScopeConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ScopeConnections client: %+v", err) + } + configureFunc(scopeConnectionsClient.Client) + + securityAdminConfigurationsClient, err := securityadminconfigurations.NewSecurityAdminConfigurationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SecurityAdminConfigurations client: %+v", err) + } + configureFunc(securityAdminConfigurationsClient.Client) + + securityPartnerProvidersClient, err := securitypartnerproviders.NewSecurityPartnerProvidersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SecurityPartnerProviders client: %+v", err) + } + configureFunc(securityPartnerProvidersClient.Client) + + securityRulesClient, err := securityrules.NewSecurityRulesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SecurityRules client: %+v", err) + } + configureFunc(securityRulesClient.Client) + + securityUserConfigurationsClient, err := securityuserconfigurations.NewSecurityUserConfigurationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SecurityUserConfigurations client: %+v", err) + } + configureFunc(securityUserConfigurationsClient.Client) + + securityUserRuleCollectionsClient, err := securityuserrulecollections.NewSecurityUserRuleCollectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SecurityUserRuleCollections client: %+v", err) + } + configureFunc(securityUserRuleCollectionsClient.Client) + + securityUserRulesClient, err := securityuserrules.NewSecurityUserRulesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SecurityUserRules client: %+v", err) + } + configureFunc(securityUserRulesClient.Client) + + serviceEndpointPoliciesClient, err := serviceendpointpolicies.NewServiceEndpointPoliciesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ServiceEndpointPolicies client: %+v", err) + } + configureFunc(serviceEndpointPoliciesClient.Client) + + serviceEndpointPolicyDefinitionsClient, err := serviceendpointpolicydefinitions.NewServiceEndpointPolicyDefinitionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ServiceEndpointPolicyDefinitions client: %+v", err) + } + configureFunc(serviceEndpointPolicyDefinitionsClient.Client) + + serviceTagsClient, err := servicetags.NewServiceTagsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ServiceTags client: %+v", err) + } + configureFunc(serviceTagsClient.Client) + + staticCidrsClient, err := staticcidrs.NewStaticCidrsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building StaticCidrs client: %+v", err) + } + configureFunc(staticCidrsClient.Client) + + staticMembersClient, err := staticmembers.NewStaticMembersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building StaticMembers client: %+v", err) + } + configureFunc(staticMembersClient.Client) + + subnetsClient, err := subnets.NewSubnetsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Subnets client: %+v", err) + } + configureFunc(subnetsClient.Client) + + trafficAnalyticsClient, err := trafficanalytics.NewTrafficAnalyticsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building TrafficAnalytics client: %+v", err) + } + configureFunc(trafficAnalyticsClient.Client) + + usagesClient, err := usages.NewUsagesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Usages client: %+v", err) + } + configureFunc(usagesClient.Client) + + vMSSPublicIPAddressesClient, err := vmsspublicipaddresses.NewVMSSPublicIPAddressesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VMSSPublicIPAddresses client: %+v", err) + } + configureFunc(vMSSPublicIPAddressesClient.Client) + + verifierWorkspacesClient, err := verifierworkspaces.NewVerifierWorkspacesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VerifierWorkspaces client: %+v", err) + } + configureFunc(verifierWorkspacesClient.Client) + + vipSwapClient, err := vipswap.NewVipSwapClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VipSwap client: %+v", err) + } + configureFunc(vipSwapClient.Client) + + virtualApplianceSitesClient, err := virtualappliancesites.NewVirtualApplianceSitesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VirtualApplianceSites client: %+v", err) + } + configureFunc(virtualApplianceSitesClient.Client) + + virtualApplianceSkusClient, err := virtualapplianceskus.NewVirtualApplianceSkusClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VirtualApplianceSkus client: %+v", err) + } + configureFunc(virtualApplianceSkusClient.Client) + + virtualNetworkGatewayConnectionsClient, err := virtualnetworkgatewayconnections.NewVirtualNetworkGatewayConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VirtualNetworkGatewayConnections client: %+v", err) + } + configureFunc(virtualNetworkGatewayConnectionsClient.Client) + + virtualNetworkGatewaysClient, err := virtualnetworkgateways.NewVirtualNetworkGatewaysClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VirtualNetworkGateways client: %+v", err) + } + configureFunc(virtualNetworkGatewaysClient.Client) + + virtualNetworkPeeringsClient, err := virtualnetworkpeerings.NewVirtualNetworkPeeringsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VirtualNetworkPeerings client: %+v", err) + } + configureFunc(virtualNetworkPeeringsClient.Client) + + virtualNetworkTapClient, err := virtualnetworktap.NewVirtualNetworkTapClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VirtualNetworkTap client: %+v", err) + } + configureFunc(virtualNetworkTapClient.Client) + + virtualNetworkTapsClient, err := virtualnetworktaps.NewVirtualNetworkTapsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VirtualNetworkTaps client: %+v", err) + } + configureFunc(virtualNetworkTapsClient.Client) + + virtualNetworksClient, err := virtualnetworks.NewVirtualNetworksClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VirtualNetworks client: %+v", err) + } + configureFunc(virtualNetworksClient.Client) + + virtualRouterPeeringsClient, err := virtualrouterpeerings.NewVirtualRouterPeeringsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VirtualRouterPeerings client: %+v", err) + } + configureFunc(virtualRouterPeeringsClient.Client) + + virtualRoutersClient, err := virtualrouters.NewVirtualRoutersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VirtualRouters client: %+v", err) + } + configureFunc(virtualRoutersClient.Client) + + virtualWANsClient, err := virtualwans.NewVirtualWANsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VirtualWANs client: %+v", err) + } + configureFunc(virtualWANsClient.Client) + + vpnGatewaysClient, err := vpngateways.NewVpnGatewaysClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VpnGateways client: %+v", err) + } + configureFunc(vpnGatewaysClient.Client) + + vpnLinkConnectionsClient, err := vpnlinkconnections.NewVpnLinkConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VpnLinkConnections client: %+v", err) + } + configureFunc(vpnLinkConnectionsClient.Client) + + vpnServerConfigurationsClient, err := vpnserverconfigurations.NewVpnServerConfigurationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VpnServerConfigurations client: %+v", err) + } + configureFunc(vpnServerConfigurationsClient.Client) + + vpnSitesClient, err := vpnsites.NewVpnSitesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VpnSites client: %+v", err) + } + configureFunc(vpnSitesClient.Client) + + webApplicationFirewallPoliciesClient, err := webapplicationfirewallpolicies.NewWebApplicationFirewallPoliciesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WebApplicationFirewallPolicies client: %+v", err) + } + configureFunc(webApplicationFirewallPoliciesClient.Client) + + webCategoriesClient, err := webcategories.NewWebCategoriesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WebCategories client: %+v", err) + } + configureFunc(webCategoriesClient.Client) + + return &Client{ + AdminRuleCollections: adminRuleCollectionsClient, + AdminRules: adminRulesClient, + ApplicationGatewayPrivateEndpointConnections: applicationGatewayPrivateEndpointConnectionsClient, + ApplicationGatewayPrivateLinkResources: applicationGatewayPrivateLinkResourcesClient, + ApplicationGatewayWafDynamicManifests: applicationGatewayWafDynamicManifestsClient, + ApplicationGateways: applicationGatewaysClient, + ApplicationSecurityGroups: applicationSecurityGroupsClient, + AvailableDelegations: availableDelegationsClient, + AvailableServiceAliases: availableServiceAliasesClient, + AzureFirewalls: azureFirewallsClient, + BastionHosts: bastionHostsClient, + BastionShareableLink: bastionShareableLinkClient, + BgpServiceCommunities: bgpServiceCommunitiesClient, + CheckDnsAvailabilities: checkDnsAvailabilitiesClient, + CloudServicePublicIPAddresses: cloudServicePublicIPAddressesClient, + ConnectionMonitors: connectionMonitorsClient, + ConnectivityConfigurations: connectivityConfigurationsClient, + CustomIPPrefixes: customIPPrefixesClient, + DdosCustomPolicies: ddosCustomPoliciesClient, + DdosProtectionPlans: ddosProtectionPlansClient, + DscpConfiguration: dscpConfigurationClient, + DscpConfigurations: dscpConfigurationsClient, + EndpointServices: endpointServicesClient, + ExpressRouteCircuitArpTable: expressRouteCircuitArpTableClient, + ExpressRouteCircuitAuthorizations: expressRouteCircuitAuthorizationsClient, + ExpressRouteCircuitConnections: expressRouteCircuitConnectionsClient, + ExpressRouteCircuitPeerings: expressRouteCircuitPeeringsClient, + ExpressRouteCircuitRoutesTable: expressRouteCircuitRoutesTableClient, + ExpressRouteCircuitRoutesTableSummary: expressRouteCircuitRoutesTableSummaryClient, + ExpressRouteCircuitStats: expressRouteCircuitStatsClient, + ExpressRouteCircuits: expressRouteCircuitsClient, + ExpressRouteConnections: expressRouteConnectionsClient, + ExpressRouteCrossConnectionArpTable: expressRouteCrossConnectionArpTableClient, + ExpressRouteCrossConnectionPeerings: expressRouteCrossConnectionPeeringsClient, + ExpressRouteCrossConnectionRouteTable: expressRouteCrossConnectionRouteTableClient, + ExpressRouteCrossConnectionRouteTableSummary: expressRouteCrossConnectionRouteTableSummaryClient, + ExpressRouteCrossConnections: expressRouteCrossConnectionsClient, + ExpressRouteGateways: expressRouteGatewaysClient, + ExpressRouteLinks: expressRouteLinksClient, + ExpressRoutePortAuthorizations: expressRoutePortAuthorizationsClient, + ExpressRoutePorts: expressRoutePortsClient, + ExpressRoutePortsLocations: expressRoutePortsLocationsClient, + ExpressRouteProviderPorts: expressRouteProviderPortsClient, + ExpressRouteServiceProviders: expressRouteServiceProvidersClient, + FirewallPolicies: firewallPoliciesClient, + FirewallPolicyRuleCollectionGroups: firewallPolicyRuleCollectionGroupsClient, + FlowLogs: flowLogsClient, + IPAllocations: iPAllocationsClient, + IPGroups: iPGroupsClient, + IPamPools: iPamPoolsClient, + LoadBalancers: loadBalancersClient, + LocalNetworkGateways: localNetworkGatewaysClient, + NatGateways: natGatewaysClient, + NetworkGroups: networkGroupsClient, + NetworkInterfaces: networkInterfacesClient, + NetworkManagerActiveConfigurations: networkManagerActiveConfigurationsClient, + NetworkManagerActiveConnectivityConfigurations: networkManagerActiveConnectivityConfigurationsClient, + NetworkManagerConnections: networkManagerConnectionsClient, + NetworkManagerEffectiveConnectivityConfiguration: networkManagerEffectiveConnectivityConfigurationClient, + NetworkManagerEffectiveSecurityAdminRules: networkManagerEffectiveSecurityAdminRulesClient, + NetworkManagerRoutingConfigurations: networkManagerRoutingConfigurationsClient, + NetworkManagers: networkManagersClient, + NetworkProfiles: networkProfilesClient, + NetworkSecurityGroups: networkSecurityGroupsClient, + NetworkSecurityPerimeterAccessRules: networkSecurityPerimeterAccessRulesClient, + NetworkSecurityPerimeterAssociableResourceTypes: networkSecurityPerimeterAssociableResourceTypesClient, + NetworkSecurityPerimeterAssociations: networkSecurityPerimeterAssociationsClient, + NetworkSecurityPerimeterLinkReferences: networkSecurityPerimeterLinkReferencesClient, + NetworkSecurityPerimeterLinks: networkSecurityPerimeterLinksClient, + NetworkSecurityPerimeterLoggingConfigurations: networkSecurityPerimeterLoggingConfigurationsClient, + NetworkSecurityPerimeterProfiles: networkSecurityPerimeterProfilesClient, + NetworkSecurityPerimeters: networkSecurityPerimetersClient, + NetworkVirtualAppliances: networkVirtualAppliancesClient, + NetworkWatchers: networkWatchersClient, + P2sVpnGateways: p2sVpnGatewaysClient, + PacketCaptures: packetCapturesClient, + PeerExpressRouteCircuitConnections: peerExpressRouteCircuitConnectionsClient, + PrivateDnsZoneGroups: privateDnsZoneGroupsClient, + PrivateEndpoints: privateEndpointsClient, + PrivateLinkServices: privateLinkServicesClient, + PublicIPAddresses: publicIPAddressesClient, + PublicIPPrefixes: publicIPPrefixesClient, + ReachabilityAnalysisIntent: reachabilityAnalysisIntentClient, + ReachabilityAnalysisIntents: reachabilityAnalysisIntentsClient, + ReachabilityAnalysisRuns: reachabilityAnalysisRunsClient, + RouteFilterRules: routeFilterRulesClient, + RouteFilters: routeFiltersClient, + RouteTables: routeTablesClient, + Routes: routesClient, + RoutingRuleCollections: routingRuleCollectionsClient, + RoutingRules: routingRulesClient, + ScopeConnections: scopeConnectionsClient, + SecurityAdminConfigurations: securityAdminConfigurationsClient, + SecurityPartnerProviders: securityPartnerProvidersClient, + SecurityRules: securityRulesClient, + SecurityUserConfigurations: securityUserConfigurationsClient, + SecurityUserRuleCollections: securityUserRuleCollectionsClient, + SecurityUserRules: securityUserRulesClient, + ServiceEndpointPolicies: serviceEndpointPoliciesClient, + ServiceEndpointPolicyDefinitions: serviceEndpointPolicyDefinitionsClient, + ServiceTags: serviceTagsClient, + StaticCidrs: staticCidrsClient, + StaticMembers: staticMembersClient, + Subnets: subnetsClient, + TrafficAnalytics: trafficAnalyticsClient, + Usages: usagesClient, + VMSSPublicIPAddresses: vMSSPublicIPAddressesClient, + VerifierWorkspaces: verifierWorkspacesClient, + VipSwap: vipSwapClient, + VirtualApplianceSites: virtualApplianceSitesClient, + VirtualApplianceSkus: virtualApplianceSkusClient, + VirtualNetworkGatewayConnections: virtualNetworkGatewayConnectionsClient, + VirtualNetworkGateways: virtualNetworkGatewaysClient, + VirtualNetworkPeerings: virtualNetworkPeeringsClient, + VirtualNetworkTap: virtualNetworkTapClient, + VirtualNetworkTaps: virtualNetworkTapsClient, + VirtualNetworks: virtualNetworksClient, + VirtualRouterPeerings: virtualRouterPeeringsClient, + VirtualRouters: virtualRoutersClient, + VirtualWANs: virtualWANsClient, + VpnGateways: vpnGatewaysClient, + VpnLinkConnections: vpnLinkConnectionsClient, + VpnServerConfigurations: vpnServerConfigurationsClient, + VpnSites: vpnSitesClient, + WebApplicationFirewallPolicies: webApplicationFirewallPoliciesClient, + WebCategories: webCategoriesClient, + }, nil +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/README.md b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/README.md new file mode 100644 index 00000000000..052daaa0b2b --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/README.md @@ -0,0 +1,71 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/cloudservicepublicipaddresses` Documentation + +The `cloudservicepublicipaddresses` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/cloudservicepublicipaddresses" +``` + + +### Client Initialization + +```go +client := cloudservicepublicipaddresses.NewCloudServicePublicIPAddressesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CloudServicePublicIPAddressesClient.PublicIPAddressesGetCloudServicePublicIPAddress` + +```go +ctx := context.TODO() +id := commonids.NewCloudServicesPublicIPAddressID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServiceName", "roleInstanceName", "networkInterfaceName", "ipConfigurationName", "publicIPAddressName") + +read, err := client.PublicIPAddressesGetCloudServicePublicIPAddress(ctx, id, cloudservicepublicipaddresses.DefaultPublicIPAddressesGetCloudServicePublicIPAddressOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CloudServicePublicIPAddressesClient.PublicIPAddressesListCloudServicePublicIPAddresses` + +```go +ctx := context.TODO() +id := cloudservicepublicipaddresses.NewProviderCloudServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServiceName") + +// alternatively `client.PublicIPAddressesListCloudServicePublicIPAddresses(ctx, id)` can be used to do batched pagination +items, err := client.PublicIPAddressesListCloudServicePublicIPAddressesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CloudServicePublicIPAddressesClient.PublicIPAddressesListCloudServiceRoleInstancePublicIPAddresses` + +```go +ctx := context.TODO() +id := commonids.NewCloudServicesIPConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServiceName", "roleInstanceName", "networkInterfaceName", "ipConfigurationName") + +// alternatively `client.PublicIPAddressesListCloudServiceRoleInstancePublicIPAddresses(ctx, id)` can be used to do batched pagination +items, err := client.PublicIPAddressesListCloudServiceRoleInstancePublicIPAddressesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/client.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/client.go new file mode 100644 index 00000000000..3ffc0d7ae83 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/client.go @@ -0,0 +1,26 @@ +package cloudservicepublicipaddresses + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloudServicePublicIPAddressesClient struct { + Client *resourcemanager.Client +} + +func NewCloudServicePublicIPAddressesClientWithBaseURI(sdkApi sdkEnv.Api) (*CloudServicePublicIPAddressesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "cloudservicepublicipaddresses", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CloudServicePublicIPAddressesClient: %+v", err) + } + + return &CloudServicePublicIPAddressesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/constants.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/constants.go new file mode 100644 index 00000000000..dd1ec78c157 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/constants.go @@ -0,0 +1,1204 @@ +package cloudservicepublicipaddresses + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/id_providercloudservice.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/id_providercloudservice.go new file mode 100644 index 00000000000..c99703d0a69 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/id_providercloudservice.go @@ -0,0 +1,130 @@ +package cloudservicepublicipaddresses + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderCloudServiceId{}) +} + +var _ resourceids.ResourceId = &ProviderCloudServiceId{} + +// ProviderCloudServiceId is a struct representing the Resource ID for a Provider Cloud Service +type ProviderCloudServiceId struct { + SubscriptionId string + ResourceGroupName string + CloudServiceName string +} + +// NewProviderCloudServiceID returns a new ProviderCloudServiceId struct +func NewProviderCloudServiceID(subscriptionId string, resourceGroupName string, cloudServiceName string) ProviderCloudServiceId { + return ProviderCloudServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudServiceName: cloudServiceName, + } +} + +// ParseProviderCloudServiceID parses 'input' into a ProviderCloudServiceId +func ParseProviderCloudServiceID(input string) (*ProviderCloudServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderCloudServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderCloudServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderCloudServiceIDInsensitively parses 'input' case-insensitively into a ProviderCloudServiceId +// note: this method should only be used for API response data and not user input +func ParseProviderCloudServiceIDInsensitively(input string) (*ProviderCloudServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderCloudServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderCloudServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderCloudServiceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudServiceName, ok = input.Parsed["cloudServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudServiceName", input) + } + + return nil +} + +// ValidateProviderCloudServiceID checks that 'input' can be parsed as a Provider Cloud Service ID +func ValidateProviderCloudServiceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderCloudServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Cloud Service ID +func (id ProviderCloudServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/cloudServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Cloud Service ID +func (id ProviderCloudServiceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCompute", "Microsoft.Compute", "Microsoft.Compute"), + resourceids.StaticSegment("staticCloudServices", "cloudServices", "cloudServices"), + resourceids.UserSpecifiedSegment("cloudServiceName", "cloudServiceName"), + } +} + +// String returns a human-readable description of this Provider Cloud Service ID +func (id ProviderCloudServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Service Name: %q", id.CloudServiceName), + } + return fmt.Sprintf("Provider Cloud Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/id_providercloudservice_test.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/id_providercloudservice_test.go new file mode 100644 index 00000000000..410cec3c911 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/id_providercloudservice_test.go @@ -0,0 +1,282 @@ +package cloudservicepublicipaddresses + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderCloudServiceId{} + +func TestNewProviderCloudServiceID(t *testing.T) { + id := NewProviderCloudServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServiceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudServiceName != "cloudServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudServiceName'", id.CloudServiceName, "cloudServiceName") + } +} + +func TestFormatProviderCloudServiceID(t *testing.T) { + actual := NewProviderCloudServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderCloudServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderCloudServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName", + Expected: &ProviderCloudServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudServiceName: "cloudServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderCloudServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudServiceName != v.Expected.CloudServiceName { + t.Fatalf("Expected %q but got %q for CloudServiceName", v.Expected.CloudServiceName, actual.CloudServiceName) + } + + } +} + +func TestParseProviderCloudServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderCloudServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName", + Expected: &ProviderCloudServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudServiceName: "cloudServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs/cLoUdSeRvIcEnAmE", + Expected: &ProviderCloudServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudServiceName: "cLoUdSeRvIcEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs/cLoUdSeRvIcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderCloudServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudServiceName != v.Expected.CloudServiceName { + t.Fatalf("Expected %q but got %q for CloudServiceName", v.Expected.CloudServiceName, actual.CloudServiceName) + } + + } +} + +func TestSegmentsForProviderCloudServiceId(t *testing.T) { + segments := ProviderCloudServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderCloudServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/method_publicipaddressesgetcloudservicepublicipaddress.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/method_publicipaddressesgetcloudservicepublicipaddress.go new file mode 100644 index 00000000000..dabdeb2c12e --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/method_publicipaddressesgetcloudservicepublicipaddress.go @@ -0,0 +1,84 @@ +package cloudservicepublicipaddresses + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressesGetCloudServicePublicIPAddressOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicIPAddress +} + +type PublicIPAddressesGetCloudServicePublicIPAddressOperationOptions struct { + Expand *string +} + +func DefaultPublicIPAddressesGetCloudServicePublicIPAddressOperationOptions() PublicIPAddressesGetCloudServicePublicIPAddressOperationOptions { + return PublicIPAddressesGetCloudServicePublicIPAddressOperationOptions{} +} + +func (o PublicIPAddressesGetCloudServicePublicIPAddressOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o PublicIPAddressesGetCloudServicePublicIPAddressOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o PublicIPAddressesGetCloudServicePublicIPAddressOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// PublicIPAddressesGetCloudServicePublicIPAddress ... +func (c CloudServicePublicIPAddressesClient) PublicIPAddressesGetCloudServicePublicIPAddress(ctx context.Context, id commonids.CloudServicesPublicIPAddressId, options PublicIPAddressesGetCloudServicePublicIPAddressOperationOptions) (result PublicIPAddressesGetCloudServicePublicIPAddressOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PublicIPAddress + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/method_publicipaddresseslistcloudservicepublicipaddresses.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/method_publicipaddresseslistcloudservicepublicipaddresses.go new file mode 100644 index 00000000000..11dfd25258c --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/method_publicipaddresseslistcloudservicepublicipaddresses.go @@ -0,0 +1,105 @@ +package cloudservicepublicipaddresses + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressesListCloudServicePublicIPAddressesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PublicIPAddress +} + +type PublicIPAddressesListCloudServicePublicIPAddressesCompleteResult struct { + LatestHttpResponse *http.Response + Items []PublicIPAddress +} + +type PublicIPAddressesListCloudServicePublicIPAddressesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *PublicIPAddressesListCloudServicePublicIPAddressesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// PublicIPAddressesListCloudServicePublicIPAddresses ... +func (c CloudServicePublicIPAddressesClient) PublicIPAddressesListCloudServicePublicIPAddresses(ctx context.Context, id ProviderCloudServiceId) (result PublicIPAddressesListCloudServicePublicIPAddressesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &PublicIPAddressesListCloudServicePublicIPAddressesCustomPager{}, + Path: fmt.Sprintf("%s/publicIPAddresses", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PublicIPAddress `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// PublicIPAddressesListCloudServicePublicIPAddressesComplete retrieves all the results into a single object +func (c CloudServicePublicIPAddressesClient) PublicIPAddressesListCloudServicePublicIPAddressesComplete(ctx context.Context, id ProviderCloudServiceId) (PublicIPAddressesListCloudServicePublicIPAddressesCompleteResult, error) { + return c.PublicIPAddressesListCloudServicePublicIPAddressesCompleteMatchingPredicate(ctx, id, PublicIPAddressOperationPredicate{}) +} + +// PublicIPAddressesListCloudServicePublicIPAddressesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CloudServicePublicIPAddressesClient) PublicIPAddressesListCloudServicePublicIPAddressesCompleteMatchingPredicate(ctx context.Context, id ProviderCloudServiceId, predicate PublicIPAddressOperationPredicate) (result PublicIPAddressesListCloudServicePublicIPAddressesCompleteResult, err error) { + items := make([]PublicIPAddress, 0) + + resp, err := c.PublicIPAddressesListCloudServicePublicIPAddresses(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = PublicIPAddressesListCloudServicePublicIPAddressesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/method_publicipaddresseslistcloudserviceroleinstancepublicipaddresses.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/method_publicipaddresseslistcloudserviceroleinstancepublicipaddresses.go new file mode 100644 index 00000000000..d1b2312ff6e --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/method_publicipaddresseslistcloudserviceroleinstancepublicipaddresses.go @@ -0,0 +1,106 @@ +package cloudservicepublicipaddresses + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressesListCloudServiceRoleInstancePublicIPAddressesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PublicIPAddress +} + +type PublicIPAddressesListCloudServiceRoleInstancePublicIPAddressesCompleteResult struct { + LatestHttpResponse *http.Response + Items []PublicIPAddress +} + +type PublicIPAddressesListCloudServiceRoleInstancePublicIPAddressesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *PublicIPAddressesListCloudServiceRoleInstancePublicIPAddressesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// PublicIPAddressesListCloudServiceRoleInstancePublicIPAddresses ... +func (c CloudServicePublicIPAddressesClient) PublicIPAddressesListCloudServiceRoleInstancePublicIPAddresses(ctx context.Context, id commonids.CloudServicesIPConfigurationId) (result PublicIPAddressesListCloudServiceRoleInstancePublicIPAddressesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &PublicIPAddressesListCloudServiceRoleInstancePublicIPAddressesCustomPager{}, + Path: fmt.Sprintf("%s/publicIPAddresses", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PublicIPAddress `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// PublicIPAddressesListCloudServiceRoleInstancePublicIPAddressesComplete retrieves all the results into a single object +func (c CloudServicePublicIPAddressesClient) PublicIPAddressesListCloudServiceRoleInstancePublicIPAddressesComplete(ctx context.Context, id commonids.CloudServicesIPConfigurationId) (PublicIPAddressesListCloudServiceRoleInstancePublicIPAddressesCompleteResult, error) { + return c.PublicIPAddressesListCloudServiceRoleInstancePublicIPAddressesCompleteMatchingPredicate(ctx, id, PublicIPAddressOperationPredicate{}) +} + +// PublicIPAddressesListCloudServiceRoleInstancePublicIPAddressesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CloudServicePublicIPAddressesClient) PublicIPAddressesListCloudServiceRoleInstancePublicIPAddressesCompleteMatchingPredicate(ctx context.Context, id commonids.CloudServicesIPConfigurationId, predicate PublicIPAddressOperationPredicate) (result PublicIPAddressesListCloudServiceRoleInstancePublicIPAddressesCompleteResult, err error) { + items := make([]PublicIPAddress, 0) + + resp, err := c.PublicIPAddressesListCloudServiceRoleInstancePublicIPAddresses(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = PublicIPAddressesListCloudServiceRoleInstancePublicIPAddressesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..da0843dfe84 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..0752ac86606 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..c5e25b3ac40 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..3301a914b9a --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..d142ad28f06 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..db43b3a90d7 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..26c6e3c6d63 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_backendaddresspool.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_backendaddresspool.go new file mode 100644 index 00000000000..11a0db48c3e --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..8b7c7a5e9a7 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..852fda62a32 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ddossettings.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ddossettings.go new file mode 100644 index 00000000000..e76df1830ad --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ddossettings.go @@ -0,0 +1,9 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_delegation.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_delegation.go new file mode 100644 index 00000000000..37ba2738f03 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_delegation.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_flowlog.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_flowlog.go new file mode 100644 index 00000000000..49c418d2b9e --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_flowlog.go @@ -0,0 +1,19 @@ +package cloudservicepublicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_flowlogformatparameters.go new file mode 100644 index 00000000000..22cce73755f --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..c8b2d0843ff --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_frontendipconfiguration.go new file mode 100644 index 00000000000..6ef8b18a318 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package cloudservicepublicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..d76b004d004 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..623add5b390 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_inboundnatrule.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_inboundnatrule.go new file mode 100644 index 00000000000..2bf55038c2e --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..9e9fd000882 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..0d2af14b267 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..5cef085cfe6 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipconfiguration.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipconfiguration.go new file mode 100644 index 00000000000..7aa8cbae351 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..cae99b1bc9d --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..d32ff6abc99 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..f1c212d87d9 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_iptag.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_iptag.go new file mode 100644 index 00000000000..9cd0c420107 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_iptag.go @@ -0,0 +1,9 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..e95c784d170 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..f2cc5fa6b36 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_natgateway.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_natgateway.go new file mode 100644 index 00000000000..d2e737891d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_natgateway.go @@ -0,0 +1,20 @@ +package cloudservicepublicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..da0d9468a50 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_natgatewaysku.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_natgatewaysku.go new file mode 100644 index 00000000000..0e1a31e6f56 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_natruleportmapping.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_natruleportmapping.go new file mode 100644 index 00000000000..9f648ba378f --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterface.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterface.go new file mode 100644 index 00000000000..8fa35f5b27b --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterface.go @@ -0,0 +1,19 @@ +package cloudservicepublicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..7841bbdaa74 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..2060396975d --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..331b8b4a8b7 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..7d326578ece --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..8b0936450ab --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..417528f526c --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..800ba33402b --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networksecuritygroup.go new file mode 100644 index 00000000000..4a17b77a5f7 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..75b57179c0e --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpoint.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpoint.go new file mode 100644 index 00000000000..092678d20e9 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpoint.go @@ -0,0 +1,19 @@ +package cloudservicepublicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpointconnection.go new file mode 100644 index 00000000000..390ed6a1a9e --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..a4a672bb9ea --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..f4475d0d46b --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..cd3b594722d --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpointproperties.go new file mode 100644 index 00000000000..b6fab9bddb7 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkservice.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkservice.go new file mode 100644 index 00000000000..47d7bc6cfba --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package cloudservicepublicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..c2e1ed2f2bb --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..12d313e2c8e --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..9c295f72e4e --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..2293fa06105 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..f0b249690b3 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..04a0f8149a7 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_publicipaddress.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_publicipaddress.go new file mode 100644 index 00000000000..0d91d1ce77a --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_publicipaddress.go @@ -0,0 +1,22 @@ +package cloudservicepublicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..59fc873f762 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..5a1a9082ad9 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_publicipaddresssku.go new file mode 100644 index 00000000000..0d24d3ce3e2 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_resourcenavigationlink.go new file mode 100644 index 00000000000..a374b51e3ce --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..bb8074b7c24 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_resourceset.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_resourceset.go new file mode 100644 index 00000000000..ea408a54b5a --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_resourceset.go @@ -0,0 +1,8 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..a92e570a340 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_route.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_route.go new file mode 100644 index 00000000000..ca309e6a8db --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_route.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_routepropertiesformat.go new file mode 100644 index 00000000000..e981b239ff0 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_routetable.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_routetable.go new file mode 100644 index 00000000000..cfe4b1aaec3 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_routetable.go @@ -0,0 +1,14 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..14537e9f6ea --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_securityrule.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_securityrule.go new file mode 100644 index 00000000000..68880b23db6 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_securityrule.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..3918c59b2ce --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceassociationlink.go new file mode 100644 index 00000000000..18402efabea --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..283dae7d051 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..cb30d331149 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..51af3fd8470 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..84bd144ecd4 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..723f9f28975 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..de8c74ebf8a --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..1e4f0c0bb52 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_subnet.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_subnet.go new file mode 100644 index 00000000000..4ae7149a7a9 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_subnet.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..cb002103a66 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_subresource.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_subresource.go new file mode 100644 index 00000000000..ee542355418 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_subresource.go @@ -0,0 +1,8 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..6e884100df3 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..e38b924bdf6 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_virtualnetworktap.go new file mode 100644 index 00000000000..9dc686dd12f --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..c0dae0b7388 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/predicates.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/predicates.go new file mode 100644 index 00000000000..f27f03144ee --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/predicates.go @@ -0,0 +1,37 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p PublicIPAddressOperationPredicate) Matches(input PublicIPAddress) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/version.go b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/version.go new file mode 100644 index 00000000000..fc17a5245e6 --- /dev/null +++ b/resource-manager/network/2024-07-01/cloudservicepublicipaddresses/version.go @@ -0,0 +1,10 @@ +package cloudservicepublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/cloudservicepublicipaddresses/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/README.md b/resource-manager/network/2024-07-01/connectionmonitors/README.md new file mode 100644 index 00000000000..f291c90dbe1 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/README.md @@ -0,0 +1,114 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/connectionmonitors` Documentation + +The `connectionmonitors` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/connectionmonitors" +``` + + +### Client Initialization + +```go +client := connectionmonitors.NewConnectionMonitorsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ConnectionMonitorsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := connectionmonitors.NewConnectionMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "connectionMonitorName") + +payload := connectionmonitors.ConnectionMonitor{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload, connectionmonitors.DefaultCreateOrUpdateOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `ConnectionMonitorsClient.Delete` + +```go +ctx := context.TODO() +id := connectionmonitors.NewConnectionMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "connectionMonitorName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ConnectionMonitorsClient.Get` + +```go +ctx := context.TODO() +id := connectionmonitors.NewConnectionMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "connectionMonitorName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ConnectionMonitorsClient.List` + +```go +ctx := context.TODO() +id := connectionmonitors.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ConnectionMonitorsClient.Stop` + +```go +ctx := context.TODO() +id := connectionmonitors.NewConnectionMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "connectionMonitorName") + +if err := client.StopThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ConnectionMonitorsClient.UpdateTags` + +```go +ctx := context.TODO() +id := connectionmonitors.NewConnectionMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "connectionMonitorName") + +payload := connectionmonitors.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/connectionmonitors/client.go b/resource-manager/network/2024-07-01/connectionmonitors/client.go new file mode 100644 index 00000000000..c23a27cd53b --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/client.go @@ -0,0 +1,26 @@ +package connectionmonitors + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorsClient struct { + Client *resourcemanager.Client +} + +func NewConnectionMonitorsClientWithBaseURI(sdkApi sdkEnv.Api) (*ConnectionMonitorsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "connectionmonitors", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ConnectionMonitorsClient: %+v", err) + } + + return &ConnectionMonitorsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/constants.go b/resource-manager/network/2024-07-01/connectionmonitors/constants.go new file mode 100644 index 00000000000..d2cdf952768 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/constants.go @@ -0,0 +1,494 @@ +package connectionmonitors + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorEndpointFilterItemType string + +const ( + ConnectionMonitorEndpointFilterItemTypeAgentAddress ConnectionMonitorEndpointFilterItemType = "AgentAddress" +) + +func PossibleValuesForConnectionMonitorEndpointFilterItemType() []string { + return []string{ + string(ConnectionMonitorEndpointFilterItemTypeAgentAddress), + } +} + +func (s *ConnectionMonitorEndpointFilterItemType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionMonitorEndpointFilterItemType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionMonitorEndpointFilterItemType(input string) (*ConnectionMonitorEndpointFilterItemType, error) { + vals := map[string]ConnectionMonitorEndpointFilterItemType{ + "agentaddress": ConnectionMonitorEndpointFilterItemTypeAgentAddress, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionMonitorEndpointFilterItemType(input) + return &out, nil +} + +type ConnectionMonitorEndpointFilterType string + +const ( + ConnectionMonitorEndpointFilterTypeInclude ConnectionMonitorEndpointFilterType = "Include" +) + +func PossibleValuesForConnectionMonitorEndpointFilterType() []string { + return []string{ + string(ConnectionMonitorEndpointFilterTypeInclude), + } +} + +func (s *ConnectionMonitorEndpointFilterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionMonitorEndpointFilterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionMonitorEndpointFilterType(input string) (*ConnectionMonitorEndpointFilterType, error) { + vals := map[string]ConnectionMonitorEndpointFilterType{ + "include": ConnectionMonitorEndpointFilterTypeInclude, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionMonitorEndpointFilterType(input) + return &out, nil +} + +type ConnectionMonitorTestConfigurationProtocol string + +const ( + ConnectionMonitorTestConfigurationProtocolHTTP ConnectionMonitorTestConfigurationProtocol = "Http" + ConnectionMonitorTestConfigurationProtocolIcmp ConnectionMonitorTestConfigurationProtocol = "Icmp" + ConnectionMonitorTestConfigurationProtocolTcp ConnectionMonitorTestConfigurationProtocol = "Tcp" +) + +func PossibleValuesForConnectionMonitorTestConfigurationProtocol() []string { + return []string{ + string(ConnectionMonitorTestConfigurationProtocolHTTP), + string(ConnectionMonitorTestConfigurationProtocolIcmp), + string(ConnectionMonitorTestConfigurationProtocolTcp), + } +} + +func (s *ConnectionMonitorTestConfigurationProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionMonitorTestConfigurationProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionMonitorTestConfigurationProtocol(input string) (*ConnectionMonitorTestConfigurationProtocol, error) { + vals := map[string]ConnectionMonitorTestConfigurationProtocol{ + "http": ConnectionMonitorTestConfigurationProtocolHTTP, + "icmp": ConnectionMonitorTestConfigurationProtocolIcmp, + "tcp": ConnectionMonitorTestConfigurationProtocolTcp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionMonitorTestConfigurationProtocol(input) + return &out, nil +} + +type ConnectionMonitorType string + +const ( + ConnectionMonitorTypeMultiEndpoint ConnectionMonitorType = "MultiEndpoint" + ConnectionMonitorTypeSingleSourceDestination ConnectionMonitorType = "SingleSourceDestination" +) + +func PossibleValuesForConnectionMonitorType() []string { + return []string{ + string(ConnectionMonitorTypeMultiEndpoint), + string(ConnectionMonitorTypeSingleSourceDestination), + } +} + +func (s *ConnectionMonitorType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionMonitorType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionMonitorType(input string) (*ConnectionMonitorType, error) { + vals := map[string]ConnectionMonitorType{ + "multiendpoint": ConnectionMonitorTypeMultiEndpoint, + "singlesourcedestination": ConnectionMonitorTypeSingleSourceDestination, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionMonitorType(input) + return &out, nil +} + +type CoverageLevel string + +const ( + CoverageLevelAboveAverage CoverageLevel = "AboveAverage" + CoverageLevelAverage CoverageLevel = "Average" + CoverageLevelBelowAverage CoverageLevel = "BelowAverage" + CoverageLevelDefault CoverageLevel = "Default" + CoverageLevelFull CoverageLevel = "Full" + CoverageLevelLow CoverageLevel = "Low" +) + +func PossibleValuesForCoverageLevel() []string { + return []string{ + string(CoverageLevelAboveAverage), + string(CoverageLevelAverage), + string(CoverageLevelBelowAverage), + string(CoverageLevelDefault), + string(CoverageLevelFull), + string(CoverageLevelLow), + } +} + +func (s *CoverageLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCoverageLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCoverageLevel(input string) (*CoverageLevel, error) { + vals := map[string]CoverageLevel{ + "aboveaverage": CoverageLevelAboveAverage, + "average": CoverageLevelAverage, + "belowaverage": CoverageLevelBelowAverage, + "default": CoverageLevelDefault, + "full": CoverageLevelFull, + "low": CoverageLevelLow, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CoverageLevel(input) + return &out, nil +} + +type DestinationPortBehavior string + +const ( + DestinationPortBehaviorListenIfAvailable DestinationPortBehavior = "ListenIfAvailable" + DestinationPortBehaviorNone DestinationPortBehavior = "None" +) + +func PossibleValuesForDestinationPortBehavior() []string { + return []string{ + string(DestinationPortBehaviorListenIfAvailable), + string(DestinationPortBehaviorNone), + } +} + +func (s *DestinationPortBehavior) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDestinationPortBehavior(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDestinationPortBehavior(input string) (*DestinationPortBehavior, error) { + vals := map[string]DestinationPortBehavior{ + "listenifavailable": DestinationPortBehaviorListenIfAvailable, + "none": DestinationPortBehaviorNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DestinationPortBehavior(input) + return &out, nil +} + +type EndpointType string + +const ( + EndpointTypeAzureArcNetwork EndpointType = "AzureArcNetwork" + EndpointTypeAzureArcVM EndpointType = "AzureArcVM" + EndpointTypeAzureSubnet EndpointType = "AzureSubnet" + EndpointTypeAzureVM EndpointType = "AzureVM" + EndpointTypeAzureVMSS EndpointType = "AzureVMSS" + EndpointTypeAzureVNet EndpointType = "AzureVNet" + EndpointTypeExternalAddress EndpointType = "ExternalAddress" + EndpointTypeMMAWorkspaceMachine EndpointType = "MMAWorkspaceMachine" + EndpointTypeMMAWorkspaceNetwork EndpointType = "MMAWorkspaceNetwork" +) + +func PossibleValuesForEndpointType() []string { + return []string{ + string(EndpointTypeAzureArcNetwork), + string(EndpointTypeAzureArcVM), + string(EndpointTypeAzureSubnet), + string(EndpointTypeAzureVM), + string(EndpointTypeAzureVMSS), + string(EndpointTypeAzureVNet), + string(EndpointTypeExternalAddress), + string(EndpointTypeMMAWorkspaceMachine), + string(EndpointTypeMMAWorkspaceNetwork), + } +} + +func (s *EndpointType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndpointType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEndpointType(input string) (*EndpointType, error) { + vals := map[string]EndpointType{ + "azurearcnetwork": EndpointTypeAzureArcNetwork, + "azurearcvm": EndpointTypeAzureArcVM, + "azuresubnet": EndpointTypeAzureSubnet, + "azurevm": EndpointTypeAzureVM, + "azurevmss": EndpointTypeAzureVMSS, + "azurevnet": EndpointTypeAzureVNet, + "externaladdress": EndpointTypeExternalAddress, + "mmaworkspacemachine": EndpointTypeMMAWorkspaceMachine, + "mmaworkspacenetwork": EndpointTypeMMAWorkspaceNetwork, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndpointType(input) + return &out, nil +} + +type HTTPConfigurationMethod string + +const ( + HTTPConfigurationMethodGet HTTPConfigurationMethod = "Get" + HTTPConfigurationMethodPost HTTPConfigurationMethod = "Post" +) + +func PossibleValuesForHTTPConfigurationMethod() []string { + return []string{ + string(HTTPConfigurationMethodGet), + string(HTTPConfigurationMethodPost), + } +} + +func (s *HTTPConfigurationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHTTPConfigurationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHTTPConfigurationMethod(input string) (*HTTPConfigurationMethod, error) { + vals := map[string]HTTPConfigurationMethod{ + "get": HTTPConfigurationMethodGet, + "post": HTTPConfigurationMethodPost, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HTTPConfigurationMethod(input) + return &out, nil +} + +type OutputType string + +const ( + OutputTypeWorkspace OutputType = "Workspace" +) + +func PossibleValuesForOutputType() []string { + return []string{ + string(OutputTypeWorkspace), + } +} + +func (s *OutputType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOutputType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOutputType(input string) (*OutputType, error) { + vals := map[string]OutputType{ + "workspace": OutputTypeWorkspace, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OutputType(input) + return &out, nil +} + +type PreferredIPVersion string + +const ( + PreferredIPVersionIPvFour PreferredIPVersion = "IPv4" + PreferredIPVersionIPvSix PreferredIPVersion = "IPv6" +) + +func PossibleValuesForPreferredIPVersion() []string { + return []string{ + string(PreferredIPVersionIPvFour), + string(PreferredIPVersionIPvSix), + } +} + +func (s *PreferredIPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePreferredIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePreferredIPVersion(input string) (*PreferredIPVersion, error) { + vals := map[string]PreferredIPVersion{ + "ipv4": PreferredIPVersionIPvFour, + "ipv6": PreferredIPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PreferredIPVersion(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/id_connectionmonitor.go b/resource-manager/network/2024-07-01/connectionmonitors/id_connectionmonitor.go new file mode 100644 index 00000000000..556a942bd1a --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/id_connectionmonitor.go @@ -0,0 +1,139 @@ +package connectionmonitors + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConnectionMonitorId{}) +} + +var _ resourceids.ResourceId = &ConnectionMonitorId{} + +// ConnectionMonitorId is a struct representing the Resource ID for a Connection Monitor +type ConnectionMonitorId struct { + SubscriptionId string + ResourceGroupName string + NetworkWatcherName string + ConnectionMonitorName string +} + +// NewConnectionMonitorID returns a new ConnectionMonitorId struct +func NewConnectionMonitorID(subscriptionId string, resourceGroupName string, networkWatcherName string, connectionMonitorName string) ConnectionMonitorId { + return ConnectionMonitorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkWatcherName: networkWatcherName, + ConnectionMonitorName: connectionMonitorName, + } +} + +// ParseConnectionMonitorID parses 'input' into a ConnectionMonitorId +func ParseConnectionMonitorID(input string) (*ConnectionMonitorId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectionMonitorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectionMonitorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConnectionMonitorIDInsensitively parses 'input' case-insensitively into a ConnectionMonitorId +// note: this method should only be used for API response data and not user input +func ParseConnectionMonitorIDInsensitively(input string) (*ConnectionMonitorId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectionMonitorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectionMonitorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConnectionMonitorId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkWatcherName, ok = input.Parsed["networkWatcherName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkWatcherName", input) + } + + if id.ConnectionMonitorName, ok = input.Parsed["connectionMonitorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectionMonitorName", input) + } + + return nil +} + +// ValidateConnectionMonitorID checks that 'input' can be parsed as a Connection Monitor ID +func ValidateConnectionMonitorID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseConnectionMonitorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Connection Monitor ID +func (id ConnectionMonitorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkWatchers/%s/connectionMonitors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkWatcherName, id.ConnectionMonitorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Connection Monitor ID +func (id ConnectionMonitorId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkWatchers", "networkWatchers", "networkWatchers"), + resourceids.UserSpecifiedSegment("networkWatcherName", "networkWatcherName"), + resourceids.StaticSegment("staticConnectionMonitors", "connectionMonitors", "connectionMonitors"), + resourceids.UserSpecifiedSegment("connectionMonitorName", "connectionMonitorName"), + } +} + +// String returns a human-readable description of this Connection Monitor ID +func (id ConnectionMonitorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Watcher Name: %q", id.NetworkWatcherName), + fmt.Sprintf("Connection Monitor Name: %q", id.ConnectionMonitorName), + } + return fmt.Sprintf("Connection Monitor (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/id_connectionmonitor_test.go b/resource-manager/network/2024-07-01/connectionmonitors/id_connectionmonitor_test.go new file mode 100644 index 00000000000..dc4d85600bd --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/id_connectionmonitor_test.go @@ -0,0 +1,327 @@ +package connectionmonitors + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ConnectionMonitorId{} + +func TestNewConnectionMonitorID(t *testing.T) { + id := NewConnectionMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "connectionMonitorName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkWatcherName != "networkWatcherName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkWatcherName'", id.NetworkWatcherName, "networkWatcherName") + } + + if id.ConnectionMonitorName != "connectionMonitorName" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectionMonitorName'", id.ConnectionMonitorName, "connectionMonitorName") + } +} + +func TestFormatConnectionMonitorID(t *testing.T) { + actual := NewConnectionMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "connectionMonitorName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/connectionMonitors/connectionMonitorName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConnectionMonitorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectionMonitorId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/connectionMonitors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/connectionMonitors/connectionMonitorName", + Expected: &ConnectionMonitorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkWatcherName: "networkWatcherName", + ConnectionMonitorName: "connectionMonitorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/connectionMonitors/connectionMonitorName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectionMonitorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkWatcherName != v.Expected.NetworkWatcherName { + t.Fatalf("Expected %q but got %q for NetworkWatcherName", v.Expected.NetworkWatcherName, actual.NetworkWatcherName) + } + + if actual.ConnectionMonitorName != v.Expected.ConnectionMonitorName { + t.Fatalf("Expected %q but got %q for ConnectionMonitorName", v.Expected.ConnectionMonitorName, actual.ConnectionMonitorName) + } + + } +} + +func TestParseConnectionMonitorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectionMonitorId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/connectionMonitors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE/cOnNeCtIoNmOnItOrS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/connectionMonitors/connectionMonitorName", + Expected: &ConnectionMonitorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkWatcherName: "networkWatcherName", + ConnectionMonitorName: "connectionMonitorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/connectionMonitors/connectionMonitorName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE/cOnNeCtIoNmOnItOrS/cOnNeCtIoNmOnItOrNaMe", + Expected: &ConnectionMonitorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkWatcherName: "nEtWoRkWaTcHeRnAmE", + ConnectionMonitorName: "cOnNeCtIoNmOnItOrNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE/cOnNeCtIoNmOnItOrS/cOnNeCtIoNmOnItOrNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectionMonitorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkWatcherName != v.Expected.NetworkWatcherName { + t.Fatalf("Expected %q but got %q for NetworkWatcherName", v.Expected.NetworkWatcherName, actual.NetworkWatcherName) + } + + if actual.ConnectionMonitorName != v.Expected.ConnectionMonitorName { + t.Fatalf("Expected %q but got %q for ConnectionMonitorName", v.Expected.ConnectionMonitorName, actual.ConnectionMonitorName) + } + + } +} + +func TestSegmentsForConnectionMonitorId(t *testing.T) { + segments := ConnectionMonitorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConnectionMonitorId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/id_networkwatcher.go b/resource-manager/network/2024-07-01/connectionmonitors/id_networkwatcher.go new file mode 100644 index 00000000000..4b6c56cb216 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/id_networkwatcher.go @@ -0,0 +1,130 @@ +package connectionmonitors + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkWatcherId{}) +} + +var _ resourceids.ResourceId = &NetworkWatcherId{} + +// NetworkWatcherId is a struct representing the Resource ID for a Network Watcher +type NetworkWatcherId struct { + SubscriptionId string + ResourceGroupName string + NetworkWatcherName string +} + +// NewNetworkWatcherID returns a new NetworkWatcherId struct +func NewNetworkWatcherID(subscriptionId string, resourceGroupName string, networkWatcherName string) NetworkWatcherId { + return NetworkWatcherId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkWatcherName: networkWatcherName, + } +} + +// ParseNetworkWatcherID parses 'input' into a NetworkWatcherId +func ParseNetworkWatcherID(input string) (*NetworkWatcherId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkWatcherId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkWatcherId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkWatcherIDInsensitively parses 'input' case-insensitively into a NetworkWatcherId +// note: this method should only be used for API response data and not user input +func ParseNetworkWatcherIDInsensitively(input string) (*NetworkWatcherId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkWatcherId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkWatcherId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkWatcherId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkWatcherName, ok = input.Parsed["networkWatcherName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkWatcherName", input) + } + + return nil +} + +// ValidateNetworkWatcherID checks that 'input' can be parsed as a Network Watcher ID +func ValidateNetworkWatcherID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkWatcherID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Watcher ID +func (id NetworkWatcherId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkWatchers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkWatcherName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Watcher ID +func (id NetworkWatcherId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkWatchers", "networkWatchers", "networkWatchers"), + resourceids.UserSpecifiedSegment("networkWatcherName", "networkWatcherName"), + } +} + +// String returns a human-readable description of this Network Watcher ID +func (id NetworkWatcherId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Watcher Name: %q", id.NetworkWatcherName), + } + return fmt.Sprintf("Network Watcher (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/id_networkwatcher_test.go b/resource-manager/network/2024-07-01/connectionmonitors/id_networkwatcher_test.go new file mode 100644 index 00000000000..4fe0debd23b --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/id_networkwatcher_test.go @@ -0,0 +1,282 @@ +package connectionmonitors + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkWatcherId{} + +func TestNewNetworkWatcherID(t *testing.T) { + id := NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkWatcherName != "networkWatcherName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkWatcherName'", id.NetworkWatcherName, "networkWatcherName") + } +} + +func TestFormatNetworkWatcherID(t *testing.T) { + actual := NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkWatcherID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkWatcherId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName", + Expected: &NetworkWatcherId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkWatcherName: "networkWatcherName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkWatcherID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkWatcherName != v.Expected.NetworkWatcherName { + t.Fatalf("Expected %q but got %q for NetworkWatcherName", v.Expected.NetworkWatcherName, actual.NetworkWatcherName) + } + + } +} + +func TestParseNetworkWatcherIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkWatcherId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName", + Expected: &NetworkWatcherId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkWatcherName: "networkWatcherName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE", + Expected: &NetworkWatcherId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkWatcherName: "nEtWoRkWaTcHeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkWatcherIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkWatcherName != v.Expected.NetworkWatcherName { + t.Fatalf("Expected %q but got %q for NetworkWatcherName", v.Expected.NetworkWatcherName, actual.NetworkWatcherName) + } + + } +} + +func TestSegmentsForNetworkWatcherId(t *testing.T) { + segments := NetworkWatcherId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkWatcherId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/method_createorupdate.go b/resource-manager/network/2024-07-01/connectionmonitors/method_createorupdate.go new file mode 100644 index 00000000000..069036d65fe --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/method_createorupdate.go @@ -0,0 +1,104 @@ +package connectionmonitors + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionMonitorResult +} + +type CreateOrUpdateOperationOptions struct { + Migrate *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Migrate != nil { + out.Append("migrate", fmt.Sprintf("%v", *o.Migrate)) + } + return &out +} + +// CreateOrUpdate ... +func (c ConnectionMonitorsClient) CreateOrUpdate(ctx context.Context, id ConnectionMonitorId, input ConnectionMonitor, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ConnectionMonitorsClient) CreateOrUpdateThenPoll(ctx context.Context, id ConnectionMonitorId, input ConnectionMonitor, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/method_delete.go b/resource-manager/network/2024-07-01/connectionmonitors/method_delete.go new file mode 100644 index 00000000000..a0d6aebb3f1 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/method_delete.go @@ -0,0 +1,70 @@ +package connectionmonitors + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ConnectionMonitorsClient) Delete(ctx context.Context, id ConnectionMonitorId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ConnectionMonitorsClient) DeleteThenPoll(ctx context.Context, id ConnectionMonitorId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/method_get.go b/resource-manager/network/2024-07-01/connectionmonitors/method_get.go new file mode 100644 index 00000000000..8087a322df3 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/method_get.go @@ -0,0 +1,53 @@ +package connectionmonitors + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionMonitorResult +} + +// Get ... +func (c ConnectionMonitorsClient) Get(ctx context.Context, id ConnectionMonitorId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectionMonitorResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/method_list.go b/resource-manager/network/2024-07-01/connectionmonitors/method_list.go new file mode 100644 index 00000000000..46eea3af26b --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/method_list.go @@ -0,0 +1,54 @@ +package connectionmonitors + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionMonitorListResult +} + +// List ... +func (c ConnectionMonitorsClient) List(ctx context.Context, id NetworkWatcherId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/connectionMonitors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectionMonitorListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/method_stop.go b/resource-manager/network/2024-07-01/connectionmonitors/method_stop.go new file mode 100644 index 00000000000..44a5d3c56a7 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/method_stop.go @@ -0,0 +1,70 @@ +package connectionmonitors + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Stop ... +func (c ConnectionMonitorsClient) Stop(ctx context.Context, id ConnectionMonitorId) (result StopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StopThenPoll performs Stop then polls until it's completed +func (c ConnectionMonitorsClient) StopThenPoll(ctx context.Context, id ConnectionMonitorId) error { + result, err := c.Stop(ctx, id) + if err != nil { + return fmt.Errorf("performing Stop: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Stop: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/method_updatetags.go b/resource-manager/network/2024-07-01/connectionmonitors/method_updatetags.go new file mode 100644 index 00000000000..e6e1f8be8d1 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/method_updatetags.go @@ -0,0 +1,57 @@ +package connectionmonitors + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionMonitorResult +} + +// UpdateTags ... +func (c ConnectionMonitorsClient) UpdateTags(ctx context.Context, id ConnectionMonitorId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectionMonitorResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitor.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitor.go new file mode 100644 index 00000000000..0257ef7bed9 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitor.go @@ -0,0 +1,10 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitor struct { + Location *string `json:"location,omitempty"` + Properties ConnectionMonitorParameters `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitordestination.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitordestination.go new file mode 100644 index 00000000000..2c1eaeadd69 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitordestination.go @@ -0,0 +1,10 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorDestination struct { + Address *string `json:"address,omitempty"` + Port *int64 `json:"port,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpoint.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpoint.go new file mode 100644 index 00000000000..b93feeafd75 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpoint.go @@ -0,0 +1,16 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorEndpoint struct { + Address *string `json:"address,omitempty"` + CoverageLevel *CoverageLevel `json:"coverageLevel,omitempty"` + Filter *ConnectionMonitorEndpointFilter `json:"filter,omitempty"` + LocationDetails *ConnectionMonitorEndpointLocationDetails `json:"locationDetails,omitempty"` + Name string `json:"name"` + ResourceId *string `json:"resourceId,omitempty"` + Scope *ConnectionMonitorEndpointScope `json:"scope,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + Type *EndpointType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpointfilter.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpointfilter.go new file mode 100644 index 00000000000..f861681a10c --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpointfilter.go @@ -0,0 +1,9 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorEndpointFilter struct { + Items *[]ConnectionMonitorEndpointFilterItem `json:"items,omitempty"` + Type *ConnectionMonitorEndpointFilterType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpointfilteritem.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpointfilteritem.go new file mode 100644 index 00000000000..49a3320062d --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpointfilteritem.go @@ -0,0 +1,9 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorEndpointFilterItem struct { + Address *string `json:"address,omitempty"` + Type *ConnectionMonitorEndpointFilterItemType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpointlocationdetails.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpointlocationdetails.go new file mode 100644 index 00000000000..5e8925459d5 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpointlocationdetails.go @@ -0,0 +1,8 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorEndpointLocationDetails struct { + Region *string `json:"region,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpointscope.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpointscope.go new file mode 100644 index 00000000000..36bb68efcaa --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpointscope.go @@ -0,0 +1,9 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorEndpointScope struct { + Exclude *[]ConnectionMonitorEndpointScopeItem `json:"exclude,omitempty"` + Include *[]ConnectionMonitorEndpointScopeItem `json:"include,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpointscopeitem.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpointscopeitem.go new file mode 100644 index 00000000000..e73b5e20b3b --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorendpointscopeitem.go @@ -0,0 +1,8 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorEndpointScopeItem struct { + Address *string `json:"address,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorhttpconfiguration.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorhttpconfiguration.go new file mode 100644 index 00000000000..51af2309e94 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorhttpconfiguration.go @@ -0,0 +1,13 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorHTTPConfiguration struct { + Method *HTTPConfigurationMethod `json:"method,omitempty"` + Path *string `json:"path,omitempty"` + Port *int64 `json:"port,omitempty"` + PreferHTTPS *bool `json:"preferHTTPS,omitempty"` + RequestHeaders *[]HTTPHeader `json:"requestHeaders,omitempty"` + ValidStatusCodeRanges *[]string `json:"validStatusCodeRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitoricmpconfiguration.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitoricmpconfiguration.go new file mode 100644 index 00000000000..6468613d1af --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitoricmpconfiguration.go @@ -0,0 +1,8 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorIcmpConfiguration struct { + DisableTraceRoute *bool `json:"disableTraceRoute,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorlistresult.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorlistresult.go new file mode 100644 index 00000000000..2e3014360ae --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorlistresult.go @@ -0,0 +1,8 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorListResult struct { + Value *[]ConnectionMonitorResult `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitoroutput.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitoroutput.go new file mode 100644 index 00000000000..fcacc064d79 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitoroutput.go @@ -0,0 +1,9 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorOutput struct { + Type *OutputType `json:"type,omitempty"` + WorkspaceSettings *ConnectionMonitorWorkspaceSettings `json:"workspaceSettings,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorparameters.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorparameters.go new file mode 100644 index 00000000000..d529e518683 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorparameters.go @@ -0,0 +1,16 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorParameters struct { + AutoStart *bool `json:"autoStart,omitempty"` + Destination *ConnectionMonitorDestination `json:"destination,omitempty"` + Endpoints *[]ConnectionMonitorEndpoint `json:"endpoints,omitempty"` + MonitoringIntervalInSeconds *int64 `json:"monitoringIntervalInSeconds,omitempty"` + Notes *string `json:"notes,omitempty"` + Outputs *[]ConnectionMonitorOutput `json:"outputs,omitempty"` + Source *ConnectionMonitorSource `json:"source,omitempty"` + TestConfigurations *[]ConnectionMonitorTestConfiguration `json:"testConfigurations,omitempty"` + TestGroups *[]ConnectionMonitorTestGroup `json:"testGroups,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorresult.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorresult.go new file mode 100644 index 00000000000..439794014f7 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorresult.go @@ -0,0 +1,14 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorResult struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ConnectionMonitorResultProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorresultproperties.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorresultproperties.go new file mode 100644 index 00000000000..0299f7f69a7 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorresultproperties.go @@ -0,0 +1,38 @@ +package connectionmonitors + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorResultProperties struct { + AutoStart *bool `json:"autoStart,omitempty"` + ConnectionMonitorType *ConnectionMonitorType `json:"connectionMonitorType,omitempty"` + Destination *ConnectionMonitorDestination `json:"destination,omitempty"` + Endpoints *[]ConnectionMonitorEndpoint `json:"endpoints,omitempty"` + MonitoringIntervalInSeconds *int64 `json:"monitoringIntervalInSeconds,omitempty"` + MonitoringStatus *string `json:"monitoringStatus,omitempty"` + Notes *string `json:"notes,omitempty"` + Outputs *[]ConnectionMonitorOutput `json:"outputs,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Source *ConnectionMonitorSource `json:"source,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TestConfigurations *[]ConnectionMonitorTestConfiguration `json:"testConfigurations,omitempty"` + TestGroups *[]ConnectionMonitorTestGroup `json:"testGroups,omitempty"` +} + +func (o *ConnectionMonitorResultProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ConnectionMonitorResultProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorsource.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorsource.go new file mode 100644 index 00000000000..39fa1ef2bdc --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorsource.go @@ -0,0 +1,9 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorSource struct { + Port *int64 `json:"port,omitempty"` + ResourceId string `json:"resourceId"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorsuccessthreshold.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorsuccessthreshold.go new file mode 100644 index 00000000000..9f6ca6fac8b --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorsuccessthreshold.go @@ -0,0 +1,9 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorSuccessThreshold struct { + ChecksFailedPercent *int64 `json:"checksFailedPercent,omitempty"` + RoundTripTimeMs *float64 `json:"roundTripTimeMs,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitortcpconfiguration.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitortcpconfiguration.go new file mode 100644 index 00000000000..99fdbf40239 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitortcpconfiguration.go @@ -0,0 +1,10 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorTcpConfiguration struct { + DestinationPortBehavior *DestinationPortBehavior `json:"destinationPortBehavior,omitempty"` + DisableTraceRoute *bool `json:"disableTraceRoute,omitempty"` + Port *int64 `json:"port,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitortestconfiguration.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitortestconfiguration.go new file mode 100644 index 00000000000..c4aa04feaba --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitortestconfiguration.go @@ -0,0 +1,15 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorTestConfiguration struct { + HTTPConfiguration *ConnectionMonitorHTTPConfiguration `json:"httpConfiguration,omitempty"` + IcmpConfiguration *ConnectionMonitorIcmpConfiguration `json:"icmpConfiguration,omitempty"` + Name string `json:"name"` + PreferredIPVersion *PreferredIPVersion `json:"preferredIPVersion,omitempty"` + Protocol ConnectionMonitorTestConfigurationProtocol `json:"protocol"` + SuccessThreshold *ConnectionMonitorSuccessThreshold `json:"successThreshold,omitempty"` + TcpConfiguration *ConnectionMonitorTcpConfiguration `json:"tcpConfiguration,omitempty"` + TestFrequencySec *int64 `json:"testFrequencySec,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitortestgroup.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitortestgroup.go new file mode 100644 index 00000000000..6eaa922f55a --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitortestgroup.go @@ -0,0 +1,12 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorTestGroup struct { + Destinations []string `json:"destinations"` + Disable *bool `json:"disable,omitempty"` + Name string `json:"name"` + Sources []string `json:"sources"` + TestConfigurations []string `json:"testConfigurations"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorworkspacesettings.go b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorworkspacesettings.go new file mode 100644 index 00000000000..ae23c31662f --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_connectionmonitorworkspacesettings.go @@ -0,0 +1,8 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionMonitorWorkspaceSettings struct { + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_httpheader.go b/resource-manager/network/2024-07-01/connectionmonitors/model_httpheader.go new file mode 100644 index 00000000000..7cae34688aa --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_httpheader.go @@ -0,0 +1,9 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPHeader struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/model_tagsobject.go b/resource-manager/network/2024-07-01/connectionmonitors/model_tagsobject.go new file mode 100644 index 00000000000..d9e7e6413ff --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/model_tagsobject.go @@ -0,0 +1,8 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectionmonitors/version.go b/resource-manager/network/2024-07-01/connectionmonitors/version.go new file mode 100644 index 00000000000..746a0daa8eb --- /dev/null +++ b/resource-manager/network/2024-07-01/connectionmonitors/version.go @@ -0,0 +1,10 @@ +package connectionmonitors + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/connectionmonitors/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/README.md b/resource-manager/network/2024-07-01/connectivityconfigurations/README.md new file mode 100644 index 00000000000..ba13a30c808 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/connectivityconfigurations` Documentation + +The `connectivityconfigurations` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/connectivityconfigurations" +``` + + +### Client Initialization + +```go +client := connectivityconfigurations.NewConnectivityConfigurationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ConnectivityConfigurationsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := connectivityconfigurations.NewConnectivityConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "connectivityConfigurationName") + +payload := connectivityconfigurations.ConnectivityConfiguration{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ConnectivityConfigurationsClient.Delete` + +```go +ctx := context.TODO() +id := connectivityconfigurations.NewConnectivityConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "connectivityConfigurationName") + +if err := client.DeleteThenPoll(ctx, id, connectivityconfigurations.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `ConnectivityConfigurationsClient.Get` + +```go +ctx := context.TODO() +id := connectivityconfigurations.NewConnectivityConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "connectivityConfigurationName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ConnectivityConfigurationsClient.List` + +```go +ctx := context.TODO() +id := connectivityconfigurations.NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + +// alternatively `client.List(ctx, id, connectivityconfigurations.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, connectivityconfigurations.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/client.go b/resource-manager/network/2024-07-01/connectivityconfigurations/client.go new file mode 100644 index 00000000000..8d908853770 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/client.go @@ -0,0 +1,26 @@ +package connectivityconfigurations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivityConfigurationsClient struct { + Client *resourcemanager.Client +} + +func NewConnectivityConfigurationsClientWithBaseURI(sdkApi sdkEnv.Api) (*ConnectivityConfigurationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "connectivityconfigurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ConnectivityConfigurationsClient: %+v", err) + } + + return &ConnectivityConfigurationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/constants.go b/resource-manager/network/2024-07-01/connectivityconfigurations/constants.go new file mode 100644 index 00000000000..644cf68e97e --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/constants.go @@ -0,0 +1,385 @@ +package connectivityconfigurations + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectedGroupAddressOverlap string + +const ( + ConnectedGroupAddressOverlapAllowed ConnectedGroupAddressOverlap = "Allowed" + ConnectedGroupAddressOverlapDisallowed ConnectedGroupAddressOverlap = "Disallowed" +) + +func PossibleValuesForConnectedGroupAddressOverlap() []string { + return []string{ + string(ConnectedGroupAddressOverlapAllowed), + string(ConnectedGroupAddressOverlapDisallowed), + } +} + +func (s *ConnectedGroupAddressOverlap) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectedGroupAddressOverlap(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectedGroupAddressOverlap(input string) (*ConnectedGroupAddressOverlap, error) { + vals := map[string]ConnectedGroupAddressOverlap{ + "allowed": ConnectedGroupAddressOverlapAllowed, + "disallowed": ConnectedGroupAddressOverlapDisallowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectedGroupAddressOverlap(input) + return &out, nil +} + +type ConnectedGroupPrivateEndpointsScale string + +const ( + ConnectedGroupPrivateEndpointsScaleHighScale ConnectedGroupPrivateEndpointsScale = "HighScale" + ConnectedGroupPrivateEndpointsScaleStandard ConnectedGroupPrivateEndpointsScale = "Standard" +) + +func PossibleValuesForConnectedGroupPrivateEndpointsScale() []string { + return []string{ + string(ConnectedGroupPrivateEndpointsScaleHighScale), + string(ConnectedGroupPrivateEndpointsScaleStandard), + } +} + +func (s *ConnectedGroupPrivateEndpointsScale) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectedGroupPrivateEndpointsScale(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectedGroupPrivateEndpointsScale(input string) (*ConnectedGroupPrivateEndpointsScale, error) { + vals := map[string]ConnectedGroupPrivateEndpointsScale{ + "highscale": ConnectedGroupPrivateEndpointsScaleHighScale, + "standard": ConnectedGroupPrivateEndpointsScaleStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectedGroupPrivateEndpointsScale(input) + return &out, nil +} + +type ConnectivityTopology string + +const ( + ConnectivityTopologyHubAndSpoke ConnectivityTopology = "HubAndSpoke" + ConnectivityTopologyMesh ConnectivityTopology = "Mesh" +) + +func PossibleValuesForConnectivityTopology() []string { + return []string{ + string(ConnectivityTopologyHubAndSpoke), + string(ConnectivityTopologyMesh), + } +} + +func (s *ConnectivityTopology) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectivityTopology(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectivityTopology(input string) (*ConnectivityTopology, error) { + vals := map[string]ConnectivityTopology{ + "hubandspoke": ConnectivityTopologyHubAndSpoke, + "mesh": ConnectivityTopologyMesh, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectivityTopology(input) + return &out, nil +} + +type DeleteExistingPeering string + +const ( + DeleteExistingPeeringFalse DeleteExistingPeering = "False" + DeleteExistingPeeringTrue DeleteExistingPeering = "True" +) + +func PossibleValuesForDeleteExistingPeering() []string { + return []string{ + string(DeleteExistingPeeringFalse), + string(DeleteExistingPeeringTrue), + } +} + +func (s *DeleteExistingPeering) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteExistingPeering(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteExistingPeering(input string) (*DeleteExistingPeering, error) { + vals := map[string]DeleteExistingPeering{ + "false": DeleteExistingPeeringFalse, + "true": DeleteExistingPeeringTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteExistingPeering(input) + return &out, nil +} + +type GroupConnectivity string + +const ( + GroupConnectivityDirectlyConnected GroupConnectivity = "DirectlyConnected" + GroupConnectivityNone GroupConnectivity = "None" +) + +func PossibleValuesForGroupConnectivity() []string { + return []string{ + string(GroupConnectivityDirectlyConnected), + string(GroupConnectivityNone), + } +} + +func (s *GroupConnectivity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupConnectivity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGroupConnectivity(input string) (*GroupConnectivity, error) { + vals := map[string]GroupConnectivity{ + "directlyconnected": GroupConnectivityDirectlyConnected, + "none": GroupConnectivityNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GroupConnectivity(input) + return &out, nil +} + +type IsGlobal string + +const ( + IsGlobalFalse IsGlobal = "False" + IsGlobalTrue IsGlobal = "True" +) + +func PossibleValuesForIsGlobal() []string { + return []string{ + string(IsGlobalFalse), + string(IsGlobalTrue), + } +} + +func (s *IsGlobal) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsGlobal(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIsGlobal(input string) (*IsGlobal, error) { + vals := map[string]IsGlobal{ + "false": IsGlobalFalse, + "true": IsGlobalTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IsGlobal(input) + return &out, nil +} + +type PeeringEnforcement string + +const ( + PeeringEnforcementEnforced PeeringEnforcement = "Enforced" + PeeringEnforcementUnenforced PeeringEnforcement = "Unenforced" +) + +func PossibleValuesForPeeringEnforcement() []string { + return []string{ + string(PeeringEnforcementEnforced), + string(PeeringEnforcementUnenforced), + } +} + +func (s *PeeringEnforcement) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePeeringEnforcement(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePeeringEnforcement(input string) (*PeeringEnforcement, error) { + vals := map[string]PeeringEnforcement{ + "enforced": PeeringEnforcementEnforced, + "unenforced": PeeringEnforcementUnenforced, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PeeringEnforcement(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type UseHubGateway string + +const ( + UseHubGatewayFalse UseHubGateway = "False" + UseHubGatewayTrue UseHubGateway = "True" +) + +func PossibleValuesForUseHubGateway() []string { + return []string{ + string(UseHubGatewayFalse), + string(UseHubGatewayTrue), + } +} + +func (s *UseHubGateway) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUseHubGateway(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUseHubGateway(input string) (*UseHubGateway, error) { + vals := map[string]UseHubGateway{ + "false": UseHubGatewayFalse, + "true": UseHubGatewayTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UseHubGateway(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/id_connectivityconfiguration.go b/resource-manager/network/2024-07-01/connectivityconfigurations/id_connectivityconfiguration.go new file mode 100644 index 00000000000..d062db15f4f --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/id_connectivityconfiguration.go @@ -0,0 +1,139 @@ +package connectivityconfigurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConnectivityConfigurationId{}) +} + +var _ resourceids.ResourceId = &ConnectivityConfigurationId{} + +// ConnectivityConfigurationId is a struct representing the Resource ID for a Connectivity Configuration +type ConnectivityConfigurationId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + ConnectivityConfigurationName string +} + +// NewConnectivityConfigurationID returns a new ConnectivityConfigurationId struct +func NewConnectivityConfigurationID(subscriptionId string, resourceGroupName string, networkManagerName string, connectivityConfigurationName string) ConnectivityConfigurationId { + return ConnectivityConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + ConnectivityConfigurationName: connectivityConfigurationName, + } +} + +// ParseConnectivityConfigurationID parses 'input' into a ConnectivityConfigurationId +func ParseConnectivityConfigurationID(input string) (*ConnectivityConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectivityConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectivityConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConnectivityConfigurationIDInsensitively parses 'input' case-insensitively into a ConnectivityConfigurationId +// note: this method should only be used for API response data and not user input +func ParseConnectivityConfigurationIDInsensitively(input string) (*ConnectivityConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectivityConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectivityConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConnectivityConfigurationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.ConnectivityConfigurationName, ok = input.Parsed["connectivityConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectivityConfigurationName", input) + } + + return nil +} + +// ValidateConnectivityConfigurationID checks that 'input' can be parsed as a Connectivity Configuration ID +func ValidateConnectivityConfigurationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseConnectivityConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Connectivity Configuration ID +func (id ConnectivityConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/connectivityConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.ConnectivityConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Connectivity Configuration ID +func (id ConnectivityConfigurationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticConnectivityConfigurations", "connectivityConfigurations", "connectivityConfigurations"), + resourceids.UserSpecifiedSegment("connectivityConfigurationName", "connectivityConfigurationName"), + } +} + +// String returns a human-readable description of this Connectivity Configuration ID +func (id ConnectivityConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Connectivity Configuration Name: %q", id.ConnectivityConfigurationName), + } + return fmt.Sprintf("Connectivity Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/id_connectivityconfiguration_test.go b/resource-manager/network/2024-07-01/connectivityconfigurations/id_connectivityconfiguration_test.go new file mode 100644 index 00000000000..62733e7673b --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/id_connectivityconfiguration_test.go @@ -0,0 +1,327 @@ +package connectivityconfigurations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ConnectivityConfigurationId{} + +func TestNewConnectivityConfigurationID(t *testing.T) { + id := NewConnectivityConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "connectivityConfigurationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.ConnectivityConfigurationName != "connectivityConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectivityConfigurationName'", id.ConnectivityConfigurationName, "connectivityConfigurationName") + } +} + +func TestFormatConnectivityConfigurationID(t *testing.T) { + actual := NewConnectivityConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "connectivityConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/connectivityConfigurations/connectivityConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConnectivityConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectivityConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/connectivityConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/connectivityConfigurations/connectivityConfigurationName", + Expected: &ConnectivityConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + ConnectivityConfigurationName: "connectivityConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/connectivityConfigurations/connectivityConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectivityConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.ConnectivityConfigurationName != v.Expected.ConnectivityConfigurationName { + t.Fatalf("Expected %q but got %q for ConnectivityConfigurationName", v.Expected.ConnectivityConfigurationName, actual.ConnectivityConfigurationName) + } + + } +} + +func TestParseConnectivityConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectivityConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/connectivityConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/cOnNeCtIvItYcOnFiGuRaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/connectivityConfigurations/connectivityConfigurationName", + Expected: &ConnectivityConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + ConnectivityConfigurationName: "connectivityConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/connectivityConfigurations/connectivityConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/cOnNeCtIvItYcOnFiGuRaTiOnS/cOnNeCtIvItYcOnFiGuRaTiOnNaMe", + Expected: &ConnectivityConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + ConnectivityConfigurationName: "cOnNeCtIvItYcOnFiGuRaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/cOnNeCtIvItYcOnFiGuRaTiOnS/cOnNeCtIvItYcOnFiGuRaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectivityConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.ConnectivityConfigurationName != v.Expected.ConnectivityConfigurationName { + t.Fatalf("Expected %q but got %q for ConnectivityConfigurationName", v.Expected.ConnectivityConfigurationName, actual.ConnectivityConfigurationName) + } + + } +} + +func TestSegmentsForConnectivityConfigurationId(t *testing.T) { + segments := ConnectivityConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConnectivityConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/id_networkmanager.go b/resource-manager/network/2024-07-01/connectivityconfigurations/id_networkmanager.go new file mode 100644 index 00000000000..2c2e4adba2f --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/id_networkmanager.go @@ -0,0 +1,130 @@ +package connectivityconfigurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkManagerId{}) +} + +var _ resourceids.ResourceId = &NetworkManagerId{} + +// NetworkManagerId is a struct representing the Resource ID for a Network Manager +type NetworkManagerId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string +} + +// NewNetworkManagerID returns a new NetworkManagerId struct +func NewNetworkManagerID(subscriptionId string, resourceGroupName string, networkManagerName string) NetworkManagerId { + return NetworkManagerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + } +} + +// ParseNetworkManagerID parses 'input' into a NetworkManagerId +func ParseNetworkManagerID(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkManagerIDInsensitively parses 'input' case-insensitively into a NetworkManagerId +// note: this method should only be used for API response data and not user input +func ParseNetworkManagerIDInsensitively(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkManagerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + return nil +} + +// ValidateNetworkManagerID checks that 'input' can be parsed as a Network Manager ID +func ValidateNetworkManagerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkManagerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Manager ID +func (id NetworkManagerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Manager ID +func (id NetworkManagerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + } +} + +// String returns a human-readable description of this Network Manager ID +func (id NetworkManagerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + } + return fmt.Sprintf("Network Manager (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/id_networkmanager_test.go b/resource-manager/network/2024-07-01/connectivityconfigurations/id_networkmanager_test.go new file mode 100644 index 00000000000..b8fa89050d7 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/id_networkmanager_test.go @@ -0,0 +1,282 @@ +package connectivityconfigurations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkManagerId{} + +func TestNewNetworkManagerID(t *testing.T) { + id := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } +} + +func TestFormatNetworkManagerID(t *testing.T) { + actual := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkManagerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestParseNetworkManagerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestSegmentsForNetworkManagerId(t *testing.T) { + segments := NetworkManagerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkManagerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/method_createorupdate.go b/resource-manager/network/2024-07-01/connectivityconfigurations/method_createorupdate.go new file mode 100644 index 00000000000..e8278cdba63 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/method_createorupdate.go @@ -0,0 +1,58 @@ +package connectivityconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectivityConfiguration +} + +// CreateOrUpdate ... +func (c ConnectivityConfigurationsClient) CreateOrUpdate(ctx context.Context, id ConnectivityConfigurationId, input ConnectivityConfiguration) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectivityConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/method_delete.go b/resource-manager/network/2024-07-01/connectivityconfigurations/method_delete.go new file mode 100644 index 00000000000..a1c5884b210 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/method_delete.go @@ -0,0 +1,100 @@ +package connectivityconfigurations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c ConnectivityConfigurationsClient) Delete(ctx context.Context, id ConnectivityConfigurationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ConnectivityConfigurationsClient) DeleteThenPoll(ctx context.Context, id ConnectivityConfigurationId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/method_get.go b/resource-manager/network/2024-07-01/connectivityconfigurations/method_get.go new file mode 100644 index 00000000000..3471bd0faf1 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/method_get.go @@ -0,0 +1,53 @@ +package connectivityconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectivityConfiguration +} + +// Get ... +func (c ConnectivityConfigurationsClient) Get(ctx context.Context, id ConnectivityConfigurationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectivityConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/method_list.go b/resource-manager/network/2024-07-01/connectivityconfigurations/method_list.go new file mode 100644 index 00000000000..6663f9e80ae --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/method_list.go @@ -0,0 +1,134 @@ +package connectivityconfigurations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ConnectivityConfiguration +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ConnectivityConfiguration +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ConnectivityConfigurationsClient) List(ctx context.Context, id NetworkManagerId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/connectivityConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ConnectivityConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ConnectivityConfigurationsClient) ListComplete(ctx context.Context, id NetworkManagerId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ConnectivityConfigurationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ConnectivityConfigurationsClient) ListCompleteMatchingPredicate(ctx context.Context, id NetworkManagerId, options ListOperationOptions, predicate ConnectivityConfigurationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ConnectivityConfiguration, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/model_connectivityconfiguration.go b/resource-manager/network/2024-07-01/connectivityconfigurations/model_connectivityconfiguration.go new file mode 100644 index 00000000000..7c6238540d1 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/model_connectivityconfiguration.go @@ -0,0 +1,17 @@ +package connectivityconfigurations + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivityConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ConnectivityConfigurationProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/model_connectivityconfigurationproperties.go b/resource-manager/network/2024-07-01/connectivityconfigurations/model_connectivityconfigurationproperties.go new file mode 100644 index 00000000000..c24600582fe --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/model_connectivityconfigurationproperties.go @@ -0,0 +1,16 @@ +package connectivityconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivityConfigurationProperties struct { + AppliesToGroups []ConnectivityGroupItem `json:"appliesToGroups"` + ConnectivityCapabilities *ConnectivityConfigurationPropertiesConnectivityCapabilities `json:"connectivityCapabilities,omitempty"` + ConnectivityTopology ConnectivityTopology `json:"connectivityTopology"` + DeleteExistingPeering *DeleteExistingPeering `json:"deleteExistingPeering,omitempty"` + Description *string `json:"description,omitempty"` + Hubs *[]Hub `json:"hubs,omitempty"` + IsGlobal *IsGlobal `json:"isGlobal,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/model_connectivityconfigurationpropertiesconnectivitycapabilities.go b/resource-manager/network/2024-07-01/connectivityconfigurations/model_connectivityconfigurationpropertiesconnectivitycapabilities.go new file mode 100644 index 00000000000..31120ffdb7a --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/model_connectivityconfigurationpropertiesconnectivitycapabilities.go @@ -0,0 +1,10 @@ +package connectivityconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivityConfigurationPropertiesConnectivityCapabilities struct { + ConnectedGroupAddressOverlap ConnectedGroupAddressOverlap `json:"connectedGroupAddressOverlap"` + ConnectedGroupPrivateEndpointsScale ConnectedGroupPrivateEndpointsScale `json:"connectedGroupPrivateEndpointsScale"` + PeeringEnforcement PeeringEnforcement `json:"peeringEnforcement"` +} diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/model_connectivitygroupitem.go b/resource-manager/network/2024-07-01/connectivityconfigurations/model_connectivitygroupitem.go new file mode 100644 index 00000000000..0ac02d12f1a --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/model_connectivitygroupitem.go @@ -0,0 +1,11 @@ +package connectivityconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivityGroupItem struct { + GroupConnectivity GroupConnectivity `json:"groupConnectivity"` + IsGlobal *IsGlobal `json:"isGlobal,omitempty"` + NetworkGroupId string `json:"networkGroupId"` + UseHubGateway *UseHubGateway `json:"useHubGateway,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/model_hub.go b/resource-manager/network/2024-07-01/connectivityconfigurations/model_hub.go new file mode 100644 index 00000000000..5e43da03fdd --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/model_hub.go @@ -0,0 +1,9 @@ +package connectivityconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Hub struct { + ResourceId *string `json:"resourceId,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/predicates.go b/resource-manager/network/2024-07-01/connectivityconfigurations/predicates.go new file mode 100644 index 00000000000..ecab73247f2 --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/predicates.go @@ -0,0 +1,32 @@ +package connectivityconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivityConfigurationOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p ConnectivityConfigurationOperationPredicate) Matches(input ConnectivityConfiguration) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/connectivityconfigurations/version.go b/resource-manager/network/2024-07-01/connectivityconfigurations/version.go new file mode 100644 index 00000000000..a775b43e66d --- /dev/null +++ b/resource-manager/network/2024-07-01/connectivityconfigurations/version.go @@ -0,0 +1,10 @@ +package connectivityconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/connectivityconfigurations/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/customipprefixes/README.md b/resource-manager/network/2024-07-01/customipprefixes/README.md new file mode 100644 index 00000000000..067a7947d5e --- /dev/null +++ b/resource-manager/network/2024-07-01/customipprefixes/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/customipprefixes` Documentation + +The `customipprefixes` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/customipprefixes" +``` + + +### Client Initialization + +```go +client := customipprefixes.NewCustomIPPrefixesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CustomIPPrefixesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := customipprefixes.NewCustomIPPrefixID("12345678-1234-9876-4563-123456789012", "example-resource-group", "customIPPrefixName") + +payload := customipprefixes.CustomIPPrefix{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CustomIPPrefixesClient.Delete` + +```go +ctx := context.TODO() +id := customipprefixes.NewCustomIPPrefixID("12345678-1234-9876-4563-123456789012", "example-resource-group", "customIPPrefixName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CustomIPPrefixesClient.Get` + +```go +ctx := context.TODO() +id := customipprefixes.NewCustomIPPrefixID("12345678-1234-9876-4563-123456789012", "example-resource-group", "customIPPrefixName") + +read, err := client.Get(ctx, id, customipprefixes.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CustomIPPrefixesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CustomIPPrefixesClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CustomIPPrefixesClient.UpdateTags` + +```go +ctx := context.TODO() +id := customipprefixes.NewCustomIPPrefixID("12345678-1234-9876-4563-123456789012", "example-resource-group", "customIPPrefixName") + +payload := customipprefixes.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/customipprefixes/client.go b/resource-manager/network/2024-07-01/customipprefixes/client.go new file mode 100644 index 00000000000..2b241f7b0e7 --- /dev/null +++ b/resource-manager/network/2024-07-01/customipprefixes/client.go @@ -0,0 +1,26 @@ +package customipprefixes + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomIPPrefixesClient struct { + Client *resourcemanager.Client +} + +func NewCustomIPPrefixesClientWithBaseURI(sdkApi sdkEnv.Api) (*CustomIPPrefixesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "customipprefixes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CustomIPPrefixesClient: %+v", err) + } + + return &CustomIPPrefixesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/customipprefixes/constants.go b/resource-manager/network/2024-07-01/customipprefixes/constants.go new file mode 100644 index 00000000000..2c9a9f7c2e2 --- /dev/null +++ b/resource-manager/network/2024-07-01/customipprefixes/constants.go @@ -0,0 +1,222 @@ +package customipprefixes + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CommissionedState string + +const ( + CommissionedStateCommissioned CommissionedState = "Commissioned" + CommissionedStateCommissionedNoInternetAdvertise CommissionedState = "CommissionedNoInternetAdvertise" + CommissionedStateCommissioning CommissionedState = "Commissioning" + CommissionedStateDecommissioning CommissionedState = "Decommissioning" + CommissionedStateDeprovisioned CommissionedState = "Deprovisioned" + CommissionedStateDeprovisioning CommissionedState = "Deprovisioning" + CommissionedStateProvisioned CommissionedState = "Provisioned" + CommissionedStateProvisioning CommissionedState = "Provisioning" +) + +func PossibleValuesForCommissionedState() []string { + return []string{ + string(CommissionedStateCommissioned), + string(CommissionedStateCommissionedNoInternetAdvertise), + string(CommissionedStateCommissioning), + string(CommissionedStateDecommissioning), + string(CommissionedStateDeprovisioned), + string(CommissionedStateDeprovisioning), + string(CommissionedStateProvisioned), + string(CommissionedStateProvisioning), + } +} + +func (s *CommissionedState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCommissionedState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCommissionedState(input string) (*CommissionedState, error) { + vals := map[string]CommissionedState{ + "commissioned": CommissionedStateCommissioned, + "commissionednointernetadvertise": CommissionedStateCommissionedNoInternetAdvertise, + "commissioning": CommissionedStateCommissioning, + "decommissioning": CommissionedStateDecommissioning, + "deprovisioned": CommissionedStateDeprovisioned, + "deprovisioning": CommissionedStateDeprovisioning, + "provisioned": CommissionedStateProvisioned, + "provisioning": CommissionedStateProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CommissionedState(input) + return &out, nil +} + +type CustomIPPrefixType string + +const ( + CustomIPPrefixTypeChild CustomIPPrefixType = "Child" + CustomIPPrefixTypeParent CustomIPPrefixType = "Parent" + CustomIPPrefixTypeSingular CustomIPPrefixType = "Singular" +) + +func PossibleValuesForCustomIPPrefixType() []string { + return []string{ + string(CustomIPPrefixTypeChild), + string(CustomIPPrefixTypeParent), + string(CustomIPPrefixTypeSingular), + } +} + +func (s *CustomIPPrefixType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomIPPrefixType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomIPPrefixType(input string) (*CustomIPPrefixType, error) { + vals := map[string]CustomIPPrefixType{ + "child": CustomIPPrefixTypeChild, + "parent": CustomIPPrefixTypeParent, + "singular": CustomIPPrefixTypeSingular, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomIPPrefixType(input) + return &out, nil +} + +type Geo string + +const ( + GeoAFRI Geo = "AFRI" + GeoAPAC Geo = "APAC" + GeoAQ Geo = "AQ" + GeoEURO Geo = "EURO" + GeoGLOBAL Geo = "GLOBAL" + GeoLATAM Geo = "LATAM" + GeoME Geo = "ME" + GeoNAM Geo = "NAM" + GeoOCEANIA Geo = "OCEANIA" +) + +func PossibleValuesForGeo() []string { + return []string{ + string(GeoAFRI), + string(GeoAPAC), + string(GeoAQ), + string(GeoEURO), + string(GeoGLOBAL), + string(GeoLATAM), + string(GeoME), + string(GeoNAM), + string(GeoOCEANIA), + } +} + +func (s *Geo) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGeo(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGeo(input string) (*Geo, error) { + vals := map[string]Geo{ + "afri": GeoAFRI, + "apac": GeoAPAC, + "aq": GeoAQ, + "euro": GeoEURO, + "global": GeoGLOBAL, + "latam": GeoLATAM, + "me": GeoME, + "nam": GeoNAM, + "oceania": GeoOCEANIA, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Geo(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/customipprefixes/id_customipprefix.go b/resource-manager/network/2024-07-01/customipprefixes/id_customipprefix.go new file mode 100644 index 00000000000..bca85243003 --- /dev/null +++ b/resource-manager/network/2024-07-01/customipprefixes/id_customipprefix.go @@ -0,0 +1,130 @@ +package customipprefixes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CustomIPPrefixId{}) +} + +var _ resourceids.ResourceId = &CustomIPPrefixId{} + +// CustomIPPrefixId is a struct representing the Resource ID for a Custom I P Prefix +type CustomIPPrefixId struct { + SubscriptionId string + ResourceGroupName string + CustomIPPrefixName string +} + +// NewCustomIPPrefixID returns a new CustomIPPrefixId struct +func NewCustomIPPrefixID(subscriptionId string, resourceGroupName string, customIPPrefixName string) CustomIPPrefixId { + return CustomIPPrefixId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CustomIPPrefixName: customIPPrefixName, + } +} + +// ParseCustomIPPrefixID parses 'input' into a CustomIPPrefixId +func ParseCustomIPPrefixID(input string) (*CustomIPPrefixId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomIPPrefixId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomIPPrefixId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCustomIPPrefixIDInsensitively parses 'input' case-insensitively into a CustomIPPrefixId +// note: this method should only be used for API response data and not user input +func ParseCustomIPPrefixIDInsensitively(input string) (*CustomIPPrefixId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomIPPrefixId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomIPPrefixId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CustomIPPrefixId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CustomIPPrefixName, ok = input.Parsed["customIPPrefixName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "customIPPrefixName", input) + } + + return nil +} + +// ValidateCustomIPPrefixID checks that 'input' can be parsed as a Custom I P Prefix ID +func ValidateCustomIPPrefixID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCustomIPPrefixID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Custom I P Prefix ID +func (id CustomIPPrefixId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/customIPPrefixes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CustomIPPrefixName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Custom I P Prefix ID +func (id CustomIPPrefixId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticCustomIPPrefixes", "customIPPrefixes", "customIPPrefixes"), + resourceids.UserSpecifiedSegment("customIPPrefixName", "customIPPrefixName"), + } +} + +// String returns a human-readable description of this Custom I P Prefix ID +func (id CustomIPPrefixId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Custom I P Prefix Name: %q", id.CustomIPPrefixName), + } + return fmt.Sprintf("Custom I P Prefix (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/customipprefixes/id_customipprefix_test.go b/resource-manager/network/2024-07-01/customipprefixes/id_customipprefix_test.go new file mode 100644 index 00000000000..dfd6b48155e --- /dev/null +++ b/resource-manager/network/2024-07-01/customipprefixes/id_customipprefix_test.go @@ -0,0 +1,282 @@ +package customipprefixes + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CustomIPPrefixId{} + +func TestNewCustomIPPrefixID(t *testing.T) { + id := NewCustomIPPrefixID("12345678-1234-9876-4563-123456789012", "example-resource-group", "customIPPrefixName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CustomIPPrefixName != "customIPPrefixName" { + t.Fatalf("Expected %q but got %q for Segment 'CustomIPPrefixName'", id.CustomIPPrefixName, "customIPPrefixName") + } +} + +func TestFormatCustomIPPrefixID(t *testing.T) { + actual := NewCustomIPPrefixID("12345678-1234-9876-4563-123456789012", "example-resource-group", "customIPPrefixName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/customIPPrefixes/customIPPrefixName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCustomIPPrefixID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomIPPrefixId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/customIPPrefixes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/customIPPrefixes/customIPPrefixName", + Expected: &CustomIPPrefixId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CustomIPPrefixName: "customIPPrefixName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/customIPPrefixes/customIPPrefixName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomIPPrefixID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CustomIPPrefixName != v.Expected.CustomIPPrefixName { + t.Fatalf("Expected %q but got %q for CustomIPPrefixName", v.Expected.CustomIPPrefixName, actual.CustomIPPrefixName) + } + + } +} + +func TestParseCustomIPPrefixIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomIPPrefixId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/customIPPrefixes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/cUsToMiPpReFiXeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/customIPPrefixes/customIPPrefixName", + Expected: &CustomIPPrefixId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CustomIPPrefixName: "customIPPrefixName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/customIPPrefixes/customIPPrefixName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/cUsToMiPpReFiXeS/cUsToMiPpReFiXnAmE", + Expected: &CustomIPPrefixId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CustomIPPrefixName: "cUsToMiPpReFiXnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/cUsToMiPpReFiXeS/cUsToMiPpReFiXnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomIPPrefixIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CustomIPPrefixName != v.Expected.CustomIPPrefixName { + t.Fatalf("Expected %q but got %q for CustomIPPrefixName", v.Expected.CustomIPPrefixName, actual.CustomIPPrefixName) + } + + } +} + +func TestSegmentsForCustomIPPrefixId(t *testing.T) { + segments := CustomIPPrefixId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CustomIPPrefixId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/customipprefixes/method_createorupdate.go b/resource-manager/network/2024-07-01/customipprefixes/method_createorupdate.go new file mode 100644 index 00000000000..88925ffb667 --- /dev/null +++ b/resource-manager/network/2024-07-01/customipprefixes/method_createorupdate.go @@ -0,0 +1,75 @@ +package customipprefixes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CustomIPPrefix +} + +// CreateOrUpdate ... +func (c CustomIPPrefixesClient) CreateOrUpdate(ctx context.Context, id CustomIPPrefixId, input CustomIPPrefix) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c CustomIPPrefixesClient) CreateOrUpdateThenPoll(ctx context.Context, id CustomIPPrefixId, input CustomIPPrefix) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/customipprefixes/method_delete.go b/resource-manager/network/2024-07-01/customipprefixes/method_delete.go new file mode 100644 index 00000000000..2233d70928d --- /dev/null +++ b/resource-manager/network/2024-07-01/customipprefixes/method_delete.go @@ -0,0 +1,71 @@ +package customipprefixes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c CustomIPPrefixesClient) Delete(ctx context.Context, id CustomIPPrefixId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c CustomIPPrefixesClient) DeleteThenPoll(ctx context.Context, id CustomIPPrefixId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/customipprefixes/method_get.go b/resource-manager/network/2024-07-01/customipprefixes/method_get.go new file mode 100644 index 00000000000..61164d79480 --- /dev/null +++ b/resource-manager/network/2024-07-01/customipprefixes/method_get.go @@ -0,0 +1,83 @@ +package customipprefixes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomIPPrefix +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c CustomIPPrefixesClient) Get(ctx context.Context, id CustomIPPrefixId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CustomIPPrefix + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/customipprefixes/method_list.go b/resource-manager/network/2024-07-01/customipprefixes/method_list.go new file mode 100644 index 00000000000..34b4f325ee9 --- /dev/null +++ b/resource-manager/network/2024-07-01/customipprefixes/method_list.go @@ -0,0 +1,106 @@ +package customipprefixes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CustomIPPrefix +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []CustomIPPrefix +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c CustomIPPrefixesClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/customIPPrefixes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CustomIPPrefix `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c CustomIPPrefixesClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, CustomIPPrefixOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CustomIPPrefixesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate CustomIPPrefixOperationPredicate) (result ListCompleteResult, err error) { + items := make([]CustomIPPrefix, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/customipprefixes/method_listall.go b/resource-manager/network/2024-07-01/customipprefixes/method_listall.go new file mode 100644 index 00000000000..82eb645deab --- /dev/null +++ b/resource-manager/network/2024-07-01/customipprefixes/method_listall.go @@ -0,0 +1,106 @@ +package customipprefixes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CustomIPPrefix +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []CustomIPPrefix +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c CustomIPPrefixesClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/customIPPrefixes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CustomIPPrefix `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c CustomIPPrefixesClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, CustomIPPrefixOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CustomIPPrefixesClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate CustomIPPrefixOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]CustomIPPrefix, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/customipprefixes/method_updatetags.go b/resource-manager/network/2024-07-01/customipprefixes/method_updatetags.go new file mode 100644 index 00000000000..2962a005ed8 --- /dev/null +++ b/resource-manager/network/2024-07-01/customipprefixes/method_updatetags.go @@ -0,0 +1,57 @@ +package customipprefixes + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomIPPrefix +} + +// UpdateTags ... +func (c CustomIPPrefixesClient) UpdateTags(ctx context.Context, id CustomIPPrefixId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CustomIPPrefix + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/customipprefixes/model_customipprefix.go b/resource-manager/network/2024-07-01/customipprefixes/model_customipprefix.go new file mode 100644 index 00000000000..fc3d26ef7a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/customipprefixes/model_customipprefix.go @@ -0,0 +1,21 @@ +package customipprefixes + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomIPPrefix struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CustomIPPrefixPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/customipprefixes/model_customipprefixpropertiesformat.go b/resource-manager/network/2024-07-01/customipprefixes/model_customipprefixpropertiesformat.go new file mode 100644 index 00000000000..f26a83b6b83 --- /dev/null +++ b/resource-manager/network/2024-07-01/customipprefixes/model_customipprefixpropertiesformat.go @@ -0,0 +1,22 @@ +package customipprefixes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomIPPrefixPropertiesFormat struct { + Asn *string `json:"asn,omitempty"` + AuthorizationMessage *string `json:"authorizationMessage,omitempty"` + ChildCustomIPPrefixes *[]SubResource `json:"childCustomIpPrefixes,omitempty"` + Cidr *string `json:"cidr,omitempty"` + CommissionedState *CommissionedState `json:"commissionedState,omitempty"` + CustomIPPrefixParent *SubResource `json:"customIpPrefixParent,omitempty"` + ExpressRouteAdvertise *bool `json:"expressRouteAdvertise,omitempty"` + FailedReason *string `json:"failedReason,omitempty"` + Geo *Geo `json:"geo,omitempty"` + NoInternetAdvertise *bool `json:"noInternetAdvertise,omitempty"` + PrefixType *CustomIPPrefixType `json:"prefixType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SignedMessage *string `json:"signedMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/customipprefixes/model_subresource.go b/resource-manager/network/2024-07-01/customipprefixes/model_subresource.go new file mode 100644 index 00000000000..2428ad08fc0 --- /dev/null +++ b/resource-manager/network/2024-07-01/customipprefixes/model_subresource.go @@ -0,0 +1,8 @@ +package customipprefixes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/customipprefixes/model_tagsobject.go b/resource-manager/network/2024-07-01/customipprefixes/model_tagsobject.go new file mode 100644 index 00000000000..f1f3aea2b6e --- /dev/null +++ b/resource-manager/network/2024-07-01/customipprefixes/model_tagsobject.go @@ -0,0 +1,8 @@ +package customipprefixes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/customipprefixes/predicates.go b/resource-manager/network/2024-07-01/customipprefixes/predicates.go new file mode 100644 index 00000000000..288f9cfa042 --- /dev/null +++ b/resource-manager/network/2024-07-01/customipprefixes/predicates.go @@ -0,0 +1,37 @@ +package customipprefixes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomIPPrefixOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p CustomIPPrefixOperationPredicate) Matches(input CustomIPPrefix) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/customipprefixes/version.go b/resource-manager/network/2024-07-01/customipprefixes/version.go new file mode 100644 index 00000000000..3800214e0af --- /dev/null +++ b/resource-manager/network/2024-07-01/customipprefixes/version.go @@ -0,0 +1,10 @@ +package customipprefixes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/customipprefixes/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/ddoscustompolicies/README.md b/resource-manager/network/2024-07-01/ddoscustompolicies/README.md new file mode 100644 index 00000000000..e6c44de9d89 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddoscustompolicies/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/ddoscustompolicies` Documentation + +The `ddoscustompolicies` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/ddoscustompolicies" +``` + + +### Client Initialization + +```go +client := ddoscustompolicies.NewDdosCustomPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DdosCustomPoliciesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := ddoscustompolicies.NewDdosCustomPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ddosCustomPolicyName") + +payload := ddoscustompolicies.DdosCustomPolicy{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DdosCustomPoliciesClient.Delete` + +```go +ctx := context.TODO() +id := ddoscustompolicies.NewDdosCustomPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ddosCustomPolicyName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DdosCustomPoliciesClient.Get` + +```go +ctx := context.TODO() +id := ddoscustompolicies.NewDdosCustomPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ddosCustomPolicyName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DdosCustomPoliciesClient.UpdateTags` + +```go +ctx := context.TODO() +id := ddoscustompolicies.NewDdosCustomPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ddosCustomPolicyName") + +payload := ddoscustompolicies.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/ddoscustompolicies/client.go b/resource-manager/network/2024-07-01/ddoscustompolicies/client.go new file mode 100644 index 00000000000..93a9d3ac0d4 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddoscustompolicies/client.go @@ -0,0 +1,26 @@ +package ddoscustompolicies + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosCustomPoliciesClient struct { + Client *resourcemanager.Client +} + +func NewDdosCustomPoliciesClientWithBaseURI(sdkApi sdkEnv.Api) (*DdosCustomPoliciesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "ddoscustompolicies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DdosCustomPoliciesClient: %+v", err) + } + + return &DdosCustomPoliciesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/ddoscustompolicies/constants.go b/resource-manager/network/2024-07-01/ddoscustompolicies/constants.go new file mode 100644 index 00000000000..e62adb4c84b --- /dev/null +++ b/resource-manager/network/2024-07-01/ddoscustompolicies/constants.go @@ -0,0 +1,57 @@ +package ddoscustompolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/ddoscustompolicies/id_ddoscustompolicy.go b/resource-manager/network/2024-07-01/ddoscustompolicies/id_ddoscustompolicy.go new file mode 100644 index 00000000000..ca83ded0034 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddoscustompolicies/id_ddoscustompolicy.go @@ -0,0 +1,130 @@ +package ddoscustompolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DdosCustomPolicyId{}) +} + +var _ resourceids.ResourceId = &DdosCustomPolicyId{} + +// DdosCustomPolicyId is a struct representing the Resource ID for a Ddos Custom Policy +type DdosCustomPolicyId struct { + SubscriptionId string + ResourceGroupName string + DdosCustomPolicyName string +} + +// NewDdosCustomPolicyID returns a new DdosCustomPolicyId struct +func NewDdosCustomPolicyID(subscriptionId string, resourceGroupName string, ddosCustomPolicyName string) DdosCustomPolicyId { + return DdosCustomPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DdosCustomPolicyName: ddosCustomPolicyName, + } +} + +// ParseDdosCustomPolicyID parses 'input' into a DdosCustomPolicyId +func ParseDdosCustomPolicyID(input string) (*DdosCustomPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&DdosCustomPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DdosCustomPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDdosCustomPolicyIDInsensitively parses 'input' case-insensitively into a DdosCustomPolicyId +// note: this method should only be used for API response data and not user input +func ParseDdosCustomPolicyIDInsensitively(input string) (*DdosCustomPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&DdosCustomPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DdosCustomPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DdosCustomPolicyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.DdosCustomPolicyName, ok = input.Parsed["ddosCustomPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ddosCustomPolicyName", input) + } + + return nil +} + +// ValidateDdosCustomPolicyID checks that 'input' can be parsed as a Ddos Custom Policy ID +func ValidateDdosCustomPolicyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDdosCustomPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Ddos Custom Policy ID +func (id DdosCustomPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/ddosCustomPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DdosCustomPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Ddos Custom Policy ID +func (id DdosCustomPolicyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticDdosCustomPolicies", "ddosCustomPolicies", "ddosCustomPolicies"), + resourceids.UserSpecifiedSegment("ddosCustomPolicyName", "ddosCustomPolicyName"), + } +} + +// String returns a human-readable description of this Ddos Custom Policy ID +func (id DdosCustomPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Ddos Custom Policy Name: %q", id.DdosCustomPolicyName), + } + return fmt.Sprintf("Ddos Custom Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/ddoscustompolicies/id_ddoscustompolicy_test.go b/resource-manager/network/2024-07-01/ddoscustompolicies/id_ddoscustompolicy_test.go new file mode 100644 index 00000000000..f740cdab70b --- /dev/null +++ b/resource-manager/network/2024-07-01/ddoscustompolicies/id_ddoscustompolicy_test.go @@ -0,0 +1,282 @@ +package ddoscustompolicies + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DdosCustomPolicyId{} + +func TestNewDdosCustomPolicyID(t *testing.T) { + id := NewDdosCustomPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ddosCustomPolicyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.DdosCustomPolicyName != "ddosCustomPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'DdosCustomPolicyName'", id.DdosCustomPolicyName, "ddosCustomPolicyName") + } +} + +func TestFormatDdosCustomPolicyID(t *testing.T) { + actual := NewDdosCustomPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ddosCustomPolicyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ddosCustomPolicies/ddosCustomPolicyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDdosCustomPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DdosCustomPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ddosCustomPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ddosCustomPolicies/ddosCustomPolicyName", + Expected: &DdosCustomPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DdosCustomPolicyName: "ddosCustomPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ddosCustomPolicies/ddosCustomPolicyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDdosCustomPolicyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DdosCustomPolicyName != v.Expected.DdosCustomPolicyName { + t.Fatalf("Expected %q but got %q for DdosCustomPolicyName", v.Expected.DdosCustomPolicyName, actual.DdosCustomPolicyName) + } + + } +} + +func TestParseDdosCustomPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DdosCustomPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ddosCustomPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/dDoScUsToMpOlIcIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ddosCustomPolicies/ddosCustomPolicyName", + Expected: &DdosCustomPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DdosCustomPolicyName: "ddosCustomPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ddosCustomPolicies/ddosCustomPolicyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/dDoScUsToMpOlIcIeS/dDoScUsToMpOlIcYnAmE", + Expected: &DdosCustomPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DdosCustomPolicyName: "dDoScUsToMpOlIcYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/dDoScUsToMpOlIcIeS/dDoScUsToMpOlIcYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDdosCustomPolicyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DdosCustomPolicyName != v.Expected.DdosCustomPolicyName { + t.Fatalf("Expected %q but got %q for DdosCustomPolicyName", v.Expected.DdosCustomPolicyName, actual.DdosCustomPolicyName) + } + + } +} + +func TestSegmentsForDdosCustomPolicyId(t *testing.T) { + segments := DdosCustomPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DdosCustomPolicyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/ddoscustompolicies/method_createorupdate.go b/resource-manager/network/2024-07-01/ddoscustompolicies/method_createorupdate.go new file mode 100644 index 00000000000..ea81bb5382f --- /dev/null +++ b/resource-manager/network/2024-07-01/ddoscustompolicies/method_createorupdate.go @@ -0,0 +1,75 @@ +package ddoscustompolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DdosCustomPolicy +} + +// CreateOrUpdate ... +func (c DdosCustomPoliciesClient) CreateOrUpdate(ctx context.Context, id DdosCustomPolicyId, input DdosCustomPolicy) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c DdosCustomPoliciesClient) CreateOrUpdateThenPoll(ctx context.Context, id DdosCustomPolicyId, input DdosCustomPolicy) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/ddoscustompolicies/method_delete.go b/resource-manager/network/2024-07-01/ddoscustompolicies/method_delete.go new file mode 100644 index 00000000000..78624333195 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddoscustompolicies/method_delete.go @@ -0,0 +1,71 @@ +package ddoscustompolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c DdosCustomPoliciesClient) Delete(ctx context.Context, id DdosCustomPolicyId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c DdosCustomPoliciesClient) DeleteThenPoll(ctx context.Context, id DdosCustomPolicyId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/ddoscustompolicies/method_get.go b/resource-manager/network/2024-07-01/ddoscustompolicies/method_get.go new file mode 100644 index 00000000000..288dcc99b4a --- /dev/null +++ b/resource-manager/network/2024-07-01/ddoscustompolicies/method_get.go @@ -0,0 +1,53 @@ +package ddoscustompolicies + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DdosCustomPolicy +} + +// Get ... +func (c DdosCustomPoliciesClient) Get(ctx context.Context, id DdosCustomPolicyId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DdosCustomPolicy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/ddoscustompolicies/method_updatetags.go b/resource-manager/network/2024-07-01/ddoscustompolicies/method_updatetags.go new file mode 100644 index 00000000000..1e74f849d0b --- /dev/null +++ b/resource-manager/network/2024-07-01/ddoscustompolicies/method_updatetags.go @@ -0,0 +1,57 @@ +package ddoscustompolicies + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DdosCustomPolicy +} + +// UpdateTags ... +func (c DdosCustomPoliciesClient) UpdateTags(ctx context.Context, id DdosCustomPolicyId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DdosCustomPolicy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/ddoscustompolicies/model_ddoscustompolicy.go b/resource-manager/network/2024-07-01/ddoscustompolicies/model_ddoscustompolicy.go new file mode 100644 index 00000000000..21c20585880 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddoscustompolicies/model_ddoscustompolicy.go @@ -0,0 +1,14 @@ +package ddoscustompolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosCustomPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DdosCustomPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ddoscustompolicies/model_ddoscustompolicypropertiesformat.go b/resource-manager/network/2024-07-01/ddoscustompolicies/model_ddoscustompolicypropertiesformat.go new file mode 100644 index 00000000000..fad59051390 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddoscustompolicies/model_ddoscustompolicypropertiesformat.go @@ -0,0 +1,9 @@ +package ddoscustompolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosCustomPolicyPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ddoscustompolicies/model_tagsobject.go b/resource-manager/network/2024-07-01/ddoscustompolicies/model_tagsobject.go new file mode 100644 index 00000000000..3b93ba90100 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddoscustompolicies/model_tagsobject.go @@ -0,0 +1,8 @@ +package ddoscustompolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ddoscustompolicies/version.go b/resource-manager/network/2024-07-01/ddoscustompolicies/version.go new file mode 100644 index 00000000000..7d8763bc6f2 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddoscustompolicies/version.go @@ -0,0 +1,10 @@ +package ddoscustompolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/ddoscustompolicies/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/ddosprotectionplans/README.md b/resource-manager/network/2024-07-01/ddosprotectionplans/README.md new file mode 100644 index 00000000000..3c9f99ba01b --- /dev/null +++ b/resource-manager/network/2024-07-01/ddosprotectionplans/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/ddosprotectionplans` Documentation + +The `ddosprotectionplans` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/ddosprotectionplans" +``` + + +### Client Initialization + +```go +client := ddosprotectionplans.NewDdosProtectionPlansClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DdosProtectionPlansClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := ddosprotectionplans.NewDdosProtectionPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ddosProtectionPlanName") + +payload := ddosprotectionplans.DdosProtectionPlan{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DdosProtectionPlansClient.Delete` + +```go +ctx := context.TODO() +id := ddosprotectionplans.NewDdosProtectionPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ddosProtectionPlanName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DdosProtectionPlansClient.Get` + +```go +ctx := context.TODO() +id := ddosprotectionplans.NewDdosProtectionPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ddosProtectionPlanName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DdosProtectionPlansClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DdosProtectionPlansClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DdosProtectionPlansClient.UpdateTags` + +```go +ctx := context.TODO() +id := ddosprotectionplans.NewDdosProtectionPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ddosProtectionPlanName") + +payload := ddosprotectionplans.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/ddosprotectionplans/client.go b/resource-manager/network/2024-07-01/ddosprotectionplans/client.go new file mode 100644 index 00000000000..e117bf49a8f --- /dev/null +++ b/resource-manager/network/2024-07-01/ddosprotectionplans/client.go @@ -0,0 +1,26 @@ +package ddosprotectionplans + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosProtectionPlansClient struct { + Client *resourcemanager.Client +} + +func NewDdosProtectionPlansClientWithBaseURI(sdkApi sdkEnv.Api) (*DdosProtectionPlansClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "ddosprotectionplans", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DdosProtectionPlansClient: %+v", err) + } + + return &DdosProtectionPlansClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/ddosprotectionplans/constants.go b/resource-manager/network/2024-07-01/ddosprotectionplans/constants.go new file mode 100644 index 00000000000..ec2a63ded59 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddosprotectionplans/constants.go @@ -0,0 +1,57 @@ +package ddosprotectionplans + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/ddosprotectionplans/id_ddosprotectionplan.go b/resource-manager/network/2024-07-01/ddosprotectionplans/id_ddosprotectionplan.go new file mode 100644 index 00000000000..b886f8a4b1f --- /dev/null +++ b/resource-manager/network/2024-07-01/ddosprotectionplans/id_ddosprotectionplan.go @@ -0,0 +1,130 @@ +package ddosprotectionplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DdosProtectionPlanId{}) +} + +var _ resourceids.ResourceId = &DdosProtectionPlanId{} + +// DdosProtectionPlanId is a struct representing the Resource ID for a Ddos Protection Plan +type DdosProtectionPlanId struct { + SubscriptionId string + ResourceGroupName string + DdosProtectionPlanName string +} + +// NewDdosProtectionPlanID returns a new DdosProtectionPlanId struct +func NewDdosProtectionPlanID(subscriptionId string, resourceGroupName string, ddosProtectionPlanName string) DdosProtectionPlanId { + return DdosProtectionPlanId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DdosProtectionPlanName: ddosProtectionPlanName, + } +} + +// ParseDdosProtectionPlanID parses 'input' into a DdosProtectionPlanId +func ParseDdosProtectionPlanID(input string) (*DdosProtectionPlanId, error) { + parser := resourceids.NewParserFromResourceIdType(&DdosProtectionPlanId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DdosProtectionPlanId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDdosProtectionPlanIDInsensitively parses 'input' case-insensitively into a DdosProtectionPlanId +// note: this method should only be used for API response data and not user input +func ParseDdosProtectionPlanIDInsensitively(input string) (*DdosProtectionPlanId, error) { + parser := resourceids.NewParserFromResourceIdType(&DdosProtectionPlanId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DdosProtectionPlanId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DdosProtectionPlanId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.DdosProtectionPlanName, ok = input.Parsed["ddosProtectionPlanName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ddosProtectionPlanName", input) + } + + return nil +} + +// ValidateDdosProtectionPlanID checks that 'input' can be parsed as a Ddos Protection Plan ID +func ValidateDdosProtectionPlanID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDdosProtectionPlanID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Ddos Protection Plan ID +func (id DdosProtectionPlanId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/ddosProtectionPlans/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DdosProtectionPlanName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Ddos Protection Plan ID +func (id DdosProtectionPlanId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticDdosProtectionPlans", "ddosProtectionPlans", "ddosProtectionPlans"), + resourceids.UserSpecifiedSegment("ddosProtectionPlanName", "ddosProtectionPlanName"), + } +} + +// String returns a human-readable description of this Ddos Protection Plan ID +func (id DdosProtectionPlanId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Ddos Protection Plan Name: %q", id.DdosProtectionPlanName), + } + return fmt.Sprintf("Ddos Protection Plan (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/ddosprotectionplans/id_ddosprotectionplan_test.go b/resource-manager/network/2024-07-01/ddosprotectionplans/id_ddosprotectionplan_test.go new file mode 100644 index 00000000000..fdebc161fb5 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddosprotectionplans/id_ddosprotectionplan_test.go @@ -0,0 +1,282 @@ +package ddosprotectionplans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DdosProtectionPlanId{} + +func TestNewDdosProtectionPlanID(t *testing.T) { + id := NewDdosProtectionPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ddosProtectionPlanName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.DdosProtectionPlanName != "ddosProtectionPlanName" { + t.Fatalf("Expected %q but got %q for Segment 'DdosProtectionPlanName'", id.DdosProtectionPlanName, "ddosProtectionPlanName") + } +} + +func TestFormatDdosProtectionPlanID(t *testing.T) { + actual := NewDdosProtectionPlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ddosProtectionPlanName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ddosProtectionPlans/ddosProtectionPlanName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDdosProtectionPlanID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DdosProtectionPlanId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ddosProtectionPlans", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ddosProtectionPlans/ddosProtectionPlanName", + Expected: &DdosProtectionPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DdosProtectionPlanName: "ddosProtectionPlanName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ddosProtectionPlans/ddosProtectionPlanName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDdosProtectionPlanID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DdosProtectionPlanName != v.Expected.DdosProtectionPlanName { + t.Fatalf("Expected %q but got %q for DdosProtectionPlanName", v.Expected.DdosProtectionPlanName, actual.DdosProtectionPlanName) + } + + } +} + +func TestParseDdosProtectionPlanIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DdosProtectionPlanId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ddosProtectionPlans", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/dDoSpRoTeCtIoNpLaNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ddosProtectionPlans/ddosProtectionPlanName", + Expected: &DdosProtectionPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DdosProtectionPlanName: "ddosProtectionPlanName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ddosProtectionPlans/ddosProtectionPlanName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/dDoSpRoTeCtIoNpLaNs/dDoSpRoTeCtIoNpLaNnAmE", + Expected: &DdosProtectionPlanId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DdosProtectionPlanName: "dDoSpRoTeCtIoNpLaNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/dDoSpRoTeCtIoNpLaNs/dDoSpRoTeCtIoNpLaNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDdosProtectionPlanIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DdosProtectionPlanName != v.Expected.DdosProtectionPlanName { + t.Fatalf("Expected %q but got %q for DdosProtectionPlanName", v.Expected.DdosProtectionPlanName, actual.DdosProtectionPlanName) + } + + } +} + +func TestSegmentsForDdosProtectionPlanId(t *testing.T) { + segments := DdosProtectionPlanId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DdosProtectionPlanId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/ddosprotectionplans/method_createorupdate.go b/resource-manager/network/2024-07-01/ddosprotectionplans/method_createorupdate.go new file mode 100644 index 00000000000..4cd5100b040 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddosprotectionplans/method_createorupdate.go @@ -0,0 +1,75 @@ +package ddosprotectionplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DdosProtectionPlan +} + +// CreateOrUpdate ... +func (c DdosProtectionPlansClient) CreateOrUpdate(ctx context.Context, id DdosProtectionPlanId, input DdosProtectionPlan) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c DdosProtectionPlansClient) CreateOrUpdateThenPoll(ctx context.Context, id DdosProtectionPlanId, input DdosProtectionPlan) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/ddosprotectionplans/method_delete.go b/resource-manager/network/2024-07-01/ddosprotectionplans/method_delete.go new file mode 100644 index 00000000000..43d058cf8b8 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddosprotectionplans/method_delete.go @@ -0,0 +1,71 @@ +package ddosprotectionplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c DdosProtectionPlansClient) Delete(ctx context.Context, id DdosProtectionPlanId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c DdosProtectionPlansClient) DeleteThenPoll(ctx context.Context, id DdosProtectionPlanId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/ddosprotectionplans/method_get.go b/resource-manager/network/2024-07-01/ddosprotectionplans/method_get.go new file mode 100644 index 00000000000..7a92875442e --- /dev/null +++ b/resource-manager/network/2024-07-01/ddosprotectionplans/method_get.go @@ -0,0 +1,53 @@ +package ddosprotectionplans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DdosProtectionPlan +} + +// Get ... +func (c DdosProtectionPlansClient) Get(ctx context.Context, id DdosProtectionPlanId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DdosProtectionPlan + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/ddosprotectionplans/method_list.go b/resource-manager/network/2024-07-01/ddosprotectionplans/method_list.go new file mode 100644 index 00000000000..3862b150045 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddosprotectionplans/method_list.go @@ -0,0 +1,106 @@ +package ddosprotectionplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DdosProtectionPlan +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []DdosProtectionPlan +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c DdosProtectionPlansClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/ddosProtectionPlans", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DdosProtectionPlan `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c DdosProtectionPlansClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, DdosProtectionPlanOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DdosProtectionPlansClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DdosProtectionPlanOperationPredicate) (result ListCompleteResult, err error) { + items := make([]DdosProtectionPlan, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/ddosprotectionplans/method_listbyresourcegroup.go b/resource-manager/network/2024-07-01/ddosprotectionplans/method_listbyresourcegroup.go new file mode 100644 index 00000000000..0f9eecd1db7 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddosprotectionplans/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package ddosprotectionplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DdosProtectionPlan +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []DdosProtectionPlan +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c DdosProtectionPlansClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/ddosProtectionPlans", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DdosProtectionPlan `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c DdosProtectionPlansClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, DdosProtectionPlanOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DdosProtectionPlansClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate DdosProtectionPlanOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]DdosProtectionPlan, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/ddosprotectionplans/method_updatetags.go b/resource-manager/network/2024-07-01/ddosprotectionplans/method_updatetags.go new file mode 100644 index 00000000000..a5b91c81b71 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddosprotectionplans/method_updatetags.go @@ -0,0 +1,57 @@ +package ddosprotectionplans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DdosProtectionPlan +} + +// UpdateTags ... +func (c DdosProtectionPlansClient) UpdateTags(ctx context.Context, id DdosProtectionPlanId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DdosProtectionPlan + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/ddosprotectionplans/model_ddosprotectionplan.go b/resource-manager/network/2024-07-01/ddosprotectionplans/model_ddosprotectionplan.go new file mode 100644 index 00000000000..3313192e51b --- /dev/null +++ b/resource-manager/network/2024-07-01/ddosprotectionplans/model_ddosprotectionplan.go @@ -0,0 +1,14 @@ +package ddosprotectionplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosProtectionPlan struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DdosProtectionPlanPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ddosprotectionplans/model_ddosprotectionplanpropertiesformat.go b/resource-manager/network/2024-07-01/ddosprotectionplans/model_ddosprotectionplanpropertiesformat.go new file mode 100644 index 00000000000..b1f0f51665d --- /dev/null +++ b/resource-manager/network/2024-07-01/ddosprotectionplans/model_ddosprotectionplanpropertiesformat.go @@ -0,0 +1,11 @@ +package ddosprotectionplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosProtectionPlanPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIPAddresses,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + VirtualNetworks *[]SubResource `json:"virtualNetworks,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ddosprotectionplans/model_subresource.go b/resource-manager/network/2024-07-01/ddosprotectionplans/model_subresource.go new file mode 100644 index 00000000000..066803386d8 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddosprotectionplans/model_subresource.go @@ -0,0 +1,8 @@ +package ddosprotectionplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ddosprotectionplans/model_tagsobject.go b/resource-manager/network/2024-07-01/ddosprotectionplans/model_tagsobject.go new file mode 100644 index 00000000000..99bf4d851b5 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddosprotectionplans/model_tagsobject.go @@ -0,0 +1,8 @@ +package ddosprotectionplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ddosprotectionplans/predicates.go b/resource-manager/network/2024-07-01/ddosprotectionplans/predicates.go new file mode 100644 index 00000000000..6ad9bbf5374 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddosprotectionplans/predicates.go @@ -0,0 +1,37 @@ +package ddosprotectionplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosProtectionPlanOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p DdosProtectionPlanOperationPredicate) Matches(input DdosProtectionPlan) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/ddosprotectionplans/version.go b/resource-manager/network/2024-07-01/ddosprotectionplans/version.go new file mode 100644 index 00000000000..00114e2ec02 --- /dev/null +++ b/resource-manager/network/2024-07-01/ddosprotectionplans/version.go @@ -0,0 +1,10 @@ +package ddosprotectionplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/ddosprotectionplans/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/README.md b/resource-manager/network/2024-07-01/dscpconfiguration/README.md new file mode 100644 index 00000000000..6c5540e44bf --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/README.md @@ -0,0 +1,65 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/dscpconfiguration` Documentation + +The `dscpconfiguration` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/dscpconfiguration" +``` + + +### Client Initialization + +```go +client := dscpconfiguration.NewDscpConfigurationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DscpConfigurationClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := dscpconfiguration.NewDscpConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dscpConfigurationName") + +payload := dscpconfiguration.DscpConfiguration{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DscpConfigurationClient.Delete` + +```go +ctx := context.TODO() +id := dscpconfiguration.NewDscpConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dscpConfigurationName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DscpConfigurationClient.Get` + +```go +ctx := context.TODO() +id := dscpconfiguration.NewDscpConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dscpConfigurationName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/client.go b/resource-manager/network/2024-07-01/dscpconfiguration/client.go new file mode 100644 index 00000000000..76ab56d4977 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/client.go @@ -0,0 +1,26 @@ +package dscpconfiguration + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DscpConfigurationClient struct { + Client *resourcemanager.Client +} + +func NewDscpConfigurationClientWithBaseURI(sdkApi sdkEnv.Api) (*DscpConfigurationClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "dscpconfiguration", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DscpConfigurationClient: %+v", err) + } + + return &DscpConfigurationClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/constants.go b/resource-manager/network/2024-07-01/dscpconfiguration/constants.go new file mode 100644 index 00000000000..3236f8e7a0a --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/constants.go @@ -0,0 +1,1266 @@ +package dscpconfiguration + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProtocolType string + +const ( + ProtocolTypeAh ProtocolType = "Ah" + ProtocolTypeAll ProtocolType = "All" + ProtocolTypeDoNotUse ProtocolType = "DoNotUse" + ProtocolTypeEsp ProtocolType = "Esp" + ProtocolTypeGre ProtocolType = "Gre" + ProtocolTypeIcmp ProtocolType = "Icmp" + ProtocolTypeTcp ProtocolType = "Tcp" + ProtocolTypeUdp ProtocolType = "Udp" + ProtocolTypeVxlan ProtocolType = "Vxlan" +) + +func PossibleValuesForProtocolType() []string { + return []string{ + string(ProtocolTypeAh), + string(ProtocolTypeAll), + string(ProtocolTypeDoNotUse), + string(ProtocolTypeEsp), + string(ProtocolTypeGre), + string(ProtocolTypeIcmp), + string(ProtocolTypeTcp), + string(ProtocolTypeUdp), + string(ProtocolTypeVxlan), + } +} + +func (s *ProtocolType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtocolType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtocolType(input string) (*ProtocolType, error) { + vals := map[string]ProtocolType{ + "ah": ProtocolTypeAh, + "all": ProtocolTypeAll, + "donotuse": ProtocolTypeDoNotUse, + "esp": ProtocolTypeEsp, + "gre": ProtocolTypeGre, + "icmp": ProtocolTypeIcmp, + "tcp": ProtocolTypeTcp, + "udp": ProtocolTypeUdp, + "vxlan": ProtocolTypeVxlan, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtocolType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/id_dscpconfiguration.go b/resource-manager/network/2024-07-01/dscpconfiguration/id_dscpconfiguration.go new file mode 100644 index 00000000000..3f91fca9e7d --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/id_dscpconfiguration.go @@ -0,0 +1,130 @@ +package dscpconfiguration + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DscpConfigurationId{}) +} + +var _ resourceids.ResourceId = &DscpConfigurationId{} + +// DscpConfigurationId is a struct representing the Resource ID for a Dscp Configuration +type DscpConfigurationId struct { + SubscriptionId string + ResourceGroupName string + DscpConfigurationName string +} + +// NewDscpConfigurationID returns a new DscpConfigurationId struct +func NewDscpConfigurationID(subscriptionId string, resourceGroupName string, dscpConfigurationName string) DscpConfigurationId { + return DscpConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DscpConfigurationName: dscpConfigurationName, + } +} + +// ParseDscpConfigurationID parses 'input' into a DscpConfigurationId +func ParseDscpConfigurationID(input string) (*DscpConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&DscpConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DscpConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDscpConfigurationIDInsensitively parses 'input' case-insensitively into a DscpConfigurationId +// note: this method should only be used for API response data and not user input +func ParseDscpConfigurationIDInsensitively(input string) (*DscpConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&DscpConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DscpConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DscpConfigurationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.DscpConfigurationName, ok = input.Parsed["dscpConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dscpConfigurationName", input) + } + + return nil +} + +// ValidateDscpConfigurationID checks that 'input' can be parsed as a Dscp Configuration ID +func ValidateDscpConfigurationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDscpConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Dscp Configuration ID +func (id DscpConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/dscpConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DscpConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Dscp Configuration ID +func (id DscpConfigurationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticDscpConfigurations", "dscpConfigurations", "dscpConfigurations"), + resourceids.UserSpecifiedSegment("dscpConfigurationName", "dscpConfigurationName"), + } +} + +// String returns a human-readable description of this Dscp Configuration ID +func (id DscpConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Dscp Configuration Name: %q", id.DscpConfigurationName), + } + return fmt.Sprintf("Dscp Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/id_dscpconfiguration_test.go b/resource-manager/network/2024-07-01/dscpconfiguration/id_dscpconfiguration_test.go new file mode 100644 index 00000000000..8cc9c26353f --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/id_dscpconfiguration_test.go @@ -0,0 +1,282 @@ +package dscpconfiguration + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DscpConfigurationId{} + +func TestNewDscpConfigurationID(t *testing.T) { + id := NewDscpConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dscpConfigurationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.DscpConfigurationName != "dscpConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'DscpConfigurationName'", id.DscpConfigurationName, "dscpConfigurationName") + } +} + +func TestFormatDscpConfigurationID(t *testing.T) { + actual := NewDscpConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dscpConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/dscpConfigurations/dscpConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDscpConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DscpConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/dscpConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/dscpConfigurations/dscpConfigurationName", + Expected: &DscpConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DscpConfigurationName: "dscpConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/dscpConfigurations/dscpConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDscpConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DscpConfigurationName != v.Expected.DscpConfigurationName { + t.Fatalf("Expected %q but got %q for DscpConfigurationName", v.Expected.DscpConfigurationName, actual.DscpConfigurationName) + } + + } +} + +func TestParseDscpConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DscpConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/dscpConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/dScPcOnFiGuRaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/dscpConfigurations/dscpConfigurationName", + Expected: &DscpConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DscpConfigurationName: "dscpConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/dscpConfigurations/dscpConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/dScPcOnFiGuRaTiOnS/dScPcOnFiGuRaTiOnNaMe", + Expected: &DscpConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DscpConfigurationName: "dScPcOnFiGuRaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/dScPcOnFiGuRaTiOnS/dScPcOnFiGuRaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDscpConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DscpConfigurationName != v.Expected.DscpConfigurationName { + t.Fatalf("Expected %q but got %q for DscpConfigurationName", v.Expected.DscpConfigurationName, actual.DscpConfigurationName) + } + + } +} + +func TestSegmentsForDscpConfigurationId(t *testing.T) { + segments := DscpConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DscpConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/method_createorupdate.go b/resource-manager/network/2024-07-01/dscpconfiguration/method_createorupdate.go new file mode 100644 index 00000000000..e2262349c4f --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/method_createorupdate.go @@ -0,0 +1,75 @@ +package dscpconfiguration + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DscpConfiguration +} + +// CreateOrUpdate ... +func (c DscpConfigurationClient) CreateOrUpdate(ctx context.Context, id DscpConfigurationId, input DscpConfiguration) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c DscpConfigurationClient) CreateOrUpdateThenPoll(ctx context.Context, id DscpConfigurationId, input DscpConfiguration) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/method_delete.go b/resource-manager/network/2024-07-01/dscpconfiguration/method_delete.go new file mode 100644 index 00000000000..85639c01f9b --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/method_delete.go @@ -0,0 +1,71 @@ +package dscpconfiguration + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c DscpConfigurationClient) Delete(ctx context.Context, id DscpConfigurationId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c DscpConfigurationClient) DeleteThenPoll(ctx context.Context, id DscpConfigurationId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/method_get.go b/resource-manager/network/2024-07-01/dscpconfiguration/method_get.go new file mode 100644 index 00000000000..cb94f50eba5 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/method_get.go @@ -0,0 +1,53 @@ +package dscpconfiguration + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DscpConfiguration +} + +// Get ... +func (c DscpConfigurationClient) Get(ctx context.Context, id DscpConfigurationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DscpConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..440846baae7 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..663b98879ff --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..5070a712a0c --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..a3ca72a1804 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..2072ac671c8 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..067b344a691 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..4a7009c2a6b --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_backendaddresspool.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_backendaddresspool.go new file mode 100644 index 00000000000..fdc704e5a94 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..8bbfd2e47e3 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..2a2e974962b --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_ddossettings.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_ddossettings.go new file mode 100644 index 00000000000..dca2e7cd55f --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_ddossettings.go @@ -0,0 +1,9 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_delegation.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_delegation.go new file mode 100644 index 00000000000..8c1fa9b43c0 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_delegation.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_dscpconfiguration.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_dscpconfiguration.go new file mode 100644 index 00000000000..04e403de3a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_dscpconfiguration.go @@ -0,0 +1,14 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DscpConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DscpConfigurationPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_dscpconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_dscpconfigurationpropertiesformat.go new file mode 100644 index 00000000000..97130781ef7 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_dscpconfigurationpropertiesformat.go @@ -0,0 +1,18 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DscpConfigurationPropertiesFormat struct { + AssociatedNetworkInterfaces *[]NetworkInterface `json:"associatedNetworkInterfaces,omitempty"` + DestinationIPRanges *[]QosIPRange `json:"destinationIpRanges,omitempty"` + DestinationPortRanges *[]QosPortRange `json:"destinationPortRanges,omitempty"` + Markings *[]int64 `json:"markings,omitempty"` + Protocol *ProtocolType `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + QosCollectionId *string `json:"qosCollectionId,omitempty"` + QosDefinitionCollection *[]QosDefinition `json:"qosDefinitionCollection,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceIPRanges *[]QosIPRange `json:"sourceIpRanges,omitempty"` + SourcePortRanges *[]QosPortRange `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_flowlog.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_flowlog.go new file mode 100644 index 00000000000..bf6d8780460 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_flowlog.go @@ -0,0 +1,19 @@ +package dscpconfiguration + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_flowlogformatparameters.go new file mode 100644 index 00000000000..f759162156c --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..11e34ba75a8 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_frontendipconfiguration.go new file mode 100644 index 00000000000..e5b91931aa4 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package dscpconfiguration + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..cc67d340130 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..c498ae3b999 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_inboundnatrule.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_inboundnatrule.go new file mode 100644 index 00000000000..cae42b6f078 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..6ee4c243e27 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..f8348469e54 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..2e916314205 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_ipconfiguration.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_ipconfiguration.go new file mode 100644 index 00000000000..b79aa52af20 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..51858f8645f --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..1a288ffd425 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..1c2988eec98 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_iptag.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_iptag.go new file mode 100644 index 00000000000..f54e708d614 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_iptag.go @@ -0,0 +1,9 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..cf9e4a0b97f --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..f1b9e0732ac --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_natgateway.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_natgateway.go new file mode 100644 index 00000000000..bd2135c7219 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_natgateway.go @@ -0,0 +1,20 @@ +package dscpconfiguration + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..54b46fec72c --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_natgatewaysku.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_natgatewaysku.go new file mode 100644 index 00000000000..38065785ee7 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_natruleportmapping.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_natruleportmapping.go new file mode 100644 index 00000000000..4f0a40c3c84 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterface.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterface.go new file mode 100644 index 00000000000..2c8dff0b372 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterface.go @@ -0,0 +1,19 @@ +package dscpconfiguration + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..db01e0a6931 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..cbe1f2ef1bc --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..1901cc2fecb --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..a54e9fc0792 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..7287ef2d8e0 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..9141e163666 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..b1504509e4c --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_networksecuritygroup.go new file mode 100644 index 00000000000..79ddb5537a1 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..76177bde258 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpoint.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpoint.go new file mode 100644 index 00000000000..b8b7f950b24 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpoint.go @@ -0,0 +1,19 @@ +package dscpconfiguration + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpointconnection.go new file mode 100644 index 00000000000..f374ac95239 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..a3590daea44 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..d15e9404362 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..fbd74e39c9c --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpointproperties.go new file mode 100644 index 00000000000..9bddc7a4349 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkservice.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkservice.go new file mode 100644 index 00000000000..3f4dea0d52f --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package dscpconfiguration + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..ca5cf780e20 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..7fa3b795937 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..003e73140c9 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..1a98c978c4e --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..298e27cde46 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..414f505d677 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_publicipaddress.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_publicipaddress.go new file mode 100644 index 00000000000..d57ce42d098 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_publicipaddress.go @@ -0,0 +1,22 @@ +package dscpconfiguration + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..9c3cb7a4ffe --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..2745ba7952e --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_publicipaddresssku.go new file mode 100644 index 00000000000..184f29e9bf9 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_qosdefinition.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_qosdefinition.go new file mode 100644 index 00000000000..ad3c5e88a17 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_qosdefinition.go @@ -0,0 +1,13 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QosDefinition struct { + DestinationIPRanges *[]QosIPRange `json:"destinationIpRanges,omitempty"` + DestinationPortRanges *[]QosPortRange `json:"destinationPortRanges,omitempty"` + Markings *[]int64 `json:"markings,omitempty"` + Protocol *ProtocolType `json:"protocol,omitempty"` + SourceIPRanges *[]QosIPRange `json:"sourceIpRanges,omitempty"` + SourcePortRanges *[]QosPortRange `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_qosiprange.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_qosiprange.go new file mode 100644 index 00000000000..9de17d31fd5 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_qosiprange.go @@ -0,0 +1,9 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QosIPRange struct { + EndIP *string `json:"endIP,omitempty"` + StartIP *string `json:"startIP,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_qosportrange.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_qosportrange.go new file mode 100644 index 00000000000..fec0d277115 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_qosportrange.go @@ -0,0 +1,9 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QosPortRange struct { + End *int64 `json:"end,omitempty"` + Start *int64 `json:"start,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_resourcenavigationlink.go new file mode 100644 index 00000000000..e5b6bc9921c --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..7119a8ad8fd --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_resourceset.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_resourceset.go new file mode 100644 index 00000000000..eb8146e0601 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_resourceset.go @@ -0,0 +1,8 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..73bc84cb5f0 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_route.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_route.go new file mode 100644 index 00000000000..43d479a10b9 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_route.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_routepropertiesformat.go new file mode 100644 index 00000000000..f0ba5752c84 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_routetable.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_routetable.go new file mode 100644 index 00000000000..ffa38a33f5c --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_routetable.go @@ -0,0 +1,14 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..f2d7db2da04 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_securityrule.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_securityrule.go new file mode 100644 index 00000000000..670a04f125b --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_securityrule.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..313bad92221 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceassociationlink.go new file mode 100644 index 00000000000..51b7b88b0b4 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..e74136ad481 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..ee33b9b67db --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..a4c7c550a6c --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..d902694b0cc --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..acf884117e3 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..94a2649c90d --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..aa82fc5a9eb --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_subnet.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_subnet.go new file mode 100644 index 00000000000..0c94d71385f --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_subnet.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..c1af7036c22 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_subresource.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_subresource.go new file mode 100644 index 00000000000..16bee506d8d --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_subresource.go @@ -0,0 +1,8 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..84d2f9e07a1 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..a1e61262ce4 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_virtualnetworktap.go new file mode 100644 index 00000000000..6b0b8a746c6 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfiguration/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..cbbb01641bc --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfiguration/version.go b/resource-manager/network/2024-07-01/dscpconfiguration/version.go new file mode 100644 index 00000000000..e528f1f3eed --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfiguration/version.go @@ -0,0 +1,10 @@ +package dscpconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/dscpconfiguration/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/README.md b/resource-manager/network/2024-07-01/dscpconfigurations/README.md new file mode 100644 index 00000000000..5cabdba1432 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/README.md @@ -0,0 +1,55 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/dscpconfigurations` Documentation + +The `dscpconfigurations` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/dscpconfigurations" +``` + + +### Client Initialization + +```go +client := dscpconfigurations.NewDscpConfigurationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DscpConfigurationsClient.DscpConfigurationList` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.DscpConfigurationList(ctx, id)` can be used to do batched pagination +items, err := client.DscpConfigurationListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DscpConfigurationsClient.DscpConfigurationListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.DscpConfigurationListAll(ctx, id)` can be used to do batched pagination +items, err := client.DscpConfigurationListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/client.go b/resource-manager/network/2024-07-01/dscpconfigurations/client.go new file mode 100644 index 00000000000..f8740f737f6 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/client.go @@ -0,0 +1,26 @@ +package dscpconfigurations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DscpConfigurationsClient struct { + Client *resourcemanager.Client +} + +func NewDscpConfigurationsClientWithBaseURI(sdkApi sdkEnv.Api) (*DscpConfigurationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "dscpconfigurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DscpConfigurationsClient: %+v", err) + } + + return &DscpConfigurationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/constants.go b/resource-manager/network/2024-07-01/dscpconfigurations/constants.go new file mode 100644 index 00000000000..9a37a868ec5 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/constants.go @@ -0,0 +1,1266 @@ +package dscpconfigurations + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProtocolType string + +const ( + ProtocolTypeAh ProtocolType = "Ah" + ProtocolTypeAll ProtocolType = "All" + ProtocolTypeDoNotUse ProtocolType = "DoNotUse" + ProtocolTypeEsp ProtocolType = "Esp" + ProtocolTypeGre ProtocolType = "Gre" + ProtocolTypeIcmp ProtocolType = "Icmp" + ProtocolTypeTcp ProtocolType = "Tcp" + ProtocolTypeUdp ProtocolType = "Udp" + ProtocolTypeVxlan ProtocolType = "Vxlan" +) + +func PossibleValuesForProtocolType() []string { + return []string{ + string(ProtocolTypeAh), + string(ProtocolTypeAll), + string(ProtocolTypeDoNotUse), + string(ProtocolTypeEsp), + string(ProtocolTypeGre), + string(ProtocolTypeIcmp), + string(ProtocolTypeTcp), + string(ProtocolTypeUdp), + string(ProtocolTypeVxlan), + } +} + +func (s *ProtocolType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtocolType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtocolType(input string) (*ProtocolType, error) { + vals := map[string]ProtocolType{ + "ah": ProtocolTypeAh, + "all": ProtocolTypeAll, + "donotuse": ProtocolTypeDoNotUse, + "esp": ProtocolTypeEsp, + "gre": ProtocolTypeGre, + "icmp": ProtocolTypeIcmp, + "tcp": ProtocolTypeTcp, + "udp": ProtocolTypeUdp, + "vxlan": ProtocolTypeVxlan, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProtocolType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/method_dscpconfigurationlist.go b/resource-manager/network/2024-07-01/dscpconfigurations/method_dscpconfigurationlist.go new file mode 100644 index 00000000000..c3e8d3869d4 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/method_dscpconfigurationlist.go @@ -0,0 +1,106 @@ +package dscpconfigurations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DscpConfigurationListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DscpConfiguration +} + +type DscpConfigurationListCompleteResult struct { + LatestHttpResponse *http.Response + Items []DscpConfiguration +} + +type DscpConfigurationListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *DscpConfigurationListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// DscpConfigurationList ... +func (c DscpConfigurationsClient) DscpConfigurationList(ctx context.Context, id commonids.ResourceGroupId) (result DscpConfigurationListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &DscpConfigurationListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/dscpConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DscpConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// DscpConfigurationListComplete retrieves all the results into a single object +func (c DscpConfigurationsClient) DscpConfigurationListComplete(ctx context.Context, id commonids.ResourceGroupId) (DscpConfigurationListCompleteResult, error) { + return c.DscpConfigurationListCompleteMatchingPredicate(ctx, id, DscpConfigurationOperationPredicate{}) +} + +// DscpConfigurationListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DscpConfigurationsClient) DscpConfigurationListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate DscpConfigurationOperationPredicate) (result DscpConfigurationListCompleteResult, err error) { + items := make([]DscpConfiguration, 0) + + resp, err := c.DscpConfigurationList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = DscpConfigurationListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/method_dscpconfigurationlistall.go b/resource-manager/network/2024-07-01/dscpconfigurations/method_dscpconfigurationlistall.go new file mode 100644 index 00000000000..fe261147a6d --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/method_dscpconfigurationlistall.go @@ -0,0 +1,106 @@ +package dscpconfigurations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DscpConfigurationListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DscpConfiguration +} + +type DscpConfigurationListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []DscpConfiguration +} + +type DscpConfigurationListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *DscpConfigurationListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// DscpConfigurationListAll ... +func (c DscpConfigurationsClient) DscpConfigurationListAll(ctx context.Context, id commonids.SubscriptionId) (result DscpConfigurationListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &DscpConfigurationListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/dscpConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DscpConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// DscpConfigurationListAllComplete retrieves all the results into a single object +func (c DscpConfigurationsClient) DscpConfigurationListAllComplete(ctx context.Context, id commonids.SubscriptionId) (DscpConfigurationListAllCompleteResult, error) { + return c.DscpConfigurationListAllCompleteMatchingPredicate(ctx, id, DscpConfigurationOperationPredicate{}) +} + +// DscpConfigurationListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DscpConfigurationsClient) DscpConfigurationListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DscpConfigurationOperationPredicate) (result DscpConfigurationListAllCompleteResult, err error) { + items := make([]DscpConfiguration, 0) + + resp, err := c.DscpConfigurationListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = DscpConfigurationListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..b7b1e084f2c --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..2ee5c1c3577 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..e420a9bdc67 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..1c532c8b751 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..461f708325f --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..7c885418df4 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..06db97d0e6f --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_backendaddresspool.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_backendaddresspool.go new file mode 100644 index 00000000000..9063fe9528b --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..9d15cc6c925 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..29791c2c31f --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_ddossettings.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_ddossettings.go new file mode 100644 index 00000000000..0a6ba1cc0f5 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_ddossettings.go @@ -0,0 +1,9 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_delegation.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_delegation.go new file mode 100644 index 00000000000..3db69c6181a --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_delegation.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_dscpconfiguration.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_dscpconfiguration.go new file mode 100644 index 00000000000..addfd61ed3c --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_dscpconfiguration.go @@ -0,0 +1,14 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DscpConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DscpConfigurationPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_dscpconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_dscpconfigurationpropertiesformat.go new file mode 100644 index 00000000000..3de3861ee9e --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_dscpconfigurationpropertiesformat.go @@ -0,0 +1,18 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DscpConfigurationPropertiesFormat struct { + AssociatedNetworkInterfaces *[]NetworkInterface `json:"associatedNetworkInterfaces,omitempty"` + DestinationIPRanges *[]QosIPRange `json:"destinationIpRanges,omitempty"` + DestinationPortRanges *[]QosPortRange `json:"destinationPortRanges,omitempty"` + Markings *[]int64 `json:"markings,omitempty"` + Protocol *ProtocolType `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + QosCollectionId *string `json:"qosCollectionId,omitempty"` + QosDefinitionCollection *[]QosDefinition `json:"qosDefinitionCollection,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceIPRanges *[]QosIPRange `json:"sourceIpRanges,omitempty"` + SourcePortRanges *[]QosPortRange `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_flowlog.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_flowlog.go new file mode 100644 index 00000000000..c4fcf026e8c --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_flowlog.go @@ -0,0 +1,19 @@ +package dscpconfigurations + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_flowlogformatparameters.go new file mode 100644 index 00000000000..c2ca6492542 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..52821e95a74 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_frontendipconfiguration.go new file mode 100644 index 00000000000..55b02b251ca --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package dscpconfigurations + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..04b3e1aafc3 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..fba1a411047 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_inboundnatrule.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_inboundnatrule.go new file mode 100644 index 00000000000..b60bfcd7088 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..598cd5d43a5 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..52328218394 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..da12d6f237b --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_ipconfiguration.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_ipconfiguration.go new file mode 100644 index 00000000000..2532732b5b2 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..ce6d532c39b --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..afde579aaa3 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..c5919fd2db3 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_iptag.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_iptag.go new file mode 100644 index 00000000000..f38ed9d8c65 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_iptag.go @@ -0,0 +1,9 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..7ad5779c262 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..313080c155c --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_natgateway.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_natgateway.go new file mode 100644 index 00000000000..64ee487573f --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_natgateway.go @@ -0,0 +1,20 @@ +package dscpconfigurations + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..7a13491dc48 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_natgatewaysku.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_natgatewaysku.go new file mode 100644 index 00000000000..f13dbd3d8fa --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_natruleportmapping.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_natruleportmapping.go new file mode 100644 index 00000000000..4f09709144d --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterface.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterface.go new file mode 100644 index 00000000000..0b5454d16ca --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterface.go @@ -0,0 +1,19 @@ +package dscpconfigurations + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..11f9a45a307 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..d4cb1b886b6 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..0b175cf4025 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..ef75e49ef70 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..9ec1ae65bd6 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..134cf5c3661 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..f77ecd6167d --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_networksecuritygroup.go new file mode 100644 index 00000000000..f9ea08d3a85 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..0cac57de47f --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpoint.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpoint.go new file mode 100644 index 00000000000..0e5fb891d8c --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpoint.go @@ -0,0 +1,19 @@ +package dscpconfigurations + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpointconnection.go new file mode 100644 index 00000000000..64a8a54e559 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..b41f2269c5b --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..cee431f3b19 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..8ffd50d3002 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpointproperties.go new file mode 100644 index 00000000000..b098e9d6023 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkservice.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkservice.go new file mode 100644 index 00000000000..60b183ef94a --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package dscpconfigurations + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..963c255ab64 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..9f2e27f4720 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..3662d04a08f --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..d0932cbb597 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..b471f35042f --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..97d69c9c197 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_publicipaddress.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_publicipaddress.go new file mode 100644 index 00000000000..4fc95713929 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_publicipaddress.go @@ -0,0 +1,22 @@ +package dscpconfigurations + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..adee4abe556 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..b1758ec95ac --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_publicipaddresssku.go new file mode 100644 index 00000000000..a429ae17ad7 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_qosdefinition.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_qosdefinition.go new file mode 100644 index 00000000000..c578549b24d --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_qosdefinition.go @@ -0,0 +1,13 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QosDefinition struct { + DestinationIPRanges *[]QosIPRange `json:"destinationIpRanges,omitempty"` + DestinationPortRanges *[]QosPortRange `json:"destinationPortRanges,omitempty"` + Markings *[]int64 `json:"markings,omitempty"` + Protocol *ProtocolType `json:"protocol,omitempty"` + SourceIPRanges *[]QosIPRange `json:"sourceIpRanges,omitempty"` + SourcePortRanges *[]QosPortRange `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_qosiprange.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_qosiprange.go new file mode 100644 index 00000000000..a7109f45e97 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_qosiprange.go @@ -0,0 +1,9 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QosIPRange struct { + EndIP *string `json:"endIP,omitempty"` + StartIP *string `json:"startIP,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_qosportrange.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_qosportrange.go new file mode 100644 index 00000000000..1c241e416d6 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_qosportrange.go @@ -0,0 +1,9 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QosPortRange struct { + End *int64 `json:"end,omitempty"` + Start *int64 `json:"start,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_resourcenavigationlink.go new file mode 100644 index 00000000000..a441a261d0b --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..42c361f9ff9 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_resourceset.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_resourceset.go new file mode 100644 index 00000000000..36c2929fe5c --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_resourceset.go @@ -0,0 +1,8 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..6cb1197a4d8 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_route.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_route.go new file mode 100644 index 00000000000..58b9462885c --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_route.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_routepropertiesformat.go new file mode 100644 index 00000000000..57d611a55aa --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_routetable.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_routetable.go new file mode 100644 index 00000000000..3c19f2937d7 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_routetable.go @@ -0,0 +1,14 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..8d9f9c65d1c --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_securityrule.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_securityrule.go new file mode 100644 index 00000000000..eefb302d3d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_securityrule.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..d43f1f5f3b1 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceassociationlink.go new file mode 100644 index 00000000000..e968a6667b0 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..3756e4aca2b --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..4576bcc01d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..e1bf0604459 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..9693e4de6b7 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..c277cb3ff86 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..31009213cca --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..b8e43ff379c --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_subnet.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_subnet.go new file mode 100644 index 00000000000..6c58caf5de4 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_subnet.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..4682cb019ea --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_subresource.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_subresource.go new file mode 100644 index 00000000000..f4f23a8234b --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_subresource.go @@ -0,0 +1,8 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..f9dd4dab77f --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..6e509b308b5 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_virtualnetworktap.go new file mode 100644 index 00000000000..ae0f9ad6412 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/dscpconfigurations/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..bc1c19bd39f --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/predicates.go b/resource-manager/network/2024-07-01/dscpconfigurations/predicates.go new file mode 100644 index 00000000000..7628df6beb6 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/predicates.go @@ -0,0 +1,37 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DscpConfigurationOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p DscpConfigurationOperationPredicate) Matches(input DscpConfiguration) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/dscpconfigurations/version.go b/resource-manager/network/2024-07-01/dscpconfigurations/version.go new file mode 100644 index 00000000000..4d4a38cfd52 --- /dev/null +++ b/resource-manager/network/2024-07-01/dscpconfigurations/version.go @@ -0,0 +1,10 @@ +package dscpconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/dscpconfigurations/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/endpointservices/README.md b/resource-manager/network/2024-07-01/endpointservices/README.md new file mode 100644 index 00000000000..930fcccb39e --- /dev/null +++ b/resource-manager/network/2024-07-01/endpointservices/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/endpointservices` Documentation + +The `endpointservices` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/endpointservices" +``` + + +### Client Initialization + +```go +client := endpointservices.NewEndpointServicesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `EndpointServicesClient.AvailableEndpointServicesList` + +```go +ctx := context.TODO() +id := endpointservices.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.AvailableEndpointServicesList(ctx, id)` can be used to do batched pagination +items, err := client.AvailableEndpointServicesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/endpointservices/client.go b/resource-manager/network/2024-07-01/endpointservices/client.go new file mode 100644 index 00000000000..44e82b37c46 --- /dev/null +++ b/resource-manager/network/2024-07-01/endpointservices/client.go @@ -0,0 +1,26 @@ +package endpointservices + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointServicesClient struct { + Client *resourcemanager.Client +} + +func NewEndpointServicesClientWithBaseURI(sdkApi sdkEnv.Api) (*EndpointServicesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "endpointservices", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating EndpointServicesClient: %+v", err) + } + + return &EndpointServicesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/endpointservices/id_location.go b/resource-manager/network/2024-07-01/endpointservices/id_location.go new file mode 100644 index 00000000000..18eaa8353af --- /dev/null +++ b/resource-manager/network/2024-07-01/endpointservices/id_location.go @@ -0,0 +1,121 @@ +package endpointservices + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Network/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/endpointservices/id_location_test.go b/resource-manager/network/2024-07-01/endpointservices/id_location_test.go new file mode 100644 index 00000000000..0213283041f --- /dev/null +++ b/resource-manager/network/2024-07-01/endpointservices/id_location_test.go @@ -0,0 +1,237 @@ +package endpointservices + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/endpointservices/method_availableendpointserviceslist.go b/resource-manager/network/2024-07-01/endpointservices/method_availableendpointserviceslist.go new file mode 100644 index 00000000000..28193e5d9e7 --- /dev/null +++ b/resource-manager/network/2024-07-01/endpointservices/method_availableendpointserviceslist.go @@ -0,0 +1,105 @@ +package endpointservices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableEndpointServicesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]EndpointServiceResult +} + +type AvailableEndpointServicesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []EndpointServiceResult +} + +type AvailableEndpointServicesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *AvailableEndpointServicesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// AvailableEndpointServicesList ... +func (c EndpointServicesClient) AvailableEndpointServicesList(ctx context.Context, id LocationId) (result AvailableEndpointServicesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &AvailableEndpointServicesListCustomPager{}, + Path: fmt.Sprintf("%s/virtualNetworkAvailableEndpointServices", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]EndpointServiceResult `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// AvailableEndpointServicesListComplete retrieves all the results into a single object +func (c EndpointServicesClient) AvailableEndpointServicesListComplete(ctx context.Context, id LocationId) (AvailableEndpointServicesListCompleteResult, error) { + return c.AvailableEndpointServicesListCompleteMatchingPredicate(ctx, id, EndpointServiceResultOperationPredicate{}) +} + +// AvailableEndpointServicesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c EndpointServicesClient) AvailableEndpointServicesListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate EndpointServiceResultOperationPredicate) (result AvailableEndpointServicesListCompleteResult, err error) { + items := make([]EndpointServiceResult, 0) + + resp, err := c.AvailableEndpointServicesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = AvailableEndpointServicesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/endpointservices/model_endpointserviceresult.go b/resource-manager/network/2024-07-01/endpointservices/model_endpointserviceresult.go new file mode 100644 index 00000000000..eae6c698d45 --- /dev/null +++ b/resource-manager/network/2024-07-01/endpointservices/model_endpointserviceresult.go @@ -0,0 +1,10 @@ +package endpointservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointServiceResult struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/endpointservices/predicates.go b/resource-manager/network/2024-07-01/endpointservices/predicates.go new file mode 100644 index 00000000000..9a5ec06a288 --- /dev/null +++ b/resource-manager/network/2024-07-01/endpointservices/predicates.go @@ -0,0 +1,27 @@ +package endpointservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointServiceResultOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p EndpointServiceResultOperationPredicate) Matches(input EndpointServiceResult) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/endpointservices/version.go b/resource-manager/network/2024-07-01/endpointservices/version.go new file mode 100644 index 00000000000..fb5b2bee36f --- /dev/null +++ b/resource-manager/network/2024-07-01/endpointservices/version.go @@ -0,0 +1,10 @@ +package endpointservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/endpointservices/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitarptable/README.md b/resource-manager/network/2024-07-01/expressroutecircuitarptable/README.md new file mode 100644 index 00000000000..2ce855b6e51 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitarptable/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitarptable` Documentation + +The `expressroutecircuitarptable` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitarptable" +``` + + +### Client Initialization + +```go +client := expressroutecircuitarptable.NewExpressRouteCircuitArpTableClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteCircuitArpTableClient.ExpressRouteCircuitsListArpTable` + +```go +ctx := context.TODO() +id := expressroutecircuitarptable.NewArpTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName", "arpTableName") + +// alternatively `client.ExpressRouteCircuitsListArpTable(ctx, id)` can be used to do batched pagination +items, err := client.ExpressRouteCircuitsListArpTableComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/expressroutecircuitarptable/client.go b/resource-manager/network/2024-07-01/expressroutecircuitarptable/client.go new file mode 100644 index 00000000000..b13a5d9774e --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitarptable/client.go @@ -0,0 +1,26 @@ +package expressroutecircuitarptable + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitArpTableClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteCircuitArpTableClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteCircuitArpTableClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressroutecircuitarptable", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteCircuitArpTableClient: %+v", err) + } + + return &ExpressRouteCircuitArpTableClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitarptable/id_arptable.go b/resource-manager/network/2024-07-01/expressroutecircuitarptable/id_arptable.go new file mode 100644 index 00000000000..d35a8eadadf --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitarptable/id_arptable.go @@ -0,0 +1,148 @@ +package expressroutecircuitarptable + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ArpTableId{}) +} + +var _ resourceids.ResourceId = &ArpTableId{} + +// ArpTableId is a struct representing the Resource ID for a Arp Table +type ArpTableId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteCircuitName string + PeeringName string + ArpTableName string +} + +// NewArpTableID returns a new ArpTableId struct +func NewArpTableID(subscriptionId string, resourceGroupName string, expressRouteCircuitName string, peeringName string, arpTableName string) ArpTableId { + return ArpTableId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteCircuitName: expressRouteCircuitName, + PeeringName: peeringName, + ArpTableName: arpTableName, + } +} + +// ParseArpTableID parses 'input' into a ArpTableId +func ParseArpTableID(input string) (*ArpTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&ArpTableId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ArpTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseArpTableIDInsensitively parses 'input' case-insensitively into a ArpTableId +// note: this method should only be used for API response data and not user input +func ParseArpTableIDInsensitively(input string) (*ArpTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&ArpTableId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ArpTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ArpTableId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteCircuitName, ok = input.Parsed["expressRouteCircuitName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteCircuitName", input) + } + + if id.PeeringName, ok = input.Parsed["peeringName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "peeringName", input) + } + + if id.ArpTableName, ok = input.Parsed["arpTableName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "arpTableName", input) + } + + return nil +} + +// ValidateArpTableID checks that 'input' can be parsed as a Arp Table ID +func ValidateArpTableID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseArpTableID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Arp Table ID +func (id ArpTableId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCircuits/%s/peerings/%s/arpTables/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteCircuitName, id.PeeringName, id.ArpTableName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Arp Table ID +func (id ArpTableId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteCircuits", "expressRouteCircuits", "expressRouteCircuits"), + resourceids.UserSpecifiedSegment("expressRouteCircuitName", "expressRouteCircuitName"), + resourceids.StaticSegment("staticPeerings", "peerings", "peerings"), + resourceids.UserSpecifiedSegment("peeringName", "peeringName"), + resourceids.StaticSegment("staticArpTables", "arpTables", "arpTables"), + resourceids.UserSpecifiedSegment("arpTableName", "arpTableName"), + } +} + +// String returns a human-readable description of this Arp Table ID +func (id ArpTableId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Circuit Name: %q", id.ExpressRouteCircuitName), + fmt.Sprintf("Peering Name: %q", id.PeeringName), + fmt.Sprintf("Arp Table Name: %q", id.ArpTableName), + } + return fmt.Sprintf("Arp Table (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitarptable/id_arptable_test.go b/resource-manager/network/2024-07-01/expressroutecircuitarptable/id_arptable_test.go new file mode 100644 index 00000000000..66d3e99f02e --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitarptable/id_arptable_test.go @@ -0,0 +1,372 @@ +package expressroutecircuitarptable + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ArpTableId{} + +func TestNewArpTableID(t *testing.T) { + id := NewArpTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName", "arpTableName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteCircuitName != "expressRouteCircuitName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteCircuitName'", id.ExpressRouteCircuitName, "expressRouteCircuitName") + } + + if id.PeeringName != "peeringName" { + t.Fatalf("Expected %q but got %q for Segment 'PeeringName'", id.PeeringName, "peeringName") + } + + if id.ArpTableName != "arpTableName" { + t.Fatalf("Expected %q but got %q for Segment 'ArpTableName'", id.ArpTableName, "arpTableName") + } +} + +func TestFormatArpTableID(t *testing.T) { + actual := NewArpTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName", "arpTableName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/arpTables/arpTableName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseArpTableID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ArpTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/arpTables", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/arpTables/arpTableName", + Expected: &ArpTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + PeeringName: "peeringName", + ArpTableName: "arpTableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/arpTables/arpTableName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseArpTableID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + if actual.ArpTableName != v.Expected.ArpTableName { + t.Fatalf("Expected %q but got %q for ArpTableName", v.Expected.ArpTableName, actual.ArpTableName) + } + + } +} + +func TestParseArpTableIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ArpTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/arpTables", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe/aRpTaBlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/arpTables/arpTableName", + Expected: &ArpTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + PeeringName: "peeringName", + ArpTableName: "arpTableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/arpTables/arpTableName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe/aRpTaBlEs/aRpTaBlEnAmE", + Expected: &ArpTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteCircuitName: "eXpReSsRoUtEcIrCuItNaMe", + PeeringName: "pEeRiNgNaMe", + ArpTableName: "aRpTaBlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe/aRpTaBlEs/aRpTaBlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseArpTableIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + if actual.ArpTableName != v.Expected.ArpTableName { + t.Fatalf("Expected %q but got %q for ArpTableName", v.Expected.ArpTableName, actual.ArpTableName) + } + + } +} + +func TestSegmentsForArpTableId(t *testing.T) { + segments := ArpTableId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ArpTableId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitarptable/method_expressroutecircuitslistarptable.go b/resource-manager/network/2024-07-01/expressroutecircuitarptable/method_expressroutecircuitslistarptable.go new file mode 100644 index 00000000000..27f7b0349e2 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitarptable/method_expressroutecircuitslistarptable.go @@ -0,0 +1,89 @@ +package expressroutecircuitarptable + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitsListArpTableOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteCircuitArpTable +} + +type ExpressRouteCircuitsListArpTableCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteCircuitArpTable +} + +type ExpressRouteCircuitsListArpTableCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ExpressRouteCircuitsListArpTableCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ExpressRouteCircuitsListArpTable ... +func (c ExpressRouteCircuitArpTableClient) ExpressRouteCircuitsListArpTable(ctx context.Context, id ArpTableId) (result ExpressRouteCircuitsListArpTableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ExpressRouteCircuitsListArpTableCustomPager{}, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ExpressRouteCircuitsListArpTableThenPoll performs ExpressRouteCircuitsListArpTable then polls until it's completed +func (c ExpressRouteCircuitArpTableClient) ExpressRouteCircuitsListArpTableThenPoll(ctx context.Context, id ArpTableId) error { + result, err := c.ExpressRouteCircuitsListArpTable(ctx, id) + if err != nil { + return fmt.Errorf("performing ExpressRouteCircuitsListArpTable: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ExpressRouteCircuitsListArpTable: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitarptable/model_expressroutecircuitarptable.go b/resource-manager/network/2024-07-01/expressroutecircuitarptable/model_expressroutecircuitarptable.go new file mode 100644 index 00000000000..8b4183dd49f --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitarptable/model_expressroutecircuitarptable.go @@ -0,0 +1,11 @@ +package expressroutecircuitarptable + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitArpTable struct { + Age *int64 `json:"age,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Interface *string `json:"interface,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitarptable/predicates.go b/resource-manager/network/2024-07-01/expressroutecircuitarptable/predicates.go new file mode 100644 index 00000000000..4143b82875f --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitarptable/predicates.go @@ -0,0 +1,32 @@ +package expressroutecircuitarptable + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitArpTableOperationPredicate struct { + Age *int64 + IPAddress *string + Interface *string + MacAddress *string +} + +func (p ExpressRouteCircuitArpTableOperationPredicate) Matches(input ExpressRouteCircuitArpTable) bool { + + if p.Age != nil && (input.Age == nil || *p.Age != *input.Age) { + return false + } + + if p.IPAddress != nil && (input.IPAddress == nil || *p.IPAddress != *input.IPAddress) { + return false + } + + if p.Interface != nil && (input.Interface == nil || *p.Interface != *input.Interface) { + return false + } + + if p.MacAddress != nil && (input.MacAddress == nil || *p.MacAddress != *input.MacAddress) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitarptable/version.go b/resource-manager/network/2024-07-01/expressroutecircuitarptable/version.go new file mode 100644 index 00000000000..dd6971ab9c8 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitarptable/version.go @@ -0,0 +1,10 @@ +package expressroutecircuitarptable + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressroutecircuitarptable/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/README.md b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/README.md new file mode 100644 index 00000000000..0a4d47abde2 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitauthorizations` Documentation + +The `expressroutecircuitauthorizations` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitauthorizations" +``` + + +### Client Initialization + +```go +client := expressroutecircuitauthorizations.NewExpressRouteCircuitAuthorizationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteCircuitAuthorizationsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := expressroutecircuitauthorizations.NewAuthorizationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "authorizationName") + +payload := expressroutecircuitauthorizations.ExpressRouteCircuitAuthorization{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRouteCircuitAuthorizationsClient.Delete` + +```go +ctx := context.TODO() +id := expressroutecircuitauthorizations.NewAuthorizationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "authorizationName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRouteCircuitAuthorizationsClient.Get` + +```go +ctx := context.TODO() +id := expressroutecircuitauthorizations.NewAuthorizationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "authorizationName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ExpressRouteCircuitAuthorizationsClient.List` + +```go +ctx := context.TODO() +id := expressroutecircuitauthorizations.NewExpressRouteCircuitID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/client.go b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/client.go new file mode 100644 index 00000000000..2d3988ae8a8 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/client.go @@ -0,0 +1,26 @@ +package expressroutecircuitauthorizations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitAuthorizationsClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteCircuitAuthorizationsClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteCircuitAuthorizationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressroutecircuitauthorizations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteCircuitAuthorizationsClient: %+v", err) + } + + return &ExpressRouteCircuitAuthorizationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/constants.go b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/constants.go new file mode 100644 index 00000000000..052d235a64f --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/constants.go @@ -0,0 +1,98 @@ +package expressroutecircuitauthorizations + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthorizationUseStatus string + +const ( + AuthorizationUseStatusAvailable AuthorizationUseStatus = "Available" + AuthorizationUseStatusInUse AuthorizationUseStatus = "InUse" +) + +func PossibleValuesForAuthorizationUseStatus() []string { + return []string{ + string(AuthorizationUseStatusAvailable), + string(AuthorizationUseStatusInUse), + } +} + +func (s *AuthorizationUseStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthorizationUseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthorizationUseStatus(input string) (*AuthorizationUseStatus, error) { + vals := map[string]AuthorizationUseStatus{ + "available": AuthorizationUseStatusAvailable, + "inuse": AuthorizationUseStatusInUse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthorizationUseStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/id_authorization.go b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/id_authorization.go new file mode 100644 index 00000000000..9da101d4a62 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/id_authorization.go @@ -0,0 +1,139 @@ +package expressroutecircuitauthorizations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AuthorizationId{}) +} + +var _ resourceids.ResourceId = &AuthorizationId{} + +// AuthorizationId is a struct representing the Resource ID for a Authorization +type AuthorizationId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteCircuitName string + AuthorizationName string +} + +// NewAuthorizationID returns a new AuthorizationId struct +func NewAuthorizationID(subscriptionId string, resourceGroupName string, expressRouteCircuitName string, authorizationName string) AuthorizationId { + return AuthorizationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteCircuitName: expressRouteCircuitName, + AuthorizationName: authorizationName, + } +} + +// ParseAuthorizationID parses 'input' into a AuthorizationId +func ParseAuthorizationID(input string) (*AuthorizationId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthorizationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthorizationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAuthorizationIDInsensitively parses 'input' case-insensitively into a AuthorizationId +// note: this method should only be used for API response data and not user input +func ParseAuthorizationIDInsensitively(input string) (*AuthorizationId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthorizationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthorizationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AuthorizationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteCircuitName, ok = input.Parsed["expressRouteCircuitName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteCircuitName", input) + } + + if id.AuthorizationName, ok = input.Parsed["authorizationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "authorizationName", input) + } + + return nil +} + +// ValidateAuthorizationID checks that 'input' can be parsed as a Authorization ID +func ValidateAuthorizationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseAuthorizationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Authorization ID +func (id AuthorizationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCircuits/%s/authorizations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteCircuitName, id.AuthorizationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Authorization ID +func (id AuthorizationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteCircuits", "expressRouteCircuits", "expressRouteCircuits"), + resourceids.UserSpecifiedSegment("expressRouteCircuitName", "expressRouteCircuitName"), + resourceids.StaticSegment("staticAuthorizations", "authorizations", "authorizations"), + resourceids.UserSpecifiedSegment("authorizationName", "authorizationName"), + } +} + +// String returns a human-readable description of this Authorization ID +func (id AuthorizationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Circuit Name: %q", id.ExpressRouteCircuitName), + fmt.Sprintf("Authorization Name: %q", id.AuthorizationName), + } + return fmt.Sprintf("Authorization (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/id_authorization_test.go b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/id_authorization_test.go new file mode 100644 index 00000000000..60d0dbacbe5 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/id_authorization_test.go @@ -0,0 +1,327 @@ +package expressroutecircuitauthorizations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AuthorizationId{} + +func TestNewAuthorizationID(t *testing.T) { + id := NewAuthorizationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "authorizationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteCircuitName != "expressRouteCircuitName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteCircuitName'", id.ExpressRouteCircuitName, "expressRouteCircuitName") + } + + if id.AuthorizationName != "authorizationName" { + t.Fatalf("Expected %q but got %q for Segment 'AuthorizationName'", id.AuthorizationName, "authorizationName") + } +} + +func TestFormatAuthorizationID(t *testing.T) { + actual := NewAuthorizationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "authorizationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/authorizations/authorizationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAuthorizationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthorizationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/authorizations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/authorizations/authorizationName", + Expected: &AuthorizationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + AuthorizationName: "authorizationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/authorizations/authorizationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthorizationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + if actual.AuthorizationName != v.Expected.AuthorizationName { + t.Fatalf("Expected %q but got %q for AuthorizationName", v.Expected.AuthorizationName, actual.AuthorizationName) + } + + } +} + +func TestParseAuthorizationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthorizationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/authorizations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/aUtHoRiZaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/authorizations/authorizationName", + Expected: &AuthorizationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + AuthorizationName: "authorizationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/authorizations/authorizationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/aUtHoRiZaTiOnS/aUtHoRiZaTiOnNaMe", + Expected: &AuthorizationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteCircuitName: "eXpReSsRoUtEcIrCuItNaMe", + AuthorizationName: "aUtHoRiZaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/aUtHoRiZaTiOnS/aUtHoRiZaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthorizationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + if actual.AuthorizationName != v.Expected.AuthorizationName { + t.Fatalf("Expected %q but got %q for AuthorizationName", v.Expected.AuthorizationName, actual.AuthorizationName) + } + + } +} + +func TestSegmentsForAuthorizationId(t *testing.T) { + segments := AuthorizationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AuthorizationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/id_expressroutecircuit.go b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/id_expressroutecircuit.go new file mode 100644 index 00000000000..210f0ae6366 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/id_expressroutecircuit.go @@ -0,0 +1,130 @@ +package expressroutecircuitauthorizations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ExpressRouteCircuitId{}) +} + +var _ resourceids.ResourceId = &ExpressRouteCircuitId{} + +// ExpressRouteCircuitId is a struct representing the Resource ID for a Express Route Circuit +type ExpressRouteCircuitId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteCircuitName string +} + +// NewExpressRouteCircuitID returns a new ExpressRouteCircuitId struct +func NewExpressRouteCircuitID(subscriptionId string, resourceGroupName string, expressRouteCircuitName string) ExpressRouteCircuitId { + return ExpressRouteCircuitId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteCircuitName: expressRouteCircuitName, + } +} + +// ParseExpressRouteCircuitID parses 'input' into a ExpressRouteCircuitId +func ParseExpressRouteCircuitID(input string) (*ExpressRouteCircuitId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteCircuitId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteCircuitId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseExpressRouteCircuitIDInsensitively parses 'input' case-insensitively into a ExpressRouteCircuitId +// note: this method should only be used for API response data and not user input +func ParseExpressRouteCircuitIDInsensitively(input string) (*ExpressRouteCircuitId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteCircuitId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteCircuitId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ExpressRouteCircuitId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteCircuitName, ok = input.Parsed["expressRouteCircuitName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteCircuitName", input) + } + + return nil +} + +// ValidateExpressRouteCircuitID checks that 'input' can be parsed as a Express Route Circuit ID +func ValidateExpressRouteCircuitID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseExpressRouteCircuitID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Express Route Circuit ID +func (id ExpressRouteCircuitId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCircuits/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteCircuitName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Express Route Circuit ID +func (id ExpressRouteCircuitId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteCircuits", "expressRouteCircuits", "expressRouteCircuits"), + resourceids.UserSpecifiedSegment("expressRouteCircuitName", "expressRouteCircuitName"), + } +} + +// String returns a human-readable description of this Express Route Circuit ID +func (id ExpressRouteCircuitId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Circuit Name: %q", id.ExpressRouteCircuitName), + } + return fmt.Sprintf("Express Route Circuit (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/id_expressroutecircuit_test.go b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/id_expressroutecircuit_test.go new file mode 100644 index 00000000000..3bd47c1b205 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/id_expressroutecircuit_test.go @@ -0,0 +1,282 @@ +package expressroutecircuitauthorizations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ExpressRouteCircuitId{} + +func TestNewExpressRouteCircuitID(t *testing.T) { + id := NewExpressRouteCircuitID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteCircuitName != "expressRouteCircuitName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteCircuitName'", id.ExpressRouteCircuitName, "expressRouteCircuitName") + } +} + +func TestFormatExpressRouteCircuitID(t *testing.T) { + actual := NewExpressRouteCircuitID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseExpressRouteCircuitID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteCircuitId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Expected: &ExpressRouteCircuitId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteCircuitID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + } +} + +func TestParseExpressRouteCircuitIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteCircuitId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Expected: &ExpressRouteCircuitId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe", + Expected: &ExpressRouteCircuitId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteCircuitName: "eXpReSsRoUtEcIrCuItNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteCircuitIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + } +} + +func TestSegmentsForExpressRouteCircuitId(t *testing.T) { + segments := ExpressRouteCircuitId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ExpressRouteCircuitId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/method_createorupdate.go b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/method_createorupdate.go new file mode 100644 index 00000000000..5fe3d709320 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/method_createorupdate.go @@ -0,0 +1,75 @@ +package expressroutecircuitauthorizations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteCircuitAuthorization +} + +// CreateOrUpdate ... +func (c ExpressRouteCircuitAuthorizationsClient) CreateOrUpdate(ctx context.Context, id AuthorizationId, input ExpressRouteCircuitAuthorization) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ExpressRouteCircuitAuthorizationsClient) CreateOrUpdateThenPoll(ctx context.Context, id AuthorizationId, input ExpressRouteCircuitAuthorization) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/method_delete.go b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/method_delete.go new file mode 100644 index 00000000000..b2c01bb7f11 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/method_delete.go @@ -0,0 +1,71 @@ +package expressroutecircuitauthorizations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ExpressRouteCircuitAuthorizationsClient) Delete(ctx context.Context, id AuthorizationId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ExpressRouteCircuitAuthorizationsClient) DeleteThenPoll(ctx context.Context, id AuthorizationId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/method_get.go b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/method_get.go new file mode 100644 index 00000000000..823c3b06cfc --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/method_get.go @@ -0,0 +1,53 @@ +package expressroutecircuitauthorizations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteCircuitAuthorization +} + +// Get ... +func (c ExpressRouteCircuitAuthorizationsClient) Get(ctx context.Context, id AuthorizationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRouteCircuitAuthorization + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/method_list.go b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/method_list.go new file mode 100644 index 00000000000..b726cae911d --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/method_list.go @@ -0,0 +1,105 @@ +package expressroutecircuitauthorizations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteCircuitAuthorization +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteCircuitAuthorization +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ExpressRouteCircuitAuthorizationsClient) List(ctx context.Context, id ExpressRouteCircuitId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/authorizations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ExpressRouteCircuitAuthorization `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ExpressRouteCircuitAuthorizationsClient) ListComplete(ctx context.Context, id ExpressRouteCircuitId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ExpressRouteCircuitAuthorizationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ExpressRouteCircuitAuthorizationsClient) ListCompleteMatchingPredicate(ctx context.Context, id ExpressRouteCircuitId, predicate ExpressRouteCircuitAuthorizationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ExpressRouteCircuitAuthorization, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/model_authorizationpropertiesformat.go b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/model_authorizationpropertiesformat.go new file mode 100644 index 00000000000..0aa969a9e6f --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/model_authorizationpropertiesformat.go @@ -0,0 +1,11 @@ +package expressroutecircuitauthorizations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthorizationPropertiesFormat struct { + AuthorizationKey *string `json:"authorizationKey,omitempty"` + AuthorizationUseStatus *AuthorizationUseStatus `json:"authorizationUseStatus,omitempty"` + ConnectionResourceUri *string `json:"connectionResourceUri,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/model_expressroutecircuitauthorization.go b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/model_expressroutecircuitauthorization.go new file mode 100644 index 00000000000..b4b084362fc --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/model_expressroutecircuitauthorization.go @@ -0,0 +1,12 @@ +package expressroutecircuitauthorizations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitAuthorization struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AuthorizationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/predicates.go b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/predicates.go new file mode 100644 index 00000000000..3533e80a13e --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/predicates.go @@ -0,0 +1,32 @@ +package expressroutecircuitauthorizations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitAuthorizationOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p ExpressRouteCircuitAuthorizationOperationPredicate) Matches(input ExpressRouteCircuitAuthorization) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/version.go b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/version.go new file mode 100644 index 00000000000..5db7c972f65 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitauthorizations/version.go @@ -0,0 +1,10 @@ +package expressroutecircuitauthorizations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressroutecircuitauthorizations/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitconnections/README.md b/resource-manager/network/2024-07-01/expressroutecircuitconnections/README.md new file mode 100644 index 00000000000..2bc1fcb7db1 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitconnections/README.md @@ -0,0 +1,83 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitconnections` Documentation + +The `expressroutecircuitconnections` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitconnections" +``` + + +### Client Initialization + +```go +client := expressroutecircuitconnections.NewExpressRouteCircuitConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteCircuitConnectionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := expressroutecircuitconnections.NewPeeringConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName", "connectionName") + +payload := expressroutecircuitconnections.ExpressRouteCircuitConnection{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRouteCircuitConnectionsClient.Delete` + +```go +ctx := context.TODO() +id := expressroutecircuitconnections.NewPeeringConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName", "connectionName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRouteCircuitConnectionsClient.Get` + +```go +ctx := context.TODO() +id := expressroutecircuitconnections.NewPeeringConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName", "connectionName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ExpressRouteCircuitConnectionsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewExpressRouteCircuitPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/expressroutecircuitconnections/client.go b/resource-manager/network/2024-07-01/expressroutecircuitconnections/client.go new file mode 100644 index 00000000000..6ce57a4cb92 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitconnections/client.go @@ -0,0 +1,26 @@ +package expressroutecircuitconnections + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteCircuitConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteCircuitConnectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressroutecircuitconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteCircuitConnectionsClient: %+v", err) + } + + return &ExpressRouteCircuitConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitconnections/constants.go b/resource-manager/network/2024-07-01/expressroutecircuitconnections/constants.go new file mode 100644 index 00000000000..8bfeb3344f9 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitconnections/constants.go @@ -0,0 +1,101 @@ +package expressroutecircuitconnections + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CircuitConnectionStatus string + +const ( + CircuitConnectionStatusConnected CircuitConnectionStatus = "Connected" + CircuitConnectionStatusConnecting CircuitConnectionStatus = "Connecting" + CircuitConnectionStatusDisconnected CircuitConnectionStatus = "Disconnected" +) + +func PossibleValuesForCircuitConnectionStatus() []string { + return []string{ + string(CircuitConnectionStatusConnected), + string(CircuitConnectionStatusConnecting), + string(CircuitConnectionStatusDisconnected), + } +} + +func (s *CircuitConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCircuitConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCircuitConnectionStatus(input string) (*CircuitConnectionStatus, error) { + vals := map[string]CircuitConnectionStatus{ + "connected": CircuitConnectionStatusConnected, + "connecting": CircuitConnectionStatusConnecting, + "disconnected": CircuitConnectionStatusDisconnected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CircuitConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitconnections/id_peeringconnection.go b/resource-manager/network/2024-07-01/expressroutecircuitconnections/id_peeringconnection.go new file mode 100644 index 00000000000..07c1226d200 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitconnections/id_peeringconnection.go @@ -0,0 +1,148 @@ +package expressroutecircuitconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PeeringConnectionId{}) +} + +var _ resourceids.ResourceId = &PeeringConnectionId{} + +// PeeringConnectionId is a struct representing the Resource ID for a Peering Connection +type PeeringConnectionId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteCircuitName string + PeeringName string + ConnectionName string +} + +// NewPeeringConnectionID returns a new PeeringConnectionId struct +func NewPeeringConnectionID(subscriptionId string, resourceGroupName string, expressRouteCircuitName string, peeringName string, connectionName string) PeeringConnectionId { + return PeeringConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteCircuitName: expressRouteCircuitName, + PeeringName: peeringName, + ConnectionName: connectionName, + } +} + +// ParsePeeringConnectionID parses 'input' into a PeeringConnectionId +func ParsePeeringConnectionID(input string) (*PeeringConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PeeringConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PeeringConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePeeringConnectionIDInsensitively parses 'input' case-insensitively into a PeeringConnectionId +// note: this method should only be used for API response data and not user input +func ParsePeeringConnectionIDInsensitively(input string) (*PeeringConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PeeringConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PeeringConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PeeringConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteCircuitName, ok = input.Parsed["expressRouteCircuitName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteCircuitName", input) + } + + if id.PeeringName, ok = input.Parsed["peeringName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "peeringName", input) + } + + if id.ConnectionName, ok = input.Parsed["connectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectionName", input) + } + + return nil +} + +// ValidatePeeringConnectionID checks that 'input' can be parsed as a Peering Connection ID +func ValidatePeeringConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePeeringConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Peering Connection ID +func (id PeeringConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCircuits/%s/peerings/%s/connections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteCircuitName, id.PeeringName, id.ConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Peering Connection ID +func (id PeeringConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteCircuits", "expressRouteCircuits", "expressRouteCircuits"), + resourceids.UserSpecifiedSegment("expressRouteCircuitName", "expressRouteCircuitName"), + resourceids.StaticSegment("staticPeerings", "peerings", "peerings"), + resourceids.UserSpecifiedSegment("peeringName", "peeringName"), + resourceids.StaticSegment("staticConnections", "connections", "connections"), + resourceids.UserSpecifiedSegment("connectionName", "connectionName"), + } +} + +// String returns a human-readable description of this Peering Connection ID +func (id PeeringConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Circuit Name: %q", id.ExpressRouteCircuitName), + fmt.Sprintf("Peering Name: %q", id.PeeringName), + fmt.Sprintf("Connection Name: %q", id.ConnectionName), + } + return fmt.Sprintf("Peering Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitconnections/id_peeringconnection_test.go b/resource-manager/network/2024-07-01/expressroutecircuitconnections/id_peeringconnection_test.go new file mode 100644 index 00000000000..f1e786ac3d2 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitconnections/id_peeringconnection_test.go @@ -0,0 +1,372 @@ +package expressroutecircuitconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PeeringConnectionId{} + +func TestNewPeeringConnectionID(t *testing.T) { + id := NewPeeringConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName", "connectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteCircuitName != "expressRouteCircuitName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteCircuitName'", id.ExpressRouteCircuitName, "expressRouteCircuitName") + } + + if id.PeeringName != "peeringName" { + t.Fatalf("Expected %q but got %q for Segment 'PeeringName'", id.PeeringName, "peeringName") + } + + if id.ConnectionName != "connectionName" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectionName'", id.ConnectionName, "connectionName") + } +} + +func TestFormatPeeringConnectionID(t *testing.T) { + actual := NewPeeringConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName", "connectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/connections/connectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePeeringConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PeeringConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/connections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/connections/connectionName", + Expected: &PeeringConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + PeeringName: "peeringName", + ConnectionName: "connectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/connections/connectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePeeringConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + if actual.ConnectionName != v.Expected.ConnectionName { + t.Fatalf("Expected %q but got %q for ConnectionName", v.Expected.ConnectionName, actual.ConnectionName) + } + + } +} + +func TestParsePeeringConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PeeringConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/connections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe/cOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/connections/connectionName", + Expected: &PeeringConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + PeeringName: "peeringName", + ConnectionName: "connectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/connections/connectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe/cOnNeCtIoNs/cOnNeCtIoNnAmE", + Expected: &PeeringConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteCircuitName: "eXpReSsRoUtEcIrCuItNaMe", + PeeringName: "pEeRiNgNaMe", + ConnectionName: "cOnNeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe/cOnNeCtIoNs/cOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePeeringConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + if actual.ConnectionName != v.Expected.ConnectionName { + t.Fatalf("Expected %q but got %q for ConnectionName", v.Expected.ConnectionName, actual.ConnectionName) + } + + } +} + +func TestSegmentsForPeeringConnectionId(t *testing.T) { + segments := PeeringConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PeeringConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitconnections/method_createorupdate.go b/resource-manager/network/2024-07-01/expressroutecircuitconnections/method_createorupdate.go new file mode 100644 index 00000000000..25bb50bd1b3 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitconnections/method_createorupdate.go @@ -0,0 +1,75 @@ +package expressroutecircuitconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteCircuitConnection +} + +// CreateOrUpdate ... +func (c ExpressRouteCircuitConnectionsClient) CreateOrUpdate(ctx context.Context, id PeeringConnectionId, input ExpressRouteCircuitConnection) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ExpressRouteCircuitConnectionsClient) CreateOrUpdateThenPoll(ctx context.Context, id PeeringConnectionId, input ExpressRouteCircuitConnection) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitconnections/method_delete.go b/resource-manager/network/2024-07-01/expressroutecircuitconnections/method_delete.go new file mode 100644 index 00000000000..1d813338ead --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitconnections/method_delete.go @@ -0,0 +1,71 @@ +package expressroutecircuitconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ExpressRouteCircuitConnectionsClient) Delete(ctx context.Context, id PeeringConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ExpressRouteCircuitConnectionsClient) DeleteThenPoll(ctx context.Context, id PeeringConnectionId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitconnections/method_get.go b/resource-manager/network/2024-07-01/expressroutecircuitconnections/method_get.go new file mode 100644 index 00000000000..ca510dffdd4 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitconnections/method_get.go @@ -0,0 +1,53 @@ +package expressroutecircuitconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteCircuitConnection +} + +// Get ... +func (c ExpressRouteCircuitConnectionsClient) Get(ctx context.Context, id PeeringConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRouteCircuitConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitconnections/method_list.go b/resource-manager/network/2024-07-01/expressroutecircuitconnections/method_list.go new file mode 100644 index 00000000000..bacd8586f75 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitconnections/method_list.go @@ -0,0 +1,106 @@ +package expressroutecircuitconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteCircuitConnection +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteCircuitConnection +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ExpressRouteCircuitConnectionsClient) List(ctx context.Context, id commonids.ExpressRouteCircuitPeeringId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/connections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ExpressRouteCircuitConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ExpressRouteCircuitConnectionsClient) ListComplete(ctx context.Context, id commonids.ExpressRouteCircuitPeeringId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ExpressRouteCircuitConnectionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ExpressRouteCircuitConnectionsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ExpressRouteCircuitPeeringId, predicate ExpressRouteCircuitConnectionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ExpressRouteCircuitConnection, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitconnections/model_expressroutecircuitconnection.go b/resource-manager/network/2024-07-01/expressroutecircuitconnections/model_expressroutecircuitconnection.go new file mode 100644 index 00000000000..689bf9a8e12 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitconnections/model_expressroutecircuitconnection.go @@ -0,0 +1,12 @@ +package expressroutecircuitconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRouteCircuitConnectionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitconnections/model_expressroutecircuitconnectionpropertiesformat.go b/resource-manager/network/2024-07-01/expressroutecircuitconnections/model_expressroutecircuitconnectionpropertiesformat.go new file mode 100644 index 00000000000..a1bf981acf3 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitconnections/model_expressroutecircuitconnectionpropertiesformat.go @@ -0,0 +1,14 @@ +package expressroutecircuitconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitConnectionPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AuthorizationKey *string `json:"authorizationKey,omitempty"` + CircuitConnectionStatus *CircuitConnectionStatus `json:"circuitConnectionStatus,omitempty"` + ExpressRouteCircuitPeering *SubResource `json:"expressRouteCircuitPeering,omitempty"` + IPv6CircuitConnectionConfig *IPv6CircuitConnectionConfig `json:"ipv6CircuitConnectionConfig,omitempty"` + PeerExpressRouteCircuitPeering *SubResource `json:"peerExpressRouteCircuitPeering,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitconnections/model_ipv6circuitconnectionconfig.go b/resource-manager/network/2024-07-01/expressroutecircuitconnections/model_ipv6circuitconnectionconfig.go new file mode 100644 index 00000000000..580b8a8dcd7 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitconnections/model_ipv6circuitconnectionconfig.go @@ -0,0 +1,9 @@ +package expressroutecircuitconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPv6CircuitConnectionConfig struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + CircuitConnectionStatus *CircuitConnectionStatus `json:"circuitConnectionStatus,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitconnections/model_subresource.go b/resource-manager/network/2024-07-01/expressroutecircuitconnections/model_subresource.go new file mode 100644 index 00000000000..d6673ed96dc --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitconnections/model_subresource.go @@ -0,0 +1,8 @@ +package expressroutecircuitconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitconnections/predicates.go b/resource-manager/network/2024-07-01/expressroutecircuitconnections/predicates.go new file mode 100644 index 00000000000..6c65b4df05d --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitconnections/predicates.go @@ -0,0 +1,32 @@ +package expressroutecircuitconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitConnectionOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p ExpressRouteCircuitConnectionOperationPredicate) Matches(input ExpressRouteCircuitConnection) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitconnections/version.go b/resource-manager/network/2024-07-01/expressroutecircuitconnections/version.go new file mode 100644 index 00000000000..cb7a0b24755 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitconnections/version.go @@ -0,0 +1,10 @@ +package expressroutecircuitconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressroutecircuitconnections/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/README.md b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/README.md new file mode 100644 index 00000000000..180cf15160b --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/README.md @@ -0,0 +1,83 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitpeerings` Documentation + +The `expressroutecircuitpeerings` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitpeerings" +``` + + +### Client Initialization + +```go +client := expressroutecircuitpeerings.NewExpressRouteCircuitPeeringsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteCircuitPeeringsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewExpressRouteCircuitPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName") + +payload := expressroutecircuitpeerings.ExpressRouteCircuitPeering{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRouteCircuitPeeringsClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewExpressRouteCircuitPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRouteCircuitPeeringsClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewExpressRouteCircuitPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ExpressRouteCircuitPeeringsClient.List` + +```go +ctx := context.TODO() +id := expressroutecircuitpeerings.NewExpressRouteCircuitID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/client.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/client.go new file mode 100644 index 00000000000..ce7c06a4f7b --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/client.go @@ -0,0 +1,26 @@ +package expressroutecircuitpeerings + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitPeeringsClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteCircuitPeeringsClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteCircuitPeeringsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressroutecircuitpeerings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteCircuitPeeringsClient: %+v", err) + } + + return &ExpressRouteCircuitPeeringsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/constants.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/constants.go new file mode 100644 index 00000000000..adf054357e4 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/constants.go @@ -0,0 +1,339 @@ +package expressroutecircuitpeerings + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdvertisedPublicPrefixPropertiesValidationState string + +const ( + AdvertisedPublicPrefixPropertiesValidationStateAsnValidationFailed AdvertisedPublicPrefixPropertiesValidationState = "AsnValidationFailed" + AdvertisedPublicPrefixPropertiesValidationStateCertificateMissingInRoutingRegistry AdvertisedPublicPrefixPropertiesValidationState = "CertificateMissingInRoutingRegistry" + AdvertisedPublicPrefixPropertiesValidationStateConfigured AdvertisedPublicPrefixPropertiesValidationState = "Configured" + AdvertisedPublicPrefixPropertiesValidationStateConfiguring AdvertisedPublicPrefixPropertiesValidationState = "Configuring" + AdvertisedPublicPrefixPropertiesValidationStateInvalidSignatureEncoding AdvertisedPublicPrefixPropertiesValidationState = "InvalidSignatureEncoding" + AdvertisedPublicPrefixPropertiesValidationStateManualValidationNeeded AdvertisedPublicPrefixPropertiesValidationState = "ManualValidationNeeded" + AdvertisedPublicPrefixPropertiesValidationStateNotConfigured AdvertisedPublicPrefixPropertiesValidationState = "NotConfigured" + AdvertisedPublicPrefixPropertiesValidationStateSignatureVerificationFailed AdvertisedPublicPrefixPropertiesValidationState = "SignatureVerificationFailed" + AdvertisedPublicPrefixPropertiesValidationStateValidationFailed AdvertisedPublicPrefixPropertiesValidationState = "ValidationFailed" + AdvertisedPublicPrefixPropertiesValidationStateValidationNeeded AdvertisedPublicPrefixPropertiesValidationState = "ValidationNeeded" +) + +func PossibleValuesForAdvertisedPublicPrefixPropertiesValidationState() []string { + return []string{ + string(AdvertisedPublicPrefixPropertiesValidationStateAsnValidationFailed), + string(AdvertisedPublicPrefixPropertiesValidationStateCertificateMissingInRoutingRegistry), + string(AdvertisedPublicPrefixPropertiesValidationStateConfigured), + string(AdvertisedPublicPrefixPropertiesValidationStateConfiguring), + string(AdvertisedPublicPrefixPropertiesValidationStateInvalidSignatureEncoding), + string(AdvertisedPublicPrefixPropertiesValidationStateManualValidationNeeded), + string(AdvertisedPublicPrefixPropertiesValidationStateNotConfigured), + string(AdvertisedPublicPrefixPropertiesValidationStateSignatureVerificationFailed), + string(AdvertisedPublicPrefixPropertiesValidationStateValidationFailed), + string(AdvertisedPublicPrefixPropertiesValidationStateValidationNeeded), + } +} + +func (s *AdvertisedPublicPrefixPropertiesValidationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAdvertisedPublicPrefixPropertiesValidationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAdvertisedPublicPrefixPropertiesValidationState(input string) (*AdvertisedPublicPrefixPropertiesValidationState, error) { + vals := map[string]AdvertisedPublicPrefixPropertiesValidationState{ + "asnvalidationfailed": AdvertisedPublicPrefixPropertiesValidationStateAsnValidationFailed, + "certificatemissinginroutingregistry": AdvertisedPublicPrefixPropertiesValidationStateCertificateMissingInRoutingRegistry, + "configured": AdvertisedPublicPrefixPropertiesValidationStateConfigured, + "configuring": AdvertisedPublicPrefixPropertiesValidationStateConfiguring, + "invalidsignatureencoding": AdvertisedPublicPrefixPropertiesValidationStateInvalidSignatureEncoding, + "manualvalidationneeded": AdvertisedPublicPrefixPropertiesValidationStateManualValidationNeeded, + "notconfigured": AdvertisedPublicPrefixPropertiesValidationStateNotConfigured, + "signatureverificationfailed": AdvertisedPublicPrefixPropertiesValidationStateSignatureVerificationFailed, + "validationfailed": AdvertisedPublicPrefixPropertiesValidationStateValidationFailed, + "validationneeded": AdvertisedPublicPrefixPropertiesValidationStateValidationNeeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AdvertisedPublicPrefixPropertiesValidationState(input) + return &out, nil +} + +type CircuitConnectionStatus string + +const ( + CircuitConnectionStatusConnected CircuitConnectionStatus = "Connected" + CircuitConnectionStatusConnecting CircuitConnectionStatus = "Connecting" + CircuitConnectionStatusDisconnected CircuitConnectionStatus = "Disconnected" +) + +func PossibleValuesForCircuitConnectionStatus() []string { + return []string{ + string(CircuitConnectionStatusConnected), + string(CircuitConnectionStatusConnecting), + string(CircuitConnectionStatusDisconnected), + } +} + +func (s *CircuitConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCircuitConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCircuitConnectionStatus(input string) (*CircuitConnectionStatus, error) { + vals := map[string]CircuitConnectionStatus{ + "connected": CircuitConnectionStatusConnected, + "connecting": CircuitConnectionStatusConnecting, + "disconnected": CircuitConnectionStatusDisconnected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CircuitConnectionStatus(input) + return &out, nil +} + +type ExpressRouteCircuitPeeringAdvertisedPublicPrefixState string + +const ( + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfigured ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "Configured" + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfiguring ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "Configuring" + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateNotConfigured ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "NotConfigured" + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateValidationNeeded ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "ValidationNeeded" +) + +func PossibleValuesForExpressRouteCircuitPeeringAdvertisedPublicPrefixState() []string { + return []string{ + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfigured), + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfiguring), + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateNotConfigured), + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateValidationNeeded), + } +} + +func (s *ExpressRouteCircuitPeeringAdvertisedPublicPrefixState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteCircuitPeeringAdvertisedPublicPrefixState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteCircuitPeeringAdvertisedPublicPrefixState(input string) (*ExpressRouteCircuitPeeringAdvertisedPublicPrefixState, error) { + vals := map[string]ExpressRouteCircuitPeeringAdvertisedPublicPrefixState{ + "configured": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfigured, + "configuring": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfiguring, + "notconfigured": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateNotConfigured, + "validationneeded": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateValidationNeeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteCircuitPeeringAdvertisedPublicPrefixState(input) + return &out, nil +} + +type ExpressRouteCircuitPeeringState string + +const ( + ExpressRouteCircuitPeeringStateDisabled ExpressRouteCircuitPeeringState = "Disabled" + ExpressRouteCircuitPeeringStateEnabled ExpressRouteCircuitPeeringState = "Enabled" +) + +func PossibleValuesForExpressRouteCircuitPeeringState() []string { + return []string{ + string(ExpressRouteCircuitPeeringStateDisabled), + string(ExpressRouteCircuitPeeringStateEnabled), + } +} + +func (s *ExpressRouteCircuitPeeringState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteCircuitPeeringState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteCircuitPeeringState(input string) (*ExpressRouteCircuitPeeringState, error) { + vals := map[string]ExpressRouteCircuitPeeringState{ + "disabled": ExpressRouteCircuitPeeringStateDisabled, + "enabled": ExpressRouteCircuitPeeringStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteCircuitPeeringState(input) + return &out, nil +} + +type ExpressRoutePeeringState string + +const ( + ExpressRoutePeeringStateDisabled ExpressRoutePeeringState = "Disabled" + ExpressRoutePeeringStateEnabled ExpressRoutePeeringState = "Enabled" +) + +func PossibleValuesForExpressRoutePeeringState() []string { + return []string{ + string(ExpressRoutePeeringStateDisabled), + string(ExpressRoutePeeringStateEnabled), + } +} + +func (s *ExpressRoutePeeringState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRoutePeeringState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRoutePeeringState(input string) (*ExpressRoutePeeringState, error) { + vals := map[string]ExpressRoutePeeringState{ + "disabled": ExpressRoutePeeringStateDisabled, + "enabled": ExpressRoutePeeringStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRoutePeeringState(input) + return &out, nil +} + +type ExpressRoutePeeringType string + +const ( + ExpressRoutePeeringTypeAzurePrivatePeering ExpressRoutePeeringType = "AzurePrivatePeering" + ExpressRoutePeeringTypeAzurePublicPeering ExpressRoutePeeringType = "AzurePublicPeering" + ExpressRoutePeeringTypeMicrosoftPeering ExpressRoutePeeringType = "MicrosoftPeering" +) + +func PossibleValuesForExpressRoutePeeringType() []string { + return []string{ + string(ExpressRoutePeeringTypeAzurePrivatePeering), + string(ExpressRoutePeeringTypeAzurePublicPeering), + string(ExpressRoutePeeringTypeMicrosoftPeering), + } +} + +func (s *ExpressRoutePeeringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRoutePeeringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRoutePeeringType(input string) (*ExpressRoutePeeringType, error) { + vals := map[string]ExpressRoutePeeringType{ + "azureprivatepeering": ExpressRoutePeeringTypeAzurePrivatePeering, + "azurepublicpeering": ExpressRoutePeeringTypeAzurePublicPeering, + "microsoftpeering": ExpressRoutePeeringTypeMicrosoftPeering, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRoutePeeringType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/id_expressroutecircuit.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/id_expressroutecircuit.go new file mode 100644 index 00000000000..02a14699ffa --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/id_expressroutecircuit.go @@ -0,0 +1,130 @@ +package expressroutecircuitpeerings + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ExpressRouteCircuitId{}) +} + +var _ resourceids.ResourceId = &ExpressRouteCircuitId{} + +// ExpressRouteCircuitId is a struct representing the Resource ID for a Express Route Circuit +type ExpressRouteCircuitId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteCircuitName string +} + +// NewExpressRouteCircuitID returns a new ExpressRouteCircuitId struct +func NewExpressRouteCircuitID(subscriptionId string, resourceGroupName string, expressRouteCircuitName string) ExpressRouteCircuitId { + return ExpressRouteCircuitId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteCircuitName: expressRouteCircuitName, + } +} + +// ParseExpressRouteCircuitID parses 'input' into a ExpressRouteCircuitId +func ParseExpressRouteCircuitID(input string) (*ExpressRouteCircuitId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteCircuitId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteCircuitId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseExpressRouteCircuitIDInsensitively parses 'input' case-insensitively into a ExpressRouteCircuitId +// note: this method should only be used for API response data and not user input +func ParseExpressRouteCircuitIDInsensitively(input string) (*ExpressRouteCircuitId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteCircuitId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteCircuitId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ExpressRouteCircuitId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteCircuitName, ok = input.Parsed["expressRouteCircuitName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteCircuitName", input) + } + + return nil +} + +// ValidateExpressRouteCircuitID checks that 'input' can be parsed as a Express Route Circuit ID +func ValidateExpressRouteCircuitID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseExpressRouteCircuitID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Express Route Circuit ID +func (id ExpressRouteCircuitId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCircuits/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteCircuitName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Express Route Circuit ID +func (id ExpressRouteCircuitId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteCircuits", "expressRouteCircuits", "expressRouteCircuits"), + resourceids.UserSpecifiedSegment("expressRouteCircuitName", "expressRouteCircuitName"), + } +} + +// String returns a human-readable description of this Express Route Circuit ID +func (id ExpressRouteCircuitId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Circuit Name: %q", id.ExpressRouteCircuitName), + } + return fmt.Sprintf("Express Route Circuit (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/id_expressroutecircuit_test.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/id_expressroutecircuit_test.go new file mode 100644 index 00000000000..9d893b6392d --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/id_expressroutecircuit_test.go @@ -0,0 +1,282 @@ +package expressroutecircuitpeerings + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ExpressRouteCircuitId{} + +func TestNewExpressRouteCircuitID(t *testing.T) { + id := NewExpressRouteCircuitID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteCircuitName != "expressRouteCircuitName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteCircuitName'", id.ExpressRouteCircuitName, "expressRouteCircuitName") + } +} + +func TestFormatExpressRouteCircuitID(t *testing.T) { + actual := NewExpressRouteCircuitID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseExpressRouteCircuitID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteCircuitId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Expected: &ExpressRouteCircuitId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteCircuitID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + } +} + +func TestParseExpressRouteCircuitIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteCircuitId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Expected: &ExpressRouteCircuitId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe", + Expected: &ExpressRouteCircuitId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteCircuitName: "eXpReSsRoUtEcIrCuItNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteCircuitIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + } +} + +func TestSegmentsForExpressRouteCircuitId(t *testing.T) { + segments := ExpressRouteCircuitId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ExpressRouteCircuitId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/method_createorupdate.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/method_createorupdate.go new file mode 100644 index 00000000000..a9056870582 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/method_createorupdate.go @@ -0,0 +1,76 @@ +package expressroutecircuitpeerings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteCircuitPeering +} + +// CreateOrUpdate ... +func (c ExpressRouteCircuitPeeringsClient) CreateOrUpdate(ctx context.Context, id commonids.ExpressRouteCircuitPeeringId, input ExpressRouteCircuitPeering) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ExpressRouteCircuitPeeringsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.ExpressRouteCircuitPeeringId, input ExpressRouteCircuitPeering) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/method_delete.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/method_delete.go new file mode 100644 index 00000000000..241c45fa414 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/method_delete.go @@ -0,0 +1,72 @@ +package expressroutecircuitpeerings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ExpressRouteCircuitPeeringsClient) Delete(ctx context.Context, id commonids.ExpressRouteCircuitPeeringId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ExpressRouteCircuitPeeringsClient) DeleteThenPoll(ctx context.Context, id commonids.ExpressRouteCircuitPeeringId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/method_get.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/method_get.go new file mode 100644 index 00000000000..217363c38a1 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/method_get.go @@ -0,0 +1,54 @@ +package expressroutecircuitpeerings + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteCircuitPeering +} + +// Get ... +func (c ExpressRouteCircuitPeeringsClient) Get(ctx context.Context, id commonids.ExpressRouteCircuitPeeringId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRouteCircuitPeering + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/method_list.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/method_list.go new file mode 100644 index 00000000000..ec6d45b259f --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/method_list.go @@ -0,0 +1,105 @@ +package expressroutecircuitpeerings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteCircuitPeering +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteCircuitPeering +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ExpressRouteCircuitPeeringsClient) List(ctx context.Context, id ExpressRouteCircuitId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/peerings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ExpressRouteCircuitPeering `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ExpressRouteCircuitPeeringsClient) ListComplete(ctx context.Context, id ExpressRouteCircuitId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ExpressRouteCircuitPeeringOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ExpressRouteCircuitPeeringsClient) ListCompleteMatchingPredicate(ctx context.Context, id ExpressRouteCircuitId, predicate ExpressRouteCircuitPeeringOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ExpressRouteCircuitPeering, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_advertisedpublicprefixproperties.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_advertisedpublicprefixproperties.go new file mode 100644 index 00000000000..2d60004e9a1 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_advertisedpublicprefixproperties.go @@ -0,0 +1,11 @@ +package expressroutecircuitpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdvertisedPublicPrefixProperties struct { + Prefix *string `json:"prefix,omitempty"` + Signature *string `json:"signature,omitempty"` + ValidationId *string `json:"validationId,omitempty"` + ValidationState *AdvertisedPublicPrefixPropertiesValidationState `json:"validationState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitconnection.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitconnection.go new file mode 100644 index 00000000000..f0bf62174ce --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitconnection.go @@ -0,0 +1,12 @@ +package expressroutecircuitpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRouteCircuitConnectionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitconnectionpropertiesformat.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitconnectionpropertiesformat.go new file mode 100644 index 00000000000..f89ab3b51e4 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitconnectionpropertiesformat.go @@ -0,0 +1,14 @@ +package expressroutecircuitpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitConnectionPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AuthorizationKey *string `json:"authorizationKey,omitempty"` + CircuitConnectionStatus *CircuitConnectionStatus `json:"circuitConnectionStatus,omitempty"` + ExpressRouteCircuitPeering *SubResource `json:"expressRouteCircuitPeering,omitempty"` + IPv6CircuitConnectionConfig *IPv6CircuitConnectionConfig `json:"ipv6CircuitConnectionConfig,omitempty"` + PeerExpressRouteCircuitPeering *SubResource `json:"peerExpressRouteCircuitPeering,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitpeering.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitpeering.go new file mode 100644 index 00000000000..5e47a7f0266 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitpeering.go @@ -0,0 +1,12 @@ +package expressroutecircuitpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitPeering struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRouteCircuitPeeringPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitpeeringconfig.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitpeeringconfig.go new file mode 100644 index 00000000000..6e523285eaa --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitpeeringconfig.go @@ -0,0 +1,14 @@ +package expressroutecircuitpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitPeeringConfig struct { + AdvertisedCommunities *[]string `json:"advertisedCommunities,omitempty"` + AdvertisedPublicPrefixInfo *[]AdvertisedPublicPrefixProperties `json:"advertisedPublicPrefixInfo,omitempty"` + AdvertisedPublicPrefixes *[]string `json:"advertisedPublicPrefixes,omitempty"` + AdvertisedPublicPrefixesState *ExpressRouteCircuitPeeringAdvertisedPublicPrefixState `json:"advertisedPublicPrefixesState,omitempty"` + CustomerASN *int64 `json:"customerASN,omitempty"` + LegacyMode *int64 `json:"legacyMode,omitempty"` + RoutingRegistryName *string `json:"routingRegistryName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitpeeringpropertiesformat.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitpeeringpropertiesformat.go new file mode 100644 index 00000000000..a54ef389df4 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitpeeringpropertiesformat.go @@ -0,0 +1,27 @@ +package expressroutecircuitpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitPeeringPropertiesFormat struct { + AzureASN *int64 `json:"azureASN,omitempty"` + Connections *[]ExpressRouteCircuitConnection `json:"connections,omitempty"` + ExpressRouteConnection *ExpressRouteConnectionId `json:"expressRouteConnection,omitempty"` + GatewayManagerEtag *string `json:"gatewayManagerEtag,omitempty"` + IPv6PeeringConfig *IPv6ExpressRouteCircuitPeeringConfig `json:"ipv6PeeringConfig,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + MicrosoftPeeringConfig *ExpressRouteCircuitPeeringConfig `json:"microsoftPeeringConfig,omitempty"` + PeerASN *int64 `json:"peerASN,omitempty"` + PeeredConnections *[]PeerExpressRouteCircuitConnection `json:"peeredConnections,omitempty"` + PeeringType *ExpressRoutePeeringType `json:"peeringType,omitempty"` + PrimaryAzurePort *string `json:"primaryAzurePort,omitempty"` + PrimaryPeerAddressPrefix *string `json:"primaryPeerAddressPrefix,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RouteFilter *SubResource `json:"routeFilter,omitempty"` + SecondaryAzurePort *string `json:"secondaryAzurePort,omitempty"` + SecondaryPeerAddressPrefix *string `json:"secondaryPeerAddressPrefix,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` + State *ExpressRoutePeeringState `json:"state,omitempty"` + Stats *ExpressRouteCircuitStats `json:"stats,omitempty"` + VlanId *int64 `json:"vlanId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitstats.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitstats.go new file mode 100644 index 00000000000..8239e6299db --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressroutecircuitstats.go @@ -0,0 +1,11 @@ +package expressroutecircuitpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitStats struct { + PrimarybytesIn *int64 `json:"primarybytesIn,omitempty"` + PrimarybytesOut *int64 `json:"primarybytesOut,omitempty"` + SecondarybytesIn *int64 `json:"secondarybytesIn,omitempty"` + SecondarybytesOut *int64 `json:"secondarybytesOut,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressrouteconnectionid.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressrouteconnectionid.go new file mode 100644 index 00000000000..f06a355d7fa --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_expressrouteconnectionid.go @@ -0,0 +1,8 @@ +package expressroutecircuitpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteConnectionId struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_ipv6circuitconnectionconfig.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_ipv6circuitconnectionconfig.go new file mode 100644 index 00000000000..ae00db3c45c --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_ipv6circuitconnectionconfig.go @@ -0,0 +1,9 @@ +package expressroutecircuitpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPv6CircuitConnectionConfig struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + CircuitConnectionStatus *CircuitConnectionStatus `json:"circuitConnectionStatus,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_ipv6expressroutecircuitpeeringconfig.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_ipv6expressroutecircuitpeeringconfig.go new file mode 100644 index 00000000000..93ee020eec6 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_ipv6expressroutecircuitpeeringconfig.go @@ -0,0 +1,12 @@ +package expressroutecircuitpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPv6ExpressRouteCircuitPeeringConfig struct { + MicrosoftPeeringConfig *ExpressRouteCircuitPeeringConfig `json:"microsoftPeeringConfig,omitempty"` + PrimaryPeerAddressPrefix *string `json:"primaryPeerAddressPrefix,omitempty"` + RouteFilter *SubResource `json:"routeFilter,omitempty"` + SecondaryPeerAddressPrefix *string `json:"secondaryPeerAddressPrefix,omitempty"` + State *ExpressRouteCircuitPeeringState `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_peerexpressroutecircuitconnection.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_peerexpressroutecircuitconnection.go new file mode 100644 index 00000000000..bc9218f9280 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_peerexpressroutecircuitconnection.go @@ -0,0 +1,12 @@ +package expressroutecircuitpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PeerExpressRouteCircuitConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PeerExpressRouteCircuitConnectionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_peerexpressroutecircuitconnectionpropertiesformat.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_peerexpressroutecircuitconnectionpropertiesformat.go new file mode 100644 index 00000000000..72eba9f327f --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_peerexpressroutecircuitconnectionpropertiesformat.go @@ -0,0 +1,14 @@ +package expressroutecircuitpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PeerExpressRouteCircuitConnectionPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AuthResourceGuid *string `json:"authResourceGuid,omitempty"` + CircuitConnectionStatus *CircuitConnectionStatus `json:"circuitConnectionStatus,omitempty"` + ConnectionName *string `json:"connectionName,omitempty"` + ExpressRouteCircuitPeering *SubResource `json:"expressRouteCircuitPeering,omitempty"` + PeerExpressRouteCircuitPeering *SubResource `json:"peerExpressRouteCircuitPeering,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_subresource.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_subresource.go new file mode 100644 index 00000000000..3143d87b0ee --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/model_subresource.go @@ -0,0 +1,8 @@ +package expressroutecircuitpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/predicates.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/predicates.go new file mode 100644 index 00000000000..1e725c4e63a --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/predicates.go @@ -0,0 +1,32 @@ +package expressroutecircuitpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitPeeringOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p ExpressRouteCircuitPeeringOperationPredicate) Matches(input ExpressRouteCircuitPeering) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitpeerings/version.go b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/version.go new file mode 100644 index 00000000000..b5238768e39 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitpeerings/version.go @@ -0,0 +1,10 @@ +package expressroutecircuitpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressroutecircuitpeerings/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitroutestable/README.md b/resource-manager/network/2024-07-01/expressroutecircuitroutestable/README.md new file mode 100644 index 00000000000..d91ffe60d26 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitroutestable/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitroutestable` Documentation + +The `expressroutecircuitroutestable` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitroutestable" +``` + + +### Client Initialization + +```go +client := expressroutecircuitroutestable.NewExpressRouteCircuitRoutesTableClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteCircuitRoutesTableClient.ExpressRouteCircuitsListRoutesTable` + +```go +ctx := context.TODO() +id := expressroutecircuitroutestable.NewPeeringRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName", "routeTableName") + +// alternatively `client.ExpressRouteCircuitsListRoutesTable(ctx, id)` can be used to do batched pagination +items, err := client.ExpressRouteCircuitsListRoutesTableComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/expressroutecircuitroutestable/client.go b/resource-manager/network/2024-07-01/expressroutecircuitroutestable/client.go new file mode 100644 index 00000000000..64933522e0c --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitroutestable/client.go @@ -0,0 +1,26 @@ +package expressroutecircuitroutestable + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitRoutesTableClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteCircuitRoutesTableClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteCircuitRoutesTableClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressroutecircuitroutestable", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteCircuitRoutesTableClient: %+v", err) + } + + return &ExpressRouteCircuitRoutesTableClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitroutestable/id_peeringroutetable.go b/resource-manager/network/2024-07-01/expressroutecircuitroutestable/id_peeringroutetable.go new file mode 100644 index 00000000000..8971fb87e03 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitroutestable/id_peeringroutetable.go @@ -0,0 +1,148 @@ +package expressroutecircuitroutestable + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PeeringRouteTableId{}) +} + +var _ resourceids.ResourceId = &PeeringRouteTableId{} + +// PeeringRouteTableId is a struct representing the Resource ID for a Peering Route Table +type PeeringRouteTableId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteCircuitName string + PeeringName string + RouteTableName string +} + +// NewPeeringRouteTableID returns a new PeeringRouteTableId struct +func NewPeeringRouteTableID(subscriptionId string, resourceGroupName string, expressRouteCircuitName string, peeringName string, routeTableName string) PeeringRouteTableId { + return PeeringRouteTableId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteCircuitName: expressRouteCircuitName, + PeeringName: peeringName, + RouteTableName: routeTableName, + } +} + +// ParsePeeringRouteTableID parses 'input' into a PeeringRouteTableId +func ParsePeeringRouteTableID(input string) (*PeeringRouteTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&PeeringRouteTableId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PeeringRouteTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePeeringRouteTableIDInsensitively parses 'input' case-insensitively into a PeeringRouteTableId +// note: this method should only be used for API response data and not user input +func ParsePeeringRouteTableIDInsensitively(input string) (*PeeringRouteTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&PeeringRouteTableId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PeeringRouteTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PeeringRouteTableId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteCircuitName, ok = input.Parsed["expressRouteCircuitName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteCircuitName", input) + } + + if id.PeeringName, ok = input.Parsed["peeringName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "peeringName", input) + } + + if id.RouteTableName, ok = input.Parsed["routeTableName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeTableName", input) + } + + return nil +} + +// ValidatePeeringRouteTableID checks that 'input' can be parsed as a Peering Route Table ID +func ValidatePeeringRouteTableID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePeeringRouteTableID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Peering Route Table ID +func (id PeeringRouteTableId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCircuits/%s/peerings/%s/routeTables/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteCircuitName, id.PeeringName, id.RouteTableName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Peering Route Table ID +func (id PeeringRouteTableId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteCircuits", "expressRouteCircuits", "expressRouteCircuits"), + resourceids.UserSpecifiedSegment("expressRouteCircuitName", "expressRouteCircuitName"), + resourceids.StaticSegment("staticPeerings", "peerings", "peerings"), + resourceids.UserSpecifiedSegment("peeringName", "peeringName"), + resourceids.StaticSegment("staticRouteTables", "routeTables", "routeTables"), + resourceids.UserSpecifiedSegment("routeTableName", "routeTableName"), + } +} + +// String returns a human-readable description of this Peering Route Table ID +func (id PeeringRouteTableId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Circuit Name: %q", id.ExpressRouteCircuitName), + fmt.Sprintf("Peering Name: %q", id.PeeringName), + fmt.Sprintf("Route Table Name: %q", id.RouteTableName), + } + return fmt.Sprintf("Peering Route Table (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitroutestable/id_peeringroutetable_test.go b/resource-manager/network/2024-07-01/expressroutecircuitroutestable/id_peeringroutetable_test.go new file mode 100644 index 00000000000..620bbfff69e --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitroutestable/id_peeringroutetable_test.go @@ -0,0 +1,372 @@ +package expressroutecircuitroutestable + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PeeringRouteTableId{} + +func TestNewPeeringRouteTableID(t *testing.T) { + id := NewPeeringRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName", "routeTableName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteCircuitName != "expressRouteCircuitName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteCircuitName'", id.ExpressRouteCircuitName, "expressRouteCircuitName") + } + + if id.PeeringName != "peeringName" { + t.Fatalf("Expected %q but got %q for Segment 'PeeringName'", id.PeeringName, "peeringName") + } + + if id.RouteTableName != "routeTableName" { + t.Fatalf("Expected %q but got %q for Segment 'RouteTableName'", id.RouteTableName, "routeTableName") + } +} + +func TestFormatPeeringRouteTableID(t *testing.T) { + actual := NewPeeringRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName", "routeTableName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/routeTables/routeTableName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePeeringRouteTableID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PeeringRouteTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/routeTables", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/routeTables/routeTableName", + Expected: &PeeringRouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + PeeringName: "peeringName", + RouteTableName: "routeTableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/routeTables/routeTableName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePeeringRouteTableID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + if actual.RouteTableName != v.Expected.RouteTableName { + t.Fatalf("Expected %q but got %q for RouteTableName", v.Expected.RouteTableName, actual.RouteTableName) + } + + } +} + +func TestParsePeeringRouteTableIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PeeringRouteTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/routeTables", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe/rOuTeTaBlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/routeTables/routeTableName", + Expected: &PeeringRouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + PeeringName: "peeringName", + RouteTableName: "routeTableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/routeTables/routeTableName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe/rOuTeTaBlEs/rOuTeTaBlEnAmE", + Expected: &PeeringRouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteCircuitName: "eXpReSsRoUtEcIrCuItNaMe", + PeeringName: "pEeRiNgNaMe", + RouteTableName: "rOuTeTaBlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe/rOuTeTaBlEs/rOuTeTaBlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePeeringRouteTableIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + if actual.RouteTableName != v.Expected.RouteTableName { + t.Fatalf("Expected %q but got %q for RouteTableName", v.Expected.RouteTableName, actual.RouteTableName) + } + + } +} + +func TestSegmentsForPeeringRouteTableId(t *testing.T) { + segments := PeeringRouteTableId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PeeringRouteTableId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitroutestable/method_expressroutecircuitslistroutestable.go b/resource-manager/network/2024-07-01/expressroutecircuitroutestable/method_expressroutecircuitslistroutestable.go new file mode 100644 index 00000000000..d193f427f2f --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitroutestable/method_expressroutecircuitslistroutestable.go @@ -0,0 +1,89 @@ +package expressroutecircuitroutestable + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitsListRoutesTableOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteCircuitRoutesTable +} + +type ExpressRouteCircuitsListRoutesTableCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteCircuitRoutesTable +} + +type ExpressRouteCircuitsListRoutesTableCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ExpressRouteCircuitsListRoutesTableCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ExpressRouteCircuitsListRoutesTable ... +func (c ExpressRouteCircuitRoutesTableClient) ExpressRouteCircuitsListRoutesTable(ctx context.Context, id PeeringRouteTableId) (result ExpressRouteCircuitsListRoutesTableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ExpressRouteCircuitsListRoutesTableCustomPager{}, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ExpressRouteCircuitsListRoutesTableThenPoll performs ExpressRouteCircuitsListRoutesTable then polls until it's completed +func (c ExpressRouteCircuitRoutesTableClient) ExpressRouteCircuitsListRoutesTableThenPoll(ctx context.Context, id PeeringRouteTableId) error { + result, err := c.ExpressRouteCircuitsListRoutesTable(ctx, id) + if err != nil { + return fmt.Errorf("performing ExpressRouteCircuitsListRoutesTable: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ExpressRouteCircuitsListRoutesTable: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitroutestable/model_expressroutecircuitroutestable.go b/resource-manager/network/2024-07-01/expressroutecircuitroutestable/model_expressroutecircuitroutestable.go new file mode 100644 index 00000000000..d70d9310d29 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitroutestable/model_expressroutecircuitroutestable.go @@ -0,0 +1,12 @@ +package expressroutecircuitroutestable + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitRoutesTable struct { + LocPrf *string `json:"locPrf,omitempty"` + Network *string `json:"network,omitempty"` + NextHop *string `json:"nextHop,omitempty"` + Path *string `json:"path,omitempty"` + Weight *int64 `json:"weight,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitroutestable/predicates.go b/resource-manager/network/2024-07-01/expressroutecircuitroutestable/predicates.go new file mode 100644 index 00000000000..81d29805310 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitroutestable/predicates.go @@ -0,0 +1,37 @@ +package expressroutecircuitroutestable + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitRoutesTableOperationPredicate struct { + LocPrf *string + Network *string + NextHop *string + Path *string + Weight *int64 +} + +func (p ExpressRouteCircuitRoutesTableOperationPredicate) Matches(input ExpressRouteCircuitRoutesTable) bool { + + if p.LocPrf != nil && (input.LocPrf == nil || *p.LocPrf != *input.LocPrf) { + return false + } + + if p.Network != nil && (input.Network == nil || *p.Network != *input.Network) { + return false + } + + if p.NextHop != nil && (input.NextHop == nil || *p.NextHop != *input.NextHop) { + return false + } + + if p.Path != nil && (input.Path == nil || *p.Path != *input.Path) { + return false + } + + if p.Weight != nil && (input.Weight == nil || *p.Weight != *input.Weight) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitroutestable/version.go b/resource-manager/network/2024-07-01/expressroutecircuitroutestable/version.go new file mode 100644 index 00000000000..04b41847b3e --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitroutestable/version.go @@ -0,0 +1,10 @@ +package expressroutecircuitroutestable + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressroutecircuitroutestable/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/README.md b/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/README.md new file mode 100644 index 00000000000..9f903171da9 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary` Documentation + +The `expressroutecircuitroutestablesummary` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary" +``` + + +### Client Initialization + +```go +client := expressroutecircuitroutestablesummary.NewExpressRouteCircuitRoutesTableSummaryClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteCircuitRoutesTableSummaryClient.ExpressRouteCircuitsListRoutesTableSummary` + +```go +ctx := context.TODO() +id := expressroutecircuitroutestablesummary.NewRouteTablesSummaryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName", "routeTablesSummaryName") + +// alternatively `client.ExpressRouteCircuitsListRoutesTableSummary(ctx, id)` can be used to do batched pagination +items, err := client.ExpressRouteCircuitsListRoutesTableSummaryComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/client.go b/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/client.go new file mode 100644 index 00000000000..1964d42b872 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/client.go @@ -0,0 +1,26 @@ +package expressroutecircuitroutestablesummary + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitRoutesTableSummaryClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteCircuitRoutesTableSummaryClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteCircuitRoutesTableSummaryClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressroutecircuitroutestablesummary", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteCircuitRoutesTableSummaryClient: %+v", err) + } + + return &ExpressRouteCircuitRoutesTableSummaryClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/id_routetablessummary.go b/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/id_routetablessummary.go new file mode 100644 index 00000000000..90ea354df62 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/id_routetablessummary.go @@ -0,0 +1,148 @@ +package expressroutecircuitroutestablesummary + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RouteTablesSummaryId{}) +} + +var _ resourceids.ResourceId = &RouteTablesSummaryId{} + +// RouteTablesSummaryId is a struct representing the Resource ID for a Route Tables Summary +type RouteTablesSummaryId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteCircuitName string + PeeringName string + RouteTablesSummaryName string +} + +// NewRouteTablesSummaryID returns a new RouteTablesSummaryId struct +func NewRouteTablesSummaryID(subscriptionId string, resourceGroupName string, expressRouteCircuitName string, peeringName string, routeTablesSummaryName string) RouteTablesSummaryId { + return RouteTablesSummaryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteCircuitName: expressRouteCircuitName, + PeeringName: peeringName, + RouteTablesSummaryName: routeTablesSummaryName, + } +} + +// ParseRouteTablesSummaryID parses 'input' into a RouteTablesSummaryId +func ParseRouteTablesSummaryID(input string) (*RouteTablesSummaryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteTablesSummaryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteTablesSummaryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRouteTablesSummaryIDInsensitively parses 'input' case-insensitively into a RouteTablesSummaryId +// note: this method should only be used for API response data and not user input +func ParseRouteTablesSummaryIDInsensitively(input string) (*RouteTablesSummaryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteTablesSummaryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteTablesSummaryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RouteTablesSummaryId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteCircuitName, ok = input.Parsed["expressRouteCircuitName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteCircuitName", input) + } + + if id.PeeringName, ok = input.Parsed["peeringName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "peeringName", input) + } + + if id.RouteTablesSummaryName, ok = input.Parsed["routeTablesSummaryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeTablesSummaryName", input) + } + + return nil +} + +// ValidateRouteTablesSummaryID checks that 'input' can be parsed as a Route Tables Summary ID +func ValidateRouteTablesSummaryID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRouteTablesSummaryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Route Tables Summary ID +func (id RouteTablesSummaryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCircuits/%s/peerings/%s/routeTablesSummary/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteCircuitName, id.PeeringName, id.RouteTablesSummaryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Route Tables Summary ID +func (id RouteTablesSummaryId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteCircuits", "expressRouteCircuits", "expressRouteCircuits"), + resourceids.UserSpecifiedSegment("expressRouteCircuitName", "expressRouteCircuitName"), + resourceids.StaticSegment("staticPeerings", "peerings", "peerings"), + resourceids.UserSpecifiedSegment("peeringName", "peeringName"), + resourceids.StaticSegment("staticRouteTablesSummary", "routeTablesSummary", "routeTablesSummary"), + resourceids.UserSpecifiedSegment("routeTablesSummaryName", "routeTablesSummaryName"), + } +} + +// String returns a human-readable description of this Route Tables Summary ID +func (id RouteTablesSummaryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Circuit Name: %q", id.ExpressRouteCircuitName), + fmt.Sprintf("Peering Name: %q", id.PeeringName), + fmt.Sprintf("Route Tables Summary Name: %q", id.RouteTablesSummaryName), + } + return fmt.Sprintf("Route Tables Summary (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/id_routetablessummary_test.go b/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/id_routetablessummary_test.go new file mode 100644 index 00000000000..2c78aaf0378 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/id_routetablessummary_test.go @@ -0,0 +1,372 @@ +package expressroutecircuitroutestablesummary + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RouteTablesSummaryId{} + +func TestNewRouteTablesSummaryID(t *testing.T) { + id := NewRouteTablesSummaryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName", "routeTablesSummaryName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteCircuitName != "expressRouteCircuitName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteCircuitName'", id.ExpressRouteCircuitName, "expressRouteCircuitName") + } + + if id.PeeringName != "peeringName" { + t.Fatalf("Expected %q but got %q for Segment 'PeeringName'", id.PeeringName, "peeringName") + } + + if id.RouteTablesSummaryName != "routeTablesSummaryName" { + t.Fatalf("Expected %q but got %q for Segment 'RouteTablesSummaryName'", id.RouteTablesSummaryName, "routeTablesSummaryName") + } +} + +func TestFormatRouteTablesSummaryID(t *testing.T) { + actual := NewRouteTablesSummaryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName", "routeTablesSummaryName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/routeTablesSummary/routeTablesSummaryName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRouteTablesSummaryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteTablesSummaryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/routeTablesSummary", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/routeTablesSummary/routeTablesSummaryName", + Expected: &RouteTablesSummaryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + PeeringName: "peeringName", + RouteTablesSummaryName: "routeTablesSummaryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/routeTablesSummary/routeTablesSummaryName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteTablesSummaryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + if actual.RouteTablesSummaryName != v.Expected.RouteTablesSummaryName { + t.Fatalf("Expected %q but got %q for RouteTablesSummaryName", v.Expected.RouteTablesSummaryName, actual.RouteTablesSummaryName) + } + + } +} + +func TestParseRouteTablesSummaryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteTablesSummaryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/routeTablesSummary", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe/rOuTeTaBlEsSuMmArY", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/routeTablesSummary/routeTablesSummaryName", + Expected: &RouteTablesSummaryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + PeeringName: "peeringName", + RouteTablesSummaryName: "routeTablesSummaryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/routeTablesSummary/routeTablesSummaryName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe/rOuTeTaBlEsSuMmArY/rOuTeTaBlEsSuMmArYnAmE", + Expected: &RouteTablesSummaryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteCircuitName: "eXpReSsRoUtEcIrCuItNaMe", + PeeringName: "pEeRiNgNaMe", + RouteTablesSummaryName: "rOuTeTaBlEsSuMmArYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe/rOuTeTaBlEsSuMmArY/rOuTeTaBlEsSuMmArYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteTablesSummaryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + if actual.RouteTablesSummaryName != v.Expected.RouteTablesSummaryName { + t.Fatalf("Expected %q but got %q for RouteTablesSummaryName", v.Expected.RouteTablesSummaryName, actual.RouteTablesSummaryName) + } + + } +} + +func TestSegmentsForRouteTablesSummaryId(t *testing.T) { + segments := RouteTablesSummaryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RouteTablesSummaryId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/method_expressroutecircuitslistroutestablesummary.go b/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/method_expressroutecircuitslistroutestablesummary.go new file mode 100644 index 00000000000..0cd493a629e --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/method_expressroutecircuitslistroutestablesummary.go @@ -0,0 +1,89 @@ +package expressroutecircuitroutestablesummary + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitsListRoutesTableSummaryOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteCircuitRoutesTableSummary +} + +type ExpressRouteCircuitsListRoutesTableSummaryCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteCircuitRoutesTableSummary +} + +type ExpressRouteCircuitsListRoutesTableSummaryCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ExpressRouteCircuitsListRoutesTableSummaryCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ExpressRouteCircuitsListRoutesTableSummary ... +func (c ExpressRouteCircuitRoutesTableSummaryClient) ExpressRouteCircuitsListRoutesTableSummary(ctx context.Context, id RouteTablesSummaryId) (result ExpressRouteCircuitsListRoutesTableSummaryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ExpressRouteCircuitsListRoutesTableSummaryCustomPager{}, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ExpressRouteCircuitsListRoutesTableSummaryThenPoll performs ExpressRouteCircuitsListRoutesTableSummary then polls until it's completed +func (c ExpressRouteCircuitRoutesTableSummaryClient) ExpressRouteCircuitsListRoutesTableSummaryThenPoll(ctx context.Context, id RouteTablesSummaryId) error { + result, err := c.ExpressRouteCircuitsListRoutesTableSummary(ctx, id) + if err != nil { + return fmt.Errorf("performing ExpressRouteCircuitsListRoutesTableSummary: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ExpressRouteCircuitsListRoutesTableSummary: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/model_expressroutecircuitroutestablesummary.go b/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/model_expressroutecircuitroutestablesummary.go new file mode 100644 index 00000000000..926fc450623 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/model_expressroutecircuitroutestablesummary.go @@ -0,0 +1,12 @@ +package expressroutecircuitroutestablesummary + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitRoutesTableSummary struct { + As *int64 `json:"as,omitempty"` + Neighbor *string `json:"neighbor,omitempty"` + StatePfxRcd *string `json:"statePfxRcd,omitempty"` + UpDown *string `json:"upDown,omitempty"` + V *int64 `json:"v,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/predicates.go b/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/predicates.go new file mode 100644 index 00000000000..1d9991e4b00 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/predicates.go @@ -0,0 +1,37 @@ +package expressroutecircuitroutestablesummary + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitRoutesTableSummaryOperationPredicate struct { + As *int64 + Neighbor *string + StatePfxRcd *string + UpDown *string + V *int64 +} + +func (p ExpressRouteCircuitRoutesTableSummaryOperationPredicate) Matches(input ExpressRouteCircuitRoutesTableSummary) bool { + + if p.As != nil && (input.As == nil || *p.As != *input.As) { + return false + } + + if p.Neighbor != nil && (input.Neighbor == nil || *p.Neighbor != *input.Neighbor) { + return false + } + + if p.StatePfxRcd != nil && (input.StatePfxRcd == nil || *p.StatePfxRcd != *input.StatePfxRcd) { + return false + } + + if p.UpDown != nil && (input.UpDown == nil || *p.UpDown != *input.UpDown) { + return false + } + + if p.V != nil && (input.V == nil || *p.V != *input.V) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/version.go b/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/version.go new file mode 100644 index 00000000000..3e9149c724c --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitroutestablesummary/version.go @@ -0,0 +1,10 @@ +package expressroutecircuitroutestablesummary + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressroutecircuitroutestablesummary/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/README.md b/resource-manager/network/2024-07-01/expressroutecircuits/README.md new file mode 100644 index 00000000000..eabfbbf8935 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuits` Documentation + +The `expressroutecircuits` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuits" +``` + + +### Client Initialization + +```go +client := expressroutecircuits.NewExpressRouteCircuitsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteCircuitsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := expressroutecircuits.NewExpressRouteCircuitID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName") + +payload := expressroutecircuits.ExpressRouteCircuit{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRouteCircuitsClient.Delete` + +```go +ctx := context.TODO() +id := expressroutecircuits.NewExpressRouteCircuitID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRouteCircuitsClient.Get` + +```go +ctx := context.TODO() +id := expressroutecircuits.NewExpressRouteCircuitID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ExpressRouteCircuitsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ExpressRouteCircuitsClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ExpressRouteCircuitsClient.UpdateTags` + +```go +ctx := context.TODO() +id := expressroutecircuits.NewExpressRouteCircuitID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName") + +payload := expressroutecircuits.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/client.go b/resource-manager/network/2024-07-01/expressroutecircuits/client.go new file mode 100644 index 00000000000..e618de82828 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/client.go @@ -0,0 +1,26 @@ +package expressroutecircuits + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitsClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteCircuitsClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteCircuitsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressroutecircuits", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteCircuitsClient: %+v", err) + } + + return &ExpressRouteCircuitsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/constants.go b/resource-manager/network/2024-07-01/expressroutecircuits/constants.go new file mode 100644 index 00000000000..ff467fc33e2 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/constants.go @@ -0,0 +1,515 @@ +package expressroutecircuits + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdvertisedPublicPrefixPropertiesValidationState string + +const ( + AdvertisedPublicPrefixPropertiesValidationStateAsnValidationFailed AdvertisedPublicPrefixPropertiesValidationState = "AsnValidationFailed" + AdvertisedPublicPrefixPropertiesValidationStateCertificateMissingInRoutingRegistry AdvertisedPublicPrefixPropertiesValidationState = "CertificateMissingInRoutingRegistry" + AdvertisedPublicPrefixPropertiesValidationStateConfigured AdvertisedPublicPrefixPropertiesValidationState = "Configured" + AdvertisedPublicPrefixPropertiesValidationStateConfiguring AdvertisedPublicPrefixPropertiesValidationState = "Configuring" + AdvertisedPublicPrefixPropertiesValidationStateInvalidSignatureEncoding AdvertisedPublicPrefixPropertiesValidationState = "InvalidSignatureEncoding" + AdvertisedPublicPrefixPropertiesValidationStateManualValidationNeeded AdvertisedPublicPrefixPropertiesValidationState = "ManualValidationNeeded" + AdvertisedPublicPrefixPropertiesValidationStateNotConfigured AdvertisedPublicPrefixPropertiesValidationState = "NotConfigured" + AdvertisedPublicPrefixPropertiesValidationStateSignatureVerificationFailed AdvertisedPublicPrefixPropertiesValidationState = "SignatureVerificationFailed" + AdvertisedPublicPrefixPropertiesValidationStateValidationFailed AdvertisedPublicPrefixPropertiesValidationState = "ValidationFailed" + AdvertisedPublicPrefixPropertiesValidationStateValidationNeeded AdvertisedPublicPrefixPropertiesValidationState = "ValidationNeeded" +) + +func PossibleValuesForAdvertisedPublicPrefixPropertiesValidationState() []string { + return []string{ + string(AdvertisedPublicPrefixPropertiesValidationStateAsnValidationFailed), + string(AdvertisedPublicPrefixPropertiesValidationStateCertificateMissingInRoutingRegistry), + string(AdvertisedPublicPrefixPropertiesValidationStateConfigured), + string(AdvertisedPublicPrefixPropertiesValidationStateConfiguring), + string(AdvertisedPublicPrefixPropertiesValidationStateInvalidSignatureEncoding), + string(AdvertisedPublicPrefixPropertiesValidationStateManualValidationNeeded), + string(AdvertisedPublicPrefixPropertiesValidationStateNotConfigured), + string(AdvertisedPublicPrefixPropertiesValidationStateSignatureVerificationFailed), + string(AdvertisedPublicPrefixPropertiesValidationStateValidationFailed), + string(AdvertisedPublicPrefixPropertiesValidationStateValidationNeeded), + } +} + +func (s *AdvertisedPublicPrefixPropertiesValidationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAdvertisedPublicPrefixPropertiesValidationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAdvertisedPublicPrefixPropertiesValidationState(input string) (*AdvertisedPublicPrefixPropertiesValidationState, error) { + vals := map[string]AdvertisedPublicPrefixPropertiesValidationState{ + "asnvalidationfailed": AdvertisedPublicPrefixPropertiesValidationStateAsnValidationFailed, + "certificatemissinginroutingregistry": AdvertisedPublicPrefixPropertiesValidationStateCertificateMissingInRoutingRegistry, + "configured": AdvertisedPublicPrefixPropertiesValidationStateConfigured, + "configuring": AdvertisedPublicPrefixPropertiesValidationStateConfiguring, + "invalidsignatureencoding": AdvertisedPublicPrefixPropertiesValidationStateInvalidSignatureEncoding, + "manualvalidationneeded": AdvertisedPublicPrefixPropertiesValidationStateManualValidationNeeded, + "notconfigured": AdvertisedPublicPrefixPropertiesValidationStateNotConfigured, + "signatureverificationfailed": AdvertisedPublicPrefixPropertiesValidationStateSignatureVerificationFailed, + "validationfailed": AdvertisedPublicPrefixPropertiesValidationStateValidationFailed, + "validationneeded": AdvertisedPublicPrefixPropertiesValidationStateValidationNeeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AdvertisedPublicPrefixPropertiesValidationState(input) + return &out, nil +} + +type AuthorizationUseStatus string + +const ( + AuthorizationUseStatusAvailable AuthorizationUseStatus = "Available" + AuthorizationUseStatusInUse AuthorizationUseStatus = "InUse" +) + +func PossibleValuesForAuthorizationUseStatus() []string { + return []string{ + string(AuthorizationUseStatusAvailable), + string(AuthorizationUseStatusInUse), + } +} + +func (s *AuthorizationUseStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthorizationUseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthorizationUseStatus(input string) (*AuthorizationUseStatus, error) { + vals := map[string]AuthorizationUseStatus{ + "available": AuthorizationUseStatusAvailable, + "inuse": AuthorizationUseStatusInUse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthorizationUseStatus(input) + return &out, nil +} + +type CircuitConnectionStatus string + +const ( + CircuitConnectionStatusConnected CircuitConnectionStatus = "Connected" + CircuitConnectionStatusConnecting CircuitConnectionStatus = "Connecting" + CircuitConnectionStatusDisconnected CircuitConnectionStatus = "Disconnected" +) + +func PossibleValuesForCircuitConnectionStatus() []string { + return []string{ + string(CircuitConnectionStatusConnected), + string(CircuitConnectionStatusConnecting), + string(CircuitConnectionStatusDisconnected), + } +} + +func (s *CircuitConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCircuitConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCircuitConnectionStatus(input string) (*CircuitConnectionStatus, error) { + vals := map[string]CircuitConnectionStatus{ + "connected": CircuitConnectionStatusConnected, + "connecting": CircuitConnectionStatusConnecting, + "disconnected": CircuitConnectionStatusDisconnected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CircuitConnectionStatus(input) + return &out, nil +} + +type ExpressRouteCircuitPeeringAdvertisedPublicPrefixState string + +const ( + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfigured ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "Configured" + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfiguring ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "Configuring" + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateNotConfigured ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "NotConfigured" + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateValidationNeeded ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "ValidationNeeded" +) + +func PossibleValuesForExpressRouteCircuitPeeringAdvertisedPublicPrefixState() []string { + return []string{ + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfigured), + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfiguring), + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateNotConfigured), + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateValidationNeeded), + } +} + +func (s *ExpressRouteCircuitPeeringAdvertisedPublicPrefixState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteCircuitPeeringAdvertisedPublicPrefixState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteCircuitPeeringAdvertisedPublicPrefixState(input string) (*ExpressRouteCircuitPeeringAdvertisedPublicPrefixState, error) { + vals := map[string]ExpressRouteCircuitPeeringAdvertisedPublicPrefixState{ + "configured": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfigured, + "configuring": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfiguring, + "notconfigured": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateNotConfigured, + "validationneeded": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateValidationNeeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteCircuitPeeringAdvertisedPublicPrefixState(input) + return &out, nil +} + +type ExpressRouteCircuitPeeringState string + +const ( + ExpressRouteCircuitPeeringStateDisabled ExpressRouteCircuitPeeringState = "Disabled" + ExpressRouteCircuitPeeringStateEnabled ExpressRouteCircuitPeeringState = "Enabled" +) + +func PossibleValuesForExpressRouteCircuitPeeringState() []string { + return []string{ + string(ExpressRouteCircuitPeeringStateDisabled), + string(ExpressRouteCircuitPeeringStateEnabled), + } +} + +func (s *ExpressRouteCircuitPeeringState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteCircuitPeeringState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteCircuitPeeringState(input string) (*ExpressRouteCircuitPeeringState, error) { + vals := map[string]ExpressRouteCircuitPeeringState{ + "disabled": ExpressRouteCircuitPeeringStateDisabled, + "enabled": ExpressRouteCircuitPeeringStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteCircuitPeeringState(input) + return &out, nil +} + +type ExpressRouteCircuitSkuFamily string + +const ( + ExpressRouteCircuitSkuFamilyMeteredData ExpressRouteCircuitSkuFamily = "MeteredData" + ExpressRouteCircuitSkuFamilyUnlimitedData ExpressRouteCircuitSkuFamily = "UnlimitedData" +) + +func PossibleValuesForExpressRouteCircuitSkuFamily() []string { + return []string{ + string(ExpressRouteCircuitSkuFamilyMeteredData), + string(ExpressRouteCircuitSkuFamilyUnlimitedData), + } +} + +func (s *ExpressRouteCircuitSkuFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteCircuitSkuFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteCircuitSkuFamily(input string) (*ExpressRouteCircuitSkuFamily, error) { + vals := map[string]ExpressRouteCircuitSkuFamily{ + "metereddata": ExpressRouteCircuitSkuFamilyMeteredData, + "unlimiteddata": ExpressRouteCircuitSkuFamilyUnlimitedData, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteCircuitSkuFamily(input) + return &out, nil +} + +type ExpressRouteCircuitSkuTier string + +const ( + ExpressRouteCircuitSkuTierBasic ExpressRouteCircuitSkuTier = "Basic" + ExpressRouteCircuitSkuTierLocal ExpressRouteCircuitSkuTier = "Local" + ExpressRouteCircuitSkuTierPremium ExpressRouteCircuitSkuTier = "Premium" + ExpressRouteCircuitSkuTierStandard ExpressRouteCircuitSkuTier = "Standard" +) + +func PossibleValuesForExpressRouteCircuitSkuTier() []string { + return []string{ + string(ExpressRouteCircuitSkuTierBasic), + string(ExpressRouteCircuitSkuTierLocal), + string(ExpressRouteCircuitSkuTierPremium), + string(ExpressRouteCircuitSkuTierStandard), + } +} + +func (s *ExpressRouteCircuitSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteCircuitSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteCircuitSkuTier(input string) (*ExpressRouteCircuitSkuTier, error) { + vals := map[string]ExpressRouteCircuitSkuTier{ + "basic": ExpressRouteCircuitSkuTierBasic, + "local": ExpressRouteCircuitSkuTierLocal, + "premium": ExpressRouteCircuitSkuTierPremium, + "standard": ExpressRouteCircuitSkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteCircuitSkuTier(input) + return &out, nil +} + +type ExpressRoutePeeringState string + +const ( + ExpressRoutePeeringStateDisabled ExpressRoutePeeringState = "Disabled" + ExpressRoutePeeringStateEnabled ExpressRoutePeeringState = "Enabled" +) + +func PossibleValuesForExpressRoutePeeringState() []string { + return []string{ + string(ExpressRoutePeeringStateDisabled), + string(ExpressRoutePeeringStateEnabled), + } +} + +func (s *ExpressRoutePeeringState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRoutePeeringState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRoutePeeringState(input string) (*ExpressRoutePeeringState, error) { + vals := map[string]ExpressRoutePeeringState{ + "disabled": ExpressRoutePeeringStateDisabled, + "enabled": ExpressRoutePeeringStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRoutePeeringState(input) + return &out, nil +} + +type ExpressRoutePeeringType string + +const ( + ExpressRoutePeeringTypeAzurePrivatePeering ExpressRoutePeeringType = "AzurePrivatePeering" + ExpressRoutePeeringTypeAzurePublicPeering ExpressRoutePeeringType = "AzurePublicPeering" + ExpressRoutePeeringTypeMicrosoftPeering ExpressRoutePeeringType = "MicrosoftPeering" +) + +func PossibleValuesForExpressRoutePeeringType() []string { + return []string{ + string(ExpressRoutePeeringTypeAzurePrivatePeering), + string(ExpressRoutePeeringTypeAzurePublicPeering), + string(ExpressRoutePeeringTypeMicrosoftPeering), + } +} + +func (s *ExpressRoutePeeringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRoutePeeringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRoutePeeringType(input string) (*ExpressRoutePeeringType, error) { + vals := map[string]ExpressRoutePeeringType{ + "azureprivatepeering": ExpressRoutePeeringTypeAzurePrivatePeering, + "azurepublicpeering": ExpressRoutePeeringTypeAzurePublicPeering, + "microsoftpeering": ExpressRoutePeeringTypeMicrosoftPeering, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRoutePeeringType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ServiceProviderProvisioningState string + +const ( + ServiceProviderProvisioningStateDeprovisioning ServiceProviderProvisioningState = "Deprovisioning" + ServiceProviderProvisioningStateNotProvisioned ServiceProviderProvisioningState = "NotProvisioned" + ServiceProviderProvisioningStateProvisioned ServiceProviderProvisioningState = "Provisioned" + ServiceProviderProvisioningStateProvisioning ServiceProviderProvisioningState = "Provisioning" +) + +func PossibleValuesForServiceProviderProvisioningState() []string { + return []string{ + string(ServiceProviderProvisioningStateDeprovisioning), + string(ServiceProviderProvisioningStateNotProvisioned), + string(ServiceProviderProvisioningStateProvisioned), + string(ServiceProviderProvisioningStateProvisioning), + } +} + +func (s *ServiceProviderProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceProviderProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceProviderProvisioningState(input string) (*ServiceProviderProvisioningState, error) { + vals := map[string]ServiceProviderProvisioningState{ + "deprovisioning": ServiceProviderProvisioningStateDeprovisioning, + "notprovisioned": ServiceProviderProvisioningStateNotProvisioned, + "provisioned": ServiceProviderProvisioningStateProvisioned, + "provisioning": ServiceProviderProvisioningStateProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceProviderProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/id_expressroutecircuit.go b/resource-manager/network/2024-07-01/expressroutecircuits/id_expressroutecircuit.go new file mode 100644 index 00000000000..7c3ebaafe98 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/id_expressroutecircuit.go @@ -0,0 +1,130 @@ +package expressroutecircuits + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ExpressRouteCircuitId{}) +} + +var _ resourceids.ResourceId = &ExpressRouteCircuitId{} + +// ExpressRouteCircuitId is a struct representing the Resource ID for a Express Route Circuit +type ExpressRouteCircuitId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteCircuitName string +} + +// NewExpressRouteCircuitID returns a new ExpressRouteCircuitId struct +func NewExpressRouteCircuitID(subscriptionId string, resourceGroupName string, expressRouteCircuitName string) ExpressRouteCircuitId { + return ExpressRouteCircuitId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteCircuitName: expressRouteCircuitName, + } +} + +// ParseExpressRouteCircuitID parses 'input' into a ExpressRouteCircuitId +func ParseExpressRouteCircuitID(input string) (*ExpressRouteCircuitId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteCircuitId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteCircuitId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseExpressRouteCircuitIDInsensitively parses 'input' case-insensitively into a ExpressRouteCircuitId +// note: this method should only be used for API response data and not user input +func ParseExpressRouteCircuitIDInsensitively(input string) (*ExpressRouteCircuitId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteCircuitId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteCircuitId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ExpressRouteCircuitId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteCircuitName, ok = input.Parsed["expressRouteCircuitName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteCircuitName", input) + } + + return nil +} + +// ValidateExpressRouteCircuitID checks that 'input' can be parsed as a Express Route Circuit ID +func ValidateExpressRouteCircuitID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseExpressRouteCircuitID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Express Route Circuit ID +func (id ExpressRouteCircuitId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCircuits/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteCircuitName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Express Route Circuit ID +func (id ExpressRouteCircuitId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteCircuits", "expressRouteCircuits", "expressRouteCircuits"), + resourceids.UserSpecifiedSegment("expressRouteCircuitName", "expressRouteCircuitName"), + } +} + +// String returns a human-readable description of this Express Route Circuit ID +func (id ExpressRouteCircuitId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Circuit Name: %q", id.ExpressRouteCircuitName), + } + return fmt.Sprintf("Express Route Circuit (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/id_expressroutecircuit_test.go b/resource-manager/network/2024-07-01/expressroutecircuits/id_expressroutecircuit_test.go new file mode 100644 index 00000000000..de1beeca125 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/id_expressroutecircuit_test.go @@ -0,0 +1,282 @@ +package expressroutecircuits + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ExpressRouteCircuitId{} + +func TestNewExpressRouteCircuitID(t *testing.T) { + id := NewExpressRouteCircuitID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteCircuitName != "expressRouteCircuitName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteCircuitName'", id.ExpressRouteCircuitName, "expressRouteCircuitName") + } +} + +func TestFormatExpressRouteCircuitID(t *testing.T) { + actual := NewExpressRouteCircuitID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseExpressRouteCircuitID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteCircuitId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Expected: &ExpressRouteCircuitId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteCircuitID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + } +} + +func TestParseExpressRouteCircuitIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteCircuitId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Expected: &ExpressRouteCircuitId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe", + Expected: &ExpressRouteCircuitId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteCircuitName: "eXpReSsRoUtEcIrCuItNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteCircuitIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + } +} + +func TestSegmentsForExpressRouteCircuitId(t *testing.T) { + segments := ExpressRouteCircuitId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ExpressRouteCircuitId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/method_createorupdate.go b/resource-manager/network/2024-07-01/expressroutecircuits/method_createorupdate.go new file mode 100644 index 00000000000..399156eb14e --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/method_createorupdate.go @@ -0,0 +1,75 @@ +package expressroutecircuits + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteCircuit +} + +// CreateOrUpdate ... +func (c ExpressRouteCircuitsClient) CreateOrUpdate(ctx context.Context, id ExpressRouteCircuitId, input ExpressRouteCircuit) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ExpressRouteCircuitsClient) CreateOrUpdateThenPoll(ctx context.Context, id ExpressRouteCircuitId, input ExpressRouteCircuit) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/method_delete.go b/resource-manager/network/2024-07-01/expressroutecircuits/method_delete.go new file mode 100644 index 00000000000..91f8aa53bed --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/method_delete.go @@ -0,0 +1,71 @@ +package expressroutecircuits + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ExpressRouteCircuitsClient) Delete(ctx context.Context, id ExpressRouteCircuitId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ExpressRouteCircuitsClient) DeleteThenPoll(ctx context.Context, id ExpressRouteCircuitId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/method_get.go b/resource-manager/network/2024-07-01/expressroutecircuits/method_get.go new file mode 100644 index 00000000000..f44a9d7ab3d --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/method_get.go @@ -0,0 +1,53 @@ +package expressroutecircuits + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteCircuit +} + +// Get ... +func (c ExpressRouteCircuitsClient) Get(ctx context.Context, id ExpressRouteCircuitId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRouteCircuit + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/method_list.go b/resource-manager/network/2024-07-01/expressroutecircuits/method_list.go new file mode 100644 index 00000000000..dae4c03fa04 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/method_list.go @@ -0,0 +1,106 @@ +package expressroutecircuits + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteCircuit +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteCircuit +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ExpressRouteCircuitsClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/expressRouteCircuits", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ExpressRouteCircuit `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ExpressRouteCircuitsClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ExpressRouteCircuitOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ExpressRouteCircuitsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ExpressRouteCircuitOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ExpressRouteCircuit, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/method_listall.go b/resource-manager/network/2024-07-01/expressroutecircuits/method_listall.go new file mode 100644 index 00000000000..815e72b26ce --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/method_listall.go @@ -0,0 +1,106 @@ +package expressroutecircuits + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteCircuit +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteCircuit +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c ExpressRouteCircuitsClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/expressRouteCircuits", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ExpressRouteCircuit `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c ExpressRouteCircuitsClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, ExpressRouteCircuitOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ExpressRouteCircuitsClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ExpressRouteCircuitOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]ExpressRouteCircuit, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/method_updatetags.go b/resource-manager/network/2024-07-01/expressroutecircuits/method_updatetags.go new file mode 100644 index 00000000000..2188a40d783 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/method_updatetags.go @@ -0,0 +1,57 @@ +package expressroutecircuits + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteCircuit +} + +// UpdateTags ... +func (c ExpressRouteCircuitsClient) UpdateTags(ctx context.Context, id ExpressRouteCircuitId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRouteCircuit + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_advertisedpublicprefixproperties.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_advertisedpublicprefixproperties.go new file mode 100644 index 00000000000..1411e7797cf --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_advertisedpublicprefixproperties.go @@ -0,0 +1,11 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdvertisedPublicPrefixProperties struct { + Prefix *string `json:"prefix,omitempty"` + Signature *string `json:"signature,omitempty"` + ValidationId *string `json:"validationId,omitempty"` + ValidationState *AdvertisedPublicPrefixPropertiesValidationState `json:"validationState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_authorizationpropertiesformat.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_authorizationpropertiesformat.go new file mode 100644 index 00000000000..65f50c0d659 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_authorizationpropertiesformat.go @@ -0,0 +1,11 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthorizationPropertiesFormat struct { + AuthorizationKey *string `json:"authorizationKey,omitempty"` + AuthorizationUseStatus *AuthorizationUseStatus `json:"authorizationUseStatus,omitempty"` + ConnectionResourceUri *string `json:"connectionResourceUri,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuit.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuit.go new file mode 100644 index 00000000000..a74493fcec8 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuit.go @@ -0,0 +1,15 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuit struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRouteCircuitPropertiesFormat `json:"properties,omitempty"` + Sku *ExpressRouteCircuitSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitauthorization.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitauthorization.go new file mode 100644 index 00000000000..2942811a91c --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitauthorization.go @@ -0,0 +1,12 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitAuthorization struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AuthorizationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitconnection.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitconnection.go new file mode 100644 index 00000000000..901ef503724 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitconnection.go @@ -0,0 +1,12 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRouteCircuitConnectionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitconnectionpropertiesformat.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitconnectionpropertiesformat.go new file mode 100644 index 00000000000..897f772964a --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitconnectionpropertiesformat.go @@ -0,0 +1,14 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitConnectionPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AuthorizationKey *string `json:"authorizationKey,omitempty"` + CircuitConnectionStatus *CircuitConnectionStatus `json:"circuitConnectionStatus,omitempty"` + ExpressRouteCircuitPeering *SubResource `json:"expressRouteCircuitPeering,omitempty"` + IPv6CircuitConnectionConfig *IPv6CircuitConnectionConfig `json:"ipv6CircuitConnectionConfig,omitempty"` + PeerExpressRouteCircuitPeering *SubResource `json:"peerExpressRouteCircuitPeering,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitpeering.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitpeering.go new file mode 100644 index 00000000000..d7431190482 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitpeering.go @@ -0,0 +1,12 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitPeering struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRouteCircuitPeeringPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitpeeringconfig.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitpeeringconfig.go new file mode 100644 index 00000000000..5f83ea40ca0 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitpeeringconfig.go @@ -0,0 +1,14 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitPeeringConfig struct { + AdvertisedCommunities *[]string `json:"advertisedCommunities,omitempty"` + AdvertisedPublicPrefixInfo *[]AdvertisedPublicPrefixProperties `json:"advertisedPublicPrefixInfo,omitempty"` + AdvertisedPublicPrefixes *[]string `json:"advertisedPublicPrefixes,omitempty"` + AdvertisedPublicPrefixesState *ExpressRouteCircuitPeeringAdvertisedPublicPrefixState `json:"advertisedPublicPrefixesState,omitempty"` + CustomerASN *int64 `json:"customerASN,omitempty"` + LegacyMode *int64 `json:"legacyMode,omitempty"` + RoutingRegistryName *string `json:"routingRegistryName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitpeeringpropertiesformat.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitpeeringpropertiesformat.go new file mode 100644 index 00000000000..87a88e75638 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitpeeringpropertiesformat.go @@ -0,0 +1,27 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitPeeringPropertiesFormat struct { + AzureASN *int64 `json:"azureASN,omitempty"` + Connections *[]ExpressRouteCircuitConnection `json:"connections,omitempty"` + ExpressRouteConnection *ExpressRouteConnectionId `json:"expressRouteConnection,omitempty"` + GatewayManagerEtag *string `json:"gatewayManagerEtag,omitempty"` + IPv6PeeringConfig *IPv6ExpressRouteCircuitPeeringConfig `json:"ipv6PeeringConfig,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + MicrosoftPeeringConfig *ExpressRouteCircuitPeeringConfig `json:"microsoftPeeringConfig,omitempty"` + PeerASN *int64 `json:"peerASN,omitempty"` + PeeredConnections *[]PeerExpressRouteCircuitConnection `json:"peeredConnections,omitempty"` + PeeringType *ExpressRoutePeeringType `json:"peeringType,omitempty"` + PrimaryAzurePort *string `json:"primaryAzurePort,omitempty"` + PrimaryPeerAddressPrefix *string `json:"primaryPeerAddressPrefix,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RouteFilter *SubResource `json:"routeFilter,omitempty"` + SecondaryAzurePort *string `json:"secondaryAzurePort,omitempty"` + SecondaryPeerAddressPrefix *string `json:"secondaryPeerAddressPrefix,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` + State *ExpressRoutePeeringState `json:"state,omitempty"` + Stats *ExpressRouteCircuitStats `json:"stats,omitempty"` + VlanId *int64 `json:"vlanId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitpropertiesformat.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitpropertiesformat.go new file mode 100644 index 00000000000..250eb3de724 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitpropertiesformat.go @@ -0,0 +1,24 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitPropertiesFormat struct { + AllowClassicOperations *bool `json:"allowClassicOperations,omitempty"` + AuthorizationKey *string `json:"authorizationKey,omitempty"` + AuthorizationStatus *string `json:"authorizationStatus,omitempty"` + Authorizations *[]ExpressRouteCircuitAuthorization `json:"authorizations,omitempty"` + BandwidthInGbps *float64 `json:"bandwidthInGbps,omitempty"` + CircuitProvisioningState *string `json:"circuitProvisioningState,omitempty"` + EnableDirectPortRateLimit *bool `json:"enableDirectPortRateLimit,omitempty"` + ExpressRoutePort *SubResource `json:"expressRoutePort,omitempty"` + GatewayManagerEtag *string `json:"gatewayManagerEtag,omitempty"` + GlobalReachEnabled *bool `json:"globalReachEnabled,omitempty"` + Peerings *[]ExpressRouteCircuitPeering `json:"peerings,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceKey *string `json:"serviceKey,omitempty"` + ServiceProviderNotes *string `json:"serviceProviderNotes,omitempty"` + ServiceProviderProperties *ExpressRouteCircuitServiceProviderProperties `json:"serviceProviderProperties,omitempty"` + ServiceProviderProvisioningState *ServiceProviderProvisioningState `json:"serviceProviderProvisioningState,omitempty"` + Stag *int64 `json:"stag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitserviceproviderproperties.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitserviceproviderproperties.go new file mode 100644 index 00000000000..432cdaf5a4a --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitserviceproviderproperties.go @@ -0,0 +1,10 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitServiceProviderProperties struct { + BandwidthInMbps *int64 `json:"bandwidthInMbps,omitempty"` + PeeringLocation *string `json:"peeringLocation,omitempty"` + ServiceProviderName *string `json:"serviceProviderName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitsku.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitsku.go new file mode 100644 index 00000000000..186629b51a6 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitsku.go @@ -0,0 +1,10 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitSku struct { + Family *ExpressRouteCircuitSkuFamily `json:"family,omitempty"` + Name *string `json:"name,omitempty"` + Tier *ExpressRouteCircuitSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitstats.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitstats.go new file mode 100644 index 00000000000..ca8cd2c52bc --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressroutecircuitstats.go @@ -0,0 +1,11 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitStats struct { + PrimarybytesIn *int64 `json:"primarybytesIn,omitempty"` + PrimarybytesOut *int64 `json:"primarybytesOut,omitempty"` + SecondarybytesIn *int64 `json:"secondarybytesIn,omitempty"` + SecondarybytesOut *int64 `json:"secondarybytesOut,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_expressrouteconnectionid.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressrouteconnectionid.go new file mode 100644 index 00000000000..70b79aa3ec7 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_expressrouteconnectionid.go @@ -0,0 +1,8 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteConnectionId struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_ipv6circuitconnectionconfig.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_ipv6circuitconnectionconfig.go new file mode 100644 index 00000000000..49a42177273 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_ipv6circuitconnectionconfig.go @@ -0,0 +1,9 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPv6CircuitConnectionConfig struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + CircuitConnectionStatus *CircuitConnectionStatus `json:"circuitConnectionStatus,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_ipv6expressroutecircuitpeeringconfig.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_ipv6expressroutecircuitpeeringconfig.go new file mode 100644 index 00000000000..02e4a94b316 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_ipv6expressroutecircuitpeeringconfig.go @@ -0,0 +1,12 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPv6ExpressRouteCircuitPeeringConfig struct { + MicrosoftPeeringConfig *ExpressRouteCircuitPeeringConfig `json:"microsoftPeeringConfig,omitempty"` + PrimaryPeerAddressPrefix *string `json:"primaryPeerAddressPrefix,omitempty"` + RouteFilter *SubResource `json:"routeFilter,omitempty"` + SecondaryPeerAddressPrefix *string `json:"secondaryPeerAddressPrefix,omitempty"` + State *ExpressRouteCircuitPeeringState `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_peerexpressroutecircuitconnection.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_peerexpressroutecircuitconnection.go new file mode 100644 index 00000000000..e52a6b6f8c3 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_peerexpressroutecircuitconnection.go @@ -0,0 +1,12 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PeerExpressRouteCircuitConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PeerExpressRouteCircuitConnectionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_peerexpressroutecircuitconnectionpropertiesformat.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_peerexpressroutecircuitconnectionpropertiesformat.go new file mode 100644 index 00000000000..804baee319a --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_peerexpressroutecircuitconnectionpropertiesformat.go @@ -0,0 +1,14 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PeerExpressRouteCircuitConnectionPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AuthResourceGuid *string `json:"authResourceGuid,omitempty"` + CircuitConnectionStatus *CircuitConnectionStatus `json:"circuitConnectionStatus,omitempty"` + ConnectionName *string `json:"connectionName,omitempty"` + ExpressRouteCircuitPeering *SubResource `json:"expressRouteCircuitPeering,omitempty"` + PeerExpressRouteCircuitPeering *SubResource `json:"peerExpressRouteCircuitPeering,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_subresource.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_subresource.go new file mode 100644 index 00000000000..daf852a98a9 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_subresource.go @@ -0,0 +1,8 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/model_tagsobject.go b/resource-manager/network/2024-07-01/expressroutecircuits/model_tagsobject.go new file mode 100644 index 00000000000..585eaaba376 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/model_tagsobject.go @@ -0,0 +1,8 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/predicates.go b/resource-manager/network/2024-07-01/expressroutecircuits/predicates.go new file mode 100644 index 00000000000..3fdbc040dbf --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/predicates.go @@ -0,0 +1,37 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ExpressRouteCircuitOperationPredicate) Matches(input ExpressRouteCircuit) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuits/version.go b/resource-manager/network/2024-07-01/expressroutecircuits/version.go new file mode 100644 index 00000000000..cde8f48691c --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuits/version.go @@ -0,0 +1,10 @@ +package expressroutecircuits + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressroutecircuits/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitstats/README.md b/resource-manager/network/2024-07-01/expressroutecircuitstats/README.md new file mode 100644 index 00000000000..60967246061 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitstats/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitstats` Documentation + +The `expressroutecircuitstats` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecircuitstats" +``` + + +### Client Initialization + +```go +client := expressroutecircuitstats.NewExpressRouteCircuitStatsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteCircuitStatsClient.ExpressRouteCircuitsGetPeeringStats` + +```go +ctx := context.TODO() +id := commonids.NewExpressRouteCircuitPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName") + +read, err := client.ExpressRouteCircuitsGetPeeringStats(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ExpressRouteCircuitStatsClient.ExpressRouteCircuitsGetStats` + +```go +ctx := context.TODO() +id := expressroutecircuitstats.NewExpressRouteCircuitID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName") + +read, err := client.ExpressRouteCircuitsGetStats(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/expressroutecircuitstats/client.go b/resource-manager/network/2024-07-01/expressroutecircuitstats/client.go new file mode 100644 index 00000000000..697e4ff2817 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitstats/client.go @@ -0,0 +1,26 @@ +package expressroutecircuitstats + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitStatsClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteCircuitStatsClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteCircuitStatsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressroutecircuitstats", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteCircuitStatsClient: %+v", err) + } + + return &ExpressRouteCircuitStatsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitstats/id_expressroutecircuit.go b/resource-manager/network/2024-07-01/expressroutecircuitstats/id_expressroutecircuit.go new file mode 100644 index 00000000000..0eba5b9c251 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitstats/id_expressroutecircuit.go @@ -0,0 +1,130 @@ +package expressroutecircuitstats + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ExpressRouteCircuitId{}) +} + +var _ resourceids.ResourceId = &ExpressRouteCircuitId{} + +// ExpressRouteCircuitId is a struct representing the Resource ID for a Express Route Circuit +type ExpressRouteCircuitId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteCircuitName string +} + +// NewExpressRouteCircuitID returns a new ExpressRouteCircuitId struct +func NewExpressRouteCircuitID(subscriptionId string, resourceGroupName string, expressRouteCircuitName string) ExpressRouteCircuitId { + return ExpressRouteCircuitId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteCircuitName: expressRouteCircuitName, + } +} + +// ParseExpressRouteCircuitID parses 'input' into a ExpressRouteCircuitId +func ParseExpressRouteCircuitID(input string) (*ExpressRouteCircuitId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteCircuitId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteCircuitId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseExpressRouteCircuitIDInsensitively parses 'input' case-insensitively into a ExpressRouteCircuitId +// note: this method should only be used for API response data and not user input +func ParseExpressRouteCircuitIDInsensitively(input string) (*ExpressRouteCircuitId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteCircuitId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteCircuitId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ExpressRouteCircuitId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteCircuitName, ok = input.Parsed["expressRouteCircuitName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteCircuitName", input) + } + + return nil +} + +// ValidateExpressRouteCircuitID checks that 'input' can be parsed as a Express Route Circuit ID +func ValidateExpressRouteCircuitID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseExpressRouteCircuitID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Express Route Circuit ID +func (id ExpressRouteCircuitId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCircuits/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteCircuitName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Express Route Circuit ID +func (id ExpressRouteCircuitId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteCircuits", "expressRouteCircuits", "expressRouteCircuits"), + resourceids.UserSpecifiedSegment("expressRouteCircuitName", "expressRouteCircuitName"), + } +} + +// String returns a human-readable description of this Express Route Circuit ID +func (id ExpressRouteCircuitId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Circuit Name: %q", id.ExpressRouteCircuitName), + } + return fmt.Sprintf("Express Route Circuit (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitstats/id_expressroutecircuit_test.go b/resource-manager/network/2024-07-01/expressroutecircuitstats/id_expressroutecircuit_test.go new file mode 100644 index 00000000000..288e8caf55e --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitstats/id_expressroutecircuit_test.go @@ -0,0 +1,282 @@ +package expressroutecircuitstats + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ExpressRouteCircuitId{} + +func TestNewExpressRouteCircuitID(t *testing.T) { + id := NewExpressRouteCircuitID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteCircuitName != "expressRouteCircuitName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteCircuitName'", id.ExpressRouteCircuitName, "expressRouteCircuitName") + } +} + +func TestFormatExpressRouteCircuitID(t *testing.T) { + actual := NewExpressRouteCircuitID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseExpressRouteCircuitID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteCircuitId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Expected: &ExpressRouteCircuitId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteCircuitID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + } +} + +func TestParseExpressRouteCircuitIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteCircuitId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Expected: &ExpressRouteCircuitId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe", + Expected: &ExpressRouteCircuitId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteCircuitName: "eXpReSsRoUtEcIrCuItNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteCircuitIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + } +} + +func TestSegmentsForExpressRouteCircuitId(t *testing.T) { + segments := ExpressRouteCircuitId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ExpressRouteCircuitId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitstats/method_expressroutecircuitsgetpeeringstats.go b/resource-manager/network/2024-07-01/expressroutecircuitstats/method_expressroutecircuitsgetpeeringstats.go new file mode 100644 index 00000000000..14b01a4f877 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitstats/method_expressroutecircuitsgetpeeringstats.go @@ -0,0 +1,55 @@ +package expressroutecircuitstats + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitsGetPeeringStatsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteCircuitStats +} + +// ExpressRouteCircuitsGetPeeringStats ... +func (c ExpressRouteCircuitStatsClient) ExpressRouteCircuitsGetPeeringStats(ctx context.Context, id commonids.ExpressRouteCircuitPeeringId) (result ExpressRouteCircuitsGetPeeringStatsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/stats", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRouteCircuitStats + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitstats/method_expressroutecircuitsgetstats.go b/resource-manager/network/2024-07-01/expressroutecircuitstats/method_expressroutecircuitsgetstats.go new file mode 100644 index 00000000000..093f31815f0 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitstats/method_expressroutecircuitsgetstats.go @@ -0,0 +1,54 @@ +package expressroutecircuitstats + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitsGetStatsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteCircuitStats +} + +// ExpressRouteCircuitsGetStats ... +func (c ExpressRouteCircuitStatsClient) ExpressRouteCircuitsGetStats(ctx context.Context, id ExpressRouteCircuitId) (result ExpressRouteCircuitsGetStatsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/stats", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRouteCircuitStats + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitstats/model_expressroutecircuitstats.go b/resource-manager/network/2024-07-01/expressroutecircuitstats/model_expressroutecircuitstats.go new file mode 100644 index 00000000000..f93c0daeba8 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitstats/model_expressroutecircuitstats.go @@ -0,0 +1,11 @@ +package expressroutecircuitstats + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitStats struct { + PrimarybytesIn *int64 `json:"primarybytesIn,omitempty"` + PrimarybytesOut *int64 `json:"primarybytesOut,omitempty"` + SecondarybytesIn *int64 `json:"secondarybytesIn,omitempty"` + SecondarybytesOut *int64 `json:"secondarybytesOut,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecircuitstats/version.go b/resource-manager/network/2024-07-01/expressroutecircuitstats/version.go new file mode 100644 index 00000000000..26a36689677 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecircuitstats/version.go @@ -0,0 +1,10 @@ +package expressroutecircuitstats + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressroutecircuitstats/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/README.md b/resource-manager/network/2024-07-01/expressrouteconnections/README.md new file mode 100644 index 00000000000..babc14a9a07 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/README.md @@ -0,0 +1,81 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteconnections` Documentation + +The `expressrouteconnections` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteconnections" +``` + + +### Client Initialization + +```go +client := expressrouteconnections.NewExpressRouteConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteConnectionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := expressrouteconnections.NewExpressRouteConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteGatewayName", "expressRouteConnectionName") + +payload := expressrouteconnections.ExpressRouteConnection{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRouteConnectionsClient.Delete` + +```go +ctx := context.TODO() +id := expressrouteconnections.NewExpressRouteConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteGatewayName", "expressRouteConnectionName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRouteConnectionsClient.Get` + +```go +ctx := context.TODO() +id := expressrouteconnections.NewExpressRouteConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteGatewayName", "expressRouteConnectionName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ExpressRouteConnectionsClient.List` + +```go +ctx := context.TODO() +id := expressrouteconnections.NewExpressRouteGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteGatewayName") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/client.go b/resource-manager/network/2024-07-01/expressrouteconnections/client.go new file mode 100644 index 00000000000..379d1d22880 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/client.go @@ -0,0 +1,26 @@ +package expressrouteconnections + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteConnectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressrouteconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteConnectionsClient: %+v", err) + } + + return &ExpressRouteConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/constants.go b/resource-manager/network/2024-07-01/expressrouteconnections/constants.go new file mode 100644 index 00000000000..571bcb03c1e --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/constants.go @@ -0,0 +1,98 @@ +package expressrouteconnections + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type VnetLocalRouteOverrideCriteria string + +const ( + VnetLocalRouteOverrideCriteriaContains VnetLocalRouteOverrideCriteria = "Contains" + VnetLocalRouteOverrideCriteriaEqual VnetLocalRouteOverrideCriteria = "Equal" +) + +func PossibleValuesForVnetLocalRouteOverrideCriteria() []string { + return []string{ + string(VnetLocalRouteOverrideCriteriaContains), + string(VnetLocalRouteOverrideCriteriaEqual), + } +} + +func (s *VnetLocalRouteOverrideCriteria) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVnetLocalRouteOverrideCriteria(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVnetLocalRouteOverrideCriteria(input string) (*VnetLocalRouteOverrideCriteria, error) { + vals := map[string]VnetLocalRouteOverrideCriteria{ + "contains": VnetLocalRouteOverrideCriteriaContains, + "equal": VnetLocalRouteOverrideCriteriaEqual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VnetLocalRouteOverrideCriteria(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/id_expressrouteconnection.go b/resource-manager/network/2024-07-01/expressrouteconnections/id_expressrouteconnection.go new file mode 100644 index 00000000000..2cf6021fe08 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/id_expressrouteconnection.go @@ -0,0 +1,139 @@ +package expressrouteconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ExpressRouteConnectionId{}) +} + +var _ resourceids.ResourceId = &ExpressRouteConnectionId{} + +// ExpressRouteConnectionId is a struct representing the Resource ID for a Express Route Connection +type ExpressRouteConnectionId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteGatewayName string + ExpressRouteConnectionName string +} + +// NewExpressRouteConnectionID returns a new ExpressRouteConnectionId struct +func NewExpressRouteConnectionID(subscriptionId string, resourceGroupName string, expressRouteGatewayName string, expressRouteConnectionName string) ExpressRouteConnectionId { + return ExpressRouteConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteGatewayName: expressRouteGatewayName, + ExpressRouteConnectionName: expressRouteConnectionName, + } +} + +// ParseExpressRouteConnectionID parses 'input' into a ExpressRouteConnectionId +func ParseExpressRouteConnectionID(input string) (*ExpressRouteConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseExpressRouteConnectionIDInsensitively parses 'input' case-insensitively into a ExpressRouteConnectionId +// note: this method should only be used for API response data and not user input +func ParseExpressRouteConnectionIDInsensitively(input string) (*ExpressRouteConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ExpressRouteConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteGatewayName, ok = input.Parsed["expressRouteGatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteGatewayName", input) + } + + if id.ExpressRouteConnectionName, ok = input.Parsed["expressRouteConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteConnectionName", input) + } + + return nil +} + +// ValidateExpressRouteConnectionID checks that 'input' can be parsed as a Express Route Connection ID +func ValidateExpressRouteConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseExpressRouteConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Express Route Connection ID +func (id ExpressRouteConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteGateways/%s/expressRouteConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteGatewayName, id.ExpressRouteConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Express Route Connection ID +func (id ExpressRouteConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteGateways", "expressRouteGateways", "expressRouteGateways"), + resourceids.UserSpecifiedSegment("expressRouteGatewayName", "expressRouteGatewayName"), + resourceids.StaticSegment("staticExpressRouteConnections", "expressRouteConnections", "expressRouteConnections"), + resourceids.UserSpecifiedSegment("expressRouteConnectionName", "expressRouteConnectionName"), + } +} + +// String returns a human-readable description of this Express Route Connection ID +func (id ExpressRouteConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Gateway Name: %q", id.ExpressRouteGatewayName), + fmt.Sprintf("Express Route Connection Name: %q", id.ExpressRouteConnectionName), + } + return fmt.Sprintf("Express Route Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/id_expressrouteconnection_test.go b/resource-manager/network/2024-07-01/expressrouteconnections/id_expressrouteconnection_test.go new file mode 100644 index 00000000000..dd3b75e24af --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/id_expressrouteconnection_test.go @@ -0,0 +1,327 @@ +package expressrouteconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ExpressRouteConnectionId{} + +func TestNewExpressRouteConnectionID(t *testing.T) { + id := NewExpressRouteConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteGatewayName", "expressRouteConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteGatewayName != "expressRouteGatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteGatewayName'", id.ExpressRouteGatewayName, "expressRouteGatewayName") + } + + if id.ExpressRouteConnectionName != "expressRouteConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteConnectionName'", id.ExpressRouteConnectionName, "expressRouteConnectionName") + } +} + +func TestFormatExpressRouteConnectionID(t *testing.T) { + actual := NewExpressRouteConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteGatewayName", "expressRouteConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName/expressRouteConnections/expressRouteConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseExpressRouteConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName/expressRouteConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName/expressRouteConnections/expressRouteConnectionName", + Expected: &ExpressRouteConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteGatewayName: "expressRouteGatewayName", + ExpressRouteConnectionName: "expressRouteConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName/expressRouteConnections/expressRouteConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteGatewayName != v.Expected.ExpressRouteGatewayName { + t.Fatalf("Expected %q but got %q for ExpressRouteGatewayName", v.Expected.ExpressRouteGatewayName, actual.ExpressRouteGatewayName) + } + + if actual.ExpressRouteConnectionName != v.Expected.ExpressRouteConnectionName { + t.Fatalf("Expected %q but got %q for ExpressRouteConnectionName", v.Expected.ExpressRouteConnectionName, actual.ExpressRouteConnectionName) + } + + } +} + +func TestParseExpressRouteConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEgAtEwAyS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEgAtEwAyS/eXpReSsRoUtEgAtEwAyNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName/expressRouteConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEgAtEwAyS/eXpReSsRoUtEgAtEwAyNaMe/eXpReSsRoUtEcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName/expressRouteConnections/expressRouteConnectionName", + Expected: &ExpressRouteConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteGatewayName: "expressRouteGatewayName", + ExpressRouteConnectionName: "expressRouteConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName/expressRouteConnections/expressRouteConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEgAtEwAyS/eXpReSsRoUtEgAtEwAyNaMe/eXpReSsRoUtEcOnNeCtIoNs/eXpReSsRoUtEcOnNeCtIoNnAmE", + Expected: &ExpressRouteConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteGatewayName: "eXpReSsRoUtEgAtEwAyNaMe", + ExpressRouteConnectionName: "eXpReSsRoUtEcOnNeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEgAtEwAyS/eXpReSsRoUtEgAtEwAyNaMe/eXpReSsRoUtEcOnNeCtIoNs/eXpReSsRoUtEcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteGatewayName != v.Expected.ExpressRouteGatewayName { + t.Fatalf("Expected %q but got %q for ExpressRouteGatewayName", v.Expected.ExpressRouteGatewayName, actual.ExpressRouteGatewayName) + } + + if actual.ExpressRouteConnectionName != v.Expected.ExpressRouteConnectionName { + t.Fatalf("Expected %q but got %q for ExpressRouteConnectionName", v.Expected.ExpressRouteConnectionName, actual.ExpressRouteConnectionName) + } + + } +} + +func TestSegmentsForExpressRouteConnectionId(t *testing.T) { + segments := ExpressRouteConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ExpressRouteConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/id_expressroutegateway.go b/resource-manager/network/2024-07-01/expressrouteconnections/id_expressroutegateway.go new file mode 100644 index 00000000000..cad59206c91 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/id_expressroutegateway.go @@ -0,0 +1,130 @@ +package expressrouteconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ExpressRouteGatewayId{}) +} + +var _ resourceids.ResourceId = &ExpressRouteGatewayId{} + +// ExpressRouteGatewayId is a struct representing the Resource ID for a Express Route Gateway +type ExpressRouteGatewayId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteGatewayName string +} + +// NewExpressRouteGatewayID returns a new ExpressRouteGatewayId struct +func NewExpressRouteGatewayID(subscriptionId string, resourceGroupName string, expressRouteGatewayName string) ExpressRouteGatewayId { + return ExpressRouteGatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteGatewayName: expressRouteGatewayName, + } +} + +// ParseExpressRouteGatewayID parses 'input' into a ExpressRouteGatewayId +func ParseExpressRouteGatewayID(input string) (*ExpressRouteGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteGatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseExpressRouteGatewayIDInsensitively parses 'input' case-insensitively into a ExpressRouteGatewayId +// note: this method should only be used for API response data and not user input +func ParseExpressRouteGatewayIDInsensitively(input string) (*ExpressRouteGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteGatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ExpressRouteGatewayId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteGatewayName, ok = input.Parsed["expressRouteGatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteGatewayName", input) + } + + return nil +} + +// ValidateExpressRouteGatewayID checks that 'input' can be parsed as a Express Route Gateway ID +func ValidateExpressRouteGatewayID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseExpressRouteGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Express Route Gateway ID +func (id ExpressRouteGatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteGateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteGatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Express Route Gateway ID +func (id ExpressRouteGatewayId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteGateways", "expressRouteGateways", "expressRouteGateways"), + resourceids.UserSpecifiedSegment("expressRouteGatewayName", "expressRouteGatewayName"), + } +} + +// String returns a human-readable description of this Express Route Gateway ID +func (id ExpressRouteGatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Gateway Name: %q", id.ExpressRouteGatewayName), + } + return fmt.Sprintf("Express Route Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/id_expressroutegateway_test.go b/resource-manager/network/2024-07-01/expressrouteconnections/id_expressroutegateway_test.go new file mode 100644 index 00000000000..6af6325d971 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/id_expressroutegateway_test.go @@ -0,0 +1,282 @@ +package expressrouteconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ExpressRouteGatewayId{} + +func TestNewExpressRouteGatewayID(t *testing.T) { + id := NewExpressRouteGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteGatewayName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteGatewayName != "expressRouteGatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteGatewayName'", id.ExpressRouteGatewayName, "expressRouteGatewayName") + } +} + +func TestFormatExpressRouteGatewayID(t *testing.T) { + actual := NewExpressRouteGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteGatewayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseExpressRouteGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName", + Expected: &ExpressRouteGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteGatewayName: "expressRouteGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteGatewayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteGatewayName != v.Expected.ExpressRouteGatewayName { + t.Fatalf("Expected %q but got %q for ExpressRouteGatewayName", v.Expected.ExpressRouteGatewayName, actual.ExpressRouteGatewayName) + } + + } +} + +func TestParseExpressRouteGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEgAtEwAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName", + Expected: &ExpressRouteGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteGatewayName: "expressRouteGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEgAtEwAyS/eXpReSsRoUtEgAtEwAyNaMe", + Expected: &ExpressRouteGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteGatewayName: "eXpReSsRoUtEgAtEwAyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEgAtEwAyS/eXpReSsRoUtEgAtEwAyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteGatewayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteGatewayName != v.Expected.ExpressRouteGatewayName { + t.Fatalf("Expected %q but got %q for ExpressRouteGatewayName", v.Expected.ExpressRouteGatewayName, actual.ExpressRouteGatewayName) + } + + } +} + +func TestSegmentsForExpressRouteGatewayId(t *testing.T) { + segments := ExpressRouteGatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ExpressRouteGatewayId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/method_createorupdate.go b/resource-manager/network/2024-07-01/expressrouteconnections/method_createorupdate.go new file mode 100644 index 00000000000..37e7c0ceddb --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/method_createorupdate.go @@ -0,0 +1,75 @@ +package expressrouteconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteConnection +} + +// CreateOrUpdate ... +func (c ExpressRouteConnectionsClient) CreateOrUpdate(ctx context.Context, id ExpressRouteConnectionId, input ExpressRouteConnection) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ExpressRouteConnectionsClient) CreateOrUpdateThenPoll(ctx context.Context, id ExpressRouteConnectionId, input ExpressRouteConnection) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/method_delete.go b/resource-manager/network/2024-07-01/expressrouteconnections/method_delete.go new file mode 100644 index 00000000000..8f3816bde32 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/method_delete.go @@ -0,0 +1,71 @@ +package expressrouteconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ExpressRouteConnectionsClient) Delete(ctx context.Context, id ExpressRouteConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ExpressRouteConnectionsClient) DeleteThenPoll(ctx context.Context, id ExpressRouteConnectionId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/method_get.go b/resource-manager/network/2024-07-01/expressrouteconnections/method_get.go new file mode 100644 index 00000000000..0116eaca5cf --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/method_get.go @@ -0,0 +1,53 @@ +package expressrouteconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteConnection +} + +// Get ... +func (c ExpressRouteConnectionsClient) Get(ctx context.Context, id ExpressRouteConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRouteConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/method_list.go b/resource-manager/network/2024-07-01/expressrouteconnections/method_list.go new file mode 100644 index 00000000000..d6233e938c4 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/method_list.go @@ -0,0 +1,54 @@ +package expressrouteconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteConnectionList +} + +// List ... +func (c ExpressRouteConnectionsClient) List(ctx context.Context, id ExpressRouteGatewayId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/expressRouteConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRouteConnectionList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/model_expressroutecircuitpeeringid.go b/resource-manager/network/2024-07-01/expressrouteconnections/model_expressroutecircuitpeeringid.go new file mode 100644 index 00000000000..3a30ff411e8 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/model_expressroutecircuitpeeringid.go @@ -0,0 +1,8 @@ +package expressrouteconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitPeeringId struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/model_expressrouteconnection.go b/resource-manager/network/2024-07-01/expressrouteconnections/model_expressrouteconnection.go new file mode 100644 index 00000000000..1e31fa6c860 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/model_expressrouteconnection.go @@ -0,0 +1,10 @@ +package expressrouteconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteConnection struct { + Id *string `json:"id,omitempty"` + Name string `json:"name"` + Properties *ExpressRouteConnectionProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/model_expressrouteconnectionlist.go b/resource-manager/network/2024-07-01/expressrouteconnections/model_expressrouteconnectionlist.go new file mode 100644 index 00000000000..a16565b3cd5 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/model_expressrouteconnectionlist.go @@ -0,0 +1,8 @@ +package expressrouteconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteConnectionList struct { + Value *[]ExpressRouteConnection `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/model_expressrouteconnectionproperties.go b/resource-manager/network/2024-07-01/expressrouteconnections/model_expressrouteconnectionproperties.go new file mode 100644 index 00000000000..2e9dddfbc1a --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/model_expressrouteconnectionproperties.go @@ -0,0 +1,15 @@ +package expressrouteconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteConnectionProperties struct { + AuthorizationKey *string `json:"authorizationKey,omitempty"` + EnableInternetSecurity *bool `json:"enableInternetSecurity,omitempty"` + EnablePrivateLinkFastPath *bool `json:"enablePrivateLinkFastPath,omitempty"` + ExpressRouteCircuitPeering ExpressRouteCircuitPeeringId `json:"expressRouteCircuitPeering"` + ExpressRouteGatewayBypass *bool `json:"expressRouteGatewayBypass,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RoutingConfiguration *RoutingConfiguration `json:"routingConfiguration,omitempty"` + RoutingWeight *int64 `json:"routingWeight,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/model_propagatedroutetable.go b/resource-manager/network/2024-07-01/expressrouteconnections/model_propagatedroutetable.go new file mode 100644 index 00000000000..7279e13359c --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/model_propagatedroutetable.go @@ -0,0 +1,9 @@ +package expressrouteconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PropagatedRouteTable struct { + Ids *[]SubResource `json:"ids,omitempty"` + Labels *[]string `json:"labels,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/model_routingconfiguration.go b/resource-manager/network/2024-07-01/expressrouteconnections/model_routingconfiguration.go new file mode 100644 index 00000000000..4e1904d9c6e --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/model_routingconfiguration.go @@ -0,0 +1,12 @@ +package expressrouteconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingConfiguration struct { + AssociatedRouteTable *SubResource `json:"associatedRouteTable,omitempty"` + InboundRouteMap *SubResource `json:"inboundRouteMap,omitempty"` + OutboundRouteMap *SubResource `json:"outboundRouteMap,omitempty"` + PropagatedRouteTables *PropagatedRouteTable `json:"propagatedRouteTables,omitempty"` + VnetRoutes *VnetRoute `json:"vnetRoutes,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/model_staticroute.go b/resource-manager/network/2024-07-01/expressrouteconnections/model_staticroute.go new file mode 100644 index 00000000000..c1e414bbe16 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/model_staticroute.go @@ -0,0 +1,10 @@ +package expressrouteconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticRoute struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + Name *string `json:"name,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/model_staticroutesconfig.go b/resource-manager/network/2024-07-01/expressrouteconnections/model_staticroutesconfig.go new file mode 100644 index 00000000000..9ee286419ac --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/model_staticroutesconfig.go @@ -0,0 +1,9 @@ +package expressrouteconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticRoutesConfig struct { + PropagateStaticRoutes *bool `json:"propagateStaticRoutes,omitempty"` + VnetLocalRouteOverrideCriteria *VnetLocalRouteOverrideCriteria `json:"vnetLocalRouteOverrideCriteria,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/model_subresource.go b/resource-manager/network/2024-07-01/expressrouteconnections/model_subresource.go new file mode 100644 index 00000000000..5a5f53696f8 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/model_subresource.go @@ -0,0 +1,8 @@ +package expressrouteconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/model_vnetroute.go b/resource-manager/network/2024-07-01/expressrouteconnections/model_vnetroute.go new file mode 100644 index 00000000000..9e296eed5de --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/model_vnetroute.go @@ -0,0 +1,10 @@ +package expressrouteconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRoute struct { + BgpConnections *[]SubResource `json:"bgpConnections,omitempty"` + StaticRoutes *[]StaticRoute `json:"staticRoutes,omitempty"` + StaticRoutesConfig *StaticRoutesConfig `json:"staticRoutesConfig,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteconnections/version.go b/resource-manager/network/2024-07-01/expressrouteconnections/version.go new file mode 100644 index 00000000000..5f8e2c37e7d --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteconnections/version.go @@ -0,0 +1,10 @@ +package expressrouteconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressrouteconnections/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/README.md b/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/README.md new file mode 100644 index 00000000000..71f87562886 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable` Documentation + +The `expressroutecrossconnectionarptable` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable" +``` + + +### Client Initialization + +```go +client := expressroutecrossconnectionarptable.NewExpressRouteCrossConnectionArpTableClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteCrossConnectionArpTableClient.ExpressRouteCrossConnectionsListArpTable` + +```go +ctx := context.TODO() +id := expressroutecrossconnectionarptable.NewPeeringArpTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName", "peeringName", "arpTableName") + +// alternatively `client.ExpressRouteCrossConnectionsListArpTable(ctx, id)` can be used to do batched pagination +items, err := client.ExpressRouteCrossConnectionsListArpTableComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/client.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/client.go new file mode 100644 index 00000000000..57ec192ecdb --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/client.go @@ -0,0 +1,26 @@ +package expressroutecrossconnectionarptable + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionArpTableClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteCrossConnectionArpTableClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteCrossConnectionArpTableClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressroutecrossconnectionarptable", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteCrossConnectionArpTableClient: %+v", err) + } + + return &ExpressRouteCrossConnectionArpTableClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/id_peeringarptable.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/id_peeringarptable.go new file mode 100644 index 00000000000..f37ffb9dda2 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/id_peeringarptable.go @@ -0,0 +1,148 @@ +package expressroutecrossconnectionarptable + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PeeringArpTableId{}) +} + +var _ resourceids.ResourceId = &PeeringArpTableId{} + +// PeeringArpTableId is a struct representing the Resource ID for a Peering Arp Table +type PeeringArpTableId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteCrossConnectionName string + PeeringName string + ArpTableName string +} + +// NewPeeringArpTableID returns a new PeeringArpTableId struct +func NewPeeringArpTableID(subscriptionId string, resourceGroupName string, expressRouteCrossConnectionName string, peeringName string, arpTableName string) PeeringArpTableId { + return PeeringArpTableId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteCrossConnectionName: expressRouteCrossConnectionName, + PeeringName: peeringName, + ArpTableName: arpTableName, + } +} + +// ParsePeeringArpTableID parses 'input' into a PeeringArpTableId +func ParsePeeringArpTableID(input string) (*PeeringArpTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&PeeringArpTableId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PeeringArpTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePeeringArpTableIDInsensitively parses 'input' case-insensitively into a PeeringArpTableId +// note: this method should only be used for API response data and not user input +func ParsePeeringArpTableIDInsensitively(input string) (*PeeringArpTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&PeeringArpTableId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PeeringArpTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PeeringArpTableId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteCrossConnectionName, ok = input.Parsed["expressRouteCrossConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteCrossConnectionName", input) + } + + if id.PeeringName, ok = input.Parsed["peeringName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "peeringName", input) + } + + if id.ArpTableName, ok = input.Parsed["arpTableName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "arpTableName", input) + } + + return nil +} + +// ValidatePeeringArpTableID checks that 'input' can be parsed as a Peering Arp Table ID +func ValidatePeeringArpTableID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePeeringArpTableID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Peering Arp Table ID +func (id PeeringArpTableId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCrossConnections/%s/peerings/%s/arpTables/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteCrossConnectionName, id.PeeringName, id.ArpTableName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Peering Arp Table ID +func (id PeeringArpTableId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteCrossConnections", "expressRouteCrossConnections", "expressRouteCrossConnections"), + resourceids.UserSpecifiedSegment("expressRouteCrossConnectionName", "expressRouteCrossConnectionName"), + resourceids.StaticSegment("staticPeerings", "peerings", "peerings"), + resourceids.UserSpecifiedSegment("peeringName", "peeringName"), + resourceids.StaticSegment("staticArpTables", "arpTables", "arpTables"), + resourceids.UserSpecifiedSegment("arpTableName", "arpTableName"), + } +} + +// String returns a human-readable description of this Peering Arp Table ID +func (id PeeringArpTableId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Cross Connection Name: %q", id.ExpressRouteCrossConnectionName), + fmt.Sprintf("Peering Name: %q", id.PeeringName), + fmt.Sprintf("Arp Table Name: %q", id.ArpTableName), + } + return fmt.Sprintf("Peering Arp Table (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/id_peeringarptable_test.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/id_peeringarptable_test.go new file mode 100644 index 00000000000..1d31f05cc7a --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/id_peeringarptable_test.go @@ -0,0 +1,372 @@ +package expressroutecrossconnectionarptable + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PeeringArpTableId{} + +func TestNewPeeringArpTableID(t *testing.T) { + id := NewPeeringArpTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName", "peeringName", "arpTableName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteCrossConnectionName != "expressRouteCrossConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteCrossConnectionName'", id.ExpressRouteCrossConnectionName, "expressRouteCrossConnectionName") + } + + if id.PeeringName != "peeringName" { + t.Fatalf("Expected %q but got %q for Segment 'PeeringName'", id.PeeringName, "peeringName") + } + + if id.ArpTableName != "arpTableName" { + t.Fatalf("Expected %q but got %q for Segment 'ArpTableName'", id.ArpTableName, "arpTableName") + } +} + +func TestFormatPeeringArpTableID(t *testing.T) { + actual := NewPeeringArpTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName", "peeringName", "arpTableName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/arpTables/arpTableName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePeeringArpTableID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PeeringArpTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/arpTables", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/arpTables/arpTableName", + Expected: &PeeringArpTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCrossConnectionName: "expressRouteCrossConnectionName", + PeeringName: "peeringName", + ArpTableName: "arpTableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/arpTables/arpTableName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePeeringArpTableID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCrossConnectionName != v.Expected.ExpressRouteCrossConnectionName { + t.Fatalf("Expected %q but got %q for ExpressRouteCrossConnectionName", v.Expected.ExpressRouteCrossConnectionName, actual.ExpressRouteCrossConnectionName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + if actual.ArpTableName != v.Expected.ArpTableName { + t.Fatalf("Expected %q but got %q for ArpTableName", v.Expected.ArpTableName, actual.ArpTableName) + } + + } +} + +func TestParsePeeringArpTableIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PeeringArpTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS/pEeRiNgNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/arpTables", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS/pEeRiNgNaMe/aRpTaBlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/arpTables/arpTableName", + Expected: &PeeringArpTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCrossConnectionName: "expressRouteCrossConnectionName", + PeeringName: "peeringName", + ArpTableName: "arpTableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/arpTables/arpTableName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS/pEeRiNgNaMe/aRpTaBlEs/aRpTaBlEnAmE", + Expected: &PeeringArpTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteCrossConnectionName: "eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe", + PeeringName: "pEeRiNgNaMe", + ArpTableName: "aRpTaBlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS/pEeRiNgNaMe/aRpTaBlEs/aRpTaBlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePeeringArpTableIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCrossConnectionName != v.Expected.ExpressRouteCrossConnectionName { + t.Fatalf("Expected %q but got %q for ExpressRouteCrossConnectionName", v.Expected.ExpressRouteCrossConnectionName, actual.ExpressRouteCrossConnectionName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + if actual.ArpTableName != v.Expected.ArpTableName { + t.Fatalf("Expected %q but got %q for ArpTableName", v.Expected.ArpTableName, actual.ArpTableName) + } + + } +} + +func TestSegmentsForPeeringArpTableId(t *testing.T) { + segments := PeeringArpTableId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PeeringArpTableId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/method_expressroutecrossconnectionslistarptable.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/method_expressroutecrossconnectionslistarptable.go new file mode 100644 index 00000000000..1aa7aed0b18 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/method_expressroutecrossconnectionslistarptable.go @@ -0,0 +1,89 @@ +package expressroutecrossconnectionarptable + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionsListArpTableOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteCircuitArpTable +} + +type ExpressRouteCrossConnectionsListArpTableCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteCircuitArpTable +} + +type ExpressRouteCrossConnectionsListArpTableCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ExpressRouteCrossConnectionsListArpTableCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ExpressRouteCrossConnectionsListArpTable ... +func (c ExpressRouteCrossConnectionArpTableClient) ExpressRouteCrossConnectionsListArpTable(ctx context.Context, id PeeringArpTableId) (result ExpressRouteCrossConnectionsListArpTableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ExpressRouteCrossConnectionsListArpTableCustomPager{}, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ExpressRouteCrossConnectionsListArpTableThenPoll performs ExpressRouteCrossConnectionsListArpTable then polls until it's completed +func (c ExpressRouteCrossConnectionArpTableClient) ExpressRouteCrossConnectionsListArpTableThenPoll(ctx context.Context, id PeeringArpTableId) error { + result, err := c.ExpressRouteCrossConnectionsListArpTable(ctx, id) + if err != nil { + return fmt.Errorf("performing ExpressRouteCrossConnectionsListArpTable: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ExpressRouteCrossConnectionsListArpTable: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/model_expressroutecircuitarptable.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/model_expressroutecircuitarptable.go new file mode 100644 index 00000000000..eb25fb1e02d --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/model_expressroutecircuitarptable.go @@ -0,0 +1,11 @@ +package expressroutecrossconnectionarptable + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitArpTable struct { + Age *int64 `json:"age,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Interface *string `json:"interface,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/predicates.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/predicates.go new file mode 100644 index 00000000000..75df45b22f9 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/predicates.go @@ -0,0 +1,32 @@ +package expressroutecrossconnectionarptable + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitArpTableOperationPredicate struct { + Age *int64 + IPAddress *string + Interface *string + MacAddress *string +} + +func (p ExpressRouteCircuitArpTableOperationPredicate) Matches(input ExpressRouteCircuitArpTable) bool { + + if p.Age != nil && (input.Age == nil || *p.Age != *input.Age) { + return false + } + + if p.IPAddress != nil && (input.IPAddress == nil || *p.IPAddress != *input.IPAddress) { + return false + } + + if p.Interface != nil && (input.Interface == nil || *p.Interface != *input.Interface) { + return false + } + + if p.MacAddress != nil && (input.MacAddress == nil || *p.MacAddress != *input.MacAddress) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/version.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/version.go new file mode 100644 index 00000000000..94c88fcfb25 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionarptable/version.go @@ -0,0 +1,10 @@ +package expressroutecrossconnectionarptable + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressroutecrossconnectionarptable/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/README.md b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/README.md new file mode 100644 index 00000000000..f0b6e45d807 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings` Documentation + +The `expressroutecrossconnectionpeerings` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings" +``` + + +### Client Initialization + +```go +client := expressroutecrossconnectionpeerings.NewExpressRouteCrossConnectionPeeringsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteCrossConnectionPeeringsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := expressroutecrossconnectionpeerings.NewPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName", "peeringName") + +payload := expressroutecrossconnectionpeerings.ExpressRouteCrossConnectionPeering{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRouteCrossConnectionPeeringsClient.Delete` + +```go +ctx := context.TODO() +id := expressroutecrossconnectionpeerings.NewPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName", "peeringName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRouteCrossConnectionPeeringsClient.Get` + +```go +ctx := context.TODO() +id := expressroutecrossconnectionpeerings.NewPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName", "peeringName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ExpressRouteCrossConnectionPeeringsClient.List` + +```go +ctx := context.TODO() +id := expressroutecrossconnectionpeerings.NewExpressRouteCrossConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/client.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/client.go new file mode 100644 index 00000000000..d2b06fe732d --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/client.go @@ -0,0 +1,26 @@ +package expressroutecrossconnectionpeerings + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionPeeringsClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteCrossConnectionPeeringsClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteCrossConnectionPeeringsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressroutecrossconnectionpeerings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteCrossConnectionPeeringsClient: %+v", err) + } + + return &ExpressRouteCrossConnectionPeeringsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/constants.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/constants.go new file mode 100644 index 00000000000..74bcdbde6eb --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/constants.go @@ -0,0 +1,295 @@ +package expressroutecrossconnectionpeerings + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdvertisedPublicPrefixPropertiesValidationState string + +const ( + AdvertisedPublicPrefixPropertiesValidationStateAsnValidationFailed AdvertisedPublicPrefixPropertiesValidationState = "AsnValidationFailed" + AdvertisedPublicPrefixPropertiesValidationStateCertificateMissingInRoutingRegistry AdvertisedPublicPrefixPropertiesValidationState = "CertificateMissingInRoutingRegistry" + AdvertisedPublicPrefixPropertiesValidationStateConfigured AdvertisedPublicPrefixPropertiesValidationState = "Configured" + AdvertisedPublicPrefixPropertiesValidationStateConfiguring AdvertisedPublicPrefixPropertiesValidationState = "Configuring" + AdvertisedPublicPrefixPropertiesValidationStateInvalidSignatureEncoding AdvertisedPublicPrefixPropertiesValidationState = "InvalidSignatureEncoding" + AdvertisedPublicPrefixPropertiesValidationStateManualValidationNeeded AdvertisedPublicPrefixPropertiesValidationState = "ManualValidationNeeded" + AdvertisedPublicPrefixPropertiesValidationStateNotConfigured AdvertisedPublicPrefixPropertiesValidationState = "NotConfigured" + AdvertisedPublicPrefixPropertiesValidationStateSignatureVerificationFailed AdvertisedPublicPrefixPropertiesValidationState = "SignatureVerificationFailed" + AdvertisedPublicPrefixPropertiesValidationStateValidationFailed AdvertisedPublicPrefixPropertiesValidationState = "ValidationFailed" + AdvertisedPublicPrefixPropertiesValidationStateValidationNeeded AdvertisedPublicPrefixPropertiesValidationState = "ValidationNeeded" +) + +func PossibleValuesForAdvertisedPublicPrefixPropertiesValidationState() []string { + return []string{ + string(AdvertisedPublicPrefixPropertiesValidationStateAsnValidationFailed), + string(AdvertisedPublicPrefixPropertiesValidationStateCertificateMissingInRoutingRegistry), + string(AdvertisedPublicPrefixPropertiesValidationStateConfigured), + string(AdvertisedPublicPrefixPropertiesValidationStateConfiguring), + string(AdvertisedPublicPrefixPropertiesValidationStateInvalidSignatureEncoding), + string(AdvertisedPublicPrefixPropertiesValidationStateManualValidationNeeded), + string(AdvertisedPublicPrefixPropertiesValidationStateNotConfigured), + string(AdvertisedPublicPrefixPropertiesValidationStateSignatureVerificationFailed), + string(AdvertisedPublicPrefixPropertiesValidationStateValidationFailed), + string(AdvertisedPublicPrefixPropertiesValidationStateValidationNeeded), + } +} + +func (s *AdvertisedPublicPrefixPropertiesValidationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAdvertisedPublicPrefixPropertiesValidationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAdvertisedPublicPrefixPropertiesValidationState(input string) (*AdvertisedPublicPrefixPropertiesValidationState, error) { + vals := map[string]AdvertisedPublicPrefixPropertiesValidationState{ + "asnvalidationfailed": AdvertisedPublicPrefixPropertiesValidationStateAsnValidationFailed, + "certificatemissinginroutingregistry": AdvertisedPublicPrefixPropertiesValidationStateCertificateMissingInRoutingRegistry, + "configured": AdvertisedPublicPrefixPropertiesValidationStateConfigured, + "configuring": AdvertisedPublicPrefixPropertiesValidationStateConfiguring, + "invalidsignatureencoding": AdvertisedPublicPrefixPropertiesValidationStateInvalidSignatureEncoding, + "manualvalidationneeded": AdvertisedPublicPrefixPropertiesValidationStateManualValidationNeeded, + "notconfigured": AdvertisedPublicPrefixPropertiesValidationStateNotConfigured, + "signatureverificationfailed": AdvertisedPublicPrefixPropertiesValidationStateSignatureVerificationFailed, + "validationfailed": AdvertisedPublicPrefixPropertiesValidationStateValidationFailed, + "validationneeded": AdvertisedPublicPrefixPropertiesValidationStateValidationNeeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AdvertisedPublicPrefixPropertiesValidationState(input) + return &out, nil +} + +type ExpressRouteCircuitPeeringAdvertisedPublicPrefixState string + +const ( + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfigured ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "Configured" + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfiguring ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "Configuring" + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateNotConfigured ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "NotConfigured" + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateValidationNeeded ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "ValidationNeeded" +) + +func PossibleValuesForExpressRouteCircuitPeeringAdvertisedPublicPrefixState() []string { + return []string{ + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfigured), + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfiguring), + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateNotConfigured), + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateValidationNeeded), + } +} + +func (s *ExpressRouteCircuitPeeringAdvertisedPublicPrefixState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteCircuitPeeringAdvertisedPublicPrefixState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteCircuitPeeringAdvertisedPublicPrefixState(input string) (*ExpressRouteCircuitPeeringAdvertisedPublicPrefixState, error) { + vals := map[string]ExpressRouteCircuitPeeringAdvertisedPublicPrefixState{ + "configured": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfigured, + "configuring": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfiguring, + "notconfigured": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateNotConfigured, + "validationneeded": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateValidationNeeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteCircuitPeeringAdvertisedPublicPrefixState(input) + return &out, nil +} + +type ExpressRouteCircuitPeeringState string + +const ( + ExpressRouteCircuitPeeringStateDisabled ExpressRouteCircuitPeeringState = "Disabled" + ExpressRouteCircuitPeeringStateEnabled ExpressRouteCircuitPeeringState = "Enabled" +) + +func PossibleValuesForExpressRouteCircuitPeeringState() []string { + return []string{ + string(ExpressRouteCircuitPeeringStateDisabled), + string(ExpressRouteCircuitPeeringStateEnabled), + } +} + +func (s *ExpressRouteCircuitPeeringState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteCircuitPeeringState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteCircuitPeeringState(input string) (*ExpressRouteCircuitPeeringState, error) { + vals := map[string]ExpressRouteCircuitPeeringState{ + "disabled": ExpressRouteCircuitPeeringStateDisabled, + "enabled": ExpressRouteCircuitPeeringStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteCircuitPeeringState(input) + return &out, nil +} + +type ExpressRoutePeeringState string + +const ( + ExpressRoutePeeringStateDisabled ExpressRoutePeeringState = "Disabled" + ExpressRoutePeeringStateEnabled ExpressRoutePeeringState = "Enabled" +) + +func PossibleValuesForExpressRoutePeeringState() []string { + return []string{ + string(ExpressRoutePeeringStateDisabled), + string(ExpressRoutePeeringStateEnabled), + } +} + +func (s *ExpressRoutePeeringState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRoutePeeringState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRoutePeeringState(input string) (*ExpressRoutePeeringState, error) { + vals := map[string]ExpressRoutePeeringState{ + "disabled": ExpressRoutePeeringStateDisabled, + "enabled": ExpressRoutePeeringStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRoutePeeringState(input) + return &out, nil +} + +type ExpressRoutePeeringType string + +const ( + ExpressRoutePeeringTypeAzurePrivatePeering ExpressRoutePeeringType = "AzurePrivatePeering" + ExpressRoutePeeringTypeAzurePublicPeering ExpressRoutePeeringType = "AzurePublicPeering" + ExpressRoutePeeringTypeMicrosoftPeering ExpressRoutePeeringType = "MicrosoftPeering" +) + +func PossibleValuesForExpressRoutePeeringType() []string { + return []string{ + string(ExpressRoutePeeringTypeAzurePrivatePeering), + string(ExpressRoutePeeringTypeAzurePublicPeering), + string(ExpressRoutePeeringTypeMicrosoftPeering), + } +} + +func (s *ExpressRoutePeeringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRoutePeeringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRoutePeeringType(input string) (*ExpressRoutePeeringType, error) { + vals := map[string]ExpressRoutePeeringType{ + "azureprivatepeering": ExpressRoutePeeringTypeAzurePrivatePeering, + "azurepublicpeering": ExpressRoutePeeringTypeAzurePublicPeering, + "microsoftpeering": ExpressRoutePeeringTypeMicrosoftPeering, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRoutePeeringType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/id_expressroutecrossconnection.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/id_expressroutecrossconnection.go new file mode 100644 index 00000000000..890e4e7d24b --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/id_expressroutecrossconnection.go @@ -0,0 +1,130 @@ +package expressroutecrossconnectionpeerings + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ExpressRouteCrossConnectionId{}) +} + +var _ resourceids.ResourceId = &ExpressRouteCrossConnectionId{} + +// ExpressRouteCrossConnectionId is a struct representing the Resource ID for a Express Route Cross Connection +type ExpressRouteCrossConnectionId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteCrossConnectionName string +} + +// NewExpressRouteCrossConnectionID returns a new ExpressRouteCrossConnectionId struct +func NewExpressRouteCrossConnectionID(subscriptionId string, resourceGroupName string, expressRouteCrossConnectionName string) ExpressRouteCrossConnectionId { + return ExpressRouteCrossConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteCrossConnectionName: expressRouteCrossConnectionName, + } +} + +// ParseExpressRouteCrossConnectionID parses 'input' into a ExpressRouteCrossConnectionId +func ParseExpressRouteCrossConnectionID(input string) (*ExpressRouteCrossConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteCrossConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteCrossConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseExpressRouteCrossConnectionIDInsensitively parses 'input' case-insensitively into a ExpressRouteCrossConnectionId +// note: this method should only be used for API response data and not user input +func ParseExpressRouteCrossConnectionIDInsensitively(input string) (*ExpressRouteCrossConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteCrossConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteCrossConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ExpressRouteCrossConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteCrossConnectionName, ok = input.Parsed["expressRouteCrossConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteCrossConnectionName", input) + } + + return nil +} + +// ValidateExpressRouteCrossConnectionID checks that 'input' can be parsed as a Express Route Cross Connection ID +func ValidateExpressRouteCrossConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseExpressRouteCrossConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Express Route Cross Connection ID +func (id ExpressRouteCrossConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCrossConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteCrossConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Express Route Cross Connection ID +func (id ExpressRouteCrossConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteCrossConnections", "expressRouteCrossConnections", "expressRouteCrossConnections"), + resourceids.UserSpecifiedSegment("expressRouteCrossConnectionName", "expressRouteCrossConnectionName"), + } +} + +// String returns a human-readable description of this Express Route Cross Connection ID +func (id ExpressRouteCrossConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Cross Connection Name: %q", id.ExpressRouteCrossConnectionName), + } + return fmt.Sprintf("Express Route Cross Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/id_expressroutecrossconnection_test.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/id_expressroutecrossconnection_test.go new file mode 100644 index 00000000000..33465dd597a --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/id_expressroutecrossconnection_test.go @@ -0,0 +1,282 @@ +package expressroutecrossconnectionpeerings + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ExpressRouteCrossConnectionId{} + +func TestNewExpressRouteCrossConnectionID(t *testing.T) { + id := NewExpressRouteCrossConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteCrossConnectionName != "expressRouteCrossConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteCrossConnectionName'", id.ExpressRouteCrossConnectionName, "expressRouteCrossConnectionName") + } +} + +func TestFormatExpressRouteCrossConnectionID(t *testing.T) { + actual := NewExpressRouteCrossConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseExpressRouteCrossConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteCrossConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName", + Expected: &ExpressRouteCrossConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCrossConnectionName: "expressRouteCrossConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteCrossConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCrossConnectionName != v.Expected.ExpressRouteCrossConnectionName { + t.Fatalf("Expected %q but got %q for ExpressRouteCrossConnectionName", v.Expected.ExpressRouteCrossConnectionName, actual.ExpressRouteCrossConnectionName) + } + + } +} + +func TestParseExpressRouteCrossConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteCrossConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName", + Expected: &ExpressRouteCrossConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCrossConnectionName: "expressRouteCrossConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe", + Expected: &ExpressRouteCrossConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteCrossConnectionName: "eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteCrossConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCrossConnectionName != v.Expected.ExpressRouteCrossConnectionName { + t.Fatalf("Expected %q but got %q for ExpressRouteCrossConnectionName", v.Expected.ExpressRouteCrossConnectionName, actual.ExpressRouteCrossConnectionName) + } + + } +} + +func TestSegmentsForExpressRouteCrossConnectionId(t *testing.T) { + segments := ExpressRouteCrossConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ExpressRouteCrossConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/id_peering.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/id_peering.go new file mode 100644 index 00000000000..c3ee06da4dc --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/id_peering.go @@ -0,0 +1,139 @@ +package expressroutecrossconnectionpeerings + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PeeringId{}) +} + +var _ resourceids.ResourceId = &PeeringId{} + +// PeeringId is a struct representing the Resource ID for a Peering +type PeeringId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteCrossConnectionName string + PeeringName string +} + +// NewPeeringID returns a new PeeringId struct +func NewPeeringID(subscriptionId string, resourceGroupName string, expressRouteCrossConnectionName string, peeringName string) PeeringId { + return PeeringId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteCrossConnectionName: expressRouteCrossConnectionName, + PeeringName: peeringName, + } +} + +// ParsePeeringID parses 'input' into a PeeringId +func ParsePeeringID(input string) (*PeeringId, error) { + parser := resourceids.NewParserFromResourceIdType(&PeeringId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PeeringId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePeeringIDInsensitively parses 'input' case-insensitively into a PeeringId +// note: this method should only be used for API response data and not user input +func ParsePeeringIDInsensitively(input string) (*PeeringId, error) { + parser := resourceids.NewParserFromResourceIdType(&PeeringId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PeeringId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PeeringId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteCrossConnectionName, ok = input.Parsed["expressRouteCrossConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteCrossConnectionName", input) + } + + if id.PeeringName, ok = input.Parsed["peeringName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "peeringName", input) + } + + return nil +} + +// ValidatePeeringID checks that 'input' can be parsed as a Peering ID +func ValidatePeeringID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePeeringID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Peering ID +func (id PeeringId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCrossConnections/%s/peerings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteCrossConnectionName, id.PeeringName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Peering ID +func (id PeeringId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteCrossConnections", "expressRouteCrossConnections", "expressRouteCrossConnections"), + resourceids.UserSpecifiedSegment("expressRouteCrossConnectionName", "expressRouteCrossConnectionName"), + resourceids.StaticSegment("staticPeerings", "peerings", "peerings"), + resourceids.UserSpecifiedSegment("peeringName", "peeringName"), + } +} + +// String returns a human-readable description of this Peering ID +func (id PeeringId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Cross Connection Name: %q", id.ExpressRouteCrossConnectionName), + fmt.Sprintf("Peering Name: %q", id.PeeringName), + } + return fmt.Sprintf("Peering (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/id_peering_test.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/id_peering_test.go new file mode 100644 index 00000000000..ac47382755d --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/id_peering_test.go @@ -0,0 +1,327 @@ +package expressroutecrossconnectionpeerings + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PeeringId{} + +func TestNewPeeringID(t *testing.T) { + id := NewPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName", "peeringName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteCrossConnectionName != "expressRouteCrossConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteCrossConnectionName'", id.ExpressRouteCrossConnectionName, "expressRouteCrossConnectionName") + } + + if id.PeeringName != "peeringName" { + t.Fatalf("Expected %q but got %q for Segment 'PeeringName'", id.PeeringName, "peeringName") + } +} + +func TestFormatPeeringID(t *testing.T) { + actual := NewPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName", "peeringName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePeeringID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PeeringId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName", + Expected: &PeeringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCrossConnectionName: "expressRouteCrossConnectionName", + PeeringName: "peeringName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePeeringID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCrossConnectionName != v.Expected.ExpressRouteCrossConnectionName { + t.Fatalf("Expected %q but got %q for ExpressRouteCrossConnectionName", v.Expected.ExpressRouteCrossConnectionName, actual.ExpressRouteCrossConnectionName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + } +} + +func TestParsePeeringIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PeeringId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName", + Expected: &PeeringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCrossConnectionName: "expressRouteCrossConnectionName", + PeeringName: "peeringName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS/pEeRiNgNaMe", + Expected: &PeeringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteCrossConnectionName: "eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe", + PeeringName: "pEeRiNgNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS/pEeRiNgNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePeeringIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCrossConnectionName != v.Expected.ExpressRouteCrossConnectionName { + t.Fatalf("Expected %q but got %q for ExpressRouteCrossConnectionName", v.Expected.ExpressRouteCrossConnectionName, actual.ExpressRouteCrossConnectionName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + } +} + +func TestSegmentsForPeeringId(t *testing.T) { + segments := PeeringId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PeeringId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/method_createorupdate.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/method_createorupdate.go new file mode 100644 index 00000000000..4cfa59c5d29 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/method_createorupdate.go @@ -0,0 +1,75 @@ +package expressroutecrossconnectionpeerings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteCrossConnectionPeering +} + +// CreateOrUpdate ... +func (c ExpressRouteCrossConnectionPeeringsClient) CreateOrUpdate(ctx context.Context, id PeeringId, input ExpressRouteCrossConnectionPeering) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ExpressRouteCrossConnectionPeeringsClient) CreateOrUpdateThenPoll(ctx context.Context, id PeeringId, input ExpressRouteCrossConnectionPeering) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/method_delete.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/method_delete.go new file mode 100644 index 00000000000..f2073ab1bd3 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/method_delete.go @@ -0,0 +1,71 @@ +package expressroutecrossconnectionpeerings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ExpressRouteCrossConnectionPeeringsClient) Delete(ctx context.Context, id PeeringId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ExpressRouteCrossConnectionPeeringsClient) DeleteThenPoll(ctx context.Context, id PeeringId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/method_get.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/method_get.go new file mode 100644 index 00000000000..4fbd73485bb --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/method_get.go @@ -0,0 +1,53 @@ +package expressroutecrossconnectionpeerings + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteCrossConnectionPeering +} + +// Get ... +func (c ExpressRouteCrossConnectionPeeringsClient) Get(ctx context.Context, id PeeringId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRouteCrossConnectionPeering + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/method_list.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/method_list.go new file mode 100644 index 00000000000..15747a19b47 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/method_list.go @@ -0,0 +1,105 @@ +package expressroutecrossconnectionpeerings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteCrossConnectionPeering +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteCrossConnectionPeering +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ExpressRouteCrossConnectionPeeringsClient) List(ctx context.Context, id ExpressRouteCrossConnectionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/peerings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ExpressRouteCrossConnectionPeering `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ExpressRouteCrossConnectionPeeringsClient) ListComplete(ctx context.Context, id ExpressRouteCrossConnectionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ExpressRouteCrossConnectionPeeringOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ExpressRouteCrossConnectionPeeringsClient) ListCompleteMatchingPredicate(ctx context.Context, id ExpressRouteCrossConnectionId, predicate ExpressRouteCrossConnectionPeeringOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ExpressRouteCrossConnectionPeering, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_advertisedpublicprefixproperties.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_advertisedpublicprefixproperties.go new file mode 100644 index 00000000000..db7faa1750a --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_advertisedpublicprefixproperties.go @@ -0,0 +1,11 @@ +package expressroutecrossconnectionpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdvertisedPublicPrefixProperties struct { + Prefix *string `json:"prefix,omitempty"` + Signature *string `json:"signature,omitempty"` + ValidationId *string `json:"validationId,omitempty"` + ValidationState *AdvertisedPublicPrefixPropertiesValidationState `json:"validationState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_expressroutecircuitpeeringconfig.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_expressroutecircuitpeeringconfig.go new file mode 100644 index 00000000000..7207f35c63a --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_expressroutecircuitpeeringconfig.go @@ -0,0 +1,14 @@ +package expressroutecrossconnectionpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitPeeringConfig struct { + AdvertisedCommunities *[]string `json:"advertisedCommunities,omitempty"` + AdvertisedPublicPrefixInfo *[]AdvertisedPublicPrefixProperties `json:"advertisedPublicPrefixInfo,omitempty"` + AdvertisedPublicPrefixes *[]string `json:"advertisedPublicPrefixes,omitempty"` + AdvertisedPublicPrefixesState *ExpressRouteCircuitPeeringAdvertisedPublicPrefixState `json:"advertisedPublicPrefixesState,omitempty"` + CustomerASN *int64 `json:"customerASN,omitempty"` + LegacyMode *int64 `json:"legacyMode,omitempty"` + RoutingRegistryName *string `json:"routingRegistryName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_expressroutecrossconnectionpeering.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_expressroutecrossconnectionpeering.go new file mode 100644 index 00000000000..3244f828098 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_expressroutecrossconnectionpeering.go @@ -0,0 +1,11 @@ +package expressroutecrossconnectionpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionPeering struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRouteCrossConnectionPeeringProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_expressroutecrossconnectionpeeringproperties.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_expressroutecrossconnectionpeeringproperties.go new file mode 100644 index 00000000000..64330e5a7ea --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_expressroutecrossconnectionpeeringproperties.go @@ -0,0 +1,22 @@ +package expressroutecrossconnectionpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionPeeringProperties struct { + AzureASN *int64 `json:"azureASN,omitempty"` + GatewayManagerEtag *string `json:"gatewayManagerEtag,omitempty"` + IPv6PeeringConfig *IPv6ExpressRouteCircuitPeeringConfig `json:"ipv6PeeringConfig,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + MicrosoftPeeringConfig *ExpressRouteCircuitPeeringConfig `json:"microsoftPeeringConfig,omitempty"` + PeerASN *int64 `json:"peerASN,omitempty"` + PeeringType *ExpressRoutePeeringType `json:"peeringType,omitempty"` + PrimaryAzurePort *string `json:"primaryAzurePort,omitempty"` + PrimaryPeerAddressPrefix *string `json:"primaryPeerAddressPrefix,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SecondaryAzurePort *string `json:"secondaryAzurePort,omitempty"` + SecondaryPeerAddressPrefix *string `json:"secondaryPeerAddressPrefix,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` + State *ExpressRoutePeeringState `json:"state,omitempty"` + VlanId *int64 `json:"vlanId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_ipv6expressroutecircuitpeeringconfig.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_ipv6expressroutecircuitpeeringconfig.go new file mode 100644 index 00000000000..ec7f2c4a72c --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_ipv6expressroutecircuitpeeringconfig.go @@ -0,0 +1,12 @@ +package expressroutecrossconnectionpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPv6ExpressRouteCircuitPeeringConfig struct { + MicrosoftPeeringConfig *ExpressRouteCircuitPeeringConfig `json:"microsoftPeeringConfig,omitempty"` + PrimaryPeerAddressPrefix *string `json:"primaryPeerAddressPrefix,omitempty"` + RouteFilter *SubResource `json:"routeFilter,omitempty"` + SecondaryPeerAddressPrefix *string `json:"secondaryPeerAddressPrefix,omitempty"` + State *ExpressRouteCircuitPeeringState `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_subresource.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_subresource.go new file mode 100644 index 00000000000..919b934c547 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/model_subresource.go @@ -0,0 +1,8 @@ +package expressroutecrossconnectionpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/predicates.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/predicates.go new file mode 100644 index 00000000000..abec5984ec1 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/predicates.go @@ -0,0 +1,27 @@ +package expressroutecrossconnectionpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionPeeringOperationPredicate struct { + Etag *string + Id *string + Name *string +} + +func (p ExpressRouteCrossConnectionPeeringOperationPredicate) Matches(input ExpressRouteCrossConnectionPeering) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/version.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/version.go new file mode 100644 index 00000000000..cef2148cf6a --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionpeerings/version.go @@ -0,0 +1,10 @@ +package expressroutecrossconnectionpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressroutecrossconnectionpeerings/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/README.md b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/README.md new file mode 100644 index 00000000000..ede7c59e0ed --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable` Documentation + +The `expressroutecrossconnectionroutetable` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable" +``` + + +### Client Initialization + +```go +client := expressroutecrossconnectionroutetable.NewExpressRouteCrossConnectionRouteTableClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteCrossConnectionRouteTableClient.ExpressRouteCrossConnectionsListRoutesTable` + +```go +ctx := context.TODO() +id := expressroutecrossconnectionroutetable.NewExpressRouteCrossConnectionPeeringRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName", "peeringName", "routeTableName") + +// alternatively `client.ExpressRouteCrossConnectionsListRoutesTable(ctx, id)` can be used to do batched pagination +items, err := client.ExpressRouteCrossConnectionsListRoutesTableComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/client.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/client.go new file mode 100644 index 00000000000..6b8b935dba0 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/client.go @@ -0,0 +1,26 @@ +package expressroutecrossconnectionroutetable + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionRouteTableClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteCrossConnectionRouteTableClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteCrossConnectionRouteTableClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressroutecrossconnectionroutetable", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteCrossConnectionRouteTableClient: %+v", err) + } + + return &ExpressRouteCrossConnectionRouteTableClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/id_expressroutecrossconnectionpeeringroutetable.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/id_expressroutecrossconnectionpeeringroutetable.go new file mode 100644 index 00000000000..29491001fbf --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/id_expressroutecrossconnectionpeeringroutetable.go @@ -0,0 +1,148 @@ +package expressroutecrossconnectionroutetable + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ExpressRouteCrossConnectionPeeringRouteTableId{}) +} + +var _ resourceids.ResourceId = &ExpressRouteCrossConnectionPeeringRouteTableId{} + +// ExpressRouteCrossConnectionPeeringRouteTableId is a struct representing the Resource ID for a Express Route Cross Connection Peering Route Table +type ExpressRouteCrossConnectionPeeringRouteTableId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteCrossConnectionName string + PeeringName string + RouteTableName string +} + +// NewExpressRouteCrossConnectionPeeringRouteTableID returns a new ExpressRouteCrossConnectionPeeringRouteTableId struct +func NewExpressRouteCrossConnectionPeeringRouteTableID(subscriptionId string, resourceGroupName string, expressRouteCrossConnectionName string, peeringName string, routeTableName string) ExpressRouteCrossConnectionPeeringRouteTableId { + return ExpressRouteCrossConnectionPeeringRouteTableId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteCrossConnectionName: expressRouteCrossConnectionName, + PeeringName: peeringName, + RouteTableName: routeTableName, + } +} + +// ParseExpressRouteCrossConnectionPeeringRouteTableID parses 'input' into a ExpressRouteCrossConnectionPeeringRouteTableId +func ParseExpressRouteCrossConnectionPeeringRouteTableID(input string) (*ExpressRouteCrossConnectionPeeringRouteTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteCrossConnectionPeeringRouteTableId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteCrossConnectionPeeringRouteTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseExpressRouteCrossConnectionPeeringRouteTableIDInsensitively parses 'input' case-insensitively into a ExpressRouteCrossConnectionPeeringRouteTableId +// note: this method should only be used for API response data and not user input +func ParseExpressRouteCrossConnectionPeeringRouteTableIDInsensitively(input string) (*ExpressRouteCrossConnectionPeeringRouteTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteCrossConnectionPeeringRouteTableId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteCrossConnectionPeeringRouteTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ExpressRouteCrossConnectionPeeringRouteTableId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteCrossConnectionName, ok = input.Parsed["expressRouteCrossConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteCrossConnectionName", input) + } + + if id.PeeringName, ok = input.Parsed["peeringName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "peeringName", input) + } + + if id.RouteTableName, ok = input.Parsed["routeTableName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeTableName", input) + } + + return nil +} + +// ValidateExpressRouteCrossConnectionPeeringRouteTableID checks that 'input' can be parsed as a Express Route Cross Connection Peering Route Table ID +func ValidateExpressRouteCrossConnectionPeeringRouteTableID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseExpressRouteCrossConnectionPeeringRouteTableID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Express Route Cross Connection Peering Route Table ID +func (id ExpressRouteCrossConnectionPeeringRouteTableId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCrossConnections/%s/peerings/%s/routeTables/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteCrossConnectionName, id.PeeringName, id.RouteTableName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Express Route Cross Connection Peering Route Table ID +func (id ExpressRouteCrossConnectionPeeringRouteTableId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteCrossConnections", "expressRouteCrossConnections", "expressRouteCrossConnections"), + resourceids.UserSpecifiedSegment("expressRouteCrossConnectionName", "expressRouteCrossConnectionName"), + resourceids.StaticSegment("staticPeerings", "peerings", "peerings"), + resourceids.UserSpecifiedSegment("peeringName", "peeringName"), + resourceids.StaticSegment("staticRouteTables", "routeTables", "routeTables"), + resourceids.UserSpecifiedSegment("routeTableName", "routeTableName"), + } +} + +// String returns a human-readable description of this Express Route Cross Connection Peering Route Table ID +func (id ExpressRouteCrossConnectionPeeringRouteTableId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Cross Connection Name: %q", id.ExpressRouteCrossConnectionName), + fmt.Sprintf("Peering Name: %q", id.PeeringName), + fmt.Sprintf("Route Table Name: %q", id.RouteTableName), + } + return fmt.Sprintf("Express Route Cross Connection Peering Route Table (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/id_expressroutecrossconnectionpeeringroutetable_test.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/id_expressroutecrossconnectionpeeringroutetable_test.go new file mode 100644 index 00000000000..2dd58fa2973 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/id_expressroutecrossconnectionpeeringroutetable_test.go @@ -0,0 +1,372 @@ +package expressroutecrossconnectionroutetable + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ExpressRouteCrossConnectionPeeringRouteTableId{} + +func TestNewExpressRouteCrossConnectionPeeringRouteTableID(t *testing.T) { + id := NewExpressRouteCrossConnectionPeeringRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName", "peeringName", "routeTableName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteCrossConnectionName != "expressRouteCrossConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteCrossConnectionName'", id.ExpressRouteCrossConnectionName, "expressRouteCrossConnectionName") + } + + if id.PeeringName != "peeringName" { + t.Fatalf("Expected %q but got %q for Segment 'PeeringName'", id.PeeringName, "peeringName") + } + + if id.RouteTableName != "routeTableName" { + t.Fatalf("Expected %q but got %q for Segment 'RouteTableName'", id.RouteTableName, "routeTableName") + } +} + +func TestFormatExpressRouteCrossConnectionPeeringRouteTableID(t *testing.T) { + actual := NewExpressRouteCrossConnectionPeeringRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName", "peeringName", "routeTableName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/routeTables/routeTableName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseExpressRouteCrossConnectionPeeringRouteTableID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteCrossConnectionPeeringRouteTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/routeTables", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/routeTables/routeTableName", + Expected: &ExpressRouteCrossConnectionPeeringRouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCrossConnectionName: "expressRouteCrossConnectionName", + PeeringName: "peeringName", + RouteTableName: "routeTableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/routeTables/routeTableName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteCrossConnectionPeeringRouteTableID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCrossConnectionName != v.Expected.ExpressRouteCrossConnectionName { + t.Fatalf("Expected %q but got %q for ExpressRouteCrossConnectionName", v.Expected.ExpressRouteCrossConnectionName, actual.ExpressRouteCrossConnectionName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + if actual.RouteTableName != v.Expected.RouteTableName { + t.Fatalf("Expected %q but got %q for RouteTableName", v.Expected.RouteTableName, actual.RouteTableName) + } + + } +} + +func TestParseExpressRouteCrossConnectionPeeringRouteTableIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteCrossConnectionPeeringRouteTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS/pEeRiNgNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/routeTables", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS/pEeRiNgNaMe/rOuTeTaBlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/routeTables/routeTableName", + Expected: &ExpressRouteCrossConnectionPeeringRouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCrossConnectionName: "expressRouteCrossConnectionName", + PeeringName: "peeringName", + RouteTableName: "routeTableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/routeTables/routeTableName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS/pEeRiNgNaMe/rOuTeTaBlEs/rOuTeTaBlEnAmE", + Expected: &ExpressRouteCrossConnectionPeeringRouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteCrossConnectionName: "eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe", + PeeringName: "pEeRiNgNaMe", + RouteTableName: "rOuTeTaBlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS/pEeRiNgNaMe/rOuTeTaBlEs/rOuTeTaBlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteCrossConnectionPeeringRouteTableIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCrossConnectionName != v.Expected.ExpressRouteCrossConnectionName { + t.Fatalf("Expected %q but got %q for ExpressRouteCrossConnectionName", v.Expected.ExpressRouteCrossConnectionName, actual.ExpressRouteCrossConnectionName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + if actual.RouteTableName != v.Expected.RouteTableName { + t.Fatalf("Expected %q but got %q for RouteTableName", v.Expected.RouteTableName, actual.RouteTableName) + } + + } +} + +func TestSegmentsForExpressRouteCrossConnectionPeeringRouteTableId(t *testing.T) { + segments := ExpressRouteCrossConnectionPeeringRouteTableId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ExpressRouteCrossConnectionPeeringRouteTableId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/method_expressroutecrossconnectionslistroutestable.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/method_expressroutecrossconnectionslistroutestable.go new file mode 100644 index 00000000000..ad01c57a508 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/method_expressroutecrossconnectionslistroutestable.go @@ -0,0 +1,89 @@ +package expressroutecrossconnectionroutetable + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionsListRoutesTableOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteCircuitRoutesTable +} + +type ExpressRouteCrossConnectionsListRoutesTableCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteCircuitRoutesTable +} + +type ExpressRouteCrossConnectionsListRoutesTableCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ExpressRouteCrossConnectionsListRoutesTableCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ExpressRouteCrossConnectionsListRoutesTable ... +func (c ExpressRouteCrossConnectionRouteTableClient) ExpressRouteCrossConnectionsListRoutesTable(ctx context.Context, id ExpressRouteCrossConnectionPeeringRouteTableId) (result ExpressRouteCrossConnectionsListRoutesTableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ExpressRouteCrossConnectionsListRoutesTableCustomPager{}, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ExpressRouteCrossConnectionsListRoutesTableThenPoll performs ExpressRouteCrossConnectionsListRoutesTable then polls until it's completed +func (c ExpressRouteCrossConnectionRouteTableClient) ExpressRouteCrossConnectionsListRoutesTableThenPoll(ctx context.Context, id ExpressRouteCrossConnectionPeeringRouteTableId) error { + result, err := c.ExpressRouteCrossConnectionsListRoutesTable(ctx, id) + if err != nil { + return fmt.Errorf("performing ExpressRouteCrossConnectionsListRoutesTable: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ExpressRouteCrossConnectionsListRoutesTable: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/model_expressroutecircuitroutestable.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/model_expressroutecircuitroutestable.go new file mode 100644 index 00000000000..4861d1c6ca2 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/model_expressroutecircuitroutestable.go @@ -0,0 +1,12 @@ +package expressroutecrossconnectionroutetable + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitRoutesTable struct { + LocPrf *string `json:"locPrf,omitempty"` + Network *string `json:"network,omitempty"` + NextHop *string `json:"nextHop,omitempty"` + Path *string `json:"path,omitempty"` + Weight *int64 `json:"weight,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/predicates.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/predicates.go new file mode 100644 index 00000000000..2f1a6174bb4 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/predicates.go @@ -0,0 +1,37 @@ +package expressroutecrossconnectionroutetable + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitRoutesTableOperationPredicate struct { + LocPrf *string + Network *string + NextHop *string + Path *string + Weight *int64 +} + +func (p ExpressRouteCircuitRoutesTableOperationPredicate) Matches(input ExpressRouteCircuitRoutesTable) bool { + + if p.LocPrf != nil && (input.LocPrf == nil || *p.LocPrf != *input.LocPrf) { + return false + } + + if p.Network != nil && (input.Network == nil || *p.Network != *input.Network) { + return false + } + + if p.NextHop != nil && (input.NextHop == nil || *p.NextHop != *input.NextHop) { + return false + } + + if p.Path != nil && (input.Path == nil || *p.Path != *input.Path) { + return false + } + + if p.Weight != nil && (input.Weight == nil || *p.Weight != *input.Weight) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/version.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/version.go new file mode 100644 index 00000000000..d7ea65e65b9 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetable/version.go @@ -0,0 +1,10 @@ +package expressroutecrossconnectionroutetable + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressroutecrossconnectionroutetable/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/README.md b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/README.md new file mode 100644 index 00000000000..82dcc0e7ab9 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary` Documentation + +The `expressroutecrossconnectionroutetablesummary` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary" +``` + + +### Client Initialization + +```go +client := expressroutecrossconnectionroutetablesummary.NewExpressRouteCrossConnectionRouteTableSummaryClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteCrossConnectionRouteTableSummaryClient.ExpressRouteCrossConnectionsListRoutesTableSummary` + +```go +ctx := context.TODO() +id := expressroutecrossconnectionroutetablesummary.NewPeeringRouteTablesSummaryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName", "peeringName", "routeTablesSummaryName") + +// alternatively `client.ExpressRouteCrossConnectionsListRoutesTableSummary(ctx, id)` can be used to do batched pagination +items, err := client.ExpressRouteCrossConnectionsListRoutesTableSummaryComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/client.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/client.go new file mode 100644 index 00000000000..aaf83cd3840 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/client.go @@ -0,0 +1,26 @@ +package expressroutecrossconnectionroutetablesummary + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionRouteTableSummaryClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteCrossConnectionRouteTableSummaryClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteCrossConnectionRouteTableSummaryClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressroutecrossconnectionroutetablesummary", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteCrossConnectionRouteTableSummaryClient: %+v", err) + } + + return &ExpressRouteCrossConnectionRouteTableSummaryClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/id_peeringroutetablessummary.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/id_peeringroutetablessummary.go new file mode 100644 index 00000000000..1d3631cb982 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/id_peeringroutetablessummary.go @@ -0,0 +1,148 @@ +package expressroutecrossconnectionroutetablesummary + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PeeringRouteTablesSummaryId{}) +} + +var _ resourceids.ResourceId = &PeeringRouteTablesSummaryId{} + +// PeeringRouteTablesSummaryId is a struct representing the Resource ID for a Peering Route Tables Summary +type PeeringRouteTablesSummaryId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteCrossConnectionName string + PeeringName string + RouteTablesSummaryName string +} + +// NewPeeringRouteTablesSummaryID returns a new PeeringRouteTablesSummaryId struct +func NewPeeringRouteTablesSummaryID(subscriptionId string, resourceGroupName string, expressRouteCrossConnectionName string, peeringName string, routeTablesSummaryName string) PeeringRouteTablesSummaryId { + return PeeringRouteTablesSummaryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteCrossConnectionName: expressRouteCrossConnectionName, + PeeringName: peeringName, + RouteTablesSummaryName: routeTablesSummaryName, + } +} + +// ParsePeeringRouteTablesSummaryID parses 'input' into a PeeringRouteTablesSummaryId +func ParsePeeringRouteTablesSummaryID(input string) (*PeeringRouteTablesSummaryId, error) { + parser := resourceids.NewParserFromResourceIdType(&PeeringRouteTablesSummaryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PeeringRouteTablesSummaryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePeeringRouteTablesSummaryIDInsensitively parses 'input' case-insensitively into a PeeringRouteTablesSummaryId +// note: this method should only be used for API response data and not user input +func ParsePeeringRouteTablesSummaryIDInsensitively(input string) (*PeeringRouteTablesSummaryId, error) { + parser := resourceids.NewParserFromResourceIdType(&PeeringRouteTablesSummaryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PeeringRouteTablesSummaryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PeeringRouteTablesSummaryId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteCrossConnectionName, ok = input.Parsed["expressRouteCrossConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteCrossConnectionName", input) + } + + if id.PeeringName, ok = input.Parsed["peeringName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "peeringName", input) + } + + if id.RouteTablesSummaryName, ok = input.Parsed["routeTablesSummaryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeTablesSummaryName", input) + } + + return nil +} + +// ValidatePeeringRouteTablesSummaryID checks that 'input' can be parsed as a Peering Route Tables Summary ID +func ValidatePeeringRouteTablesSummaryID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePeeringRouteTablesSummaryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Peering Route Tables Summary ID +func (id PeeringRouteTablesSummaryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCrossConnections/%s/peerings/%s/routeTablesSummary/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteCrossConnectionName, id.PeeringName, id.RouteTablesSummaryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Peering Route Tables Summary ID +func (id PeeringRouteTablesSummaryId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteCrossConnections", "expressRouteCrossConnections", "expressRouteCrossConnections"), + resourceids.UserSpecifiedSegment("expressRouteCrossConnectionName", "expressRouteCrossConnectionName"), + resourceids.StaticSegment("staticPeerings", "peerings", "peerings"), + resourceids.UserSpecifiedSegment("peeringName", "peeringName"), + resourceids.StaticSegment("staticRouteTablesSummary", "routeTablesSummary", "routeTablesSummary"), + resourceids.UserSpecifiedSegment("routeTablesSummaryName", "routeTablesSummaryName"), + } +} + +// String returns a human-readable description of this Peering Route Tables Summary ID +func (id PeeringRouteTablesSummaryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Cross Connection Name: %q", id.ExpressRouteCrossConnectionName), + fmt.Sprintf("Peering Name: %q", id.PeeringName), + fmt.Sprintf("Route Tables Summary Name: %q", id.RouteTablesSummaryName), + } + return fmt.Sprintf("Peering Route Tables Summary (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/id_peeringroutetablessummary_test.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/id_peeringroutetablessummary_test.go new file mode 100644 index 00000000000..6d2bdf44468 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/id_peeringroutetablessummary_test.go @@ -0,0 +1,372 @@ +package expressroutecrossconnectionroutetablesummary + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PeeringRouteTablesSummaryId{} + +func TestNewPeeringRouteTablesSummaryID(t *testing.T) { + id := NewPeeringRouteTablesSummaryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName", "peeringName", "routeTablesSummaryName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteCrossConnectionName != "expressRouteCrossConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteCrossConnectionName'", id.ExpressRouteCrossConnectionName, "expressRouteCrossConnectionName") + } + + if id.PeeringName != "peeringName" { + t.Fatalf("Expected %q but got %q for Segment 'PeeringName'", id.PeeringName, "peeringName") + } + + if id.RouteTablesSummaryName != "routeTablesSummaryName" { + t.Fatalf("Expected %q but got %q for Segment 'RouteTablesSummaryName'", id.RouteTablesSummaryName, "routeTablesSummaryName") + } +} + +func TestFormatPeeringRouteTablesSummaryID(t *testing.T) { + actual := NewPeeringRouteTablesSummaryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName", "peeringName", "routeTablesSummaryName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/routeTablesSummary/routeTablesSummaryName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePeeringRouteTablesSummaryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PeeringRouteTablesSummaryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/routeTablesSummary", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/routeTablesSummary/routeTablesSummaryName", + Expected: &PeeringRouteTablesSummaryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCrossConnectionName: "expressRouteCrossConnectionName", + PeeringName: "peeringName", + RouteTablesSummaryName: "routeTablesSummaryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/routeTablesSummary/routeTablesSummaryName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePeeringRouteTablesSummaryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCrossConnectionName != v.Expected.ExpressRouteCrossConnectionName { + t.Fatalf("Expected %q but got %q for ExpressRouteCrossConnectionName", v.Expected.ExpressRouteCrossConnectionName, actual.ExpressRouteCrossConnectionName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + if actual.RouteTablesSummaryName != v.Expected.RouteTablesSummaryName { + t.Fatalf("Expected %q but got %q for RouteTablesSummaryName", v.Expected.RouteTablesSummaryName, actual.RouteTablesSummaryName) + } + + } +} + +func TestParsePeeringRouteTablesSummaryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PeeringRouteTablesSummaryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS/pEeRiNgNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/routeTablesSummary", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS/pEeRiNgNaMe/rOuTeTaBlEsSuMmArY", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/routeTablesSummary/routeTablesSummaryName", + Expected: &PeeringRouteTablesSummaryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCrossConnectionName: "expressRouteCrossConnectionName", + PeeringName: "peeringName", + RouteTablesSummaryName: "routeTablesSummaryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/peerings/peeringName/routeTablesSummary/routeTablesSummaryName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS/pEeRiNgNaMe/rOuTeTaBlEsSuMmArY/rOuTeTaBlEsSuMmArYnAmE", + Expected: &PeeringRouteTablesSummaryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteCrossConnectionName: "eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe", + PeeringName: "pEeRiNgNaMe", + RouteTablesSummaryName: "rOuTeTaBlEsSuMmArYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/pEeRiNgS/pEeRiNgNaMe/rOuTeTaBlEsSuMmArY/rOuTeTaBlEsSuMmArYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePeeringRouteTablesSummaryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCrossConnectionName != v.Expected.ExpressRouteCrossConnectionName { + t.Fatalf("Expected %q but got %q for ExpressRouteCrossConnectionName", v.Expected.ExpressRouteCrossConnectionName, actual.ExpressRouteCrossConnectionName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + if actual.RouteTablesSummaryName != v.Expected.RouteTablesSummaryName { + t.Fatalf("Expected %q but got %q for RouteTablesSummaryName", v.Expected.RouteTablesSummaryName, actual.RouteTablesSummaryName) + } + + } +} + +func TestSegmentsForPeeringRouteTablesSummaryId(t *testing.T) { + segments := PeeringRouteTablesSummaryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PeeringRouteTablesSummaryId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/method_expressroutecrossconnectionslistroutestablesummary.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/method_expressroutecrossconnectionslistroutestablesummary.go new file mode 100644 index 00000000000..64acafa8284 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/method_expressroutecrossconnectionslistroutestablesummary.go @@ -0,0 +1,89 @@ +package expressroutecrossconnectionroutetablesummary + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionsListRoutesTableSummaryOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteCrossConnectionRoutesTableSummary +} + +type ExpressRouteCrossConnectionsListRoutesTableSummaryCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteCrossConnectionRoutesTableSummary +} + +type ExpressRouteCrossConnectionsListRoutesTableSummaryCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ExpressRouteCrossConnectionsListRoutesTableSummaryCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ExpressRouteCrossConnectionsListRoutesTableSummary ... +func (c ExpressRouteCrossConnectionRouteTableSummaryClient) ExpressRouteCrossConnectionsListRoutesTableSummary(ctx context.Context, id PeeringRouteTablesSummaryId) (result ExpressRouteCrossConnectionsListRoutesTableSummaryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ExpressRouteCrossConnectionsListRoutesTableSummaryCustomPager{}, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ExpressRouteCrossConnectionsListRoutesTableSummaryThenPoll performs ExpressRouteCrossConnectionsListRoutesTableSummary then polls until it's completed +func (c ExpressRouteCrossConnectionRouteTableSummaryClient) ExpressRouteCrossConnectionsListRoutesTableSummaryThenPoll(ctx context.Context, id PeeringRouteTablesSummaryId) error { + result, err := c.ExpressRouteCrossConnectionsListRoutesTableSummary(ctx, id) + if err != nil { + return fmt.Errorf("performing ExpressRouteCrossConnectionsListRoutesTableSummary: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ExpressRouteCrossConnectionsListRoutesTableSummary: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/model_expressroutecrossconnectionroutestablesummary.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/model_expressroutecrossconnectionroutestablesummary.go new file mode 100644 index 00000000000..e13df051962 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/model_expressroutecrossconnectionroutestablesummary.go @@ -0,0 +1,11 @@ +package expressroutecrossconnectionroutetablesummary + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionRoutesTableSummary struct { + Asn *int64 `json:"asn,omitempty"` + Neighbor *string `json:"neighbor,omitempty"` + StateOrPrefixesReceived *string `json:"stateOrPrefixesReceived,omitempty"` + UpDown *string `json:"upDown,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/predicates.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/predicates.go new file mode 100644 index 00000000000..8399718cebc --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/predicates.go @@ -0,0 +1,32 @@ +package expressroutecrossconnectionroutetablesummary + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionRoutesTableSummaryOperationPredicate struct { + Asn *int64 + Neighbor *string + StateOrPrefixesReceived *string + UpDown *string +} + +func (p ExpressRouteCrossConnectionRoutesTableSummaryOperationPredicate) Matches(input ExpressRouteCrossConnectionRoutesTableSummary) bool { + + if p.Asn != nil && (input.Asn == nil || *p.Asn != *input.Asn) { + return false + } + + if p.Neighbor != nil && (input.Neighbor == nil || *p.Neighbor != *input.Neighbor) { + return false + } + + if p.StateOrPrefixesReceived != nil && (input.StateOrPrefixesReceived == nil || *p.StateOrPrefixesReceived != *input.StateOrPrefixesReceived) { + return false + } + + if p.UpDown != nil && (input.UpDown == nil || *p.UpDown != *input.UpDown) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/version.go b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/version.go new file mode 100644 index 00000000000..a12d878cc6a --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnectionroutetablesummary/version.go @@ -0,0 +1,10 @@ +package expressroutecrossconnectionroutetablesummary + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressroutecrossconnectionroutetablesummary/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/README.md b/resource-manager/network/2024-07-01/expressroutecrossconnections/README.md new file mode 100644 index 00000000000..47fb07a99c4 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/README.md @@ -0,0 +1,109 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecrossconnections` Documentation + +The `expressroutecrossconnections` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutecrossconnections" +``` + + +### Client Initialization + +```go +client := expressroutecrossconnections.NewExpressRouteCrossConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteCrossConnectionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := expressroutecrossconnections.NewExpressRouteCrossConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName") + +payload := expressroutecrossconnections.ExpressRouteCrossConnection{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRouteCrossConnectionsClient.Get` + +```go +ctx := context.TODO() +id := expressroutecrossconnections.NewExpressRouteCrossConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ExpressRouteCrossConnectionsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, expressroutecrossconnections.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, expressroutecrossconnections.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ExpressRouteCrossConnectionsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ExpressRouteCrossConnectionsClient.UpdateTags` + +```go +ctx := context.TODO() +id := expressroutecrossconnections.NewExpressRouteCrossConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName") + +payload := expressroutecrossconnections.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/client.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/client.go new file mode 100644 index 00000000000..5df85aad3d6 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/client.go @@ -0,0 +1,26 @@ +package expressroutecrossconnections + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteCrossConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteCrossConnectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressroutecrossconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteCrossConnectionsClient: %+v", err) + } + + return &ExpressRouteCrossConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/constants.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/constants.go new file mode 100644 index 00000000000..2ba4da411ba --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/constants.go @@ -0,0 +1,342 @@ +package expressroutecrossconnections + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdvertisedPublicPrefixPropertiesValidationState string + +const ( + AdvertisedPublicPrefixPropertiesValidationStateAsnValidationFailed AdvertisedPublicPrefixPropertiesValidationState = "AsnValidationFailed" + AdvertisedPublicPrefixPropertiesValidationStateCertificateMissingInRoutingRegistry AdvertisedPublicPrefixPropertiesValidationState = "CertificateMissingInRoutingRegistry" + AdvertisedPublicPrefixPropertiesValidationStateConfigured AdvertisedPublicPrefixPropertiesValidationState = "Configured" + AdvertisedPublicPrefixPropertiesValidationStateConfiguring AdvertisedPublicPrefixPropertiesValidationState = "Configuring" + AdvertisedPublicPrefixPropertiesValidationStateInvalidSignatureEncoding AdvertisedPublicPrefixPropertiesValidationState = "InvalidSignatureEncoding" + AdvertisedPublicPrefixPropertiesValidationStateManualValidationNeeded AdvertisedPublicPrefixPropertiesValidationState = "ManualValidationNeeded" + AdvertisedPublicPrefixPropertiesValidationStateNotConfigured AdvertisedPublicPrefixPropertiesValidationState = "NotConfigured" + AdvertisedPublicPrefixPropertiesValidationStateSignatureVerificationFailed AdvertisedPublicPrefixPropertiesValidationState = "SignatureVerificationFailed" + AdvertisedPublicPrefixPropertiesValidationStateValidationFailed AdvertisedPublicPrefixPropertiesValidationState = "ValidationFailed" + AdvertisedPublicPrefixPropertiesValidationStateValidationNeeded AdvertisedPublicPrefixPropertiesValidationState = "ValidationNeeded" +) + +func PossibleValuesForAdvertisedPublicPrefixPropertiesValidationState() []string { + return []string{ + string(AdvertisedPublicPrefixPropertiesValidationStateAsnValidationFailed), + string(AdvertisedPublicPrefixPropertiesValidationStateCertificateMissingInRoutingRegistry), + string(AdvertisedPublicPrefixPropertiesValidationStateConfigured), + string(AdvertisedPublicPrefixPropertiesValidationStateConfiguring), + string(AdvertisedPublicPrefixPropertiesValidationStateInvalidSignatureEncoding), + string(AdvertisedPublicPrefixPropertiesValidationStateManualValidationNeeded), + string(AdvertisedPublicPrefixPropertiesValidationStateNotConfigured), + string(AdvertisedPublicPrefixPropertiesValidationStateSignatureVerificationFailed), + string(AdvertisedPublicPrefixPropertiesValidationStateValidationFailed), + string(AdvertisedPublicPrefixPropertiesValidationStateValidationNeeded), + } +} + +func (s *AdvertisedPublicPrefixPropertiesValidationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAdvertisedPublicPrefixPropertiesValidationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAdvertisedPublicPrefixPropertiesValidationState(input string) (*AdvertisedPublicPrefixPropertiesValidationState, error) { + vals := map[string]AdvertisedPublicPrefixPropertiesValidationState{ + "asnvalidationfailed": AdvertisedPublicPrefixPropertiesValidationStateAsnValidationFailed, + "certificatemissinginroutingregistry": AdvertisedPublicPrefixPropertiesValidationStateCertificateMissingInRoutingRegistry, + "configured": AdvertisedPublicPrefixPropertiesValidationStateConfigured, + "configuring": AdvertisedPublicPrefixPropertiesValidationStateConfiguring, + "invalidsignatureencoding": AdvertisedPublicPrefixPropertiesValidationStateInvalidSignatureEncoding, + "manualvalidationneeded": AdvertisedPublicPrefixPropertiesValidationStateManualValidationNeeded, + "notconfigured": AdvertisedPublicPrefixPropertiesValidationStateNotConfigured, + "signatureverificationfailed": AdvertisedPublicPrefixPropertiesValidationStateSignatureVerificationFailed, + "validationfailed": AdvertisedPublicPrefixPropertiesValidationStateValidationFailed, + "validationneeded": AdvertisedPublicPrefixPropertiesValidationStateValidationNeeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AdvertisedPublicPrefixPropertiesValidationState(input) + return &out, nil +} + +type ExpressRouteCircuitPeeringAdvertisedPublicPrefixState string + +const ( + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfigured ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "Configured" + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfiguring ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "Configuring" + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateNotConfigured ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "NotConfigured" + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateValidationNeeded ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "ValidationNeeded" +) + +func PossibleValuesForExpressRouteCircuitPeeringAdvertisedPublicPrefixState() []string { + return []string{ + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfigured), + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfiguring), + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateNotConfigured), + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateValidationNeeded), + } +} + +func (s *ExpressRouteCircuitPeeringAdvertisedPublicPrefixState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteCircuitPeeringAdvertisedPublicPrefixState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteCircuitPeeringAdvertisedPublicPrefixState(input string) (*ExpressRouteCircuitPeeringAdvertisedPublicPrefixState, error) { + vals := map[string]ExpressRouteCircuitPeeringAdvertisedPublicPrefixState{ + "configured": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfigured, + "configuring": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfiguring, + "notconfigured": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateNotConfigured, + "validationneeded": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateValidationNeeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteCircuitPeeringAdvertisedPublicPrefixState(input) + return &out, nil +} + +type ExpressRouteCircuitPeeringState string + +const ( + ExpressRouteCircuitPeeringStateDisabled ExpressRouteCircuitPeeringState = "Disabled" + ExpressRouteCircuitPeeringStateEnabled ExpressRouteCircuitPeeringState = "Enabled" +) + +func PossibleValuesForExpressRouteCircuitPeeringState() []string { + return []string{ + string(ExpressRouteCircuitPeeringStateDisabled), + string(ExpressRouteCircuitPeeringStateEnabled), + } +} + +func (s *ExpressRouteCircuitPeeringState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteCircuitPeeringState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteCircuitPeeringState(input string) (*ExpressRouteCircuitPeeringState, error) { + vals := map[string]ExpressRouteCircuitPeeringState{ + "disabled": ExpressRouteCircuitPeeringStateDisabled, + "enabled": ExpressRouteCircuitPeeringStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteCircuitPeeringState(input) + return &out, nil +} + +type ExpressRoutePeeringState string + +const ( + ExpressRoutePeeringStateDisabled ExpressRoutePeeringState = "Disabled" + ExpressRoutePeeringStateEnabled ExpressRoutePeeringState = "Enabled" +) + +func PossibleValuesForExpressRoutePeeringState() []string { + return []string{ + string(ExpressRoutePeeringStateDisabled), + string(ExpressRoutePeeringStateEnabled), + } +} + +func (s *ExpressRoutePeeringState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRoutePeeringState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRoutePeeringState(input string) (*ExpressRoutePeeringState, error) { + vals := map[string]ExpressRoutePeeringState{ + "disabled": ExpressRoutePeeringStateDisabled, + "enabled": ExpressRoutePeeringStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRoutePeeringState(input) + return &out, nil +} + +type ExpressRoutePeeringType string + +const ( + ExpressRoutePeeringTypeAzurePrivatePeering ExpressRoutePeeringType = "AzurePrivatePeering" + ExpressRoutePeeringTypeAzurePublicPeering ExpressRoutePeeringType = "AzurePublicPeering" + ExpressRoutePeeringTypeMicrosoftPeering ExpressRoutePeeringType = "MicrosoftPeering" +) + +func PossibleValuesForExpressRoutePeeringType() []string { + return []string{ + string(ExpressRoutePeeringTypeAzurePrivatePeering), + string(ExpressRoutePeeringTypeAzurePublicPeering), + string(ExpressRoutePeeringTypeMicrosoftPeering), + } +} + +func (s *ExpressRoutePeeringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRoutePeeringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRoutePeeringType(input string) (*ExpressRoutePeeringType, error) { + vals := map[string]ExpressRoutePeeringType{ + "azureprivatepeering": ExpressRoutePeeringTypeAzurePrivatePeering, + "azurepublicpeering": ExpressRoutePeeringTypeAzurePublicPeering, + "microsoftpeering": ExpressRoutePeeringTypeMicrosoftPeering, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRoutePeeringType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ServiceProviderProvisioningState string + +const ( + ServiceProviderProvisioningStateDeprovisioning ServiceProviderProvisioningState = "Deprovisioning" + ServiceProviderProvisioningStateNotProvisioned ServiceProviderProvisioningState = "NotProvisioned" + ServiceProviderProvisioningStateProvisioned ServiceProviderProvisioningState = "Provisioned" + ServiceProviderProvisioningStateProvisioning ServiceProviderProvisioningState = "Provisioning" +) + +func PossibleValuesForServiceProviderProvisioningState() []string { + return []string{ + string(ServiceProviderProvisioningStateDeprovisioning), + string(ServiceProviderProvisioningStateNotProvisioned), + string(ServiceProviderProvisioningStateProvisioned), + string(ServiceProviderProvisioningStateProvisioning), + } +} + +func (s *ServiceProviderProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceProviderProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceProviderProvisioningState(input string) (*ServiceProviderProvisioningState, error) { + vals := map[string]ServiceProviderProvisioningState{ + "deprovisioning": ServiceProviderProvisioningStateDeprovisioning, + "notprovisioned": ServiceProviderProvisioningStateNotProvisioned, + "provisioned": ServiceProviderProvisioningStateProvisioned, + "provisioning": ServiceProviderProvisioningStateProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceProviderProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/id_expressroutecrossconnection.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/id_expressroutecrossconnection.go new file mode 100644 index 00000000000..10dc03f9c00 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/id_expressroutecrossconnection.go @@ -0,0 +1,130 @@ +package expressroutecrossconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ExpressRouteCrossConnectionId{}) +} + +var _ resourceids.ResourceId = &ExpressRouteCrossConnectionId{} + +// ExpressRouteCrossConnectionId is a struct representing the Resource ID for a Express Route Cross Connection +type ExpressRouteCrossConnectionId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteCrossConnectionName string +} + +// NewExpressRouteCrossConnectionID returns a new ExpressRouteCrossConnectionId struct +func NewExpressRouteCrossConnectionID(subscriptionId string, resourceGroupName string, expressRouteCrossConnectionName string) ExpressRouteCrossConnectionId { + return ExpressRouteCrossConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteCrossConnectionName: expressRouteCrossConnectionName, + } +} + +// ParseExpressRouteCrossConnectionID parses 'input' into a ExpressRouteCrossConnectionId +func ParseExpressRouteCrossConnectionID(input string) (*ExpressRouteCrossConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteCrossConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteCrossConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseExpressRouteCrossConnectionIDInsensitively parses 'input' case-insensitively into a ExpressRouteCrossConnectionId +// note: this method should only be used for API response data and not user input +func ParseExpressRouteCrossConnectionIDInsensitively(input string) (*ExpressRouteCrossConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteCrossConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteCrossConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ExpressRouteCrossConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteCrossConnectionName, ok = input.Parsed["expressRouteCrossConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteCrossConnectionName", input) + } + + return nil +} + +// ValidateExpressRouteCrossConnectionID checks that 'input' can be parsed as a Express Route Cross Connection ID +func ValidateExpressRouteCrossConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseExpressRouteCrossConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Express Route Cross Connection ID +func (id ExpressRouteCrossConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCrossConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteCrossConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Express Route Cross Connection ID +func (id ExpressRouteCrossConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteCrossConnections", "expressRouteCrossConnections", "expressRouteCrossConnections"), + resourceids.UserSpecifiedSegment("expressRouteCrossConnectionName", "expressRouteCrossConnectionName"), + } +} + +// String returns a human-readable description of this Express Route Cross Connection ID +func (id ExpressRouteCrossConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Cross Connection Name: %q", id.ExpressRouteCrossConnectionName), + } + return fmt.Sprintf("Express Route Cross Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/id_expressroutecrossconnection_test.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/id_expressroutecrossconnection_test.go new file mode 100644 index 00000000000..11f11c44f51 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/id_expressroutecrossconnection_test.go @@ -0,0 +1,282 @@ +package expressroutecrossconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ExpressRouteCrossConnectionId{} + +func TestNewExpressRouteCrossConnectionID(t *testing.T) { + id := NewExpressRouteCrossConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteCrossConnectionName != "expressRouteCrossConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteCrossConnectionName'", id.ExpressRouteCrossConnectionName, "expressRouteCrossConnectionName") + } +} + +func TestFormatExpressRouteCrossConnectionID(t *testing.T) { + actual := NewExpressRouteCrossConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCrossConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseExpressRouteCrossConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteCrossConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName", + Expected: &ExpressRouteCrossConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCrossConnectionName: "expressRouteCrossConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteCrossConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCrossConnectionName != v.Expected.ExpressRouteCrossConnectionName { + t.Fatalf("Expected %q but got %q for ExpressRouteCrossConnectionName", v.Expected.ExpressRouteCrossConnectionName, actual.ExpressRouteCrossConnectionName) + } + + } +} + +func TestParseExpressRouteCrossConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteCrossConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName", + Expected: &ExpressRouteCrossConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCrossConnectionName: "expressRouteCrossConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCrossConnections/expressRouteCrossConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe", + Expected: &ExpressRouteCrossConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteCrossConnectionName: "eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcRoSsCoNnEcTiOnS/eXpReSsRoUtEcRoSsCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteCrossConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCrossConnectionName != v.Expected.ExpressRouteCrossConnectionName { + t.Fatalf("Expected %q but got %q for ExpressRouteCrossConnectionName", v.Expected.ExpressRouteCrossConnectionName, actual.ExpressRouteCrossConnectionName) + } + + } +} + +func TestSegmentsForExpressRouteCrossConnectionId(t *testing.T) { + segments := ExpressRouteCrossConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ExpressRouteCrossConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/method_createorupdate.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/method_createorupdate.go new file mode 100644 index 00000000000..bc67ec4a5f8 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/method_createorupdate.go @@ -0,0 +1,74 @@ +package expressroutecrossconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteCrossConnection +} + +// CreateOrUpdate ... +func (c ExpressRouteCrossConnectionsClient) CreateOrUpdate(ctx context.Context, id ExpressRouteCrossConnectionId, input ExpressRouteCrossConnection) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ExpressRouteCrossConnectionsClient) CreateOrUpdateThenPoll(ctx context.Context, id ExpressRouteCrossConnectionId, input ExpressRouteCrossConnection) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/method_get.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/method_get.go new file mode 100644 index 00000000000..e68e3ddc46d --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/method_get.go @@ -0,0 +1,53 @@ +package expressroutecrossconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteCrossConnection +} + +// Get ... +func (c ExpressRouteCrossConnectionsClient) Get(ctx context.Context, id ExpressRouteCrossConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRouteCrossConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/method_list.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/method_list.go new file mode 100644 index 00000000000..402193d8419 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/method_list.go @@ -0,0 +1,135 @@ +package expressroutecrossconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteCrossConnection +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteCrossConnection +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ExpressRouteCrossConnectionsClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/expressRouteCrossConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ExpressRouteCrossConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ExpressRouteCrossConnectionsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ExpressRouteCrossConnectionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ExpressRouteCrossConnectionsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate ExpressRouteCrossConnectionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ExpressRouteCrossConnection, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/method_listbyresourcegroup.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/method_listbyresourcegroup.go new file mode 100644 index 00000000000..f16b017a526 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package expressroutecrossconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteCrossConnection +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteCrossConnection +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c ExpressRouteCrossConnectionsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/expressRouteCrossConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ExpressRouteCrossConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ExpressRouteCrossConnectionsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ExpressRouteCrossConnectionOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ExpressRouteCrossConnectionsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ExpressRouteCrossConnectionOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ExpressRouteCrossConnection, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/method_updatetags.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/method_updatetags.go new file mode 100644 index 00000000000..e55953bde8f --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/method_updatetags.go @@ -0,0 +1,57 @@ +package expressroutecrossconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteCrossConnection +} + +// UpdateTags ... +func (c ExpressRouteCrossConnectionsClient) UpdateTags(ctx context.Context, id ExpressRouteCrossConnectionId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRouteCrossConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/model_advertisedpublicprefixproperties.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_advertisedpublicprefixproperties.go new file mode 100644 index 00000000000..63948392649 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_advertisedpublicprefixproperties.go @@ -0,0 +1,11 @@ +package expressroutecrossconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdvertisedPublicPrefixProperties struct { + Prefix *string `json:"prefix,omitempty"` + Signature *string `json:"signature,omitempty"` + ValidationId *string `json:"validationId,omitempty"` + ValidationState *AdvertisedPublicPrefixPropertiesValidationState `json:"validationState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecircuitpeeringconfig.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecircuitpeeringconfig.go new file mode 100644 index 00000000000..a134ed87d0a --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecircuitpeeringconfig.go @@ -0,0 +1,14 @@ +package expressroutecrossconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitPeeringConfig struct { + AdvertisedCommunities *[]string `json:"advertisedCommunities,omitempty"` + AdvertisedPublicPrefixInfo *[]AdvertisedPublicPrefixProperties `json:"advertisedPublicPrefixInfo,omitempty"` + AdvertisedPublicPrefixes *[]string `json:"advertisedPublicPrefixes,omitempty"` + AdvertisedPublicPrefixesState *ExpressRouteCircuitPeeringAdvertisedPublicPrefixState `json:"advertisedPublicPrefixesState,omitempty"` + CustomerASN *int64 `json:"customerASN,omitempty"` + LegacyMode *int64 `json:"legacyMode,omitempty"` + RoutingRegistryName *string `json:"routingRegistryName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecircuitreference.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecircuitreference.go new file mode 100644 index 00000000000..cbf4167bab5 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecircuitreference.go @@ -0,0 +1,8 @@ +package expressroutecrossconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecrossconnection.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecrossconnection.go new file mode 100644 index 00000000000..52da62754ff --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecrossconnection.go @@ -0,0 +1,14 @@ +package expressroutecrossconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRouteCrossConnectionProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecrossconnectionpeering.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecrossconnectionpeering.go new file mode 100644 index 00000000000..e207a422215 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecrossconnectionpeering.go @@ -0,0 +1,11 @@ +package expressroutecrossconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionPeering struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRouteCrossConnectionPeeringProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecrossconnectionpeeringproperties.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecrossconnectionpeeringproperties.go new file mode 100644 index 00000000000..0d9a1673538 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecrossconnectionpeeringproperties.go @@ -0,0 +1,22 @@ +package expressroutecrossconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionPeeringProperties struct { + AzureASN *int64 `json:"azureASN,omitempty"` + GatewayManagerEtag *string `json:"gatewayManagerEtag,omitempty"` + IPv6PeeringConfig *IPv6ExpressRouteCircuitPeeringConfig `json:"ipv6PeeringConfig,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + MicrosoftPeeringConfig *ExpressRouteCircuitPeeringConfig `json:"microsoftPeeringConfig,omitempty"` + PeerASN *int64 `json:"peerASN,omitempty"` + PeeringType *ExpressRoutePeeringType `json:"peeringType,omitempty"` + PrimaryAzurePort *string `json:"primaryAzurePort,omitempty"` + PrimaryPeerAddressPrefix *string `json:"primaryPeerAddressPrefix,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SecondaryAzurePort *string `json:"secondaryAzurePort,omitempty"` + SecondaryPeerAddressPrefix *string `json:"secondaryPeerAddressPrefix,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` + State *ExpressRoutePeeringState `json:"state,omitempty"` + VlanId *int64 `json:"vlanId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecrossconnectionproperties.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecrossconnectionproperties.go new file mode 100644 index 00000000000..84515d8082c --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_expressroutecrossconnectionproperties.go @@ -0,0 +1,17 @@ +package expressroutecrossconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionProperties struct { + BandwidthInMbps *int64 `json:"bandwidthInMbps,omitempty"` + ExpressRouteCircuit *ExpressRouteCircuitReference `json:"expressRouteCircuit,omitempty"` + PeeringLocation *string `json:"peeringLocation,omitempty"` + Peerings *[]ExpressRouteCrossConnectionPeering `json:"peerings,omitempty"` + PrimaryAzurePort *string `json:"primaryAzurePort,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + STag *int64 `json:"sTag,omitempty"` + SecondaryAzurePort *string `json:"secondaryAzurePort,omitempty"` + ServiceProviderNotes *string `json:"serviceProviderNotes,omitempty"` + ServiceProviderProvisioningState *ServiceProviderProvisioningState `json:"serviceProviderProvisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/model_ipv6expressroutecircuitpeeringconfig.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_ipv6expressroutecircuitpeeringconfig.go new file mode 100644 index 00000000000..0101ae80d9e --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_ipv6expressroutecircuitpeeringconfig.go @@ -0,0 +1,12 @@ +package expressroutecrossconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPv6ExpressRouteCircuitPeeringConfig struct { + MicrosoftPeeringConfig *ExpressRouteCircuitPeeringConfig `json:"microsoftPeeringConfig,omitempty"` + PrimaryPeerAddressPrefix *string `json:"primaryPeerAddressPrefix,omitempty"` + RouteFilter *SubResource `json:"routeFilter,omitempty"` + SecondaryPeerAddressPrefix *string `json:"secondaryPeerAddressPrefix,omitempty"` + State *ExpressRouteCircuitPeeringState `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/model_subresource.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_subresource.go new file mode 100644 index 00000000000..b2922ebb4d1 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_subresource.go @@ -0,0 +1,8 @@ +package expressroutecrossconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/model_tagsobject.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_tagsobject.go new file mode 100644 index 00000000000..f47ce1a3f42 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/model_tagsobject.go @@ -0,0 +1,8 @@ +package expressroutecrossconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/predicates.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/predicates.go new file mode 100644 index 00000000000..f3d9b3a8dff --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/predicates.go @@ -0,0 +1,37 @@ +package expressroutecrossconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCrossConnectionOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ExpressRouteCrossConnectionOperationPredicate) Matches(input ExpressRouteCrossConnection) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressroutecrossconnections/version.go b/resource-manager/network/2024-07-01/expressroutecrossconnections/version.go new file mode 100644 index 00000000000..e58c8fd8f58 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutecrossconnections/version.go @@ -0,0 +1,10 @@ +package expressroutecrossconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressroutecrossconnections/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/README.md b/resource-manager/network/2024-07-01/expressroutegateways/README.md new file mode 100644 index 00000000000..6985b5e10ac --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/README.md @@ -0,0 +1,115 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutegateways` Documentation + +The `expressroutegateways` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutegateways" +``` + + +### Client Initialization + +```go +client := expressroutegateways.NewExpressRouteGatewaysClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteGatewaysClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := expressroutegateways.NewExpressRouteGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteGatewayName") + +payload := expressroutegateways.ExpressRouteGateway{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRouteGatewaysClient.Delete` + +```go +ctx := context.TODO() +id := expressroutegateways.NewExpressRouteGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteGatewayName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRouteGatewaysClient.Get` + +```go +ctx := context.TODO() +id := expressroutegateways.NewExpressRouteGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteGatewayName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ExpressRouteGatewaysClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +read, err := client.ListByResourceGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ExpressRouteGatewaysClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.ListBySubscription(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ExpressRouteGatewaysClient.UpdateTags` + +```go +ctx := context.TODO() +id := expressroutegateways.NewExpressRouteGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteGatewayName") + +payload := expressroutegateways.TagsObject{ + // ... +} + + +if err := client.UpdateTagsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/network/2024-07-01/expressroutegateways/client.go b/resource-manager/network/2024-07-01/expressroutegateways/client.go new file mode 100644 index 00000000000..292ef72ff7b --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/client.go @@ -0,0 +1,26 @@ +package expressroutegateways + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteGatewaysClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteGatewaysClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteGatewaysClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressroutegateways", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteGatewaysClient: %+v", err) + } + + return &ExpressRouteGatewaysClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/constants.go b/resource-manager/network/2024-07-01/expressroutegateways/constants.go new file mode 100644 index 00000000000..ce8f5d5f24a --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/constants.go @@ -0,0 +1,98 @@ +package expressroutegateways + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type VnetLocalRouteOverrideCriteria string + +const ( + VnetLocalRouteOverrideCriteriaContains VnetLocalRouteOverrideCriteria = "Contains" + VnetLocalRouteOverrideCriteriaEqual VnetLocalRouteOverrideCriteria = "Equal" +) + +func PossibleValuesForVnetLocalRouteOverrideCriteria() []string { + return []string{ + string(VnetLocalRouteOverrideCriteriaContains), + string(VnetLocalRouteOverrideCriteriaEqual), + } +} + +func (s *VnetLocalRouteOverrideCriteria) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVnetLocalRouteOverrideCriteria(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVnetLocalRouteOverrideCriteria(input string) (*VnetLocalRouteOverrideCriteria, error) { + vals := map[string]VnetLocalRouteOverrideCriteria{ + "contains": VnetLocalRouteOverrideCriteriaContains, + "equal": VnetLocalRouteOverrideCriteriaEqual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VnetLocalRouteOverrideCriteria(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/id_expressroutegateway.go b/resource-manager/network/2024-07-01/expressroutegateways/id_expressroutegateway.go new file mode 100644 index 00000000000..924fe72c4ec --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/id_expressroutegateway.go @@ -0,0 +1,130 @@ +package expressroutegateways + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ExpressRouteGatewayId{}) +} + +var _ resourceids.ResourceId = &ExpressRouteGatewayId{} + +// ExpressRouteGatewayId is a struct representing the Resource ID for a Express Route Gateway +type ExpressRouteGatewayId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteGatewayName string +} + +// NewExpressRouteGatewayID returns a new ExpressRouteGatewayId struct +func NewExpressRouteGatewayID(subscriptionId string, resourceGroupName string, expressRouteGatewayName string) ExpressRouteGatewayId { + return ExpressRouteGatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteGatewayName: expressRouteGatewayName, + } +} + +// ParseExpressRouteGatewayID parses 'input' into a ExpressRouteGatewayId +func ParseExpressRouteGatewayID(input string) (*ExpressRouteGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteGatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseExpressRouteGatewayIDInsensitively parses 'input' case-insensitively into a ExpressRouteGatewayId +// note: this method should only be used for API response data and not user input +func ParseExpressRouteGatewayIDInsensitively(input string) (*ExpressRouteGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteGatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ExpressRouteGatewayId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteGatewayName, ok = input.Parsed["expressRouteGatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteGatewayName", input) + } + + return nil +} + +// ValidateExpressRouteGatewayID checks that 'input' can be parsed as a Express Route Gateway ID +func ValidateExpressRouteGatewayID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseExpressRouteGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Express Route Gateway ID +func (id ExpressRouteGatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteGateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteGatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Express Route Gateway ID +func (id ExpressRouteGatewayId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteGateways", "expressRouteGateways", "expressRouteGateways"), + resourceids.UserSpecifiedSegment("expressRouteGatewayName", "expressRouteGatewayName"), + } +} + +// String returns a human-readable description of this Express Route Gateway ID +func (id ExpressRouteGatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Gateway Name: %q", id.ExpressRouteGatewayName), + } + return fmt.Sprintf("Express Route Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/id_expressroutegateway_test.go b/resource-manager/network/2024-07-01/expressroutegateways/id_expressroutegateway_test.go new file mode 100644 index 00000000000..b91b7d0b332 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/id_expressroutegateway_test.go @@ -0,0 +1,282 @@ +package expressroutegateways + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ExpressRouteGatewayId{} + +func TestNewExpressRouteGatewayID(t *testing.T) { + id := NewExpressRouteGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteGatewayName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteGatewayName != "expressRouteGatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteGatewayName'", id.ExpressRouteGatewayName, "expressRouteGatewayName") + } +} + +func TestFormatExpressRouteGatewayID(t *testing.T) { + actual := NewExpressRouteGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteGatewayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseExpressRouteGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName", + Expected: &ExpressRouteGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteGatewayName: "expressRouteGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteGatewayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteGatewayName != v.Expected.ExpressRouteGatewayName { + t.Fatalf("Expected %q but got %q for ExpressRouteGatewayName", v.Expected.ExpressRouteGatewayName, actual.ExpressRouteGatewayName) + } + + } +} + +func TestParseExpressRouteGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEgAtEwAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName", + Expected: &ExpressRouteGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteGatewayName: "expressRouteGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEgAtEwAyS/eXpReSsRoUtEgAtEwAyNaMe", + Expected: &ExpressRouteGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteGatewayName: "eXpReSsRoUtEgAtEwAyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEgAtEwAyS/eXpReSsRoUtEgAtEwAyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteGatewayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteGatewayName != v.Expected.ExpressRouteGatewayName { + t.Fatalf("Expected %q but got %q for ExpressRouteGatewayName", v.Expected.ExpressRouteGatewayName, actual.ExpressRouteGatewayName) + } + + } +} + +func TestSegmentsForExpressRouteGatewayId(t *testing.T) { + segments := ExpressRouteGatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ExpressRouteGatewayId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/method_createorupdate.go b/resource-manager/network/2024-07-01/expressroutegateways/method_createorupdate.go new file mode 100644 index 00000000000..b02bd6b5ebb --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/method_createorupdate.go @@ -0,0 +1,75 @@ +package expressroutegateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteGateway +} + +// CreateOrUpdate ... +func (c ExpressRouteGatewaysClient) CreateOrUpdate(ctx context.Context, id ExpressRouteGatewayId, input ExpressRouteGateway) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ExpressRouteGatewaysClient) CreateOrUpdateThenPoll(ctx context.Context, id ExpressRouteGatewayId, input ExpressRouteGateway) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/method_delete.go b/resource-manager/network/2024-07-01/expressroutegateways/method_delete.go new file mode 100644 index 00000000000..200f12cef03 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/method_delete.go @@ -0,0 +1,71 @@ +package expressroutegateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ExpressRouteGatewaysClient) Delete(ctx context.Context, id ExpressRouteGatewayId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ExpressRouteGatewaysClient) DeleteThenPoll(ctx context.Context, id ExpressRouteGatewayId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/method_get.go b/resource-manager/network/2024-07-01/expressroutegateways/method_get.go new file mode 100644 index 00000000000..3fe9ab488d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/method_get.go @@ -0,0 +1,53 @@ +package expressroutegateways + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteGateway +} + +// Get ... +func (c ExpressRouteGatewaysClient) Get(ctx context.Context, id ExpressRouteGatewayId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRouteGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/method_listbyresourcegroup.go b/resource-manager/network/2024-07-01/expressroutegateways/method_listbyresourcegroup.go new file mode 100644 index 00000000000..f76de802a39 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/method_listbyresourcegroup.go @@ -0,0 +1,55 @@ +package expressroutegateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteGatewayList +} + +// ListByResourceGroup ... +func (c ExpressRouteGatewaysClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/expressRouteGateways", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRouteGatewayList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/method_listbysubscription.go b/resource-manager/network/2024-07-01/expressroutegateways/method_listbysubscription.go new file mode 100644 index 00000000000..840cb62145e --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/method_listbysubscription.go @@ -0,0 +1,55 @@ +package expressroutegateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteGatewayList +} + +// ListBySubscription ... +func (c ExpressRouteGatewaysClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/expressRouteGateways", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRouteGatewayList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/method_updatetags.go b/resource-manager/network/2024-07-01/expressroutegateways/method_updatetags.go new file mode 100644 index 00000000000..26c61ce6010 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/method_updatetags.go @@ -0,0 +1,75 @@ +package expressroutegateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteGateway +} + +// UpdateTags ... +func (c ExpressRouteGatewaysClient) UpdateTags(ctx context.Context, id ExpressRouteGatewayId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateTagsThenPoll performs UpdateTags then polls until it's completed +func (c ExpressRouteGatewaysClient) UpdateTagsThenPoll(ctx context.Context, id ExpressRouteGatewayId, input TagsObject) error { + result, err := c.UpdateTags(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UpdateTags: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpdateTags: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutecircuitpeeringid.go b/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutecircuitpeeringid.go new file mode 100644 index 00000000000..832d97a1174 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutecircuitpeeringid.go @@ -0,0 +1,8 @@ +package expressroutegateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitPeeringId struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/model_expressrouteconnection.go b/resource-manager/network/2024-07-01/expressroutegateways/model_expressrouteconnection.go new file mode 100644 index 00000000000..99219dd6cfd --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/model_expressrouteconnection.go @@ -0,0 +1,10 @@ +package expressroutegateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteConnection struct { + Id *string `json:"id,omitempty"` + Name string `json:"name"` + Properties *ExpressRouteConnectionProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/model_expressrouteconnectionproperties.go b/resource-manager/network/2024-07-01/expressroutegateways/model_expressrouteconnectionproperties.go new file mode 100644 index 00000000000..931b412129f --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/model_expressrouteconnectionproperties.go @@ -0,0 +1,15 @@ +package expressroutegateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteConnectionProperties struct { + AuthorizationKey *string `json:"authorizationKey,omitempty"` + EnableInternetSecurity *bool `json:"enableInternetSecurity,omitempty"` + EnablePrivateLinkFastPath *bool `json:"enablePrivateLinkFastPath,omitempty"` + ExpressRouteCircuitPeering ExpressRouteCircuitPeeringId `json:"expressRouteCircuitPeering"` + ExpressRouteGatewayBypass *bool `json:"expressRouteGatewayBypass,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RoutingConfiguration *RoutingConfiguration `json:"routingConfiguration,omitempty"` + RoutingWeight *int64 `json:"routingWeight,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutegateway.go b/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutegateway.go new file mode 100644 index 00000000000..5505ff540a8 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutegateway.go @@ -0,0 +1,14 @@ +package expressroutegateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRouteGatewayProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutegatewaylist.go b/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutegatewaylist.go new file mode 100644 index 00000000000..51667424380 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutegatewaylist.go @@ -0,0 +1,8 @@ +package expressroutegateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteGatewayList struct { + Value *[]ExpressRouteGateway `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutegatewayproperties.go b/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutegatewayproperties.go new file mode 100644 index 00000000000..4860e7d555a --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutegatewayproperties.go @@ -0,0 +1,12 @@ +package expressroutegateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteGatewayProperties struct { + AllowNonVirtualWanTraffic *bool `json:"allowNonVirtualWanTraffic,omitempty"` + AutoScaleConfiguration *ExpressRouteGatewayPropertiesAutoScaleConfiguration `json:"autoScaleConfiguration,omitempty"` + ExpressRouteConnections *[]ExpressRouteConnection `json:"expressRouteConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualHub VirtualHubId `json:"virtualHub"` +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutegatewaypropertiesautoscaleconfiguration.go b/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutegatewaypropertiesautoscaleconfiguration.go new file mode 100644 index 00000000000..60677f25d4c --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutegatewaypropertiesautoscaleconfiguration.go @@ -0,0 +1,8 @@ +package expressroutegateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteGatewayPropertiesAutoScaleConfiguration struct { + Bounds *ExpressRouteGatewayPropertiesAutoScaleConfigurationBounds `json:"bounds,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutegatewaypropertiesautoscaleconfigurationbounds.go b/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutegatewaypropertiesautoscaleconfigurationbounds.go new file mode 100644 index 00000000000..65a1ccb474b --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/model_expressroutegatewaypropertiesautoscaleconfigurationbounds.go @@ -0,0 +1,9 @@ +package expressroutegateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteGatewayPropertiesAutoScaleConfigurationBounds struct { + Max *int64 `json:"max,omitempty"` + Min *int64 `json:"min,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/model_propagatedroutetable.go b/resource-manager/network/2024-07-01/expressroutegateways/model_propagatedroutetable.go new file mode 100644 index 00000000000..93c6f306054 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/model_propagatedroutetable.go @@ -0,0 +1,9 @@ +package expressroutegateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PropagatedRouteTable struct { + Ids *[]SubResource `json:"ids,omitempty"` + Labels *[]string `json:"labels,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/model_routingconfiguration.go b/resource-manager/network/2024-07-01/expressroutegateways/model_routingconfiguration.go new file mode 100644 index 00000000000..670d9907881 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/model_routingconfiguration.go @@ -0,0 +1,12 @@ +package expressroutegateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingConfiguration struct { + AssociatedRouteTable *SubResource `json:"associatedRouteTable,omitempty"` + InboundRouteMap *SubResource `json:"inboundRouteMap,omitempty"` + OutboundRouteMap *SubResource `json:"outboundRouteMap,omitempty"` + PropagatedRouteTables *PropagatedRouteTable `json:"propagatedRouteTables,omitempty"` + VnetRoutes *VnetRoute `json:"vnetRoutes,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/model_staticroute.go b/resource-manager/network/2024-07-01/expressroutegateways/model_staticroute.go new file mode 100644 index 00000000000..29422baf743 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/model_staticroute.go @@ -0,0 +1,10 @@ +package expressroutegateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticRoute struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + Name *string `json:"name,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/model_staticroutesconfig.go b/resource-manager/network/2024-07-01/expressroutegateways/model_staticroutesconfig.go new file mode 100644 index 00000000000..d570d0ec17a --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/model_staticroutesconfig.go @@ -0,0 +1,9 @@ +package expressroutegateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticRoutesConfig struct { + PropagateStaticRoutes *bool `json:"propagateStaticRoutes,omitempty"` + VnetLocalRouteOverrideCriteria *VnetLocalRouteOverrideCriteria `json:"vnetLocalRouteOverrideCriteria,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/model_subresource.go b/resource-manager/network/2024-07-01/expressroutegateways/model_subresource.go new file mode 100644 index 00000000000..f86e3493340 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/model_subresource.go @@ -0,0 +1,8 @@ +package expressroutegateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/model_tagsobject.go b/resource-manager/network/2024-07-01/expressroutegateways/model_tagsobject.go new file mode 100644 index 00000000000..706aff41cd4 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/model_tagsobject.go @@ -0,0 +1,8 @@ +package expressroutegateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/model_virtualhubid.go b/resource-manager/network/2024-07-01/expressroutegateways/model_virtualhubid.go new file mode 100644 index 00000000000..41cb5ff6fd1 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/model_virtualhubid.go @@ -0,0 +1,8 @@ +package expressroutegateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubId struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/model_vnetroute.go b/resource-manager/network/2024-07-01/expressroutegateways/model_vnetroute.go new file mode 100644 index 00000000000..c9586e946c6 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/model_vnetroute.go @@ -0,0 +1,10 @@ +package expressroutegateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRoute struct { + BgpConnections *[]SubResource `json:"bgpConnections,omitempty"` + StaticRoutes *[]StaticRoute `json:"staticRoutes,omitempty"` + StaticRoutesConfig *StaticRoutesConfig `json:"staticRoutesConfig,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutegateways/version.go b/resource-manager/network/2024-07-01/expressroutegateways/version.go new file mode 100644 index 00000000000..9ef74eb25fa --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutegateways/version.go @@ -0,0 +1,10 @@ +package expressroutegateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressroutegateways/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressroutelinks/README.md b/resource-manager/network/2024-07-01/expressroutelinks/README.md new file mode 100644 index 00000000000..dc51a117ab1 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutelinks/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutelinks` Documentation + +The `expressroutelinks` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressroutelinks" +``` + + +### Client Initialization + +```go +client := expressroutelinks.NewExpressRouteLinksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteLinksClient.Get` + +```go +ctx := context.TODO() +id := expressroutelinks.NewLinkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName", "linkName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ExpressRouteLinksClient.List` + +```go +ctx := context.TODO() +id := expressroutelinks.NewExpressRoutePortID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/expressroutelinks/client.go b/resource-manager/network/2024-07-01/expressroutelinks/client.go new file mode 100644 index 00000000000..5b75ccca68f --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutelinks/client.go @@ -0,0 +1,26 @@ +package expressroutelinks + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteLinksClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteLinksClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteLinksClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressroutelinks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteLinksClient: %+v", err) + } + + return &ExpressRouteLinksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutelinks/constants.go b/resource-manager/network/2024-07-01/expressroutelinks/constants.go new file mode 100644 index 00000000000..bc075bf128a --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutelinks/constants.go @@ -0,0 +1,227 @@ +package expressroutelinks + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteLinkAdminState string + +const ( + ExpressRouteLinkAdminStateDisabled ExpressRouteLinkAdminState = "Disabled" + ExpressRouteLinkAdminStateEnabled ExpressRouteLinkAdminState = "Enabled" +) + +func PossibleValuesForExpressRouteLinkAdminState() []string { + return []string{ + string(ExpressRouteLinkAdminStateDisabled), + string(ExpressRouteLinkAdminStateEnabled), + } +} + +func (s *ExpressRouteLinkAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteLinkAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteLinkAdminState(input string) (*ExpressRouteLinkAdminState, error) { + vals := map[string]ExpressRouteLinkAdminState{ + "disabled": ExpressRouteLinkAdminStateDisabled, + "enabled": ExpressRouteLinkAdminStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteLinkAdminState(input) + return &out, nil +} + +type ExpressRouteLinkConnectorType string + +const ( + ExpressRouteLinkConnectorTypeLC ExpressRouteLinkConnectorType = "LC" + ExpressRouteLinkConnectorTypeSC ExpressRouteLinkConnectorType = "SC" +) + +func PossibleValuesForExpressRouteLinkConnectorType() []string { + return []string{ + string(ExpressRouteLinkConnectorTypeLC), + string(ExpressRouteLinkConnectorTypeSC), + } +} + +func (s *ExpressRouteLinkConnectorType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteLinkConnectorType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteLinkConnectorType(input string) (*ExpressRouteLinkConnectorType, error) { + vals := map[string]ExpressRouteLinkConnectorType{ + "lc": ExpressRouteLinkConnectorTypeLC, + "sc": ExpressRouteLinkConnectorTypeSC, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteLinkConnectorType(input) + return &out, nil +} + +type ExpressRouteLinkMacSecCipher string + +const ( + ExpressRouteLinkMacSecCipherGcmAesOneTwoEight ExpressRouteLinkMacSecCipher = "GcmAes128" + ExpressRouteLinkMacSecCipherGcmAesTwoFiveSix ExpressRouteLinkMacSecCipher = "GcmAes256" + ExpressRouteLinkMacSecCipherGcmAesXpnOneTwoEight ExpressRouteLinkMacSecCipher = "GcmAesXpn128" + ExpressRouteLinkMacSecCipherGcmAesXpnTwoFiveSix ExpressRouteLinkMacSecCipher = "GcmAesXpn256" +) + +func PossibleValuesForExpressRouteLinkMacSecCipher() []string { + return []string{ + string(ExpressRouteLinkMacSecCipherGcmAesOneTwoEight), + string(ExpressRouteLinkMacSecCipherGcmAesTwoFiveSix), + string(ExpressRouteLinkMacSecCipherGcmAesXpnOneTwoEight), + string(ExpressRouteLinkMacSecCipherGcmAesXpnTwoFiveSix), + } +} + +func (s *ExpressRouteLinkMacSecCipher) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteLinkMacSecCipher(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteLinkMacSecCipher(input string) (*ExpressRouteLinkMacSecCipher, error) { + vals := map[string]ExpressRouteLinkMacSecCipher{ + "gcmaes128": ExpressRouteLinkMacSecCipherGcmAesOneTwoEight, + "gcmaes256": ExpressRouteLinkMacSecCipherGcmAesTwoFiveSix, + "gcmaesxpn128": ExpressRouteLinkMacSecCipherGcmAesXpnOneTwoEight, + "gcmaesxpn256": ExpressRouteLinkMacSecCipherGcmAesXpnTwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteLinkMacSecCipher(input) + return &out, nil +} + +type ExpressRouteLinkMacSecSciState string + +const ( + ExpressRouteLinkMacSecSciStateDisabled ExpressRouteLinkMacSecSciState = "Disabled" + ExpressRouteLinkMacSecSciStateEnabled ExpressRouteLinkMacSecSciState = "Enabled" +) + +func PossibleValuesForExpressRouteLinkMacSecSciState() []string { + return []string{ + string(ExpressRouteLinkMacSecSciStateDisabled), + string(ExpressRouteLinkMacSecSciStateEnabled), + } +} + +func (s *ExpressRouteLinkMacSecSciState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteLinkMacSecSciState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteLinkMacSecSciState(input string) (*ExpressRouteLinkMacSecSciState, error) { + vals := map[string]ExpressRouteLinkMacSecSciState{ + "disabled": ExpressRouteLinkMacSecSciStateDisabled, + "enabled": ExpressRouteLinkMacSecSciStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteLinkMacSecSciState(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/expressroutelinks/id_expressrouteport.go b/resource-manager/network/2024-07-01/expressroutelinks/id_expressrouteport.go new file mode 100644 index 00000000000..6e1bb1a7c09 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutelinks/id_expressrouteport.go @@ -0,0 +1,130 @@ +package expressroutelinks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ExpressRoutePortId{}) +} + +var _ resourceids.ResourceId = &ExpressRoutePortId{} + +// ExpressRoutePortId is a struct representing the Resource ID for a Express Route Port +type ExpressRoutePortId struct { + SubscriptionId string + ResourceGroupName string + ExpressRoutePortName string +} + +// NewExpressRoutePortID returns a new ExpressRoutePortId struct +func NewExpressRoutePortID(subscriptionId string, resourceGroupName string, expressRoutePortName string) ExpressRoutePortId { + return ExpressRoutePortId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRoutePortName: expressRoutePortName, + } +} + +// ParseExpressRoutePortID parses 'input' into a ExpressRoutePortId +func ParseExpressRoutePortID(input string) (*ExpressRoutePortId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRoutePortId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRoutePortId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseExpressRoutePortIDInsensitively parses 'input' case-insensitively into a ExpressRoutePortId +// note: this method should only be used for API response data and not user input +func ParseExpressRoutePortIDInsensitively(input string) (*ExpressRoutePortId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRoutePortId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRoutePortId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ExpressRoutePortId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRoutePortName, ok = input.Parsed["expressRoutePortName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRoutePortName", input) + } + + return nil +} + +// ValidateExpressRoutePortID checks that 'input' can be parsed as a Express Route Port ID +func ValidateExpressRoutePortID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseExpressRoutePortID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Express Route Port ID +func (id ExpressRoutePortId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRoutePorts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRoutePortName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Express Route Port ID +func (id ExpressRoutePortId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRoutePorts", "expressRoutePorts", "expressRoutePorts"), + resourceids.UserSpecifiedSegment("expressRoutePortName", "expressRoutePortName"), + } +} + +// String returns a human-readable description of this Express Route Port ID +func (id ExpressRoutePortId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Port Name: %q", id.ExpressRoutePortName), + } + return fmt.Sprintf("Express Route Port (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutelinks/id_expressrouteport_test.go b/resource-manager/network/2024-07-01/expressroutelinks/id_expressrouteport_test.go new file mode 100644 index 00000000000..bbd9899f2f5 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutelinks/id_expressrouteport_test.go @@ -0,0 +1,282 @@ +package expressroutelinks + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ExpressRoutePortId{} + +func TestNewExpressRoutePortID(t *testing.T) { + id := NewExpressRoutePortID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRoutePortName != "expressRoutePortName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRoutePortName'", id.ExpressRoutePortName, "expressRoutePortName") + } +} + +func TestFormatExpressRoutePortID(t *testing.T) { + actual := NewExpressRoutePortID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseExpressRoutePortID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRoutePortId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName", + Expected: &ExpressRoutePortId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRoutePortName: "expressRoutePortName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRoutePortID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRoutePortName != v.Expected.ExpressRoutePortName { + t.Fatalf("Expected %q but got %q for ExpressRoutePortName", v.Expected.ExpressRoutePortName, actual.ExpressRoutePortName) + } + + } +} + +func TestParseExpressRoutePortIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRoutePortId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName", + Expected: &ExpressRoutePortId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRoutePortName: "expressRoutePortName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs/eXpReSsRoUtEpOrTnAmE", + Expected: &ExpressRoutePortId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRoutePortName: "eXpReSsRoUtEpOrTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs/eXpReSsRoUtEpOrTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRoutePortIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRoutePortName != v.Expected.ExpressRoutePortName { + t.Fatalf("Expected %q but got %q for ExpressRoutePortName", v.Expected.ExpressRoutePortName, actual.ExpressRoutePortName) + } + + } +} + +func TestSegmentsForExpressRoutePortId(t *testing.T) { + segments := ExpressRoutePortId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ExpressRoutePortId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutelinks/id_link.go b/resource-manager/network/2024-07-01/expressroutelinks/id_link.go new file mode 100644 index 00000000000..b4b3d9bb8d7 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutelinks/id_link.go @@ -0,0 +1,139 @@ +package expressroutelinks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LinkId{}) +} + +var _ resourceids.ResourceId = &LinkId{} + +// LinkId is a struct representing the Resource ID for a Link +type LinkId struct { + SubscriptionId string + ResourceGroupName string + ExpressRoutePortName string + LinkName string +} + +// NewLinkID returns a new LinkId struct +func NewLinkID(subscriptionId string, resourceGroupName string, expressRoutePortName string, linkName string) LinkId { + return LinkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRoutePortName: expressRoutePortName, + LinkName: linkName, + } +} + +// ParseLinkID parses 'input' into a LinkId +func ParseLinkID(input string) (*LinkId, error) { + parser := resourceids.NewParserFromResourceIdType(&LinkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LinkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLinkIDInsensitively parses 'input' case-insensitively into a LinkId +// note: this method should only be used for API response data and not user input +func ParseLinkIDInsensitively(input string) (*LinkId, error) { + parser := resourceids.NewParserFromResourceIdType(&LinkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LinkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LinkId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRoutePortName, ok = input.Parsed["expressRoutePortName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRoutePortName", input) + } + + if id.LinkName, ok = input.Parsed["linkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "linkName", input) + } + + return nil +} + +// ValidateLinkID checks that 'input' can be parsed as a Link ID +func ValidateLinkID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLinkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Link ID +func (id LinkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRoutePorts/%s/links/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRoutePortName, id.LinkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Link ID +func (id LinkId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRoutePorts", "expressRoutePorts", "expressRoutePorts"), + resourceids.UserSpecifiedSegment("expressRoutePortName", "expressRoutePortName"), + resourceids.StaticSegment("staticLinks", "links", "links"), + resourceids.UserSpecifiedSegment("linkName", "linkName"), + } +} + +// String returns a human-readable description of this Link ID +func (id LinkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Port Name: %q", id.ExpressRoutePortName), + fmt.Sprintf("Link Name: %q", id.LinkName), + } + return fmt.Sprintf("Link (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressroutelinks/id_link_test.go b/resource-manager/network/2024-07-01/expressroutelinks/id_link_test.go new file mode 100644 index 00000000000..887755cd7ec --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutelinks/id_link_test.go @@ -0,0 +1,327 @@ +package expressroutelinks + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LinkId{} + +func TestNewLinkID(t *testing.T) { + id := NewLinkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName", "linkName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRoutePortName != "expressRoutePortName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRoutePortName'", id.ExpressRoutePortName, "expressRoutePortName") + } + + if id.LinkName != "linkName" { + t.Fatalf("Expected %q but got %q for Segment 'LinkName'", id.LinkName, "linkName") + } +} + +func TestFormatLinkID(t *testing.T) { + actual := NewLinkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName", "linkName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/links/linkName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLinkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LinkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/links", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/links/linkName", + Expected: &LinkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRoutePortName: "expressRoutePortName", + LinkName: "linkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/links/linkName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLinkID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRoutePortName != v.Expected.ExpressRoutePortName { + t.Fatalf("Expected %q but got %q for ExpressRoutePortName", v.Expected.ExpressRoutePortName, actual.ExpressRoutePortName) + } + + if actual.LinkName != v.Expected.LinkName { + t.Fatalf("Expected %q but got %q for LinkName", v.Expected.LinkName, actual.LinkName) + } + + } +} + +func TestParseLinkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LinkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs/eXpReSsRoUtEpOrTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/links", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs/eXpReSsRoUtEpOrTnAmE/lInKs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/links/linkName", + Expected: &LinkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRoutePortName: "expressRoutePortName", + LinkName: "linkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/links/linkName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs/eXpReSsRoUtEpOrTnAmE/lInKs/lInKnAmE", + Expected: &LinkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRoutePortName: "eXpReSsRoUtEpOrTnAmE", + LinkName: "lInKnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs/eXpReSsRoUtEpOrTnAmE/lInKs/lInKnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLinkIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRoutePortName != v.Expected.ExpressRoutePortName { + t.Fatalf("Expected %q but got %q for ExpressRoutePortName", v.Expected.ExpressRoutePortName, actual.ExpressRoutePortName) + } + + if actual.LinkName != v.Expected.LinkName { + t.Fatalf("Expected %q but got %q for LinkName", v.Expected.LinkName, actual.LinkName) + } + + } +} + +func TestSegmentsForLinkId(t *testing.T) { + segments := LinkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LinkId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressroutelinks/method_get.go b/resource-manager/network/2024-07-01/expressroutelinks/method_get.go new file mode 100644 index 00000000000..3f132947b99 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutelinks/method_get.go @@ -0,0 +1,53 @@ +package expressroutelinks + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteLink +} + +// Get ... +func (c ExpressRouteLinksClient) Get(ctx context.Context, id LinkId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRouteLink + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressroutelinks/method_list.go b/resource-manager/network/2024-07-01/expressroutelinks/method_list.go new file mode 100644 index 00000000000..bfee432049c --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutelinks/method_list.go @@ -0,0 +1,105 @@ +package expressroutelinks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteLink +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteLink +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ExpressRouteLinksClient) List(ctx context.Context, id ExpressRoutePortId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/links", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ExpressRouteLink `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ExpressRouteLinksClient) ListComplete(ctx context.Context, id ExpressRoutePortId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ExpressRouteLinkOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ExpressRouteLinksClient) ListCompleteMatchingPredicate(ctx context.Context, id ExpressRoutePortId, predicate ExpressRouteLinkOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ExpressRouteLink, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/expressroutelinks/model_expressroutelink.go b/resource-manager/network/2024-07-01/expressroutelinks/model_expressroutelink.go new file mode 100644 index 00000000000..d8919f16d71 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutelinks/model_expressroutelink.go @@ -0,0 +1,11 @@ +package expressroutelinks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRouteLinkPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutelinks/model_expressroutelinkmacsecconfig.go b/resource-manager/network/2024-07-01/expressroutelinks/model_expressroutelinkmacsecconfig.go new file mode 100644 index 00000000000..91551b3b16f --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutelinks/model_expressroutelinkmacsecconfig.go @@ -0,0 +1,11 @@ +package expressroutelinks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteLinkMacSecConfig struct { + CakSecretIdentifier *string `json:"cakSecretIdentifier,omitempty"` + Cipher *ExpressRouteLinkMacSecCipher `json:"cipher,omitempty"` + CknSecretIdentifier *string `json:"cknSecretIdentifier,omitempty"` + SciState *ExpressRouteLinkMacSecSciState `json:"sciState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutelinks/model_expressroutelinkpropertiesformat.go b/resource-manager/network/2024-07-01/expressroutelinks/model_expressroutelinkpropertiesformat.go new file mode 100644 index 00000000000..6d9466ff4ff --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutelinks/model_expressroutelinkpropertiesformat.go @@ -0,0 +1,16 @@ +package expressroutelinks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteLinkPropertiesFormat struct { + AdminState *ExpressRouteLinkAdminState `json:"adminState,omitempty"` + ColoLocation *string `json:"coloLocation,omitempty"` + ConnectorType *ExpressRouteLinkConnectorType `json:"connectorType,omitempty"` + InterfaceName *string `json:"interfaceName,omitempty"` + MacSecConfig *ExpressRouteLinkMacSecConfig `json:"macSecConfig,omitempty"` + PatchPanelId *string `json:"patchPanelId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RackId *string `json:"rackId,omitempty"` + RouterName *string `json:"routerName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressroutelinks/predicates.go b/resource-manager/network/2024-07-01/expressroutelinks/predicates.go new file mode 100644 index 00000000000..bd6127afc55 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutelinks/predicates.go @@ -0,0 +1,27 @@ +package expressroutelinks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteLinkOperationPredicate struct { + Etag *string + Id *string + Name *string +} + +func (p ExpressRouteLinkOperationPredicate) Matches(input ExpressRouteLink) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressroutelinks/version.go b/resource-manager/network/2024-07-01/expressroutelinks/version.go new file mode 100644 index 00000000000..1e9d9fbeb96 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressroutelinks/version.go @@ -0,0 +1,10 @@ +package expressroutelinks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressroutelinks/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressrouteportauthorizations/README.md b/resource-manager/network/2024-07-01/expressrouteportauthorizations/README.md new file mode 100644 index 00000000000..8bca2bcec40 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportauthorizations/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteportauthorizations` Documentation + +The `expressrouteportauthorizations` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteportauthorizations" +``` + + +### Client Initialization + +```go +client := expressrouteportauthorizations.NewExpressRoutePortAuthorizationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRoutePortAuthorizationsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := expressrouteportauthorizations.NewExpressRoutePortAuthorizationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName", "authorizationName") + +payload := expressrouteportauthorizations.ExpressRoutePortAuthorization{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRoutePortAuthorizationsClient.Delete` + +```go +ctx := context.TODO() +id := expressrouteportauthorizations.NewExpressRoutePortAuthorizationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName", "authorizationName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRoutePortAuthorizationsClient.Get` + +```go +ctx := context.TODO() +id := expressrouteportauthorizations.NewExpressRoutePortAuthorizationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName", "authorizationName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ExpressRoutePortAuthorizationsClient.List` + +```go +ctx := context.TODO() +id := expressrouteportauthorizations.NewExpressRoutePortID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/expressrouteportauthorizations/client.go b/resource-manager/network/2024-07-01/expressrouteportauthorizations/client.go new file mode 100644 index 00000000000..3405a1acb86 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportauthorizations/client.go @@ -0,0 +1,26 @@ +package expressrouteportauthorizations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRoutePortAuthorizationsClient struct { + Client *resourcemanager.Client +} + +func NewExpressRoutePortAuthorizationsClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRoutePortAuthorizationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressrouteportauthorizations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRoutePortAuthorizationsClient: %+v", err) + } + + return &ExpressRoutePortAuthorizationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressrouteportauthorizations/constants.go b/resource-manager/network/2024-07-01/expressrouteportauthorizations/constants.go new file mode 100644 index 00000000000..3fbd20f1075 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportauthorizations/constants.go @@ -0,0 +1,98 @@ +package expressrouteportauthorizations + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRoutePortAuthorizationUseStatus string + +const ( + ExpressRoutePortAuthorizationUseStatusAvailable ExpressRoutePortAuthorizationUseStatus = "Available" + ExpressRoutePortAuthorizationUseStatusInUse ExpressRoutePortAuthorizationUseStatus = "InUse" +) + +func PossibleValuesForExpressRoutePortAuthorizationUseStatus() []string { + return []string{ + string(ExpressRoutePortAuthorizationUseStatusAvailable), + string(ExpressRoutePortAuthorizationUseStatusInUse), + } +} + +func (s *ExpressRoutePortAuthorizationUseStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRoutePortAuthorizationUseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRoutePortAuthorizationUseStatus(input string) (*ExpressRoutePortAuthorizationUseStatus, error) { + vals := map[string]ExpressRoutePortAuthorizationUseStatus{ + "available": ExpressRoutePortAuthorizationUseStatusAvailable, + "inuse": ExpressRoutePortAuthorizationUseStatusInUse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRoutePortAuthorizationUseStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/expressrouteportauthorizations/id_expressrouteport.go b/resource-manager/network/2024-07-01/expressrouteportauthorizations/id_expressrouteport.go new file mode 100644 index 00000000000..b9d13e5b843 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportauthorizations/id_expressrouteport.go @@ -0,0 +1,130 @@ +package expressrouteportauthorizations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ExpressRoutePortId{}) +} + +var _ resourceids.ResourceId = &ExpressRoutePortId{} + +// ExpressRoutePortId is a struct representing the Resource ID for a Express Route Port +type ExpressRoutePortId struct { + SubscriptionId string + ResourceGroupName string + ExpressRoutePortName string +} + +// NewExpressRoutePortID returns a new ExpressRoutePortId struct +func NewExpressRoutePortID(subscriptionId string, resourceGroupName string, expressRoutePortName string) ExpressRoutePortId { + return ExpressRoutePortId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRoutePortName: expressRoutePortName, + } +} + +// ParseExpressRoutePortID parses 'input' into a ExpressRoutePortId +func ParseExpressRoutePortID(input string) (*ExpressRoutePortId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRoutePortId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRoutePortId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseExpressRoutePortIDInsensitively parses 'input' case-insensitively into a ExpressRoutePortId +// note: this method should only be used for API response data and not user input +func ParseExpressRoutePortIDInsensitively(input string) (*ExpressRoutePortId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRoutePortId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRoutePortId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ExpressRoutePortId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRoutePortName, ok = input.Parsed["expressRoutePortName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRoutePortName", input) + } + + return nil +} + +// ValidateExpressRoutePortID checks that 'input' can be parsed as a Express Route Port ID +func ValidateExpressRoutePortID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseExpressRoutePortID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Express Route Port ID +func (id ExpressRoutePortId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRoutePorts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRoutePortName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Express Route Port ID +func (id ExpressRoutePortId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRoutePorts", "expressRoutePorts", "expressRoutePorts"), + resourceids.UserSpecifiedSegment("expressRoutePortName", "expressRoutePortName"), + } +} + +// String returns a human-readable description of this Express Route Port ID +func (id ExpressRoutePortId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Port Name: %q", id.ExpressRoutePortName), + } + return fmt.Sprintf("Express Route Port (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressrouteportauthorizations/id_expressrouteport_test.go b/resource-manager/network/2024-07-01/expressrouteportauthorizations/id_expressrouteport_test.go new file mode 100644 index 00000000000..5e5c2cdda01 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportauthorizations/id_expressrouteport_test.go @@ -0,0 +1,282 @@ +package expressrouteportauthorizations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ExpressRoutePortId{} + +func TestNewExpressRoutePortID(t *testing.T) { + id := NewExpressRoutePortID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRoutePortName != "expressRoutePortName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRoutePortName'", id.ExpressRoutePortName, "expressRoutePortName") + } +} + +func TestFormatExpressRoutePortID(t *testing.T) { + actual := NewExpressRoutePortID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseExpressRoutePortID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRoutePortId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName", + Expected: &ExpressRoutePortId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRoutePortName: "expressRoutePortName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRoutePortID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRoutePortName != v.Expected.ExpressRoutePortName { + t.Fatalf("Expected %q but got %q for ExpressRoutePortName", v.Expected.ExpressRoutePortName, actual.ExpressRoutePortName) + } + + } +} + +func TestParseExpressRoutePortIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRoutePortId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName", + Expected: &ExpressRoutePortId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRoutePortName: "expressRoutePortName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs/eXpReSsRoUtEpOrTnAmE", + Expected: &ExpressRoutePortId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRoutePortName: "eXpReSsRoUtEpOrTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs/eXpReSsRoUtEpOrTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRoutePortIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRoutePortName != v.Expected.ExpressRoutePortName { + t.Fatalf("Expected %q but got %q for ExpressRoutePortName", v.Expected.ExpressRoutePortName, actual.ExpressRoutePortName) + } + + } +} + +func TestSegmentsForExpressRoutePortId(t *testing.T) { + segments := ExpressRoutePortId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ExpressRoutePortId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressrouteportauthorizations/id_expressrouteportauthorization.go b/resource-manager/network/2024-07-01/expressrouteportauthorizations/id_expressrouteportauthorization.go new file mode 100644 index 00000000000..f0a6e19528d --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportauthorizations/id_expressrouteportauthorization.go @@ -0,0 +1,139 @@ +package expressrouteportauthorizations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ExpressRoutePortAuthorizationId{}) +} + +var _ resourceids.ResourceId = &ExpressRoutePortAuthorizationId{} + +// ExpressRoutePortAuthorizationId is a struct representing the Resource ID for a Express Route Port Authorization +type ExpressRoutePortAuthorizationId struct { + SubscriptionId string + ResourceGroupName string + ExpressRoutePortName string + AuthorizationName string +} + +// NewExpressRoutePortAuthorizationID returns a new ExpressRoutePortAuthorizationId struct +func NewExpressRoutePortAuthorizationID(subscriptionId string, resourceGroupName string, expressRoutePortName string, authorizationName string) ExpressRoutePortAuthorizationId { + return ExpressRoutePortAuthorizationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRoutePortName: expressRoutePortName, + AuthorizationName: authorizationName, + } +} + +// ParseExpressRoutePortAuthorizationID parses 'input' into a ExpressRoutePortAuthorizationId +func ParseExpressRoutePortAuthorizationID(input string) (*ExpressRoutePortAuthorizationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRoutePortAuthorizationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRoutePortAuthorizationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseExpressRoutePortAuthorizationIDInsensitively parses 'input' case-insensitively into a ExpressRoutePortAuthorizationId +// note: this method should only be used for API response data and not user input +func ParseExpressRoutePortAuthorizationIDInsensitively(input string) (*ExpressRoutePortAuthorizationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRoutePortAuthorizationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRoutePortAuthorizationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ExpressRoutePortAuthorizationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRoutePortName, ok = input.Parsed["expressRoutePortName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRoutePortName", input) + } + + if id.AuthorizationName, ok = input.Parsed["authorizationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "authorizationName", input) + } + + return nil +} + +// ValidateExpressRoutePortAuthorizationID checks that 'input' can be parsed as a Express Route Port Authorization ID +func ValidateExpressRoutePortAuthorizationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseExpressRoutePortAuthorizationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Express Route Port Authorization ID +func (id ExpressRoutePortAuthorizationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRoutePorts/%s/authorizations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRoutePortName, id.AuthorizationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Express Route Port Authorization ID +func (id ExpressRoutePortAuthorizationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRoutePorts", "expressRoutePorts", "expressRoutePorts"), + resourceids.UserSpecifiedSegment("expressRoutePortName", "expressRoutePortName"), + resourceids.StaticSegment("staticAuthorizations", "authorizations", "authorizations"), + resourceids.UserSpecifiedSegment("authorizationName", "authorizationName"), + } +} + +// String returns a human-readable description of this Express Route Port Authorization ID +func (id ExpressRoutePortAuthorizationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Port Name: %q", id.ExpressRoutePortName), + fmt.Sprintf("Authorization Name: %q", id.AuthorizationName), + } + return fmt.Sprintf("Express Route Port Authorization (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressrouteportauthorizations/id_expressrouteportauthorization_test.go b/resource-manager/network/2024-07-01/expressrouteportauthorizations/id_expressrouteportauthorization_test.go new file mode 100644 index 00000000000..9d5c1ec5fb9 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportauthorizations/id_expressrouteportauthorization_test.go @@ -0,0 +1,327 @@ +package expressrouteportauthorizations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ExpressRoutePortAuthorizationId{} + +func TestNewExpressRoutePortAuthorizationID(t *testing.T) { + id := NewExpressRoutePortAuthorizationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName", "authorizationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRoutePortName != "expressRoutePortName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRoutePortName'", id.ExpressRoutePortName, "expressRoutePortName") + } + + if id.AuthorizationName != "authorizationName" { + t.Fatalf("Expected %q but got %q for Segment 'AuthorizationName'", id.AuthorizationName, "authorizationName") + } +} + +func TestFormatExpressRoutePortAuthorizationID(t *testing.T) { + actual := NewExpressRoutePortAuthorizationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName", "authorizationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/authorizations/authorizationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseExpressRoutePortAuthorizationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRoutePortAuthorizationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/authorizations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/authorizations/authorizationName", + Expected: &ExpressRoutePortAuthorizationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRoutePortName: "expressRoutePortName", + AuthorizationName: "authorizationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/authorizations/authorizationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRoutePortAuthorizationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRoutePortName != v.Expected.ExpressRoutePortName { + t.Fatalf("Expected %q but got %q for ExpressRoutePortName", v.Expected.ExpressRoutePortName, actual.ExpressRoutePortName) + } + + if actual.AuthorizationName != v.Expected.AuthorizationName { + t.Fatalf("Expected %q but got %q for AuthorizationName", v.Expected.AuthorizationName, actual.AuthorizationName) + } + + } +} + +func TestParseExpressRoutePortAuthorizationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRoutePortAuthorizationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs/eXpReSsRoUtEpOrTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/authorizations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs/eXpReSsRoUtEpOrTnAmE/aUtHoRiZaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/authorizations/authorizationName", + Expected: &ExpressRoutePortAuthorizationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRoutePortName: "expressRoutePortName", + AuthorizationName: "authorizationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/authorizations/authorizationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs/eXpReSsRoUtEpOrTnAmE/aUtHoRiZaTiOnS/aUtHoRiZaTiOnNaMe", + Expected: &ExpressRoutePortAuthorizationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRoutePortName: "eXpReSsRoUtEpOrTnAmE", + AuthorizationName: "aUtHoRiZaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs/eXpReSsRoUtEpOrTnAmE/aUtHoRiZaTiOnS/aUtHoRiZaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRoutePortAuthorizationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRoutePortName != v.Expected.ExpressRoutePortName { + t.Fatalf("Expected %q but got %q for ExpressRoutePortName", v.Expected.ExpressRoutePortName, actual.ExpressRoutePortName) + } + + if actual.AuthorizationName != v.Expected.AuthorizationName { + t.Fatalf("Expected %q but got %q for AuthorizationName", v.Expected.AuthorizationName, actual.AuthorizationName) + } + + } +} + +func TestSegmentsForExpressRoutePortAuthorizationId(t *testing.T) { + segments := ExpressRoutePortAuthorizationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ExpressRoutePortAuthorizationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressrouteportauthorizations/method_createorupdate.go b/resource-manager/network/2024-07-01/expressrouteportauthorizations/method_createorupdate.go new file mode 100644 index 00000000000..9e08a949ed3 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportauthorizations/method_createorupdate.go @@ -0,0 +1,75 @@ +package expressrouteportauthorizations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRoutePortAuthorization +} + +// CreateOrUpdate ... +func (c ExpressRoutePortAuthorizationsClient) CreateOrUpdate(ctx context.Context, id ExpressRoutePortAuthorizationId, input ExpressRoutePortAuthorization) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ExpressRoutePortAuthorizationsClient) CreateOrUpdateThenPoll(ctx context.Context, id ExpressRoutePortAuthorizationId, input ExpressRoutePortAuthorization) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressrouteportauthorizations/method_delete.go b/resource-manager/network/2024-07-01/expressrouteportauthorizations/method_delete.go new file mode 100644 index 00000000000..8940670b615 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportauthorizations/method_delete.go @@ -0,0 +1,71 @@ +package expressrouteportauthorizations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ExpressRoutePortAuthorizationsClient) Delete(ctx context.Context, id ExpressRoutePortAuthorizationId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ExpressRoutePortAuthorizationsClient) DeleteThenPoll(ctx context.Context, id ExpressRoutePortAuthorizationId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressrouteportauthorizations/method_get.go b/resource-manager/network/2024-07-01/expressrouteportauthorizations/method_get.go new file mode 100644 index 00000000000..c8df23b8dfd --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportauthorizations/method_get.go @@ -0,0 +1,53 @@ +package expressrouteportauthorizations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRoutePortAuthorization +} + +// Get ... +func (c ExpressRoutePortAuthorizationsClient) Get(ctx context.Context, id ExpressRoutePortAuthorizationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRoutePortAuthorization + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressrouteportauthorizations/method_list.go b/resource-manager/network/2024-07-01/expressrouteportauthorizations/method_list.go new file mode 100644 index 00000000000..66e64adc644 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportauthorizations/method_list.go @@ -0,0 +1,105 @@ +package expressrouteportauthorizations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRoutePortAuthorization +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRoutePortAuthorization +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ExpressRoutePortAuthorizationsClient) List(ctx context.Context, id ExpressRoutePortId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/authorizations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ExpressRoutePortAuthorization `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ExpressRoutePortAuthorizationsClient) ListComplete(ctx context.Context, id ExpressRoutePortId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ExpressRoutePortAuthorizationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ExpressRoutePortAuthorizationsClient) ListCompleteMatchingPredicate(ctx context.Context, id ExpressRoutePortId, predicate ExpressRoutePortAuthorizationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ExpressRoutePortAuthorization, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/expressrouteportauthorizations/model_expressrouteportauthorization.go b/resource-manager/network/2024-07-01/expressrouteportauthorizations/model_expressrouteportauthorization.go new file mode 100644 index 00000000000..aee29af0a99 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportauthorizations/model_expressrouteportauthorization.go @@ -0,0 +1,12 @@ +package expressrouteportauthorizations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRoutePortAuthorization struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRoutePortAuthorizationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteportauthorizations/model_expressrouteportauthorizationpropertiesformat.go b/resource-manager/network/2024-07-01/expressrouteportauthorizations/model_expressrouteportauthorizationpropertiesformat.go new file mode 100644 index 00000000000..9370c4f6323 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportauthorizations/model_expressrouteportauthorizationpropertiesformat.go @@ -0,0 +1,11 @@ +package expressrouteportauthorizations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRoutePortAuthorizationPropertiesFormat struct { + AuthorizationKey *string `json:"authorizationKey,omitempty"` + AuthorizationUseStatus *ExpressRoutePortAuthorizationUseStatus `json:"authorizationUseStatus,omitempty"` + CircuitResourceUri *string `json:"circuitResourceUri,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteportauthorizations/predicates.go b/resource-manager/network/2024-07-01/expressrouteportauthorizations/predicates.go new file mode 100644 index 00000000000..d12fc29e52a --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportauthorizations/predicates.go @@ -0,0 +1,32 @@ +package expressrouteportauthorizations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRoutePortAuthorizationOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p ExpressRoutePortAuthorizationOperationPredicate) Matches(input ExpressRoutePortAuthorization) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressrouteportauthorizations/version.go b/resource-manager/network/2024-07-01/expressrouteportauthorizations/version.go new file mode 100644 index 00000000000..08a7a803c06 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportauthorizations/version.go @@ -0,0 +1,10 @@ +package expressrouteportauthorizations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressrouteportauthorizations/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/README.md b/resource-manager/network/2024-07-01/expressrouteports/README.md new file mode 100644 index 00000000000..75dd09ad328 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/README.md @@ -0,0 +1,142 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteports` Documentation + +The `expressrouteports` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteports" +``` + + +### Client Initialization + +```go +client := expressrouteports.NewExpressRoutePortsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRoutePortsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := expressrouteports.NewExpressRoutePortID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName") + +payload := expressrouteports.ExpressRoutePort{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRoutePortsClient.Delete` + +```go +ctx := context.TODO() +id := expressrouteports.NewExpressRoutePortID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ExpressRoutePortsClient.GenerateLOA` + +```go +ctx := context.TODO() +id := expressrouteports.NewExpressRoutePortID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName") + +payload := expressrouteports.GenerateExpressRoutePortsLOARequest{ + // ... +} + + +read, err := client.GenerateLOA(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ExpressRoutePortsClient.Get` + +```go +ctx := context.TODO() +id := expressrouteports.NewExpressRoutePortID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ExpressRoutePortsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ExpressRoutePortsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ExpressRoutePortsClient.UpdateTags` + +```go +ctx := context.TODO() +id := expressrouteports.NewExpressRoutePortID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName") + +payload := expressrouteports.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/expressrouteports/client.go b/resource-manager/network/2024-07-01/expressrouteports/client.go new file mode 100644 index 00000000000..82e57d5b54f --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/client.go @@ -0,0 +1,26 @@ +package expressrouteports + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRoutePortsClient struct { + Client *resourcemanager.Client +} + +func NewExpressRoutePortsClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRoutePortsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressrouteports", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRoutePortsClient: %+v", err) + } + + return &ExpressRoutePortsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/constants.go b/resource-manager/network/2024-07-01/expressrouteports/constants.go new file mode 100644 index 00000000000..0c08bc2c72f --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/constants.go @@ -0,0 +1,309 @@ +package expressrouteports + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteLinkAdminState string + +const ( + ExpressRouteLinkAdminStateDisabled ExpressRouteLinkAdminState = "Disabled" + ExpressRouteLinkAdminStateEnabled ExpressRouteLinkAdminState = "Enabled" +) + +func PossibleValuesForExpressRouteLinkAdminState() []string { + return []string{ + string(ExpressRouteLinkAdminStateDisabled), + string(ExpressRouteLinkAdminStateEnabled), + } +} + +func (s *ExpressRouteLinkAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteLinkAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteLinkAdminState(input string) (*ExpressRouteLinkAdminState, error) { + vals := map[string]ExpressRouteLinkAdminState{ + "disabled": ExpressRouteLinkAdminStateDisabled, + "enabled": ExpressRouteLinkAdminStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteLinkAdminState(input) + return &out, nil +} + +type ExpressRouteLinkConnectorType string + +const ( + ExpressRouteLinkConnectorTypeLC ExpressRouteLinkConnectorType = "LC" + ExpressRouteLinkConnectorTypeSC ExpressRouteLinkConnectorType = "SC" +) + +func PossibleValuesForExpressRouteLinkConnectorType() []string { + return []string{ + string(ExpressRouteLinkConnectorTypeLC), + string(ExpressRouteLinkConnectorTypeSC), + } +} + +func (s *ExpressRouteLinkConnectorType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteLinkConnectorType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteLinkConnectorType(input string) (*ExpressRouteLinkConnectorType, error) { + vals := map[string]ExpressRouteLinkConnectorType{ + "lc": ExpressRouteLinkConnectorTypeLC, + "sc": ExpressRouteLinkConnectorTypeSC, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteLinkConnectorType(input) + return &out, nil +} + +type ExpressRouteLinkMacSecCipher string + +const ( + ExpressRouteLinkMacSecCipherGcmAesOneTwoEight ExpressRouteLinkMacSecCipher = "GcmAes128" + ExpressRouteLinkMacSecCipherGcmAesTwoFiveSix ExpressRouteLinkMacSecCipher = "GcmAes256" + ExpressRouteLinkMacSecCipherGcmAesXpnOneTwoEight ExpressRouteLinkMacSecCipher = "GcmAesXpn128" + ExpressRouteLinkMacSecCipherGcmAesXpnTwoFiveSix ExpressRouteLinkMacSecCipher = "GcmAesXpn256" +) + +func PossibleValuesForExpressRouteLinkMacSecCipher() []string { + return []string{ + string(ExpressRouteLinkMacSecCipherGcmAesOneTwoEight), + string(ExpressRouteLinkMacSecCipherGcmAesTwoFiveSix), + string(ExpressRouteLinkMacSecCipherGcmAesXpnOneTwoEight), + string(ExpressRouteLinkMacSecCipherGcmAesXpnTwoFiveSix), + } +} + +func (s *ExpressRouteLinkMacSecCipher) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteLinkMacSecCipher(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteLinkMacSecCipher(input string) (*ExpressRouteLinkMacSecCipher, error) { + vals := map[string]ExpressRouteLinkMacSecCipher{ + "gcmaes128": ExpressRouteLinkMacSecCipherGcmAesOneTwoEight, + "gcmaes256": ExpressRouteLinkMacSecCipherGcmAesTwoFiveSix, + "gcmaesxpn128": ExpressRouteLinkMacSecCipherGcmAesXpnOneTwoEight, + "gcmaesxpn256": ExpressRouteLinkMacSecCipherGcmAesXpnTwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteLinkMacSecCipher(input) + return &out, nil +} + +type ExpressRouteLinkMacSecSciState string + +const ( + ExpressRouteLinkMacSecSciStateDisabled ExpressRouteLinkMacSecSciState = "Disabled" + ExpressRouteLinkMacSecSciStateEnabled ExpressRouteLinkMacSecSciState = "Enabled" +) + +func PossibleValuesForExpressRouteLinkMacSecSciState() []string { + return []string{ + string(ExpressRouteLinkMacSecSciStateDisabled), + string(ExpressRouteLinkMacSecSciStateEnabled), + } +} + +func (s *ExpressRouteLinkMacSecSciState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteLinkMacSecSciState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteLinkMacSecSciState(input string) (*ExpressRouteLinkMacSecSciState, error) { + vals := map[string]ExpressRouteLinkMacSecSciState{ + "disabled": ExpressRouteLinkMacSecSciStateDisabled, + "enabled": ExpressRouteLinkMacSecSciStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteLinkMacSecSciState(input) + return &out, nil +} + +type ExpressRoutePortsBillingType string + +const ( + ExpressRoutePortsBillingTypeMeteredData ExpressRoutePortsBillingType = "MeteredData" + ExpressRoutePortsBillingTypeUnlimitedData ExpressRoutePortsBillingType = "UnlimitedData" +) + +func PossibleValuesForExpressRoutePortsBillingType() []string { + return []string{ + string(ExpressRoutePortsBillingTypeMeteredData), + string(ExpressRoutePortsBillingTypeUnlimitedData), + } +} + +func (s *ExpressRoutePortsBillingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRoutePortsBillingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRoutePortsBillingType(input string) (*ExpressRoutePortsBillingType, error) { + vals := map[string]ExpressRoutePortsBillingType{ + "metereddata": ExpressRoutePortsBillingTypeMeteredData, + "unlimiteddata": ExpressRoutePortsBillingTypeUnlimitedData, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRoutePortsBillingType(input) + return &out, nil +} + +type ExpressRoutePortsEncapsulation string + +const ( + ExpressRoutePortsEncapsulationDotOneQ ExpressRoutePortsEncapsulation = "Dot1Q" + ExpressRoutePortsEncapsulationQinQ ExpressRoutePortsEncapsulation = "QinQ" +) + +func PossibleValuesForExpressRoutePortsEncapsulation() []string { + return []string{ + string(ExpressRoutePortsEncapsulationDotOneQ), + string(ExpressRoutePortsEncapsulationQinQ), + } +} + +func (s *ExpressRoutePortsEncapsulation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRoutePortsEncapsulation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRoutePortsEncapsulation(input string) (*ExpressRoutePortsEncapsulation, error) { + vals := map[string]ExpressRoutePortsEncapsulation{ + "dot1q": ExpressRoutePortsEncapsulationDotOneQ, + "qinq": ExpressRoutePortsEncapsulationQinQ, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRoutePortsEncapsulation(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/id_expressrouteport.go b/resource-manager/network/2024-07-01/expressrouteports/id_expressrouteport.go new file mode 100644 index 00000000000..17c2ee16ba0 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/id_expressrouteport.go @@ -0,0 +1,130 @@ +package expressrouteports + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ExpressRoutePortId{}) +} + +var _ resourceids.ResourceId = &ExpressRoutePortId{} + +// ExpressRoutePortId is a struct representing the Resource ID for a Express Route Port +type ExpressRoutePortId struct { + SubscriptionId string + ResourceGroupName string + ExpressRoutePortName string +} + +// NewExpressRoutePortID returns a new ExpressRoutePortId struct +func NewExpressRoutePortID(subscriptionId string, resourceGroupName string, expressRoutePortName string) ExpressRoutePortId { + return ExpressRoutePortId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRoutePortName: expressRoutePortName, + } +} + +// ParseExpressRoutePortID parses 'input' into a ExpressRoutePortId +func ParseExpressRoutePortID(input string) (*ExpressRoutePortId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRoutePortId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRoutePortId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseExpressRoutePortIDInsensitively parses 'input' case-insensitively into a ExpressRoutePortId +// note: this method should only be used for API response data and not user input +func ParseExpressRoutePortIDInsensitively(input string) (*ExpressRoutePortId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRoutePortId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRoutePortId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ExpressRoutePortId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRoutePortName, ok = input.Parsed["expressRoutePortName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRoutePortName", input) + } + + return nil +} + +// ValidateExpressRoutePortID checks that 'input' can be parsed as a Express Route Port ID +func ValidateExpressRoutePortID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseExpressRoutePortID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Express Route Port ID +func (id ExpressRoutePortId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRoutePorts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRoutePortName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Express Route Port ID +func (id ExpressRoutePortId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRoutePorts", "expressRoutePorts", "expressRoutePorts"), + resourceids.UserSpecifiedSegment("expressRoutePortName", "expressRoutePortName"), + } +} + +// String returns a human-readable description of this Express Route Port ID +func (id ExpressRoutePortId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Port Name: %q", id.ExpressRoutePortName), + } + return fmt.Sprintf("Express Route Port (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/id_expressrouteport_test.go b/resource-manager/network/2024-07-01/expressrouteports/id_expressrouteport_test.go new file mode 100644 index 00000000000..be222ef21b0 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/id_expressrouteport_test.go @@ -0,0 +1,282 @@ +package expressrouteports + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ExpressRoutePortId{} + +func TestNewExpressRoutePortID(t *testing.T) { + id := NewExpressRoutePortID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRoutePortName != "expressRoutePortName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRoutePortName'", id.ExpressRoutePortName, "expressRoutePortName") + } +} + +func TestFormatExpressRoutePortID(t *testing.T) { + actual := NewExpressRoutePortID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRoutePortName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseExpressRoutePortID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRoutePortId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName", + Expected: &ExpressRoutePortId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRoutePortName: "expressRoutePortName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRoutePortID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRoutePortName != v.Expected.ExpressRoutePortName { + t.Fatalf("Expected %q but got %q for ExpressRoutePortName", v.Expected.ExpressRoutePortName, actual.ExpressRoutePortName) + } + + } +} + +func TestParseExpressRoutePortIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRoutePortId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName", + Expected: &ExpressRoutePortId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRoutePortName: "expressRoutePortName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRoutePorts/expressRoutePortName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs/eXpReSsRoUtEpOrTnAmE", + Expected: &ExpressRoutePortId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRoutePortName: "eXpReSsRoUtEpOrTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTs/eXpReSsRoUtEpOrTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRoutePortIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRoutePortName != v.Expected.ExpressRoutePortName { + t.Fatalf("Expected %q but got %q for ExpressRoutePortName", v.Expected.ExpressRoutePortName, actual.ExpressRoutePortName) + } + + } +} + +func TestSegmentsForExpressRoutePortId(t *testing.T) { + segments := ExpressRoutePortId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ExpressRoutePortId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/method_createorupdate.go b/resource-manager/network/2024-07-01/expressrouteports/method_createorupdate.go new file mode 100644 index 00000000000..34782a4d4f3 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/method_createorupdate.go @@ -0,0 +1,75 @@ +package expressrouteports + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRoutePort +} + +// CreateOrUpdate ... +func (c ExpressRoutePortsClient) CreateOrUpdate(ctx context.Context, id ExpressRoutePortId, input ExpressRoutePort) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ExpressRoutePortsClient) CreateOrUpdateThenPoll(ctx context.Context, id ExpressRoutePortId, input ExpressRoutePort) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/method_delete.go b/resource-manager/network/2024-07-01/expressrouteports/method_delete.go new file mode 100644 index 00000000000..899e7de35bd --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/method_delete.go @@ -0,0 +1,71 @@ +package expressrouteports + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ExpressRoutePortsClient) Delete(ctx context.Context, id ExpressRoutePortId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ExpressRoutePortsClient) DeleteThenPoll(ctx context.Context, id ExpressRoutePortId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/method_generateloa.go b/resource-manager/network/2024-07-01/expressrouteports/method_generateloa.go new file mode 100644 index 00000000000..d5725e743a6 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/method_generateloa.go @@ -0,0 +1,58 @@ +package expressrouteports + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GenerateLOAOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GenerateExpressRoutePortsLOAResult +} + +// GenerateLOA ... +func (c ExpressRoutePortsClient) GenerateLOA(ctx context.Context, id ExpressRoutePortId, input GenerateExpressRoutePortsLOARequest) (result GenerateLOAOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/generateLoa", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model GenerateExpressRoutePortsLOAResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/method_get.go b/resource-manager/network/2024-07-01/expressrouteports/method_get.go new file mode 100644 index 00000000000..dda9cada850 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/method_get.go @@ -0,0 +1,53 @@ +package expressrouteports + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRoutePort +} + +// Get ... +func (c ExpressRoutePortsClient) Get(ctx context.Context, id ExpressRoutePortId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRoutePort + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/method_list.go b/resource-manager/network/2024-07-01/expressrouteports/method_list.go new file mode 100644 index 00000000000..6ad9fc7015f --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/method_list.go @@ -0,0 +1,106 @@ +package expressrouteports + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRoutePort +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRoutePort +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ExpressRoutePortsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/expressRoutePorts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ExpressRoutePort `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ExpressRoutePortsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ExpressRoutePortOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ExpressRoutePortsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ExpressRoutePortOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ExpressRoutePort, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/method_listbyresourcegroup.go b/resource-manager/network/2024-07-01/expressrouteports/method_listbyresourcegroup.go new file mode 100644 index 00000000000..ff3df3bfada --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package expressrouteports + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRoutePort +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRoutePort +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c ExpressRoutePortsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/expressRoutePorts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ExpressRoutePort `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ExpressRoutePortsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ExpressRoutePortOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ExpressRoutePortsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ExpressRoutePortOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ExpressRoutePort, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/method_updatetags.go b/resource-manager/network/2024-07-01/expressrouteports/method_updatetags.go new file mode 100644 index 00000000000..7ce98b9327b --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/method_updatetags.go @@ -0,0 +1,57 @@ +package expressrouteports + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRoutePort +} + +// UpdateTags ... +func (c ExpressRoutePortsClient) UpdateTags(ctx context.Context, id ExpressRoutePortId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRoutePort + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/model_expressroutelink.go b/resource-manager/network/2024-07-01/expressrouteports/model_expressroutelink.go new file mode 100644 index 00000000000..60ed59156ad --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/model_expressroutelink.go @@ -0,0 +1,11 @@ +package expressrouteports + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRouteLinkPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/model_expressroutelinkmacsecconfig.go b/resource-manager/network/2024-07-01/expressrouteports/model_expressroutelinkmacsecconfig.go new file mode 100644 index 00000000000..f41c94b3401 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/model_expressroutelinkmacsecconfig.go @@ -0,0 +1,11 @@ +package expressrouteports + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteLinkMacSecConfig struct { + CakSecretIdentifier *string `json:"cakSecretIdentifier,omitempty"` + Cipher *ExpressRouteLinkMacSecCipher `json:"cipher,omitempty"` + CknSecretIdentifier *string `json:"cknSecretIdentifier,omitempty"` + SciState *ExpressRouteLinkMacSecSciState `json:"sciState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/model_expressroutelinkpropertiesformat.go b/resource-manager/network/2024-07-01/expressrouteports/model_expressroutelinkpropertiesformat.go new file mode 100644 index 00000000000..a9fd2f6e03d --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/model_expressroutelinkpropertiesformat.go @@ -0,0 +1,16 @@ +package expressrouteports + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteLinkPropertiesFormat struct { + AdminState *ExpressRouteLinkAdminState `json:"adminState,omitempty"` + ColoLocation *string `json:"coloLocation,omitempty"` + ConnectorType *ExpressRouteLinkConnectorType `json:"connectorType,omitempty"` + InterfaceName *string `json:"interfaceName,omitempty"` + MacSecConfig *ExpressRouteLinkMacSecConfig `json:"macSecConfig,omitempty"` + PatchPanelId *string `json:"patchPanelId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RackId *string `json:"rackId,omitempty"` + RouterName *string `json:"routerName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/model_expressrouteport.go b/resource-manager/network/2024-07-01/expressrouteports/model_expressrouteport.go new file mode 100644 index 00000000000..4e2aa94784f --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/model_expressrouteport.go @@ -0,0 +1,19 @@ +package expressrouteports + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRoutePort struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRoutePortPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/model_expressrouteportpropertiesformat.go b/resource-manager/network/2024-07-01/expressrouteports/model_expressrouteportpropertiesformat.go new file mode 100644 index 00000000000..897d5ea08de --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/model_expressrouteportpropertiesformat.go @@ -0,0 +1,19 @@ +package expressrouteports + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRoutePortPropertiesFormat struct { + AllocationDate *string `json:"allocationDate,omitempty"` + BandwidthInGbps *int64 `json:"bandwidthInGbps,omitempty"` + BillingType *ExpressRoutePortsBillingType `json:"billingType,omitempty"` + Circuits *[]SubResource `json:"circuits,omitempty"` + Encapsulation *ExpressRoutePortsEncapsulation `json:"encapsulation,omitempty"` + EtherType *string `json:"etherType,omitempty"` + Links *[]ExpressRouteLink `json:"links,omitempty"` + Mtu *string `json:"mtu,omitempty"` + PeeringLocation *string `json:"peeringLocation,omitempty"` + ProvisionedBandwidthInGbps *float64 `json:"provisionedBandwidthInGbps,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/model_generateexpressrouteportsloarequest.go b/resource-manager/network/2024-07-01/expressrouteports/model_generateexpressrouteportsloarequest.go new file mode 100644 index 00000000000..d588660f834 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/model_generateexpressrouteportsloarequest.go @@ -0,0 +1,8 @@ +package expressrouteports + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GenerateExpressRoutePortsLOARequest struct { + CustomerName string `json:"customerName"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/model_generateexpressrouteportsloaresult.go b/resource-manager/network/2024-07-01/expressrouteports/model_generateexpressrouteportsloaresult.go new file mode 100644 index 00000000000..54defeace0f --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/model_generateexpressrouteportsloaresult.go @@ -0,0 +1,8 @@ +package expressrouteports + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GenerateExpressRoutePortsLOAResult struct { + EncodedContent *string `json:"encodedContent,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/model_subresource.go b/resource-manager/network/2024-07-01/expressrouteports/model_subresource.go new file mode 100644 index 00000000000..ef7329a3163 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/model_subresource.go @@ -0,0 +1,8 @@ +package expressrouteports + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/model_tagsobject.go b/resource-manager/network/2024-07-01/expressrouteports/model_tagsobject.go new file mode 100644 index 00000000000..d0cb6f9d317 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/model_tagsobject.go @@ -0,0 +1,8 @@ +package expressrouteports + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/predicates.go b/resource-manager/network/2024-07-01/expressrouteports/predicates.go new file mode 100644 index 00000000000..7339fac991b --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/predicates.go @@ -0,0 +1,37 @@ +package expressrouteports + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRoutePortOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ExpressRoutePortOperationPredicate) Matches(input ExpressRoutePort) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressrouteports/version.go b/resource-manager/network/2024-07-01/expressrouteports/version.go new file mode 100644 index 00000000000..edc1b3a7d28 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteports/version.go @@ -0,0 +1,10 @@ +package expressrouteports + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressrouteports/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressrouteportslocations/README.md b/resource-manager/network/2024-07-01/expressrouteportslocations/README.md new file mode 100644 index 00000000000..adef6fff643 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportslocations/README.md @@ -0,0 +1,54 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteportslocations` Documentation + +The `expressrouteportslocations` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteportslocations" +``` + + +### Client Initialization + +```go +client := expressrouteportslocations.NewExpressRoutePortsLocationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRoutePortsLocationsClient.Get` + +```go +ctx := context.TODO() +id := expressrouteportslocations.NewExpressRoutePortsLocationID("12345678-1234-9876-4563-123456789012", "expressRoutePortsLocationName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ExpressRoutePortsLocationsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/expressrouteportslocations/client.go b/resource-manager/network/2024-07-01/expressrouteportslocations/client.go new file mode 100644 index 00000000000..11ea98b6cb3 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportslocations/client.go @@ -0,0 +1,26 @@ +package expressrouteportslocations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRoutePortsLocationsClient struct { + Client *resourcemanager.Client +} + +func NewExpressRoutePortsLocationsClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRoutePortsLocationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressrouteportslocations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRoutePortsLocationsClient: %+v", err) + } + + return &ExpressRoutePortsLocationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressrouteportslocations/constants.go b/resource-manager/network/2024-07-01/expressrouteportslocations/constants.go new file mode 100644 index 00000000000..79d7bad3ae5 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportslocations/constants.go @@ -0,0 +1,57 @@ +package expressrouteportslocations + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/expressrouteportslocations/id_expressrouteportslocation.go b/resource-manager/network/2024-07-01/expressrouteportslocations/id_expressrouteportslocation.go new file mode 100644 index 00000000000..d8025eb5937 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportslocations/id_expressrouteportslocation.go @@ -0,0 +1,121 @@ +package expressrouteportslocations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ExpressRoutePortsLocationId{}) +} + +var _ resourceids.ResourceId = &ExpressRoutePortsLocationId{} + +// ExpressRoutePortsLocationId is a struct representing the Resource ID for a Express Route Ports Location +type ExpressRoutePortsLocationId struct { + SubscriptionId string + ExpressRoutePortsLocationName string +} + +// NewExpressRoutePortsLocationID returns a new ExpressRoutePortsLocationId struct +func NewExpressRoutePortsLocationID(subscriptionId string, expressRoutePortsLocationName string) ExpressRoutePortsLocationId { + return ExpressRoutePortsLocationId{ + SubscriptionId: subscriptionId, + ExpressRoutePortsLocationName: expressRoutePortsLocationName, + } +} + +// ParseExpressRoutePortsLocationID parses 'input' into a ExpressRoutePortsLocationId +func ParseExpressRoutePortsLocationID(input string) (*ExpressRoutePortsLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRoutePortsLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRoutePortsLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseExpressRoutePortsLocationIDInsensitively parses 'input' case-insensitively into a ExpressRoutePortsLocationId +// note: this method should only be used for API response data and not user input +func ParseExpressRoutePortsLocationIDInsensitively(input string) (*ExpressRoutePortsLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRoutePortsLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRoutePortsLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ExpressRoutePortsLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ExpressRoutePortsLocationName, ok = input.Parsed["expressRoutePortsLocationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRoutePortsLocationName", input) + } + + return nil +} + +// ValidateExpressRoutePortsLocationID checks that 'input' can be parsed as a Express Route Ports Location ID +func ValidateExpressRoutePortsLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseExpressRoutePortsLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Express Route Ports Location ID +func (id ExpressRoutePortsLocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Network/expressRoutePortsLocations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ExpressRoutePortsLocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Express Route Ports Location ID +func (id ExpressRoutePortsLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRoutePortsLocations", "expressRoutePortsLocations", "expressRoutePortsLocations"), + resourceids.UserSpecifiedSegment("expressRoutePortsLocationName", "expressRoutePortsLocationName"), + } +} + +// String returns a human-readable description of this Express Route Ports Location ID +func (id ExpressRoutePortsLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Express Route Ports Location Name: %q", id.ExpressRoutePortsLocationName), + } + return fmt.Sprintf("Express Route Ports Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressrouteportslocations/id_expressrouteportslocation_test.go b/resource-manager/network/2024-07-01/expressrouteportslocations/id_expressrouteportslocation_test.go new file mode 100644 index 00000000000..693718559ff --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportslocations/id_expressrouteportslocation_test.go @@ -0,0 +1,237 @@ +package expressrouteportslocations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ExpressRoutePortsLocationId{} + +func TestNewExpressRoutePortsLocationID(t *testing.T) { + id := NewExpressRoutePortsLocationID("12345678-1234-9876-4563-123456789012", "expressRoutePortsLocationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ExpressRoutePortsLocationName != "expressRoutePortsLocationName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRoutePortsLocationName'", id.ExpressRoutePortsLocationName, "expressRoutePortsLocationName") + } +} + +func TestFormatExpressRoutePortsLocationID(t *testing.T) { + actual := NewExpressRoutePortsLocationID("12345678-1234-9876-4563-123456789012", "expressRoutePortsLocationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/expressRoutePortsLocations/expressRoutePortsLocationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseExpressRoutePortsLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRoutePortsLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/expressRoutePortsLocations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/expressRoutePortsLocations/expressRoutePortsLocationName", + Expected: &ExpressRoutePortsLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ExpressRoutePortsLocationName: "expressRoutePortsLocationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/expressRoutePortsLocations/expressRoutePortsLocationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRoutePortsLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ExpressRoutePortsLocationName != v.Expected.ExpressRoutePortsLocationName { + t.Fatalf("Expected %q but got %q for ExpressRoutePortsLocationName", v.Expected.ExpressRoutePortsLocationName, actual.ExpressRoutePortsLocationName) + } + + } +} + +func TestParseExpressRoutePortsLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRoutePortsLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/expressRoutePortsLocations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTsLoCaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/expressRoutePortsLocations/expressRoutePortsLocationName", + Expected: &ExpressRoutePortsLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ExpressRoutePortsLocationName: "expressRoutePortsLocationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/expressRoutePortsLocations/expressRoutePortsLocationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTsLoCaTiOnS/eXpReSsRoUtEpOrTsLoCaTiOnNaMe", + Expected: &ExpressRoutePortsLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ExpressRoutePortsLocationName: "eXpReSsRoUtEpOrTsLoCaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpOrTsLoCaTiOnS/eXpReSsRoUtEpOrTsLoCaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRoutePortsLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ExpressRoutePortsLocationName != v.Expected.ExpressRoutePortsLocationName { + t.Fatalf("Expected %q but got %q for ExpressRoutePortsLocationName", v.Expected.ExpressRoutePortsLocationName, actual.ExpressRoutePortsLocationName) + } + + } +} + +func TestSegmentsForExpressRoutePortsLocationId(t *testing.T) { + segments := ExpressRoutePortsLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ExpressRoutePortsLocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressrouteportslocations/method_get.go b/resource-manager/network/2024-07-01/expressrouteportslocations/method_get.go new file mode 100644 index 00000000000..41422952079 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportslocations/method_get.go @@ -0,0 +1,53 @@ +package expressrouteportslocations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRoutePortsLocation +} + +// Get ... +func (c ExpressRoutePortsLocationsClient) Get(ctx context.Context, id ExpressRoutePortsLocationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRoutePortsLocation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressrouteportslocations/method_list.go b/resource-manager/network/2024-07-01/expressrouteportslocations/method_list.go new file mode 100644 index 00000000000..32b0a19fa28 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportslocations/method_list.go @@ -0,0 +1,106 @@ +package expressrouteportslocations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRoutePortsLocation +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRoutePortsLocation +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ExpressRoutePortsLocationsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/expressRoutePortsLocations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ExpressRoutePortsLocation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ExpressRoutePortsLocationsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ExpressRoutePortsLocationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ExpressRoutePortsLocationsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ExpressRoutePortsLocationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ExpressRoutePortsLocation, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/expressrouteportslocations/model_expressrouteportslocation.go b/resource-manager/network/2024-07-01/expressrouteportslocations/model_expressrouteportslocation.go new file mode 100644 index 00000000000..86d94dc7922 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportslocations/model_expressrouteportslocation.go @@ -0,0 +1,13 @@ +package expressrouteportslocations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRoutePortsLocation struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRoutePortsLocationPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteportslocations/model_expressrouteportslocationbandwidths.go b/resource-manager/network/2024-07-01/expressrouteportslocations/model_expressrouteportslocationbandwidths.go new file mode 100644 index 00000000000..018cb977672 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportslocations/model_expressrouteportslocationbandwidths.go @@ -0,0 +1,9 @@ +package expressrouteportslocations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRoutePortsLocationBandwidths struct { + OfferName *string `json:"offerName,omitempty"` + ValueInGbps *int64 `json:"valueInGbps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteportslocations/model_expressrouteportslocationpropertiesformat.go b/resource-manager/network/2024-07-01/expressrouteportslocations/model_expressrouteportslocationpropertiesformat.go new file mode 100644 index 00000000000..fa52c31306b --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportslocations/model_expressrouteportslocationpropertiesformat.go @@ -0,0 +1,11 @@ +package expressrouteportslocations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRoutePortsLocationPropertiesFormat struct { + Address *string `json:"address,omitempty"` + AvailableBandwidths *[]ExpressRoutePortsLocationBandwidths `json:"availableBandwidths,omitempty"` + Contact *string `json:"contact,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteportslocations/predicates.go b/resource-manager/network/2024-07-01/expressrouteportslocations/predicates.go new file mode 100644 index 00000000000..3b345c2e1f5 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportslocations/predicates.go @@ -0,0 +1,32 @@ +package expressrouteportslocations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRoutePortsLocationOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ExpressRoutePortsLocationOperationPredicate) Matches(input ExpressRoutePortsLocation) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressrouteportslocations/version.go b/resource-manager/network/2024-07-01/expressrouteportslocations/version.go new file mode 100644 index 00000000000..4e53c96ddfc --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteportslocations/version.go @@ -0,0 +1,10 @@ +package expressrouteportslocations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressrouteportslocations/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressrouteproviderports/README.md b/resource-manager/network/2024-07-01/expressrouteproviderports/README.md new file mode 100644 index 00000000000..a2ceb788201 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteproviderports/README.md @@ -0,0 +1,54 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteproviderports` Documentation + +The `expressrouteproviderports` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteproviderports" +``` + + +### Client Initialization + +```go +client := expressrouteproviderports.NewExpressRouteProviderPortsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteProviderPortsClient.ExpressRouteProviderPort` + +```go +ctx := context.TODO() +id := expressrouteproviderports.NewExpressRouteProviderPortID("12345678-1234-9876-4563-123456789012", "expressRouteProviderPortName") + +read, err := client.ExpressRouteProviderPort(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ExpressRouteProviderPortsClient.LocationList` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.LocationList(ctx, id, expressrouteproviderports.DefaultLocationListOperationOptions())` can be used to do batched pagination +items, err := client.LocationListComplete(ctx, id, expressrouteproviderports.DefaultLocationListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/expressrouteproviderports/client.go b/resource-manager/network/2024-07-01/expressrouteproviderports/client.go new file mode 100644 index 00000000000..dad656ec6d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteproviderports/client.go @@ -0,0 +1,26 @@ +package expressrouteproviderports + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteProviderPortsClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteProviderPortsClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteProviderPortsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressrouteproviderports", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteProviderPortsClient: %+v", err) + } + + return &ExpressRouteProviderPortsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressrouteproviderports/id_expressrouteproviderport.go b/resource-manager/network/2024-07-01/expressrouteproviderports/id_expressrouteproviderport.go new file mode 100644 index 00000000000..142c36fee12 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteproviderports/id_expressrouteproviderport.go @@ -0,0 +1,121 @@ +package expressrouteproviderports + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ExpressRouteProviderPortId{}) +} + +var _ resourceids.ResourceId = &ExpressRouteProviderPortId{} + +// ExpressRouteProviderPortId is a struct representing the Resource ID for a Express Route Provider Port +type ExpressRouteProviderPortId struct { + SubscriptionId string + ExpressRouteProviderPortName string +} + +// NewExpressRouteProviderPortID returns a new ExpressRouteProviderPortId struct +func NewExpressRouteProviderPortID(subscriptionId string, expressRouteProviderPortName string) ExpressRouteProviderPortId { + return ExpressRouteProviderPortId{ + SubscriptionId: subscriptionId, + ExpressRouteProviderPortName: expressRouteProviderPortName, + } +} + +// ParseExpressRouteProviderPortID parses 'input' into a ExpressRouteProviderPortId +func ParseExpressRouteProviderPortID(input string) (*ExpressRouteProviderPortId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteProviderPortId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteProviderPortId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseExpressRouteProviderPortIDInsensitively parses 'input' case-insensitively into a ExpressRouteProviderPortId +// note: this method should only be used for API response data and not user input +func ParseExpressRouteProviderPortIDInsensitively(input string) (*ExpressRouteProviderPortId, error) { + parser := resourceids.NewParserFromResourceIdType(&ExpressRouteProviderPortId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ExpressRouteProviderPortId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ExpressRouteProviderPortId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ExpressRouteProviderPortName, ok = input.Parsed["expressRouteProviderPortName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteProviderPortName", input) + } + + return nil +} + +// ValidateExpressRouteProviderPortID checks that 'input' can be parsed as a Express Route Provider Port ID +func ValidateExpressRouteProviderPortID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseExpressRouteProviderPortID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Express Route Provider Port ID +func (id ExpressRouteProviderPortId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Network/expressRouteProviderPorts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ExpressRouteProviderPortName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Express Route Provider Port ID +func (id ExpressRouteProviderPortId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteProviderPorts", "expressRouteProviderPorts", "expressRouteProviderPorts"), + resourceids.UserSpecifiedSegment("expressRouteProviderPortName", "expressRouteProviderPortName"), + } +} + +// String returns a human-readable description of this Express Route Provider Port ID +func (id ExpressRouteProviderPortId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Express Route Provider Port Name: %q", id.ExpressRouteProviderPortName), + } + return fmt.Sprintf("Express Route Provider Port (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/expressrouteproviderports/id_expressrouteproviderport_test.go b/resource-manager/network/2024-07-01/expressrouteproviderports/id_expressrouteproviderport_test.go new file mode 100644 index 00000000000..04d9684f23d --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteproviderports/id_expressrouteproviderport_test.go @@ -0,0 +1,237 @@ +package expressrouteproviderports + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ExpressRouteProviderPortId{} + +func TestNewExpressRouteProviderPortID(t *testing.T) { + id := NewExpressRouteProviderPortID("12345678-1234-9876-4563-123456789012", "expressRouteProviderPortName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ExpressRouteProviderPortName != "expressRouteProviderPortName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteProviderPortName'", id.ExpressRouteProviderPortName, "expressRouteProviderPortName") + } +} + +func TestFormatExpressRouteProviderPortID(t *testing.T) { + actual := NewExpressRouteProviderPortID("12345678-1234-9876-4563-123456789012", "expressRouteProviderPortName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/expressRouteProviderPorts/expressRouteProviderPortName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseExpressRouteProviderPortID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteProviderPortId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/expressRouteProviderPorts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/expressRouteProviderPorts/expressRouteProviderPortName", + Expected: &ExpressRouteProviderPortId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ExpressRouteProviderPortName: "expressRouteProviderPortName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/expressRouteProviderPorts/expressRouteProviderPortName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteProviderPortID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ExpressRouteProviderPortName != v.Expected.ExpressRouteProviderPortName { + t.Fatalf("Expected %q but got %q for ExpressRouteProviderPortName", v.Expected.ExpressRouteProviderPortName, actual.ExpressRouteProviderPortName) + } + + } +} + +func TestParseExpressRouteProviderPortIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ExpressRouteProviderPortId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/expressRouteProviderPorts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpRoViDeRpOrTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/expressRouteProviderPorts/expressRouteProviderPortName", + Expected: &ExpressRouteProviderPortId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ExpressRouteProviderPortName: "expressRouteProviderPortName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/expressRouteProviderPorts/expressRouteProviderPortName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpRoViDeRpOrTs/eXpReSsRoUtEpRoViDeRpOrTnAmE", + Expected: &ExpressRouteProviderPortId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ExpressRouteProviderPortName: "eXpReSsRoUtEpRoViDeRpOrTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEpRoViDeRpOrTs/eXpReSsRoUtEpRoViDeRpOrTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseExpressRouteProviderPortIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ExpressRouteProviderPortName != v.Expected.ExpressRouteProviderPortName { + t.Fatalf("Expected %q but got %q for ExpressRouteProviderPortName", v.Expected.ExpressRouteProviderPortName, actual.ExpressRouteProviderPortName) + } + + } +} + +func TestSegmentsForExpressRouteProviderPortId(t *testing.T) { + segments := ExpressRouteProviderPortId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ExpressRouteProviderPortId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/expressrouteproviderports/method_expressrouteproviderport.go b/resource-manager/network/2024-07-01/expressrouteproviderports/method_expressrouteproviderport.go new file mode 100644 index 00000000000..c264bf3b8aa --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteproviderports/method_expressrouteproviderport.go @@ -0,0 +1,53 @@ +package expressrouteproviderports + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteProviderPortOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExpressRouteProviderPort +} + +// ExpressRouteProviderPort ... +func (c ExpressRouteProviderPortsClient) ExpressRouteProviderPort(ctx context.Context, id ExpressRouteProviderPortId) (result ExpressRouteProviderPortOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExpressRouteProviderPort + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/expressrouteproviderports/method_locationlist.go b/resource-manager/network/2024-07-01/expressrouteproviderports/method_locationlist.go new file mode 100644 index 00000000000..93d35794cf0 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteproviderports/method_locationlist.go @@ -0,0 +1,135 @@ +package expressrouteproviderports + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocationListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteProviderPort +} + +type LocationListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteProviderPort +} + +type LocationListOperationOptions struct { + Filter *string +} + +func DefaultLocationListOperationOptions() LocationListOperationOptions { + return LocationListOperationOptions{} +} + +func (o LocationListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o LocationListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o LocationListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type LocationListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *LocationListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// LocationList ... +func (c ExpressRouteProviderPortsClient) LocationList(ctx context.Context, id commonids.SubscriptionId, options LocationListOperationOptions) (result LocationListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &LocationListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/expressRouteProviderPorts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ExpressRouteProviderPort `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// LocationListComplete retrieves all the results into a single object +func (c ExpressRouteProviderPortsClient) LocationListComplete(ctx context.Context, id commonids.SubscriptionId, options LocationListOperationOptions) (LocationListCompleteResult, error) { + return c.LocationListCompleteMatchingPredicate(ctx, id, options, ExpressRouteProviderPortOperationPredicate{}) +} + +// LocationListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ExpressRouteProviderPortsClient) LocationListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options LocationListOperationOptions, predicate ExpressRouteProviderPortOperationPredicate) (result LocationListCompleteResult, err error) { + items := make([]ExpressRouteProviderPort, 0) + + resp, err := c.LocationList(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = LocationListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/expressrouteproviderports/model_expressrouteproviderport.go b/resource-manager/network/2024-07-01/expressrouteproviderports/model_expressrouteproviderport.go new file mode 100644 index 00000000000..9bb3723c40e --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteproviderports/model_expressrouteproviderport.go @@ -0,0 +1,14 @@ +package expressrouteproviderports + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteProviderPort struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRouteProviderPortProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteproviderports/model_expressrouteproviderportproperties.go b/resource-manager/network/2024-07-01/expressrouteproviderports/model_expressrouteproviderportproperties.go new file mode 100644 index 00000000000..d0a93ccf046 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteproviderports/model_expressrouteproviderportproperties.go @@ -0,0 +1,15 @@ +package expressrouteproviderports + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteProviderPortProperties struct { + OverprovisionFactor *int64 `json:"overprovisionFactor,omitempty"` + PeeringLocation *string `json:"peeringLocation,omitempty"` + PortBandwidthInMbps *int64 `json:"portBandwidthInMbps,omitempty"` + PortPairDescriptor *string `json:"portPairDescriptor,omitempty"` + PrimaryAzurePort *string `json:"primaryAzurePort,omitempty"` + RemainingBandwidthInMbps *int64 `json:"remainingBandwidthInMbps,omitempty"` + SecondaryAzurePort *string `json:"secondaryAzurePort,omitempty"` + UsedBandwidthInMbps *int64 `json:"usedBandwidthInMbps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteproviderports/predicates.go b/resource-manager/network/2024-07-01/expressrouteproviderports/predicates.go new file mode 100644 index 00000000000..ea48d5c374c --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteproviderports/predicates.go @@ -0,0 +1,37 @@ +package expressrouteproviderports + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteProviderPortOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p ExpressRouteProviderPortOperationPredicate) Matches(input ExpressRouteProviderPort) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressrouteproviderports/version.go b/resource-manager/network/2024-07-01/expressrouteproviderports/version.go new file mode 100644 index 00000000000..146449877b6 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteproviderports/version.go @@ -0,0 +1,10 @@ +package expressrouteproviderports + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressrouteproviderports/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/expressrouteserviceproviders/README.md b/resource-manager/network/2024-07-01/expressrouteserviceproviders/README.md new file mode 100644 index 00000000000..bf3a4de58ba --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteserviceproviders/README.md @@ -0,0 +1,38 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteserviceproviders` Documentation + +The `expressrouteserviceproviders` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/expressrouteserviceproviders" +``` + + +### Client Initialization + +```go +client := expressrouteserviceproviders.NewExpressRouteServiceProvidersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ExpressRouteServiceProvidersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/expressrouteserviceproviders/client.go b/resource-manager/network/2024-07-01/expressrouteserviceproviders/client.go new file mode 100644 index 00000000000..a20fad2a136 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteserviceproviders/client.go @@ -0,0 +1,26 @@ +package expressrouteserviceproviders + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteServiceProvidersClient struct { + Client *resourcemanager.Client +} + +func NewExpressRouteServiceProvidersClientWithBaseURI(sdkApi sdkEnv.Api) (*ExpressRouteServiceProvidersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "expressrouteserviceproviders", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ExpressRouteServiceProvidersClient: %+v", err) + } + + return &ExpressRouteServiceProvidersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/expressrouteserviceproviders/constants.go b/resource-manager/network/2024-07-01/expressrouteserviceproviders/constants.go new file mode 100644 index 00000000000..7e0b7b9a059 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteserviceproviders/constants.go @@ -0,0 +1,57 @@ +package expressrouteserviceproviders + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/expressrouteserviceproviders/method_list.go b/resource-manager/network/2024-07-01/expressrouteserviceproviders/method_list.go new file mode 100644 index 00000000000..e8d2935ffea --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteserviceproviders/method_list.go @@ -0,0 +1,106 @@ +package expressrouteserviceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteServiceProvider +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ExpressRouteServiceProvider +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ExpressRouteServiceProvidersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/expressRouteServiceProviders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ExpressRouteServiceProvider `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ExpressRouteServiceProvidersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ExpressRouteServiceProviderOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ExpressRouteServiceProvidersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ExpressRouteServiceProviderOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ExpressRouteServiceProvider, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/expressrouteserviceproviders/model_expressrouteserviceprovider.go b/resource-manager/network/2024-07-01/expressrouteserviceproviders/model_expressrouteserviceprovider.go new file mode 100644 index 00000000000..156136ef150 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteserviceproviders/model_expressrouteserviceprovider.go @@ -0,0 +1,13 @@ +package expressrouteserviceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteServiceProvider struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRouteServiceProviderPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteserviceproviders/model_expressrouteserviceproviderbandwidthsoffered.go b/resource-manager/network/2024-07-01/expressrouteserviceproviders/model_expressrouteserviceproviderbandwidthsoffered.go new file mode 100644 index 00000000000..72758b5e1d5 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteserviceproviders/model_expressrouteserviceproviderbandwidthsoffered.go @@ -0,0 +1,9 @@ +package expressrouteserviceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteServiceProviderBandwidthsOffered struct { + OfferName *string `json:"offerName,omitempty"` + ValueInMbps *int64 `json:"valueInMbps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteserviceproviders/model_expressrouteserviceproviderpropertiesformat.go b/resource-manager/network/2024-07-01/expressrouteserviceproviders/model_expressrouteserviceproviderpropertiesformat.go new file mode 100644 index 00000000000..e3c3cc178f9 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteserviceproviders/model_expressrouteserviceproviderpropertiesformat.go @@ -0,0 +1,10 @@ +package expressrouteserviceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteServiceProviderPropertiesFormat struct { + BandwidthsOffered *[]ExpressRouteServiceProviderBandwidthsOffered `json:"bandwidthsOffered,omitempty"` + PeeringLocations *[]string `json:"peeringLocations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/expressrouteserviceproviders/predicates.go b/resource-manager/network/2024-07-01/expressrouteserviceproviders/predicates.go new file mode 100644 index 00000000000..d2c605983d7 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteserviceproviders/predicates.go @@ -0,0 +1,32 @@ +package expressrouteserviceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteServiceProviderOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ExpressRouteServiceProviderOperationPredicate) Matches(input ExpressRouteServiceProvider) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/expressrouteserviceproviders/version.go b/resource-manager/network/2024-07-01/expressrouteserviceproviders/version.go new file mode 100644 index 00000000000..3e49c28d028 --- /dev/null +++ b/resource-manager/network/2024-07-01/expressrouteserviceproviders/version.go @@ -0,0 +1,10 @@ +package expressrouteserviceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/expressrouteserviceproviders/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/README.md b/resource-manager/network/2024-07-01/firewallpolicies/README.md new file mode 100644 index 00000000000..a2d1b076c56 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/README.md @@ -0,0 +1,355 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/firewallpolicies` Documentation + +The `firewallpolicies` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/firewallpolicies" +``` + + +### Client Initialization + +```go +client := firewallpolicies.NewFirewallPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FirewallPoliciesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := firewallpolicies.NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName") + +payload := firewallpolicies.FirewallPolicy{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `FirewallPoliciesClient.Delete` + +```go +ctx := context.TODO() +id := firewallpolicies.NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `FirewallPoliciesClient.FirewallPolicyDeploymentsDeploy` + +```go +ctx := context.TODO() +id := firewallpolicies.NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName") + +if err := client.FirewallPolicyDeploymentsDeployThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `FirewallPoliciesClient.FirewallPolicyDraftsCreateOrUpdate` + +```go +ctx := context.TODO() +id := firewallpolicies.NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName") + +payload := firewallpolicies.FirewallPolicyDraft{ + // ... +} + + +read, err := client.FirewallPolicyDraftsCreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FirewallPoliciesClient.FirewallPolicyDraftsDelete` + +```go +ctx := context.TODO() +id := firewallpolicies.NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName") + +read, err := client.FirewallPolicyDraftsDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FirewallPoliciesClient.FirewallPolicyDraftsGet` + +```go +ctx := context.TODO() +id := firewallpolicies.NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName") + +read, err := client.FirewallPolicyDraftsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FirewallPoliciesClient.FirewallPolicyIdpsSignaturesFilterValuesList` + +```go +ctx := context.TODO() +id := firewallpolicies.NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName") + +payload := firewallpolicies.SignatureOverridesFilterValuesQuery{ + // ... +} + + +read, err := client.FirewallPolicyIdpsSignaturesFilterValuesList(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FirewallPoliciesClient.FirewallPolicyIdpsSignaturesList` + +```go +ctx := context.TODO() +id := firewallpolicies.NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName") + +payload := firewallpolicies.IDPSQueryObject{ + // ... +} + + +read, err := client.FirewallPolicyIdpsSignaturesList(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FirewallPoliciesClient.FirewallPolicyIdpsSignaturesOverridesGet` + +```go +ctx := context.TODO() +id := firewallpolicies.NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName") + +read, err := client.FirewallPolicyIdpsSignaturesOverridesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FirewallPoliciesClient.FirewallPolicyIdpsSignaturesOverridesList` + +```go +ctx := context.TODO() +id := firewallpolicies.NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName") + +read, err := client.FirewallPolicyIdpsSignaturesOverridesList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FirewallPoliciesClient.FirewallPolicyIdpsSignaturesOverridesPatch` + +```go +ctx := context.TODO() +id := firewallpolicies.NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName") + +payload := firewallpolicies.SignaturesOverrides{ + // ... +} + + +read, err := client.FirewallPolicyIdpsSignaturesOverridesPatch(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FirewallPoliciesClient.FirewallPolicyIdpsSignaturesOverridesPut` + +```go +ctx := context.TODO() +id := firewallpolicies.NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName") + +payload := firewallpolicies.SignaturesOverrides{ + // ... +} + + +read, err := client.FirewallPolicyIdpsSignaturesOverridesPut(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FirewallPoliciesClient.FirewallPolicyRuleCollectionGroupDraftsCreateOrUpdate` + +```go +ctx := context.TODO() +id := firewallpolicies.NewRuleCollectionGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName", "ruleCollectionGroupName") + +payload := firewallpolicies.FirewallPolicyRuleCollectionGroupDraft{ + // ... +} + + +read, err := client.FirewallPolicyRuleCollectionGroupDraftsCreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FirewallPoliciesClient.FirewallPolicyRuleCollectionGroupDraftsDelete` + +```go +ctx := context.TODO() +id := firewallpolicies.NewRuleCollectionGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName", "ruleCollectionGroupName") + +read, err := client.FirewallPolicyRuleCollectionGroupDraftsDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FirewallPoliciesClient.FirewallPolicyRuleCollectionGroupDraftsGet` + +```go +ctx := context.TODO() +id := firewallpolicies.NewRuleCollectionGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName", "ruleCollectionGroupName") + +read, err := client.FirewallPolicyRuleCollectionGroupDraftsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FirewallPoliciesClient.Get` + +```go +ctx := context.TODO() +id := firewallpolicies.NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName") + +read, err := client.Get(ctx, id, firewallpolicies.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FirewallPoliciesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `FirewallPoliciesClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `FirewallPoliciesClient.UpdateTags` + +```go +ctx := context.TODO() +id := firewallpolicies.NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName") + +payload := firewallpolicies.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/firewallpolicies/client.go b/resource-manager/network/2024-07-01/firewallpolicies/client.go new file mode 100644 index 00000000000..fba92b74070 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/client.go @@ -0,0 +1,26 @@ +package firewallpolicies + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPoliciesClient struct { + Client *resourcemanager.Client +} + +func NewFirewallPoliciesClientWithBaseURI(sdkApi sdkEnv.Api) (*FirewallPoliciesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "firewallpolicies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FirewallPoliciesClient: %+v", err) + } + + return &FirewallPoliciesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/constants.go b/resource-manager/network/2024-07-01/firewallpolicies/constants.go new file mode 100644 index 00000000000..3c38f3bb536 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/constants.go @@ -0,0 +1,671 @@ +package firewallpolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoLearnPrivateRangesMode string + +const ( + AutoLearnPrivateRangesModeDisabled AutoLearnPrivateRangesMode = "Disabled" + AutoLearnPrivateRangesModeEnabled AutoLearnPrivateRangesMode = "Enabled" +) + +func PossibleValuesForAutoLearnPrivateRangesMode() []string { + return []string{ + string(AutoLearnPrivateRangesModeDisabled), + string(AutoLearnPrivateRangesModeEnabled), + } +} + +func (s *AutoLearnPrivateRangesMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoLearnPrivateRangesMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoLearnPrivateRangesMode(input string) (*AutoLearnPrivateRangesMode, error) { + vals := map[string]AutoLearnPrivateRangesMode{ + "disabled": AutoLearnPrivateRangesModeDisabled, + "enabled": AutoLearnPrivateRangesModeEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoLearnPrivateRangesMode(input) + return &out, nil +} + +type AzureFirewallThreatIntelMode string + +const ( + AzureFirewallThreatIntelModeAlert AzureFirewallThreatIntelMode = "Alert" + AzureFirewallThreatIntelModeDeny AzureFirewallThreatIntelMode = "Deny" + AzureFirewallThreatIntelModeOff AzureFirewallThreatIntelMode = "Off" +) + +func PossibleValuesForAzureFirewallThreatIntelMode() []string { + return []string{ + string(AzureFirewallThreatIntelModeAlert), + string(AzureFirewallThreatIntelModeDeny), + string(AzureFirewallThreatIntelModeOff), + } +} + +func (s *AzureFirewallThreatIntelMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureFirewallThreatIntelMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureFirewallThreatIntelMode(input string) (*AzureFirewallThreatIntelMode, error) { + vals := map[string]AzureFirewallThreatIntelMode{ + "alert": AzureFirewallThreatIntelModeAlert, + "deny": AzureFirewallThreatIntelModeDeny, + "off": AzureFirewallThreatIntelModeOff, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureFirewallThreatIntelMode(input) + return &out, nil +} + +type FirewallPolicyFilterRuleCollectionActionType string + +const ( + FirewallPolicyFilterRuleCollectionActionTypeAllow FirewallPolicyFilterRuleCollectionActionType = "Allow" + FirewallPolicyFilterRuleCollectionActionTypeDeny FirewallPolicyFilterRuleCollectionActionType = "Deny" +) + +func PossibleValuesForFirewallPolicyFilterRuleCollectionActionType() []string { + return []string{ + string(FirewallPolicyFilterRuleCollectionActionTypeAllow), + string(FirewallPolicyFilterRuleCollectionActionTypeDeny), + } +} + +func (s *FirewallPolicyFilterRuleCollectionActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallPolicyFilterRuleCollectionActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallPolicyFilterRuleCollectionActionType(input string) (*FirewallPolicyFilterRuleCollectionActionType, error) { + vals := map[string]FirewallPolicyFilterRuleCollectionActionType{ + "allow": FirewallPolicyFilterRuleCollectionActionTypeAllow, + "deny": FirewallPolicyFilterRuleCollectionActionTypeDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallPolicyFilterRuleCollectionActionType(input) + return &out, nil +} + +type FirewallPolicyIDPSQuerySortOrder string + +const ( + FirewallPolicyIDPSQuerySortOrderAscending FirewallPolicyIDPSQuerySortOrder = "Ascending" + FirewallPolicyIDPSQuerySortOrderDescending FirewallPolicyIDPSQuerySortOrder = "Descending" +) + +func PossibleValuesForFirewallPolicyIDPSQuerySortOrder() []string { + return []string{ + string(FirewallPolicyIDPSQuerySortOrderAscending), + string(FirewallPolicyIDPSQuerySortOrderDescending), + } +} + +func (s *FirewallPolicyIDPSQuerySortOrder) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallPolicyIDPSQuerySortOrder(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallPolicyIDPSQuerySortOrder(input string) (*FirewallPolicyIDPSQuerySortOrder, error) { + vals := map[string]FirewallPolicyIDPSQuerySortOrder{ + "ascending": FirewallPolicyIDPSQuerySortOrderAscending, + "descending": FirewallPolicyIDPSQuerySortOrderDescending, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallPolicyIDPSQuerySortOrder(input) + return &out, nil +} + +type FirewallPolicyIDPSSignatureDirection int64 + +const ( + FirewallPolicyIDPSSignatureDirectionFive FirewallPolicyIDPSSignatureDirection = 5 + FirewallPolicyIDPSSignatureDirectionFour FirewallPolicyIDPSSignatureDirection = 4 + FirewallPolicyIDPSSignatureDirectionOne FirewallPolicyIDPSSignatureDirection = 1 + FirewallPolicyIDPSSignatureDirectionThree FirewallPolicyIDPSSignatureDirection = 3 + FirewallPolicyIDPSSignatureDirectionTwo FirewallPolicyIDPSSignatureDirection = 2 + FirewallPolicyIDPSSignatureDirectionZero FirewallPolicyIDPSSignatureDirection = 0 +) + +func PossibleValuesForFirewallPolicyIDPSSignatureDirection() []int64 { + return []int64{ + int64(FirewallPolicyIDPSSignatureDirectionFive), + int64(FirewallPolicyIDPSSignatureDirectionFour), + int64(FirewallPolicyIDPSSignatureDirectionOne), + int64(FirewallPolicyIDPSSignatureDirectionThree), + int64(FirewallPolicyIDPSSignatureDirectionTwo), + int64(FirewallPolicyIDPSSignatureDirectionZero), + } +} + +type FirewallPolicyIDPSSignatureMode int64 + +const ( + FirewallPolicyIDPSSignatureModeOne FirewallPolicyIDPSSignatureMode = 1 + FirewallPolicyIDPSSignatureModeTwo FirewallPolicyIDPSSignatureMode = 2 + FirewallPolicyIDPSSignatureModeZero FirewallPolicyIDPSSignatureMode = 0 +) + +func PossibleValuesForFirewallPolicyIDPSSignatureMode() []int64 { + return []int64{ + int64(FirewallPolicyIDPSSignatureModeOne), + int64(FirewallPolicyIDPSSignatureModeTwo), + int64(FirewallPolicyIDPSSignatureModeZero), + } +} + +type FirewallPolicyIDPSSignatureSeverity int64 + +const ( + FirewallPolicyIDPSSignatureSeverityOne FirewallPolicyIDPSSignatureSeverity = 1 + FirewallPolicyIDPSSignatureSeverityThree FirewallPolicyIDPSSignatureSeverity = 3 + FirewallPolicyIDPSSignatureSeverityTwo FirewallPolicyIDPSSignatureSeverity = 2 +) + +func PossibleValuesForFirewallPolicyIDPSSignatureSeverity() []int64 { + return []int64{ + int64(FirewallPolicyIDPSSignatureSeverityOne), + int64(FirewallPolicyIDPSSignatureSeverityThree), + int64(FirewallPolicyIDPSSignatureSeverityTwo), + } +} + +type FirewallPolicyIntrusionDetectionProfileType string + +const ( + FirewallPolicyIntrusionDetectionProfileTypeAdvanced FirewallPolicyIntrusionDetectionProfileType = "Advanced" + FirewallPolicyIntrusionDetectionProfileTypeBasic FirewallPolicyIntrusionDetectionProfileType = "Basic" + FirewallPolicyIntrusionDetectionProfileTypeExtended FirewallPolicyIntrusionDetectionProfileType = "Extended" + FirewallPolicyIntrusionDetectionProfileTypeStandard FirewallPolicyIntrusionDetectionProfileType = "Standard" +) + +func PossibleValuesForFirewallPolicyIntrusionDetectionProfileType() []string { + return []string{ + string(FirewallPolicyIntrusionDetectionProfileTypeAdvanced), + string(FirewallPolicyIntrusionDetectionProfileTypeBasic), + string(FirewallPolicyIntrusionDetectionProfileTypeExtended), + string(FirewallPolicyIntrusionDetectionProfileTypeStandard), + } +} + +func (s *FirewallPolicyIntrusionDetectionProfileType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallPolicyIntrusionDetectionProfileType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallPolicyIntrusionDetectionProfileType(input string) (*FirewallPolicyIntrusionDetectionProfileType, error) { + vals := map[string]FirewallPolicyIntrusionDetectionProfileType{ + "advanced": FirewallPolicyIntrusionDetectionProfileTypeAdvanced, + "basic": FirewallPolicyIntrusionDetectionProfileTypeBasic, + "extended": FirewallPolicyIntrusionDetectionProfileTypeExtended, + "standard": FirewallPolicyIntrusionDetectionProfileTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallPolicyIntrusionDetectionProfileType(input) + return &out, nil +} + +type FirewallPolicyIntrusionDetectionProtocol string + +const ( + FirewallPolicyIntrusionDetectionProtocolANY FirewallPolicyIntrusionDetectionProtocol = "ANY" + FirewallPolicyIntrusionDetectionProtocolICMP FirewallPolicyIntrusionDetectionProtocol = "ICMP" + FirewallPolicyIntrusionDetectionProtocolTCP FirewallPolicyIntrusionDetectionProtocol = "TCP" + FirewallPolicyIntrusionDetectionProtocolUDP FirewallPolicyIntrusionDetectionProtocol = "UDP" +) + +func PossibleValuesForFirewallPolicyIntrusionDetectionProtocol() []string { + return []string{ + string(FirewallPolicyIntrusionDetectionProtocolANY), + string(FirewallPolicyIntrusionDetectionProtocolICMP), + string(FirewallPolicyIntrusionDetectionProtocolTCP), + string(FirewallPolicyIntrusionDetectionProtocolUDP), + } +} + +func (s *FirewallPolicyIntrusionDetectionProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallPolicyIntrusionDetectionProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallPolicyIntrusionDetectionProtocol(input string) (*FirewallPolicyIntrusionDetectionProtocol, error) { + vals := map[string]FirewallPolicyIntrusionDetectionProtocol{ + "any": FirewallPolicyIntrusionDetectionProtocolANY, + "icmp": FirewallPolicyIntrusionDetectionProtocolICMP, + "tcp": FirewallPolicyIntrusionDetectionProtocolTCP, + "udp": FirewallPolicyIntrusionDetectionProtocolUDP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallPolicyIntrusionDetectionProtocol(input) + return &out, nil +} + +type FirewallPolicyIntrusionDetectionStateType string + +const ( + FirewallPolicyIntrusionDetectionStateTypeAlert FirewallPolicyIntrusionDetectionStateType = "Alert" + FirewallPolicyIntrusionDetectionStateTypeDeny FirewallPolicyIntrusionDetectionStateType = "Deny" + FirewallPolicyIntrusionDetectionStateTypeOff FirewallPolicyIntrusionDetectionStateType = "Off" +) + +func PossibleValuesForFirewallPolicyIntrusionDetectionStateType() []string { + return []string{ + string(FirewallPolicyIntrusionDetectionStateTypeAlert), + string(FirewallPolicyIntrusionDetectionStateTypeDeny), + string(FirewallPolicyIntrusionDetectionStateTypeOff), + } +} + +func (s *FirewallPolicyIntrusionDetectionStateType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallPolicyIntrusionDetectionStateType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallPolicyIntrusionDetectionStateType(input string) (*FirewallPolicyIntrusionDetectionStateType, error) { + vals := map[string]FirewallPolicyIntrusionDetectionStateType{ + "alert": FirewallPolicyIntrusionDetectionStateTypeAlert, + "deny": FirewallPolicyIntrusionDetectionStateTypeDeny, + "off": FirewallPolicyIntrusionDetectionStateTypeOff, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallPolicyIntrusionDetectionStateType(input) + return &out, nil +} + +type FirewallPolicyNatRuleCollectionActionType string + +const ( + FirewallPolicyNatRuleCollectionActionTypeDNAT FirewallPolicyNatRuleCollectionActionType = "DNAT" +) + +func PossibleValuesForFirewallPolicyNatRuleCollectionActionType() []string { + return []string{ + string(FirewallPolicyNatRuleCollectionActionTypeDNAT), + } +} + +func (s *FirewallPolicyNatRuleCollectionActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallPolicyNatRuleCollectionActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallPolicyNatRuleCollectionActionType(input string) (*FirewallPolicyNatRuleCollectionActionType, error) { + vals := map[string]FirewallPolicyNatRuleCollectionActionType{ + "dnat": FirewallPolicyNatRuleCollectionActionTypeDNAT, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallPolicyNatRuleCollectionActionType(input) + return &out, nil +} + +type FirewallPolicyRuleApplicationProtocolType string + +const ( + FirewallPolicyRuleApplicationProtocolTypeHTTP FirewallPolicyRuleApplicationProtocolType = "Http" + FirewallPolicyRuleApplicationProtocolTypeHTTPS FirewallPolicyRuleApplicationProtocolType = "Https" +) + +func PossibleValuesForFirewallPolicyRuleApplicationProtocolType() []string { + return []string{ + string(FirewallPolicyRuleApplicationProtocolTypeHTTP), + string(FirewallPolicyRuleApplicationProtocolTypeHTTPS), + } +} + +func (s *FirewallPolicyRuleApplicationProtocolType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallPolicyRuleApplicationProtocolType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallPolicyRuleApplicationProtocolType(input string) (*FirewallPolicyRuleApplicationProtocolType, error) { + vals := map[string]FirewallPolicyRuleApplicationProtocolType{ + "http": FirewallPolicyRuleApplicationProtocolTypeHTTP, + "https": FirewallPolicyRuleApplicationProtocolTypeHTTPS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallPolicyRuleApplicationProtocolType(input) + return &out, nil +} + +type FirewallPolicyRuleCollectionType string + +const ( + FirewallPolicyRuleCollectionTypeFirewallPolicyFilterRuleCollection FirewallPolicyRuleCollectionType = "FirewallPolicyFilterRuleCollection" + FirewallPolicyRuleCollectionTypeFirewallPolicyNatRuleCollection FirewallPolicyRuleCollectionType = "FirewallPolicyNatRuleCollection" +) + +func PossibleValuesForFirewallPolicyRuleCollectionType() []string { + return []string{ + string(FirewallPolicyRuleCollectionTypeFirewallPolicyFilterRuleCollection), + string(FirewallPolicyRuleCollectionTypeFirewallPolicyNatRuleCollection), + } +} + +func (s *FirewallPolicyRuleCollectionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallPolicyRuleCollectionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallPolicyRuleCollectionType(input string) (*FirewallPolicyRuleCollectionType, error) { + vals := map[string]FirewallPolicyRuleCollectionType{ + "firewallpolicyfilterrulecollection": FirewallPolicyRuleCollectionTypeFirewallPolicyFilterRuleCollection, + "firewallpolicynatrulecollection": FirewallPolicyRuleCollectionTypeFirewallPolicyNatRuleCollection, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallPolicyRuleCollectionType(input) + return &out, nil +} + +type FirewallPolicyRuleNetworkProtocol string + +const ( + FirewallPolicyRuleNetworkProtocolAny FirewallPolicyRuleNetworkProtocol = "Any" + FirewallPolicyRuleNetworkProtocolICMP FirewallPolicyRuleNetworkProtocol = "ICMP" + FirewallPolicyRuleNetworkProtocolTCP FirewallPolicyRuleNetworkProtocol = "TCP" + FirewallPolicyRuleNetworkProtocolUDP FirewallPolicyRuleNetworkProtocol = "UDP" +) + +func PossibleValuesForFirewallPolicyRuleNetworkProtocol() []string { + return []string{ + string(FirewallPolicyRuleNetworkProtocolAny), + string(FirewallPolicyRuleNetworkProtocolICMP), + string(FirewallPolicyRuleNetworkProtocolTCP), + string(FirewallPolicyRuleNetworkProtocolUDP), + } +} + +func (s *FirewallPolicyRuleNetworkProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallPolicyRuleNetworkProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallPolicyRuleNetworkProtocol(input string) (*FirewallPolicyRuleNetworkProtocol, error) { + vals := map[string]FirewallPolicyRuleNetworkProtocol{ + "any": FirewallPolicyRuleNetworkProtocolAny, + "icmp": FirewallPolicyRuleNetworkProtocolICMP, + "tcp": FirewallPolicyRuleNetworkProtocolTCP, + "udp": FirewallPolicyRuleNetworkProtocolUDP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallPolicyRuleNetworkProtocol(input) + return &out, nil +} + +type FirewallPolicyRuleType string + +const ( + FirewallPolicyRuleTypeApplicationRule FirewallPolicyRuleType = "ApplicationRule" + FirewallPolicyRuleTypeNatRule FirewallPolicyRuleType = "NatRule" + FirewallPolicyRuleTypeNetworkRule FirewallPolicyRuleType = "NetworkRule" +) + +func PossibleValuesForFirewallPolicyRuleType() []string { + return []string{ + string(FirewallPolicyRuleTypeApplicationRule), + string(FirewallPolicyRuleTypeNatRule), + string(FirewallPolicyRuleTypeNetworkRule), + } +} + +func (s *FirewallPolicyRuleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallPolicyRuleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallPolicyRuleType(input string) (*FirewallPolicyRuleType, error) { + vals := map[string]FirewallPolicyRuleType{ + "applicationrule": FirewallPolicyRuleTypeApplicationRule, + "natrule": FirewallPolicyRuleTypeNatRule, + "networkrule": FirewallPolicyRuleTypeNetworkRule, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallPolicyRuleType(input) + return &out, nil +} + +type FirewallPolicySkuTier string + +const ( + FirewallPolicySkuTierBasic FirewallPolicySkuTier = "Basic" + FirewallPolicySkuTierPremium FirewallPolicySkuTier = "Premium" + FirewallPolicySkuTierStandard FirewallPolicySkuTier = "Standard" +) + +func PossibleValuesForFirewallPolicySkuTier() []string { + return []string{ + string(FirewallPolicySkuTierBasic), + string(FirewallPolicySkuTierPremium), + string(FirewallPolicySkuTierStandard), + } +} + +func (s *FirewallPolicySkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallPolicySkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallPolicySkuTier(input string) (*FirewallPolicySkuTier, error) { + vals := map[string]FirewallPolicySkuTier{ + "basic": FirewallPolicySkuTierBasic, + "premium": FirewallPolicySkuTierPremium, + "standard": FirewallPolicySkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallPolicySkuTier(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/id_firewallpolicy.go b/resource-manager/network/2024-07-01/firewallpolicies/id_firewallpolicy.go new file mode 100644 index 00000000000..fdb530b0470 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/id_firewallpolicy.go @@ -0,0 +1,130 @@ +package firewallpolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&FirewallPolicyId{}) +} + +var _ resourceids.ResourceId = &FirewallPolicyId{} + +// FirewallPolicyId is a struct representing the Resource ID for a Firewall Policy +type FirewallPolicyId struct { + SubscriptionId string + ResourceGroupName string + FirewallPolicyName string +} + +// NewFirewallPolicyID returns a new FirewallPolicyId struct +func NewFirewallPolicyID(subscriptionId string, resourceGroupName string, firewallPolicyName string) FirewallPolicyId { + return FirewallPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FirewallPolicyName: firewallPolicyName, + } +} + +// ParseFirewallPolicyID parses 'input' into a FirewallPolicyId +func ParseFirewallPolicyID(input string) (*FirewallPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&FirewallPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FirewallPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFirewallPolicyIDInsensitively parses 'input' case-insensitively into a FirewallPolicyId +// note: this method should only be used for API response data and not user input +func ParseFirewallPolicyIDInsensitively(input string) (*FirewallPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&FirewallPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FirewallPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FirewallPolicyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.FirewallPolicyName, ok = input.Parsed["firewallPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "firewallPolicyName", input) + } + + return nil +} + +// ValidateFirewallPolicyID checks that 'input' can be parsed as a Firewall Policy ID +func ValidateFirewallPolicyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseFirewallPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Firewall Policy ID +func (id FirewallPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/firewallPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FirewallPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Firewall Policy ID +func (id FirewallPolicyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticFirewallPolicies", "firewallPolicies", "firewallPolicies"), + resourceids.UserSpecifiedSegment("firewallPolicyName", "firewallPolicyName"), + } +} + +// String returns a human-readable description of this Firewall Policy ID +func (id FirewallPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Firewall Policy Name: %q", id.FirewallPolicyName), + } + return fmt.Sprintf("Firewall Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/id_firewallpolicy_test.go b/resource-manager/network/2024-07-01/firewallpolicies/id_firewallpolicy_test.go new file mode 100644 index 00000000000..000de24b284 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/id_firewallpolicy_test.go @@ -0,0 +1,282 @@ +package firewallpolicies + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &FirewallPolicyId{} + +func TestNewFirewallPolicyID(t *testing.T) { + id := NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.FirewallPolicyName != "firewallPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'FirewallPolicyName'", id.FirewallPolicyName, "firewallPolicyName") + } +} + +func TestFormatFirewallPolicyID(t *testing.T) { + actual := NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFirewallPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FirewallPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName", + Expected: &FirewallPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FirewallPolicyName: "firewallPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFirewallPolicyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.FirewallPolicyName != v.Expected.FirewallPolicyName { + t.Fatalf("Expected %q but got %q for FirewallPolicyName", v.Expected.FirewallPolicyName, actual.FirewallPolicyName) + } + + } +} + +func TestParseFirewallPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FirewallPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/fIrEwAlLpOlIcIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName", + Expected: &FirewallPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FirewallPolicyName: "firewallPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/fIrEwAlLpOlIcIeS/fIrEwAlLpOlIcYnAmE", + Expected: &FirewallPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FirewallPolicyName: "fIrEwAlLpOlIcYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/fIrEwAlLpOlIcIeS/fIrEwAlLpOlIcYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFirewallPolicyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.FirewallPolicyName != v.Expected.FirewallPolicyName { + t.Fatalf("Expected %q but got %q for FirewallPolicyName", v.Expected.FirewallPolicyName, actual.FirewallPolicyName) + } + + } +} + +func TestSegmentsForFirewallPolicyId(t *testing.T) { + segments := FirewallPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FirewallPolicyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/id_rulecollectiongroup.go b/resource-manager/network/2024-07-01/firewallpolicies/id_rulecollectiongroup.go new file mode 100644 index 00000000000..66f9d049a7c --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/id_rulecollectiongroup.go @@ -0,0 +1,139 @@ +package firewallpolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RuleCollectionGroupId{}) +} + +var _ resourceids.ResourceId = &RuleCollectionGroupId{} + +// RuleCollectionGroupId is a struct representing the Resource ID for a Rule Collection Group +type RuleCollectionGroupId struct { + SubscriptionId string + ResourceGroupName string + FirewallPolicyName string + RuleCollectionGroupName string +} + +// NewRuleCollectionGroupID returns a new RuleCollectionGroupId struct +func NewRuleCollectionGroupID(subscriptionId string, resourceGroupName string, firewallPolicyName string, ruleCollectionGroupName string) RuleCollectionGroupId { + return RuleCollectionGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FirewallPolicyName: firewallPolicyName, + RuleCollectionGroupName: ruleCollectionGroupName, + } +} + +// ParseRuleCollectionGroupID parses 'input' into a RuleCollectionGroupId +func ParseRuleCollectionGroupID(input string) (*RuleCollectionGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleCollectionGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleCollectionGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRuleCollectionGroupIDInsensitively parses 'input' case-insensitively into a RuleCollectionGroupId +// note: this method should only be used for API response data and not user input +func ParseRuleCollectionGroupIDInsensitively(input string) (*RuleCollectionGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleCollectionGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleCollectionGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RuleCollectionGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.FirewallPolicyName, ok = input.Parsed["firewallPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "firewallPolicyName", input) + } + + if id.RuleCollectionGroupName, ok = input.Parsed["ruleCollectionGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleCollectionGroupName", input) + } + + return nil +} + +// ValidateRuleCollectionGroupID checks that 'input' can be parsed as a Rule Collection Group ID +func ValidateRuleCollectionGroupID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRuleCollectionGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rule Collection Group ID +func (id RuleCollectionGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/firewallPolicies/%s/ruleCollectionGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FirewallPolicyName, id.RuleCollectionGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rule Collection Group ID +func (id RuleCollectionGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticFirewallPolicies", "firewallPolicies", "firewallPolicies"), + resourceids.UserSpecifiedSegment("firewallPolicyName", "firewallPolicyName"), + resourceids.StaticSegment("staticRuleCollectionGroups", "ruleCollectionGroups", "ruleCollectionGroups"), + resourceids.UserSpecifiedSegment("ruleCollectionGroupName", "ruleCollectionGroupName"), + } +} + +// String returns a human-readable description of this Rule Collection Group ID +func (id RuleCollectionGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Firewall Policy Name: %q", id.FirewallPolicyName), + fmt.Sprintf("Rule Collection Group Name: %q", id.RuleCollectionGroupName), + } + return fmt.Sprintf("Rule Collection Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/id_rulecollectiongroup_test.go b/resource-manager/network/2024-07-01/firewallpolicies/id_rulecollectiongroup_test.go new file mode 100644 index 00000000000..4992adde5de --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/id_rulecollectiongroup_test.go @@ -0,0 +1,327 @@ +package firewallpolicies + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RuleCollectionGroupId{} + +func TestNewRuleCollectionGroupID(t *testing.T) { + id := NewRuleCollectionGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName", "ruleCollectionGroupName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.FirewallPolicyName != "firewallPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'FirewallPolicyName'", id.FirewallPolicyName, "firewallPolicyName") + } + + if id.RuleCollectionGroupName != "ruleCollectionGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleCollectionGroupName'", id.RuleCollectionGroupName, "ruleCollectionGroupName") + } +} + +func TestFormatRuleCollectionGroupID(t *testing.T) { + actual := NewRuleCollectionGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName", "ruleCollectionGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/ruleCollectionGroups/ruleCollectionGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRuleCollectionGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleCollectionGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/ruleCollectionGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/ruleCollectionGroups/ruleCollectionGroupName", + Expected: &RuleCollectionGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FirewallPolicyName: "firewallPolicyName", + RuleCollectionGroupName: "ruleCollectionGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/ruleCollectionGroups/ruleCollectionGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleCollectionGroupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.FirewallPolicyName != v.Expected.FirewallPolicyName { + t.Fatalf("Expected %q but got %q for FirewallPolicyName", v.Expected.FirewallPolicyName, actual.FirewallPolicyName) + } + + if actual.RuleCollectionGroupName != v.Expected.RuleCollectionGroupName { + t.Fatalf("Expected %q but got %q for RuleCollectionGroupName", v.Expected.RuleCollectionGroupName, actual.RuleCollectionGroupName) + } + + } +} + +func TestParseRuleCollectionGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleCollectionGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/fIrEwAlLpOlIcIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/fIrEwAlLpOlIcIeS/fIrEwAlLpOlIcYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/ruleCollectionGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/fIrEwAlLpOlIcIeS/fIrEwAlLpOlIcYnAmE/rUlEcOlLeCtIoNgRoUpS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/ruleCollectionGroups/ruleCollectionGroupName", + Expected: &RuleCollectionGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FirewallPolicyName: "firewallPolicyName", + RuleCollectionGroupName: "ruleCollectionGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/ruleCollectionGroups/ruleCollectionGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/fIrEwAlLpOlIcIeS/fIrEwAlLpOlIcYnAmE/rUlEcOlLeCtIoNgRoUpS/rUlEcOlLeCtIoNgRoUpNaMe", + Expected: &RuleCollectionGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FirewallPolicyName: "fIrEwAlLpOlIcYnAmE", + RuleCollectionGroupName: "rUlEcOlLeCtIoNgRoUpNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/fIrEwAlLpOlIcIeS/fIrEwAlLpOlIcYnAmE/rUlEcOlLeCtIoNgRoUpS/rUlEcOlLeCtIoNgRoUpNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleCollectionGroupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.FirewallPolicyName != v.Expected.FirewallPolicyName { + t.Fatalf("Expected %q but got %q for FirewallPolicyName", v.Expected.FirewallPolicyName, actual.FirewallPolicyName) + } + + if actual.RuleCollectionGroupName != v.Expected.RuleCollectionGroupName { + t.Fatalf("Expected %q but got %q for RuleCollectionGroupName", v.Expected.RuleCollectionGroupName, actual.RuleCollectionGroupName) + } + + } +} + +func TestSegmentsForRuleCollectionGroupId(t *testing.T) { + segments := RuleCollectionGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RuleCollectionGroupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_createorupdate.go b/resource-manager/network/2024-07-01/firewallpolicies/method_createorupdate.go new file mode 100644 index 00000000000..0492bbef61e --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_createorupdate.go @@ -0,0 +1,75 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *FirewallPolicy +} + +// CreateOrUpdate ... +func (c FirewallPoliciesClient) CreateOrUpdate(ctx context.Context, id FirewallPolicyId, input FirewallPolicy) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c FirewallPoliciesClient) CreateOrUpdateThenPoll(ctx context.Context, id FirewallPolicyId, input FirewallPolicy) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_delete.go b/resource-manager/network/2024-07-01/firewallpolicies/method_delete.go new file mode 100644 index 00000000000..432932fda66 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_delete.go @@ -0,0 +1,71 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c FirewallPoliciesClient) Delete(ctx context.Context, id FirewallPolicyId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c FirewallPoliciesClient) DeleteThenPoll(ctx context.Context, id FirewallPolicyId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicydeploymentsdeploy.go b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicydeploymentsdeploy.go new file mode 100644 index 00000000000..2b0ff5b7afe --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicydeploymentsdeploy.go @@ -0,0 +1,69 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyDeploymentsDeployOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// FirewallPolicyDeploymentsDeploy ... +func (c FirewallPoliciesClient) FirewallPolicyDeploymentsDeploy(ctx context.Context, id FirewallPolicyId) (result FirewallPolicyDeploymentsDeployOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// FirewallPolicyDeploymentsDeployThenPoll performs FirewallPolicyDeploymentsDeploy then polls until it's completed +func (c FirewallPoliciesClient) FirewallPolicyDeploymentsDeployThenPoll(ctx context.Context, id FirewallPolicyId) error { + result, err := c.FirewallPolicyDeploymentsDeploy(ctx, id) + if err != nil { + return fmt.Errorf("performing FirewallPolicyDeploymentsDeploy: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after FirewallPolicyDeploymentsDeploy: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicydraftscreateorupdate.go b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicydraftscreateorupdate.go new file mode 100644 index 00000000000..a355d78a767 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicydraftscreateorupdate.go @@ -0,0 +1,59 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyDraftsCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FirewallPolicyDraft +} + +// FirewallPolicyDraftsCreateOrUpdate ... +func (c FirewallPoliciesClient) FirewallPolicyDraftsCreateOrUpdate(ctx context.Context, id FirewallPolicyId, input FirewallPolicyDraft) (result FirewallPolicyDraftsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/firewallPolicyDrafts/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FirewallPolicyDraft + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicydraftsdelete.go b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicydraftsdelete.go new file mode 100644 index 00000000000..a0fd3352ff2 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicydraftsdelete.go @@ -0,0 +1,48 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyDraftsDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// FirewallPolicyDraftsDelete ... +func (c FirewallPoliciesClient) FirewallPolicyDraftsDelete(ctx context.Context, id FirewallPolicyId) (result FirewallPolicyDraftsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/firewallPolicyDrafts/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicydraftsget.go b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicydraftsget.go new file mode 100644 index 00000000000..804027dd952 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicydraftsget.go @@ -0,0 +1,54 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyDraftsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FirewallPolicyDraft +} + +// FirewallPolicyDraftsGet ... +func (c FirewallPoliciesClient) FirewallPolicyDraftsGet(ctx context.Context, id FirewallPolicyId) (result FirewallPolicyDraftsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/firewallPolicyDrafts/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FirewallPolicyDraft + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignaturesfiltervalueslist.go b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignaturesfiltervalueslist.go new file mode 100644 index 00000000000..afb4f37a3fa --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignaturesfiltervalueslist.go @@ -0,0 +1,58 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyIdpsSignaturesFilterValuesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SignatureOverridesFilterValuesResponse +} + +// FirewallPolicyIdpsSignaturesFilterValuesList ... +func (c FirewallPoliciesClient) FirewallPolicyIdpsSignaturesFilterValuesList(ctx context.Context, id FirewallPolicyId, input SignatureOverridesFilterValuesQuery) (result FirewallPolicyIdpsSignaturesFilterValuesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listIdpsFilterOptions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SignatureOverridesFilterValuesResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignatureslist.go b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignatureslist.go new file mode 100644 index 00000000000..657d39e5a74 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignatureslist.go @@ -0,0 +1,58 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyIdpsSignaturesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *QueryResults +} + +// FirewallPolicyIdpsSignaturesList ... +func (c FirewallPoliciesClient) FirewallPolicyIdpsSignaturesList(ctx context.Context, id FirewallPolicyId, input IDPSQueryObject) (result FirewallPolicyIdpsSignaturesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listIdpsSignatures", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model QueryResults + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignaturesoverridesget.go b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignaturesoverridesget.go new file mode 100644 index 00000000000..4ff22b6ea42 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignaturesoverridesget.go @@ -0,0 +1,54 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyIdpsSignaturesOverridesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SignaturesOverrides +} + +// FirewallPolicyIdpsSignaturesOverridesGet ... +func (c FirewallPoliciesClient) FirewallPolicyIdpsSignaturesOverridesGet(ctx context.Context, id FirewallPolicyId) (result FirewallPolicyIdpsSignaturesOverridesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/signatureOverrides/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SignaturesOverrides + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignaturesoverrideslist.go b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignaturesoverrideslist.go new file mode 100644 index 00000000000..253dc4d8073 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignaturesoverrideslist.go @@ -0,0 +1,54 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyIdpsSignaturesOverridesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SignaturesOverridesList +} + +// FirewallPolicyIdpsSignaturesOverridesList ... +func (c FirewallPoliciesClient) FirewallPolicyIdpsSignaturesOverridesList(ctx context.Context, id FirewallPolicyId) (result FirewallPolicyIdpsSignaturesOverridesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/signatureOverrides", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SignaturesOverridesList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignaturesoverridespatch.go b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignaturesoverridespatch.go new file mode 100644 index 00000000000..ebb6a03296b --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignaturesoverridespatch.go @@ -0,0 +1,58 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyIdpsSignaturesOverridesPatchOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SignaturesOverrides +} + +// FirewallPolicyIdpsSignaturesOverridesPatch ... +func (c FirewallPoliciesClient) FirewallPolicyIdpsSignaturesOverridesPatch(ctx context.Context, id FirewallPolicyId, input SignaturesOverrides) (result FirewallPolicyIdpsSignaturesOverridesPatchOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/signatureOverrides/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SignaturesOverrides + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignaturesoverridesput.go b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignaturesoverridesput.go new file mode 100644 index 00000000000..51a0cf8dcc5 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyidpssignaturesoverridesput.go @@ -0,0 +1,58 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyIdpsSignaturesOverridesPutOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SignaturesOverrides +} + +// FirewallPolicyIdpsSignaturesOverridesPut ... +func (c FirewallPoliciesClient) FirewallPolicyIdpsSignaturesOverridesPut(ctx context.Context, id FirewallPolicyId, input SignaturesOverrides) (result FirewallPolicyIdpsSignaturesOverridesPutOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/signatureOverrides/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SignaturesOverrides + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyrulecollectiongroupdraftscreateorupdate.go b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyrulecollectiongroupdraftscreateorupdate.go new file mode 100644 index 00000000000..168eab6a2f2 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyrulecollectiongroupdraftscreateorupdate.go @@ -0,0 +1,59 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyRuleCollectionGroupDraftsCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FirewallPolicyRuleCollectionGroupDraft +} + +// FirewallPolicyRuleCollectionGroupDraftsCreateOrUpdate ... +func (c FirewallPoliciesClient) FirewallPolicyRuleCollectionGroupDraftsCreateOrUpdate(ctx context.Context, id RuleCollectionGroupId, input FirewallPolicyRuleCollectionGroupDraft) (result FirewallPolicyRuleCollectionGroupDraftsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/ruleCollectionGroupDrafts/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FirewallPolicyRuleCollectionGroupDraft + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyrulecollectiongroupdraftsdelete.go b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyrulecollectiongroupdraftsdelete.go new file mode 100644 index 00000000000..da02af84b53 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyrulecollectiongroupdraftsdelete.go @@ -0,0 +1,48 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyRuleCollectionGroupDraftsDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// FirewallPolicyRuleCollectionGroupDraftsDelete ... +func (c FirewallPoliciesClient) FirewallPolicyRuleCollectionGroupDraftsDelete(ctx context.Context, id RuleCollectionGroupId) (result FirewallPolicyRuleCollectionGroupDraftsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/ruleCollectionGroupDrafts/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyrulecollectiongroupdraftsget.go b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyrulecollectiongroupdraftsget.go new file mode 100644 index 00000000000..8d2027a6a40 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_firewallpolicyrulecollectiongroupdraftsget.go @@ -0,0 +1,54 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyRuleCollectionGroupDraftsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FirewallPolicyRuleCollectionGroupDraft +} + +// FirewallPolicyRuleCollectionGroupDraftsGet ... +func (c FirewallPoliciesClient) FirewallPolicyRuleCollectionGroupDraftsGet(ctx context.Context, id RuleCollectionGroupId) (result FirewallPolicyRuleCollectionGroupDraftsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/ruleCollectionGroupDrafts/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FirewallPolicyRuleCollectionGroupDraft + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_get.go b/resource-manager/network/2024-07-01/firewallpolicies/method_get.go new file mode 100644 index 00000000000..c57af3124f0 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_get.go @@ -0,0 +1,83 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FirewallPolicy +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c FirewallPoliciesClient) Get(ctx context.Context, id FirewallPolicyId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FirewallPolicy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_list.go b/resource-manager/network/2024-07-01/firewallpolicies/method_list.go new file mode 100644 index 00000000000..84096e094ce --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_list.go @@ -0,0 +1,106 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FirewallPolicy +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []FirewallPolicy +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c FirewallPoliciesClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/firewallPolicies", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FirewallPolicy `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c FirewallPoliciesClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, FirewallPolicyOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FirewallPoliciesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate FirewallPolicyOperationPredicate) (result ListCompleteResult, err error) { + items := make([]FirewallPolicy, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_listall.go b/resource-manager/network/2024-07-01/firewallpolicies/method_listall.go new file mode 100644 index 00000000000..8b1106b1f8b --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_listall.go @@ -0,0 +1,106 @@ +package firewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FirewallPolicy +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []FirewallPolicy +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c FirewallPoliciesClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/firewallPolicies", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FirewallPolicy `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c FirewallPoliciesClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, FirewallPolicyOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FirewallPoliciesClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate FirewallPolicyOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]FirewallPolicy, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/method_updatetags.go b/resource-manager/network/2024-07-01/firewallpolicies/method_updatetags.go new file mode 100644 index 00000000000..66cfb5cb6d4 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/method_updatetags.go @@ -0,0 +1,57 @@ +package firewallpolicies + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FirewallPolicy +} + +// UpdateTags ... +func (c FirewallPoliciesClient) UpdateTags(ctx context.Context, id FirewallPolicyId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FirewallPolicy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_applicationrule.go b/resource-manager/network/2024-07-01/firewallpolicies/model_applicationrule.go new file mode 100644 index 00000000000..151ed288bae --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_applicationrule.go @@ -0,0 +1,63 @@ +package firewallpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FirewallPolicyRule = ApplicationRule{} + +type ApplicationRule struct { + DestinationAddresses *[]string `json:"destinationAddresses,omitempty"` + FqdnTags *[]string `json:"fqdnTags,omitempty"` + HTTPHeadersToInsert *[]FirewallPolicyHTTPHeaderToInsert `json:"httpHeadersToInsert,omitempty"` + Protocols *[]FirewallPolicyRuleApplicationProtocol `json:"protocols,omitempty"` + SourceAddresses *[]string `json:"sourceAddresses,omitempty"` + SourceIPGroups *[]string `json:"sourceIpGroups,omitempty"` + TargetFqdns *[]string `json:"targetFqdns,omitempty"` + TargetURLs *[]string `json:"targetUrls,omitempty"` + TerminateTLS *bool `json:"terminateTLS,omitempty"` + WebCategories *[]string `json:"webCategories,omitempty"` + + // Fields inherited from FirewallPolicyRule + + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + RuleType FirewallPolicyRuleType `json:"ruleType"` +} + +func (s ApplicationRule) FirewallPolicyRule() BaseFirewallPolicyRuleImpl { + return BaseFirewallPolicyRuleImpl{ + Description: s.Description, + Name: s.Name, + RuleType: s.RuleType, + } +} + +var _ json.Marshaler = ApplicationRule{} + +func (s ApplicationRule) MarshalJSON() ([]byte, error) { + type wrapper ApplicationRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ApplicationRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ApplicationRule: %+v", err) + } + + decoded["ruleType"] = "ApplicationRule" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ApplicationRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_dnssettings.go b/resource-manager/network/2024-07-01/firewallpolicies/model_dnssettings.go new file mode 100644 index 00000000000..6983f66f9dd --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_dnssettings.go @@ -0,0 +1,10 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DnsSettings struct { + EnableProxy *bool `json:"enableProxy,omitempty"` + RequireProxyForNetworkRules *bool `json:"requireProxyForNetworkRules,omitempty"` + Servers *[]string `json:"servers,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_explicitproxy.go b/resource-manager/network/2024-07-01/firewallpolicies/model_explicitproxy.go new file mode 100644 index 00000000000..d8af7221ddf --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_explicitproxy.go @@ -0,0 +1,13 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExplicitProxy struct { + EnableExplicitProxy *bool `json:"enableExplicitProxy,omitempty"` + EnablePacFile *bool `json:"enablePacFile,omitempty"` + HTTPPort *int64 `json:"httpPort,omitempty"` + HTTPSPort *int64 `json:"httpsPort,omitempty"` + PacFile *string `json:"pacFile,omitempty"` + PacFilePort *int64 `json:"pacFilePort,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_filteritems.go b/resource-manager/network/2024-07-01/firewallpolicies/model_filteritems.go new file mode 100644 index 00000000000..943657d23f0 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_filteritems.go @@ -0,0 +1,9 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FilterItems struct { + Field *string `json:"field,omitempty"` + Values *[]string `json:"values,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicy.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicy.go new file mode 100644 index 00000000000..fb85165c9d9 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicy.go @@ -0,0 +1,19 @@ +package firewallpolicies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FirewallPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicycertificateauthority.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicycertificateauthority.go new file mode 100644 index 00000000000..b1d1e5fcdd8 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicycertificateauthority.go @@ -0,0 +1,9 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyCertificateAuthority struct { + KeyVaultSecretId *string `json:"keyVaultSecretId,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicydraft.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicydraft.go new file mode 100644 index 00000000000..1f156e948dd --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicydraft.go @@ -0,0 +1,13 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyDraft struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FirewallPolicyDraftProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicydraftproperties.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicydraftproperties.go new file mode 100644 index 00000000000..7303ad731f2 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicydraftproperties.go @@ -0,0 +1,16 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyDraftProperties struct { + BasePolicy *SubResource `json:"basePolicy,omitempty"` + DnsSettings *DnsSettings `json:"dnsSettings,omitempty"` + ExplicitProxy *ExplicitProxy `json:"explicitProxy,omitempty"` + Insights *FirewallPolicyInsights `json:"insights,omitempty"` + IntrusionDetection *FirewallPolicyIntrusionDetection `json:"intrusionDetection,omitempty"` + Snat *FirewallPolicySNAT `json:"snat,omitempty"` + Sql *FirewallPolicySQL `json:"sql,omitempty"` + ThreatIntelMode *AzureFirewallThreatIntelMode `json:"threatIntelMode,omitempty"` + ThreatIntelWhitelist *FirewallPolicyThreatIntelWhitelist `json:"threatIntelWhitelist,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyfilterrulecollection.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyfilterrulecollection.go new file mode 100644 index 00000000000..1253bbae742 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyfilterrulecollection.go @@ -0,0 +1,98 @@ +package firewallpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FirewallPolicyRuleCollection = FirewallPolicyFilterRuleCollection{} + +type FirewallPolicyFilterRuleCollection struct { + Action *FirewallPolicyFilterRuleCollectionAction `json:"action,omitempty"` + Rules *[]FirewallPolicyRule `json:"rules,omitempty"` + + // Fields inherited from FirewallPolicyRuleCollection + + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + RuleCollectionType FirewallPolicyRuleCollectionType `json:"ruleCollectionType"` +} + +func (s FirewallPolicyFilterRuleCollection) FirewallPolicyRuleCollection() BaseFirewallPolicyRuleCollectionImpl { + return BaseFirewallPolicyRuleCollectionImpl{ + Name: s.Name, + Priority: s.Priority, + RuleCollectionType: s.RuleCollectionType, + } +} + +var _ json.Marshaler = FirewallPolicyFilterRuleCollection{} + +func (s FirewallPolicyFilterRuleCollection) MarshalJSON() ([]byte, error) { + type wrapper FirewallPolicyFilterRuleCollection + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FirewallPolicyFilterRuleCollection: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FirewallPolicyFilterRuleCollection: %+v", err) + } + + decoded["ruleCollectionType"] = "FirewallPolicyFilterRuleCollection" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FirewallPolicyFilterRuleCollection: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &FirewallPolicyFilterRuleCollection{} + +func (s *FirewallPolicyFilterRuleCollection) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Action *FirewallPolicyFilterRuleCollectionAction `json:"action,omitempty"` + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + RuleCollectionType FirewallPolicyRuleCollectionType `json:"ruleCollectionType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Action = decoded.Action + s.Name = decoded.Name + s.Priority = decoded.Priority + s.RuleCollectionType = decoded.RuleCollectionType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling FirewallPolicyFilterRuleCollection into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["rules"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling Rules into list []json.RawMessage: %+v", err) + } + + output := make([]FirewallPolicyRule, 0) + for i, val := range listTemp { + impl, err := UnmarshalFirewallPolicyRuleImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'Rules' for 'FirewallPolicyFilterRuleCollection': %+v", i, err) + } + output = append(output, impl) + } + s.Rules = &output + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyfilterrulecollectionaction.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyfilterrulecollectionaction.go new file mode 100644 index 00000000000..fdd82344dc1 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyfilterrulecollectionaction.go @@ -0,0 +1,8 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyFilterRuleCollectionAction struct { + Type *FirewallPolicyFilterRuleCollectionActionType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyhttpheadertoinsert.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyhttpheadertoinsert.go new file mode 100644 index 00000000000..27586a9bc9d --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyhttpheadertoinsert.go @@ -0,0 +1,9 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyHTTPHeaderToInsert struct { + HeaderName *string `json:"headerName,omitempty"` + HeaderValue *string `json:"headerValue,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyinsights.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyinsights.go new file mode 100644 index 00000000000..5af7b2e446d --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyinsights.go @@ -0,0 +1,10 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyInsights struct { + IsEnabled *bool `json:"isEnabled,omitempty"` + LogAnalyticsResources *FirewallPolicyLogAnalyticsResources `json:"logAnalyticsResources,omitempty"` + RetentionDays *int64 `json:"retentionDays,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyintrusiondetection.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyintrusiondetection.go new file mode 100644 index 00000000000..f51c93257c5 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyintrusiondetection.go @@ -0,0 +1,10 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyIntrusionDetection struct { + Configuration *FirewallPolicyIntrusionDetectionConfiguration `json:"configuration,omitempty"` + Mode *FirewallPolicyIntrusionDetectionStateType `json:"mode,omitempty"` + Profile *FirewallPolicyIntrusionDetectionProfileType `json:"profile,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyintrusiondetectionbypasstrafficspecifications.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyintrusiondetectionbypasstrafficspecifications.go new file mode 100644 index 00000000000..088a6c5515f --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyintrusiondetectionbypasstrafficspecifications.go @@ -0,0 +1,15 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyIntrusionDetectionBypassTrafficSpecifications struct { + Description *string `json:"description,omitempty"` + DestinationAddresses *[]string `json:"destinationAddresses,omitempty"` + DestinationIPGroups *[]string `json:"destinationIpGroups,omitempty"` + DestinationPorts *[]string `json:"destinationPorts,omitempty"` + Name *string `json:"name,omitempty"` + Protocol *FirewallPolicyIntrusionDetectionProtocol `json:"protocol,omitempty"` + SourceAddresses *[]string `json:"sourceAddresses,omitempty"` + SourceIPGroups *[]string `json:"sourceIpGroups,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyintrusiondetectionconfiguration.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyintrusiondetectionconfiguration.go new file mode 100644 index 00000000000..dce919867c0 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyintrusiondetectionconfiguration.go @@ -0,0 +1,10 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyIntrusionDetectionConfiguration struct { + BypassTrafficSettings *[]FirewallPolicyIntrusionDetectionBypassTrafficSpecifications `json:"bypassTrafficSettings,omitempty"` + PrivateRanges *[]string `json:"privateRanges,omitempty"` + SignatureOverrides *[]FirewallPolicyIntrusionDetectionSignatureSpecification `json:"signatureOverrides,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyintrusiondetectionsignaturespecification.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyintrusiondetectionsignaturespecification.go new file mode 100644 index 00000000000..2bae7fe0f04 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyintrusiondetectionsignaturespecification.go @@ -0,0 +1,9 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyIntrusionDetectionSignatureSpecification struct { + Id *string `json:"id,omitempty"` + Mode *FirewallPolicyIntrusionDetectionStateType `json:"mode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyloganalyticsresources.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyloganalyticsresources.go new file mode 100644 index 00000000000..4f1280d942b --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyloganalyticsresources.go @@ -0,0 +1,9 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyLogAnalyticsResources struct { + DefaultWorkspaceId *SubResource `json:"defaultWorkspaceId,omitempty"` + Workspaces *[]FirewallPolicyLogAnalyticsWorkspace `json:"workspaces,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyloganalyticsworkspace.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyloganalyticsworkspace.go new file mode 100644 index 00000000000..4cc72aa7cbb --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyloganalyticsworkspace.go @@ -0,0 +1,9 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyLogAnalyticsWorkspace struct { + Region *string `json:"region,omitempty"` + WorkspaceId *SubResource `json:"workspaceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicynatrulecollection.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicynatrulecollection.go new file mode 100644 index 00000000000..8bb8e5f0f6a --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicynatrulecollection.go @@ -0,0 +1,98 @@ +package firewallpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FirewallPolicyRuleCollection = FirewallPolicyNatRuleCollection{} + +type FirewallPolicyNatRuleCollection struct { + Action *FirewallPolicyNatRuleCollectionAction `json:"action,omitempty"` + Rules *[]FirewallPolicyRule `json:"rules,omitempty"` + + // Fields inherited from FirewallPolicyRuleCollection + + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + RuleCollectionType FirewallPolicyRuleCollectionType `json:"ruleCollectionType"` +} + +func (s FirewallPolicyNatRuleCollection) FirewallPolicyRuleCollection() BaseFirewallPolicyRuleCollectionImpl { + return BaseFirewallPolicyRuleCollectionImpl{ + Name: s.Name, + Priority: s.Priority, + RuleCollectionType: s.RuleCollectionType, + } +} + +var _ json.Marshaler = FirewallPolicyNatRuleCollection{} + +func (s FirewallPolicyNatRuleCollection) MarshalJSON() ([]byte, error) { + type wrapper FirewallPolicyNatRuleCollection + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FirewallPolicyNatRuleCollection: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FirewallPolicyNatRuleCollection: %+v", err) + } + + decoded["ruleCollectionType"] = "FirewallPolicyNatRuleCollection" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FirewallPolicyNatRuleCollection: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &FirewallPolicyNatRuleCollection{} + +func (s *FirewallPolicyNatRuleCollection) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Action *FirewallPolicyNatRuleCollectionAction `json:"action,omitempty"` + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + RuleCollectionType FirewallPolicyRuleCollectionType `json:"ruleCollectionType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Action = decoded.Action + s.Name = decoded.Name + s.Priority = decoded.Priority + s.RuleCollectionType = decoded.RuleCollectionType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling FirewallPolicyNatRuleCollection into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["rules"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling Rules into list []json.RawMessage: %+v", err) + } + + output := make([]FirewallPolicyRule, 0) + for i, val := range listTemp { + impl, err := UnmarshalFirewallPolicyRuleImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'Rules' for 'FirewallPolicyNatRuleCollection': %+v", i, err) + } + output = append(output, impl) + } + s.Rules = &output + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicynatrulecollectionaction.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicynatrulecollectionaction.go new file mode 100644 index 00000000000..4b895cf6198 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicynatrulecollectionaction.go @@ -0,0 +1,8 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyNatRuleCollectionAction struct { + Type *FirewallPolicyNatRuleCollectionActionType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicypropertiesformat.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicypropertiesformat.go new file mode 100644 index 00000000000..b439737323d --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicypropertiesformat.go @@ -0,0 +1,23 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyPropertiesFormat struct { + BasePolicy *SubResource `json:"basePolicy,omitempty"` + ChildPolicies *[]SubResource `json:"childPolicies,omitempty"` + DnsSettings *DnsSettings `json:"dnsSettings,omitempty"` + ExplicitProxy *ExplicitProxy `json:"explicitProxy,omitempty"` + Firewalls *[]SubResource `json:"firewalls,omitempty"` + Insights *FirewallPolicyInsights `json:"insights,omitempty"` + IntrusionDetection *FirewallPolicyIntrusionDetection `json:"intrusionDetection,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RuleCollectionGroups *[]SubResource `json:"ruleCollectionGroups,omitempty"` + Size *string `json:"size,omitempty"` + Sku *FirewallPolicySku `json:"sku,omitempty"` + Snat *FirewallPolicySNAT `json:"snat,omitempty"` + Sql *FirewallPolicySQL `json:"sql,omitempty"` + ThreatIntelMode *AzureFirewallThreatIntelMode `json:"threatIntelMode,omitempty"` + ThreatIntelWhitelist *FirewallPolicyThreatIntelWhitelist `json:"threatIntelWhitelist,omitempty"` + TransportSecurity *FirewallPolicyTransportSecurity `json:"transportSecurity,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyrule.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyrule.go new file mode 100644 index 00000000000..08c058378ae --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyrule.go @@ -0,0 +1,93 @@ +package firewallpolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyRule interface { + FirewallPolicyRule() BaseFirewallPolicyRuleImpl +} + +var _ FirewallPolicyRule = BaseFirewallPolicyRuleImpl{} + +type BaseFirewallPolicyRuleImpl struct { + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + RuleType FirewallPolicyRuleType `json:"ruleType"` +} + +func (s BaseFirewallPolicyRuleImpl) FirewallPolicyRule() BaseFirewallPolicyRuleImpl { + return s +} + +var _ FirewallPolicyRule = RawFirewallPolicyRuleImpl{} + +// RawFirewallPolicyRuleImpl 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 RawFirewallPolicyRuleImpl struct { + firewallPolicyRule BaseFirewallPolicyRuleImpl + Type string + Values map[string]interface{} +} + +func (s RawFirewallPolicyRuleImpl) FirewallPolicyRule() BaseFirewallPolicyRuleImpl { + return s.firewallPolicyRule +} + +func UnmarshalFirewallPolicyRuleImplementation(input []byte) (FirewallPolicyRule, 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 FirewallPolicyRule into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["ruleType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "ApplicationRule") { + var out ApplicationRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ApplicationRule: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "NatRule") { + var out NatRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NatRule: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "NetworkRule") { + var out NetworkRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NetworkRule: %+v", err) + } + return out, nil + } + + var parent BaseFirewallPolicyRuleImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseFirewallPolicyRuleImpl: %+v", err) + } + + return RawFirewallPolicyRuleImpl{ + firewallPolicyRule: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyruleapplicationprotocol.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyruleapplicationprotocol.go new file mode 100644 index 00000000000..4c9fdab828c --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyruleapplicationprotocol.go @@ -0,0 +1,9 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyRuleApplicationProtocol struct { + Port *int64 `json:"port,omitempty"` + ProtocolType *FirewallPolicyRuleApplicationProtocolType `json:"protocolType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyrulecollection.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyrulecollection.go new file mode 100644 index 00000000000..8e3be4c748e --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyrulecollection.go @@ -0,0 +1,85 @@ +package firewallpolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyRuleCollection interface { + FirewallPolicyRuleCollection() BaseFirewallPolicyRuleCollectionImpl +} + +var _ FirewallPolicyRuleCollection = BaseFirewallPolicyRuleCollectionImpl{} + +type BaseFirewallPolicyRuleCollectionImpl struct { + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + RuleCollectionType FirewallPolicyRuleCollectionType `json:"ruleCollectionType"` +} + +func (s BaseFirewallPolicyRuleCollectionImpl) FirewallPolicyRuleCollection() BaseFirewallPolicyRuleCollectionImpl { + return s +} + +var _ FirewallPolicyRuleCollection = RawFirewallPolicyRuleCollectionImpl{} + +// RawFirewallPolicyRuleCollectionImpl 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 RawFirewallPolicyRuleCollectionImpl struct { + firewallPolicyRuleCollection BaseFirewallPolicyRuleCollectionImpl + Type string + Values map[string]interface{} +} + +func (s RawFirewallPolicyRuleCollectionImpl) FirewallPolicyRuleCollection() BaseFirewallPolicyRuleCollectionImpl { + return s.firewallPolicyRuleCollection +} + +func UnmarshalFirewallPolicyRuleCollectionImplementation(input []byte) (FirewallPolicyRuleCollection, 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 FirewallPolicyRuleCollection into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["ruleCollectionType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "FirewallPolicyFilterRuleCollection") { + var out FirewallPolicyFilterRuleCollection + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FirewallPolicyFilterRuleCollection: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "FirewallPolicyNatRuleCollection") { + var out FirewallPolicyNatRuleCollection + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FirewallPolicyNatRuleCollection: %+v", err) + } + return out, nil + } + + var parent BaseFirewallPolicyRuleCollectionImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseFirewallPolicyRuleCollectionImpl: %+v", err) + } + + return RawFirewallPolicyRuleCollectionImpl{ + firewallPolicyRuleCollection: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyrulecollectiongroupdraft.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyrulecollectiongroupdraft.go new file mode 100644 index 00000000000..638137d0747 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyrulecollectiongroupdraft.go @@ -0,0 +1,11 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyRuleCollectionGroupDraft struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FirewallPolicyRuleCollectionGroupDraftProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyrulecollectiongroupdraftproperties.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyrulecollectiongroupdraftproperties.go new file mode 100644 index 00000000000..a25c504563e --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicyrulecollectiongroupdraftproperties.go @@ -0,0 +1,54 @@ +package firewallpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyRuleCollectionGroupDraftProperties struct { + Priority *int64 `json:"priority,omitempty"` + RuleCollections *[]FirewallPolicyRuleCollection `json:"ruleCollections,omitempty"` + Size *string `json:"size,omitempty"` +} + +var _ json.Unmarshaler = &FirewallPolicyRuleCollectionGroupDraftProperties{} + +func (s *FirewallPolicyRuleCollectionGroupDraftProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Priority *int64 `json:"priority,omitempty"` + Size *string `json:"size,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Priority = decoded.Priority + s.Size = decoded.Size + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling FirewallPolicyRuleCollectionGroupDraftProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["ruleCollections"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling RuleCollections into list []json.RawMessage: %+v", err) + } + + output := make([]FirewallPolicyRuleCollection, 0) + for i, val := range listTemp { + impl, err := UnmarshalFirewallPolicyRuleCollectionImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'RuleCollections' for 'FirewallPolicyRuleCollectionGroupDraftProperties': %+v", i, err) + } + output = append(output, impl) + } + s.RuleCollections = &output + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicysku.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicysku.go new file mode 100644 index 00000000000..6c0cef08260 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicysku.go @@ -0,0 +1,8 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicySku struct { + Tier *FirewallPolicySkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicysnat.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicysnat.go new file mode 100644 index 00000000000..33dcf12744e --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicysnat.go @@ -0,0 +1,9 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicySNAT struct { + AutoLearnPrivateRanges *AutoLearnPrivateRangesMode `json:"autoLearnPrivateRanges,omitempty"` + PrivateRanges *[]string `json:"privateRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicysql.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicysql.go new file mode 100644 index 00000000000..32e50565577 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicysql.go @@ -0,0 +1,8 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicySQL struct { + AllowSqlRedirect *bool `json:"allowSqlRedirect,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicythreatintelwhitelist.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicythreatintelwhitelist.go new file mode 100644 index 00000000000..376fba1c268 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicythreatintelwhitelist.go @@ -0,0 +1,9 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyThreatIntelWhitelist struct { + Fqdns *[]string `json:"fqdns,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicytransportsecurity.go b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicytransportsecurity.go new file mode 100644 index 00000000000..9fdbf9b4877 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_firewallpolicytransportsecurity.go @@ -0,0 +1,8 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyTransportSecurity struct { + CertificateAuthority *FirewallPolicyCertificateAuthority `json:"certificateAuthority,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_idpsqueryobject.go b/resource-manager/network/2024-07-01/firewallpolicies/model_idpsqueryobject.go new file mode 100644 index 00000000000..3a1aca509b6 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_idpsqueryobject.go @@ -0,0 +1,12 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IDPSQueryObject struct { + Filters *[]FilterItems `json:"filters,omitempty"` + OrderBy *OrderBy `json:"orderBy,omitempty"` + ResultsPerPage *int64 `json:"resultsPerPage,omitempty"` + Search *string `json:"search,omitempty"` + Skip *int64 `json:"skip,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_natrule.go b/resource-manager/network/2024-07-01/firewallpolicies/model_natrule.go new file mode 100644 index 00000000000..29ada8c31d1 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_natrule.go @@ -0,0 +1,61 @@ +package firewallpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FirewallPolicyRule = NatRule{} + +type NatRule struct { + DestinationAddresses *[]string `json:"destinationAddresses,omitempty"` + DestinationPorts *[]string `json:"destinationPorts,omitempty"` + IPProtocols *[]FirewallPolicyRuleNetworkProtocol `json:"ipProtocols,omitempty"` + SourceAddresses *[]string `json:"sourceAddresses,omitempty"` + SourceIPGroups *[]string `json:"sourceIpGroups,omitempty"` + TranslatedAddress *string `json:"translatedAddress,omitempty"` + TranslatedFqdn *string `json:"translatedFqdn,omitempty"` + TranslatedPort *string `json:"translatedPort,omitempty"` + + // Fields inherited from FirewallPolicyRule + + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + RuleType FirewallPolicyRuleType `json:"ruleType"` +} + +func (s NatRule) FirewallPolicyRule() BaseFirewallPolicyRuleImpl { + return BaseFirewallPolicyRuleImpl{ + Description: s.Description, + Name: s.Name, + RuleType: s.RuleType, + } +} + +var _ json.Marshaler = NatRule{} + +func (s NatRule) MarshalJSON() ([]byte, error) { + type wrapper NatRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NatRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NatRule: %+v", err) + } + + decoded["ruleType"] = "NatRule" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NatRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_networkrule.go b/resource-manager/network/2024-07-01/firewallpolicies/model_networkrule.go new file mode 100644 index 00000000000..aa890c1a8bb --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_networkrule.go @@ -0,0 +1,60 @@ +package firewallpolicies + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FirewallPolicyRule = NetworkRule{} + +type NetworkRule struct { + DestinationAddresses *[]string `json:"destinationAddresses,omitempty"` + DestinationFqdns *[]string `json:"destinationFqdns,omitempty"` + DestinationIPGroups *[]string `json:"destinationIpGroups,omitempty"` + DestinationPorts *[]string `json:"destinationPorts,omitempty"` + IPProtocols *[]FirewallPolicyRuleNetworkProtocol `json:"ipProtocols,omitempty"` + SourceAddresses *[]string `json:"sourceAddresses,omitempty"` + SourceIPGroups *[]string `json:"sourceIpGroups,omitempty"` + + // Fields inherited from FirewallPolicyRule + + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + RuleType FirewallPolicyRuleType `json:"ruleType"` +} + +func (s NetworkRule) FirewallPolicyRule() BaseFirewallPolicyRuleImpl { + return BaseFirewallPolicyRuleImpl{ + Description: s.Description, + Name: s.Name, + RuleType: s.RuleType, + } +} + +var _ json.Marshaler = NetworkRule{} + +func (s NetworkRule) MarshalJSON() ([]byte, error) { + type wrapper NetworkRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NetworkRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NetworkRule: %+v", err) + } + + decoded["ruleType"] = "NetworkRule" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NetworkRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_orderby.go b/resource-manager/network/2024-07-01/firewallpolicies/model_orderby.go new file mode 100644 index 00000000000..db1d05e4478 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_orderby.go @@ -0,0 +1,9 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OrderBy struct { + Field *string `json:"field,omitempty"` + Order *FirewallPolicyIDPSQuerySortOrder `json:"order,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_queryresults.go b/resource-manager/network/2024-07-01/firewallpolicies/model_queryresults.go new file mode 100644 index 00000000000..4c0591a2f83 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_queryresults.go @@ -0,0 +1,9 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryResults struct { + MatchingRecordsCount *int64 `json:"matchingRecordsCount,omitempty"` + Signatures *[]SingleQueryResult `json:"signatures,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_signatureoverridesfiltervaluesquery.go b/resource-manager/network/2024-07-01/firewallpolicies/model_signatureoverridesfiltervaluesquery.go new file mode 100644 index 00000000000..718d141e3c0 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_signatureoverridesfiltervaluesquery.go @@ -0,0 +1,8 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignatureOverridesFilterValuesQuery struct { + FilterName *string `json:"filterName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_signatureoverridesfiltervaluesresponse.go b/resource-manager/network/2024-07-01/firewallpolicies/model_signatureoverridesfiltervaluesresponse.go new file mode 100644 index 00000000000..4b135d882ba --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_signatureoverridesfiltervaluesresponse.go @@ -0,0 +1,8 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignatureOverridesFilterValuesResponse struct { + FilterValues *[]string `json:"filterValues,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_signaturesoverrides.go b/resource-manager/network/2024-07-01/firewallpolicies/model_signaturesoverrides.go new file mode 100644 index 00000000000..2f1b84510c9 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_signaturesoverrides.go @@ -0,0 +1,11 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignaturesOverrides struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SignaturesOverridesProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_signaturesoverrideslist.go b/resource-manager/network/2024-07-01/firewallpolicies/model_signaturesoverrideslist.go new file mode 100644 index 00000000000..d403a4eb590 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_signaturesoverrideslist.go @@ -0,0 +1,8 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignaturesOverridesList struct { + Value *[]SignaturesOverrides `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_signaturesoverridesproperties.go b/resource-manager/network/2024-07-01/firewallpolicies/model_signaturesoverridesproperties.go new file mode 100644 index 00000000000..a93d8699c02 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_signaturesoverridesproperties.go @@ -0,0 +1,8 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SignaturesOverridesProperties struct { + Signatures *map[string]string `json:"signatures,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_singlequeryresult.go b/resource-manager/network/2024-07-01/firewallpolicies/model_singlequeryresult.go new file mode 100644 index 00000000000..cbf78585e56 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_singlequeryresult.go @@ -0,0 +1,18 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SingleQueryResult struct { + Description *string `json:"description,omitempty"` + DestinationPorts *[]string `json:"destinationPorts,omitempty"` + Direction *FirewallPolicyIDPSSignatureDirection `json:"direction,omitempty"` + Group *string `json:"group,omitempty"` + InheritedFromParentPolicy *bool `json:"inheritedFromParentPolicy,omitempty"` + LastUpdated *string `json:"lastUpdated,omitempty"` + Mode *FirewallPolicyIDPSSignatureMode `json:"mode,omitempty"` + Protocol *string `json:"protocol,omitempty"` + Severity *FirewallPolicyIDPSSignatureSeverity `json:"severity,omitempty"` + SignatureId *int64 `json:"signatureId,omitempty"` + SourcePorts *[]string `json:"sourcePorts,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_subresource.go b/resource-manager/network/2024-07-01/firewallpolicies/model_subresource.go new file mode 100644 index 00000000000..abee9f81d03 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_subresource.go @@ -0,0 +1,8 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/model_tagsobject.go b/resource-manager/network/2024-07-01/firewallpolicies/model_tagsobject.go new file mode 100644 index 00000000000..22cc23110be --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/model_tagsobject.go @@ -0,0 +1,8 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/predicates.go b/resource-manager/network/2024-07-01/firewallpolicies/predicates.go new file mode 100644 index 00000000000..2640042ba7a --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/predicates.go @@ -0,0 +1,37 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p FirewallPolicyOperationPredicate) Matches(input FirewallPolicy) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/firewallpolicies/version.go b/resource-manager/network/2024-07-01/firewallpolicies/version.go new file mode 100644 index 00000000000..221591ea837 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicies/version.go @@ -0,0 +1,10 @@ +package firewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/firewallpolicies/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/README.md b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/README.md new file mode 100644 index 00000000000..be2b167fea9 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups` Documentation + +The `firewallpolicyrulecollectiongroups` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups" +``` + + +### Client Initialization + +```go +client := firewallpolicyrulecollectiongroups.NewFirewallPolicyRuleCollectionGroupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FirewallPolicyRuleCollectionGroupsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := firewallpolicyrulecollectiongroups.NewRuleCollectionGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName", "ruleCollectionGroupName") + +payload := firewallpolicyrulecollectiongroups.FirewallPolicyRuleCollectionGroup{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `FirewallPolicyRuleCollectionGroupsClient.Delete` + +```go +ctx := context.TODO() +id := firewallpolicyrulecollectiongroups.NewRuleCollectionGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName", "ruleCollectionGroupName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `FirewallPolicyRuleCollectionGroupsClient.Get` + +```go +ctx := context.TODO() +id := firewallpolicyrulecollectiongroups.NewRuleCollectionGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName", "ruleCollectionGroupName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FirewallPolicyRuleCollectionGroupsClient.List` + +```go +ctx := context.TODO() +id := firewallpolicyrulecollectiongroups.NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/client.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/client.go new file mode 100644 index 00000000000..2c48ff99f6d --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/client.go @@ -0,0 +1,26 @@ +package firewallpolicyrulecollectiongroups + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyRuleCollectionGroupsClient struct { + Client *resourcemanager.Client +} + +func NewFirewallPolicyRuleCollectionGroupsClientWithBaseURI(sdkApi sdkEnv.Api) (*FirewallPolicyRuleCollectionGroupsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "firewallpolicyrulecollectiongroups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FirewallPolicyRuleCollectionGroupsClient: %+v", err) + } + + return &FirewallPolicyRuleCollectionGroupsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/constants.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/constants.go new file mode 100644 index 00000000000..73fd6902a8b --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/constants.go @@ -0,0 +1,309 @@ +package firewallpolicyrulecollectiongroups + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyFilterRuleCollectionActionType string + +const ( + FirewallPolicyFilterRuleCollectionActionTypeAllow FirewallPolicyFilterRuleCollectionActionType = "Allow" + FirewallPolicyFilterRuleCollectionActionTypeDeny FirewallPolicyFilterRuleCollectionActionType = "Deny" +) + +func PossibleValuesForFirewallPolicyFilterRuleCollectionActionType() []string { + return []string{ + string(FirewallPolicyFilterRuleCollectionActionTypeAllow), + string(FirewallPolicyFilterRuleCollectionActionTypeDeny), + } +} + +func (s *FirewallPolicyFilterRuleCollectionActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallPolicyFilterRuleCollectionActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallPolicyFilterRuleCollectionActionType(input string) (*FirewallPolicyFilterRuleCollectionActionType, error) { + vals := map[string]FirewallPolicyFilterRuleCollectionActionType{ + "allow": FirewallPolicyFilterRuleCollectionActionTypeAllow, + "deny": FirewallPolicyFilterRuleCollectionActionTypeDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallPolicyFilterRuleCollectionActionType(input) + return &out, nil +} + +type FirewallPolicyNatRuleCollectionActionType string + +const ( + FirewallPolicyNatRuleCollectionActionTypeDNAT FirewallPolicyNatRuleCollectionActionType = "DNAT" +) + +func PossibleValuesForFirewallPolicyNatRuleCollectionActionType() []string { + return []string{ + string(FirewallPolicyNatRuleCollectionActionTypeDNAT), + } +} + +func (s *FirewallPolicyNatRuleCollectionActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallPolicyNatRuleCollectionActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallPolicyNatRuleCollectionActionType(input string) (*FirewallPolicyNatRuleCollectionActionType, error) { + vals := map[string]FirewallPolicyNatRuleCollectionActionType{ + "dnat": FirewallPolicyNatRuleCollectionActionTypeDNAT, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallPolicyNatRuleCollectionActionType(input) + return &out, nil +} + +type FirewallPolicyRuleApplicationProtocolType string + +const ( + FirewallPolicyRuleApplicationProtocolTypeHTTP FirewallPolicyRuleApplicationProtocolType = "Http" + FirewallPolicyRuleApplicationProtocolTypeHTTPS FirewallPolicyRuleApplicationProtocolType = "Https" +) + +func PossibleValuesForFirewallPolicyRuleApplicationProtocolType() []string { + return []string{ + string(FirewallPolicyRuleApplicationProtocolTypeHTTP), + string(FirewallPolicyRuleApplicationProtocolTypeHTTPS), + } +} + +func (s *FirewallPolicyRuleApplicationProtocolType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallPolicyRuleApplicationProtocolType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallPolicyRuleApplicationProtocolType(input string) (*FirewallPolicyRuleApplicationProtocolType, error) { + vals := map[string]FirewallPolicyRuleApplicationProtocolType{ + "http": FirewallPolicyRuleApplicationProtocolTypeHTTP, + "https": FirewallPolicyRuleApplicationProtocolTypeHTTPS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallPolicyRuleApplicationProtocolType(input) + return &out, nil +} + +type FirewallPolicyRuleCollectionType string + +const ( + FirewallPolicyRuleCollectionTypeFirewallPolicyFilterRuleCollection FirewallPolicyRuleCollectionType = "FirewallPolicyFilterRuleCollection" + FirewallPolicyRuleCollectionTypeFirewallPolicyNatRuleCollection FirewallPolicyRuleCollectionType = "FirewallPolicyNatRuleCollection" +) + +func PossibleValuesForFirewallPolicyRuleCollectionType() []string { + return []string{ + string(FirewallPolicyRuleCollectionTypeFirewallPolicyFilterRuleCollection), + string(FirewallPolicyRuleCollectionTypeFirewallPolicyNatRuleCollection), + } +} + +func (s *FirewallPolicyRuleCollectionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallPolicyRuleCollectionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallPolicyRuleCollectionType(input string) (*FirewallPolicyRuleCollectionType, error) { + vals := map[string]FirewallPolicyRuleCollectionType{ + "firewallpolicyfilterrulecollection": FirewallPolicyRuleCollectionTypeFirewallPolicyFilterRuleCollection, + "firewallpolicynatrulecollection": FirewallPolicyRuleCollectionTypeFirewallPolicyNatRuleCollection, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallPolicyRuleCollectionType(input) + return &out, nil +} + +type FirewallPolicyRuleNetworkProtocol string + +const ( + FirewallPolicyRuleNetworkProtocolAny FirewallPolicyRuleNetworkProtocol = "Any" + FirewallPolicyRuleNetworkProtocolICMP FirewallPolicyRuleNetworkProtocol = "ICMP" + FirewallPolicyRuleNetworkProtocolTCP FirewallPolicyRuleNetworkProtocol = "TCP" + FirewallPolicyRuleNetworkProtocolUDP FirewallPolicyRuleNetworkProtocol = "UDP" +) + +func PossibleValuesForFirewallPolicyRuleNetworkProtocol() []string { + return []string{ + string(FirewallPolicyRuleNetworkProtocolAny), + string(FirewallPolicyRuleNetworkProtocolICMP), + string(FirewallPolicyRuleNetworkProtocolTCP), + string(FirewallPolicyRuleNetworkProtocolUDP), + } +} + +func (s *FirewallPolicyRuleNetworkProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallPolicyRuleNetworkProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallPolicyRuleNetworkProtocol(input string) (*FirewallPolicyRuleNetworkProtocol, error) { + vals := map[string]FirewallPolicyRuleNetworkProtocol{ + "any": FirewallPolicyRuleNetworkProtocolAny, + "icmp": FirewallPolicyRuleNetworkProtocolICMP, + "tcp": FirewallPolicyRuleNetworkProtocolTCP, + "udp": FirewallPolicyRuleNetworkProtocolUDP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallPolicyRuleNetworkProtocol(input) + return &out, nil +} + +type FirewallPolicyRuleType string + +const ( + FirewallPolicyRuleTypeApplicationRule FirewallPolicyRuleType = "ApplicationRule" + FirewallPolicyRuleTypeNatRule FirewallPolicyRuleType = "NatRule" + FirewallPolicyRuleTypeNetworkRule FirewallPolicyRuleType = "NetworkRule" +) + +func PossibleValuesForFirewallPolicyRuleType() []string { + return []string{ + string(FirewallPolicyRuleTypeApplicationRule), + string(FirewallPolicyRuleTypeNatRule), + string(FirewallPolicyRuleTypeNetworkRule), + } +} + +func (s *FirewallPolicyRuleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallPolicyRuleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallPolicyRuleType(input string) (*FirewallPolicyRuleType, error) { + vals := map[string]FirewallPolicyRuleType{ + "applicationrule": FirewallPolicyRuleTypeApplicationRule, + "natrule": FirewallPolicyRuleTypeNatRule, + "networkrule": FirewallPolicyRuleTypeNetworkRule, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallPolicyRuleType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/id_firewallpolicy.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/id_firewallpolicy.go new file mode 100644 index 00000000000..fbd53108c84 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/id_firewallpolicy.go @@ -0,0 +1,130 @@ +package firewallpolicyrulecollectiongroups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&FirewallPolicyId{}) +} + +var _ resourceids.ResourceId = &FirewallPolicyId{} + +// FirewallPolicyId is a struct representing the Resource ID for a Firewall Policy +type FirewallPolicyId struct { + SubscriptionId string + ResourceGroupName string + FirewallPolicyName string +} + +// NewFirewallPolicyID returns a new FirewallPolicyId struct +func NewFirewallPolicyID(subscriptionId string, resourceGroupName string, firewallPolicyName string) FirewallPolicyId { + return FirewallPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FirewallPolicyName: firewallPolicyName, + } +} + +// ParseFirewallPolicyID parses 'input' into a FirewallPolicyId +func ParseFirewallPolicyID(input string) (*FirewallPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&FirewallPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FirewallPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFirewallPolicyIDInsensitively parses 'input' case-insensitively into a FirewallPolicyId +// note: this method should only be used for API response data and not user input +func ParseFirewallPolicyIDInsensitively(input string) (*FirewallPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&FirewallPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FirewallPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FirewallPolicyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.FirewallPolicyName, ok = input.Parsed["firewallPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "firewallPolicyName", input) + } + + return nil +} + +// ValidateFirewallPolicyID checks that 'input' can be parsed as a Firewall Policy ID +func ValidateFirewallPolicyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseFirewallPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Firewall Policy ID +func (id FirewallPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/firewallPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FirewallPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Firewall Policy ID +func (id FirewallPolicyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticFirewallPolicies", "firewallPolicies", "firewallPolicies"), + resourceids.UserSpecifiedSegment("firewallPolicyName", "firewallPolicyName"), + } +} + +// String returns a human-readable description of this Firewall Policy ID +func (id FirewallPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Firewall Policy Name: %q", id.FirewallPolicyName), + } + return fmt.Sprintf("Firewall Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/id_firewallpolicy_test.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/id_firewallpolicy_test.go new file mode 100644 index 00000000000..56913881d12 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/id_firewallpolicy_test.go @@ -0,0 +1,282 @@ +package firewallpolicyrulecollectiongroups + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &FirewallPolicyId{} + +func TestNewFirewallPolicyID(t *testing.T) { + id := NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.FirewallPolicyName != "firewallPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'FirewallPolicyName'", id.FirewallPolicyName, "firewallPolicyName") + } +} + +func TestFormatFirewallPolicyID(t *testing.T) { + actual := NewFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFirewallPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FirewallPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName", + Expected: &FirewallPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FirewallPolicyName: "firewallPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFirewallPolicyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.FirewallPolicyName != v.Expected.FirewallPolicyName { + t.Fatalf("Expected %q but got %q for FirewallPolicyName", v.Expected.FirewallPolicyName, actual.FirewallPolicyName) + } + + } +} + +func TestParseFirewallPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FirewallPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/fIrEwAlLpOlIcIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName", + Expected: &FirewallPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FirewallPolicyName: "firewallPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/fIrEwAlLpOlIcIeS/fIrEwAlLpOlIcYnAmE", + Expected: &FirewallPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FirewallPolicyName: "fIrEwAlLpOlIcYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/fIrEwAlLpOlIcIeS/fIrEwAlLpOlIcYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFirewallPolicyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.FirewallPolicyName != v.Expected.FirewallPolicyName { + t.Fatalf("Expected %q but got %q for FirewallPolicyName", v.Expected.FirewallPolicyName, actual.FirewallPolicyName) + } + + } +} + +func TestSegmentsForFirewallPolicyId(t *testing.T) { + segments := FirewallPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FirewallPolicyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/id_rulecollectiongroup.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/id_rulecollectiongroup.go new file mode 100644 index 00000000000..6828a1a7381 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/id_rulecollectiongroup.go @@ -0,0 +1,139 @@ +package firewallpolicyrulecollectiongroups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RuleCollectionGroupId{}) +} + +var _ resourceids.ResourceId = &RuleCollectionGroupId{} + +// RuleCollectionGroupId is a struct representing the Resource ID for a Rule Collection Group +type RuleCollectionGroupId struct { + SubscriptionId string + ResourceGroupName string + FirewallPolicyName string + RuleCollectionGroupName string +} + +// NewRuleCollectionGroupID returns a new RuleCollectionGroupId struct +func NewRuleCollectionGroupID(subscriptionId string, resourceGroupName string, firewallPolicyName string, ruleCollectionGroupName string) RuleCollectionGroupId { + return RuleCollectionGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + FirewallPolicyName: firewallPolicyName, + RuleCollectionGroupName: ruleCollectionGroupName, + } +} + +// ParseRuleCollectionGroupID parses 'input' into a RuleCollectionGroupId +func ParseRuleCollectionGroupID(input string) (*RuleCollectionGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleCollectionGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleCollectionGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRuleCollectionGroupIDInsensitively parses 'input' case-insensitively into a RuleCollectionGroupId +// note: this method should only be used for API response data and not user input +func ParseRuleCollectionGroupIDInsensitively(input string) (*RuleCollectionGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleCollectionGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleCollectionGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RuleCollectionGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.FirewallPolicyName, ok = input.Parsed["firewallPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "firewallPolicyName", input) + } + + if id.RuleCollectionGroupName, ok = input.Parsed["ruleCollectionGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleCollectionGroupName", input) + } + + return nil +} + +// ValidateRuleCollectionGroupID checks that 'input' can be parsed as a Rule Collection Group ID +func ValidateRuleCollectionGroupID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRuleCollectionGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rule Collection Group ID +func (id RuleCollectionGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/firewallPolicies/%s/ruleCollectionGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FirewallPolicyName, id.RuleCollectionGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rule Collection Group ID +func (id RuleCollectionGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticFirewallPolicies", "firewallPolicies", "firewallPolicies"), + resourceids.UserSpecifiedSegment("firewallPolicyName", "firewallPolicyName"), + resourceids.StaticSegment("staticRuleCollectionGroups", "ruleCollectionGroups", "ruleCollectionGroups"), + resourceids.UserSpecifiedSegment("ruleCollectionGroupName", "ruleCollectionGroupName"), + } +} + +// String returns a human-readable description of this Rule Collection Group ID +func (id RuleCollectionGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Firewall Policy Name: %q", id.FirewallPolicyName), + fmt.Sprintf("Rule Collection Group Name: %q", id.RuleCollectionGroupName), + } + return fmt.Sprintf("Rule Collection Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/id_rulecollectiongroup_test.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/id_rulecollectiongroup_test.go new file mode 100644 index 00000000000..ba24b7cdb4b --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/id_rulecollectiongroup_test.go @@ -0,0 +1,327 @@ +package firewallpolicyrulecollectiongroups + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RuleCollectionGroupId{} + +func TestNewRuleCollectionGroupID(t *testing.T) { + id := NewRuleCollectionGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName", "ruleCollectionGroupName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.FirewallPolicyName != "firewallPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'FirewallPolicyName'", id.FirewallPolicyName, "firewallPolicyName") + } + + if id.RuleCollectionGroupName != "ruleCollectionGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleCollectionGroupName'", id.RuleCollectionGroupName, "ruleCollectionGroupName") + } +} + +func TestFormatRuleCollectionGroupID(t *testing.T) { + actual := NewRuleCollectionGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "firewallPolicyName", "ruleCollectionGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/ruleCollectionGroups/ruleCollectionGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRuleCollectionGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleCollectionGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/ruleCollectionGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/ruleCollectionGroups/ruleCollectionGroupName", + Expected: &RuleCollectionGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FirewallPolicyName: "firewallPolicyName", + RuleCollectionGroupName: "ruleCollectionGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/ruleCollectionGroups/ruleCollectionGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleCollectionGroupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.FirewallPolicyName != v.Expected.FirewallPolicyName { + t.Fatalf("Expected %q but got %q for FirewallPolicyName", v.Expected.FirewallPolicyName, actual.FirewallPolicyName) + } + + if actual.RuleCollectionGroupName != v.Expected.RuleCollectionGroupName { + t.Fatalf("Expected %q but got %q for RuleCollectionGroupName", v.Expected.RuleCollectionGroupName, actual.RuleCollectionGroupName) + } + + } +} + +func TestParseRuleCollectionGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleCollectionGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/fIrEwAlLpOlIcIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/fIrEwAlLpOlIcIeS/fIrEwAlLpOlIcYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/ruleCollectionGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/fIrEwAlLpOlIcIeS/fIrEwAlLpOlIcYnAmE/rUlEcOlLeCtIoNgRoUpS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/ruleCollectionGroups/ruleCollectionGroupName", + Expected: &RuleCollectionGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + FirewallPolicyName: "firewallPolicyName", + RuleCollectionGroupName: "ruleCollectionGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/firewallPolicies/firewallPolicyName/ruleCollectionGroups/ruleCollectionGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/fIrEwAlLpOlIcIeS/fIrEwAlLpOlIcYnAmE/rUlEcOlLeCtIoNgRoUpS/rUlEcOlLeCtIoNgRoUpNaMe", + Expected: &RuleCollectionGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + FirewallPolicyName: "fIrEwAlLpOlIcYnAmE", + RuleCollectionGroupName: "rUlEcOlLeCtIoNgRoUpNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/fIrEwAlLpOlIcIeS/fIrEwAlLpOlIcYnAmE/rUlEcOlLeCtIoNgRoUpS/rUlEcOlLeCtIoNgRoUpNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleCollectionGroupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.FirewallPolicyName != v.Expected.FirewallPolicyName { + t.Fatalf("Expected %q but got %q for FirewallPolicyName", v.Expected.FirewallPolicyName, actual.FirewallPolicyName) + } + + if actual.RuleCollectionGroupName != v.Expected.RuleCollectionGroupName { + t.Fatalf("Expected %q but got %q for RuleCollectionGroupName", v.Expected.RuleCollectionGroupName, actual.RuleCollectionGroupName) + } + + } +} + +func TestSegmentsForRuleCollectionGroupId(t *testing.T) { + segments := RuleCollectionGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RuleCollectionGroupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/method_createorupdate.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/method_createorupdate.go new file mode 100644 index 00000000000..b067734262c --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/method_createorupdate.go @@ -0,0 +1,75 @@ +package firewallpolicyrulecollectiongroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *FirewallPolicyRuleCollectionGroup +} + +// CreateOrUpdate ... +func (c FirewallPolicyRuleCollectionGroupsClient) CreateOrUpdate(ctx context.Context, id RuleCollectionGroupId, input FirewallPolicyRuleCollectionGroup) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c FirewallPolicyRuleCollectionGroupsClient) CreateOrUpdateThenPoll(ctx context.Context, id RuleCollectionGroupId, input FirewallPolicyRuleCollectionGroup) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/method_delete.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/method_delete.go new file mode 100644 index 00000000000..159bb061b84 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/method_delete.go @@ -0,0 +1,71 @@ +package firewallpolicyrulecollectiongroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c FirewallPolicyRuleCollectionGroupsClient) Delete(ctx context.Context, id RuleCollectionGroupId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c FirewallPolicyRuleCollectionGroupsClient) DeleteThenPoll(ctx context.Context, id RuleCollectionGroupId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/method_get.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/method_get.go new file mode 100644 index 00000000000..2f494c21970 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/method_get.go @@ -0,0 +1,53 @@ +package firewallpolicyrulecollectiongroups + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FirewallPolicyRuleCollectionGroup +} + +// Get ... +func (c FirewallPolicyRuleCollectionGroupsClient) Get(ctx context.Context, id RuleCollectionGroupId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FirewallPolicyRuleCollectionGroup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/method_list.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/method_list.go new file mode 100644 index 00000000000..09dd83c8896 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/method_list.go @@ -0,0 +1,105 @@ +package firewallpolicyrulecollectiongroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FirewallPolicyRuleCollectionGroup +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []FirewallPolicyRuleCollectionGroup +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c FirewallPolicyRuleCollectionGroupsClient) List(ctx context.Context, id FirewallPolicyId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/ruleCollectionGroups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FirewallPolicyRuleCollectionGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c FirewallPolicyRuleCollectionGroupsClient) ListComplete(ctx context.Context, id FirewallPolicyId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, FirewallPolicyRuleCollectionGroupOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FirewallPolicyRuleCollectionGroupsClient) ListCompleteMatchingPredicate(ctx context.Context, id FirewallPolicyId, predicate FirewallPolicyRuleCollectionGroupOperationPredicate) (result ListCompleteResult, err error) { + items := make([]FirewallPolicyRuleCollectionGroup, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_applicationrule.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_applicationrule.go new file mode 100644 index 00000000000..1684b7ab31b --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_applicationrule.go @@ -0,0 +1,63 @@ +package firewallpolicyrulecollectiongroups + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FirewallPolicyRule = ApplicationRule{} + +type ApplicationRule struct { + DestinationAddresses *[]string `json:"destinationAddresses,omitempty"` + FqdnTags *[]string `json:"fqdnTags,omitempty"` + HTTPHeadersToInsert *[]FirewallPolicyHTTPHeaderToInsert `json:"httpHeadersToInsert,omitempty"` + Protocols *[]FirewallPolicyRuleApplicationProtocol `json:"protocols,omitempty"` + SourceAddresses *[]string `json:"sourceAddresses,omitempty"` + SourceIPGroups *[]string `json:"sourceIpGroups,omitempty"` + TargetFqdns *[]string `json:"targetFqdns,omitempty"` + TargetURLs *[]string `json:"targetUrls,omitempty"` + TerminateTLS *bool `json:"terminateTLS,omitempty"` + WebCategories *[]string `json:"webCategories,omitempty"` + + // Fields inherited from FirewallPolicyRule + + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + RuleType FirewallPolicyRuleType `json:"ruleType"` +} + +func (s ApplicationRule) FirewallPolicyRule() BaseFirewallPolicyRuleImpl { + return BaseFirewallPolicyRuleImpl{ + Description: s.Description, + Name: s.Name, + RuleType: s.RuleType, + } +} + +var _ json.Marshaler = ApplicationRule{} + +func (s ApplicationRule) MarshalJSON() ([]byte, error) { + type wrapper ApplicationRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ApplicationRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ApplicationRule: %+v", err) + } + + decoded["ruleType"] = "ApplicationRule" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ApplicationRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyfilterrulecollection.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyfilterrulecollection.go new file mode 100644 index 00000000000..142e33508f8 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyfilterrulecollection.go @@ -0,0 +1,98 @@ +package firewallpolicyrulecollectiongroups + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FirewallPolicyRuleCollection = FirewallPolicyFilterRuleCollection{} + +type FirewallPolicyFilterRuleCollection struct { + Action *FirewallPolicyFilterRuleCollectionAction `json:"action,omitempty"` + Rules *[]FirewallPolicyRule `json:"rules,omitempty"` + + // Fields inherited from FirewallPolicyRuleCollection + + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + RuleCollectionType FirewallPolicyRuleCollectionType `json:"ruleCollectionType"` +} + +func (s FirewallPolicyFilterRuleCollection) FirewallPolicyRuleCollection() BaseFirewallPolicyRuleCollectionImpl { + return BaseFirewallPolicyRuleCollectionImpl{ + Name: s.Name, + Priority: s.Priority, + RuleCollectionType: s.RuleCollectionType, + } +} + +var _ json.Marshaler = FirewallPolicyFilterRuleCollection{} + +func (s FirewallPolicyFilterRuleCollection) MarshalJSON() ([]byte, error) { + type wrapper FirewallPolicyFilterRuleCollection + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FirewallPolicyFilterRuleCollection: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FirewallPolicyFilterRuleCollection: %+v", err) + } + + decoded["ruleCollectionType"] = "FirewallPolicyFilterRuleCollection" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FirewallPolicyFilterRuleCollection: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &FirewallPolicyFilterRuleCollection{} + +func (s *FirewallPolicyFilterRuleCollection) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Action *FirewallPolicyFilterRuleCollectionAction `json:"action,omitempty"` + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + RuleCollectionType FirewallPolicyRuleCollectionType `json:"ruleCollectionType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Action = decoded.Action + s.Name = decoded.Name + s.Priority = decoded.Priority + s.RuleCollectionType = decoded.RuleCollectionType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling FirewallPolicyFilterRuleCollection into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["rules"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling Rules into list []json.RawMessage: %+v", err) + } + + output := make([]FirewallPolicyRule, 0) + for i, val := range listTemp { + impl, err := UnmarshalFirewallPolicyRuleImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'Rules' for 'FirewallPolicyFilterRuleCollection': %+v", i, err) + } + output = append(output, impl) + } + s.Rules = &output + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyfilterrulecollectionaction.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyfilterrulecollectionaction.go new file mode 100644 index 00000000000..42d0cb7d127 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyfilterrulecollectionaction.go @@ -0,0 +1,8 @@ +package firewallpolicyrulecollectiongroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyFilterRuleCollectionAction struct { + Type *FirewallPolicyFilterRuleCollectionActionType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyhttpheadertoinsert.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyhttpheadertoinsert.go new file mode 100644 index 00000000000..f7dd43c6089 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyhttpheadertoinsert.go @@ -0,0 +1,9 @@ +package firewallpolicyrulecollectiongroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyHTTPHeaderToInsert struct { + HeaderName *string `json:"headerName,omitempty"` + HeaderValue *string `json:"headerValue,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicynatrulecollection.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicynatrulecollection.go new file mode 100644 index 00000000000..5e7e93c25d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicynatrulecollection.go @@ -0,0 +1,98 @@ +package firewallpolicyrulecollectiongroups + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FirewallPolicyRuleCollection = FirewallPolicyNatRuleCollection{} + +type FirewallPolicyNatRuleCollection struct { + Action *FirewallPolicyNatRuleCollectionAction `json:"action,omitempty"` + Rules *[]FirewallPolicyRule `json:"rules,omitempty"` + + // Fields inherited from FirewallPolicyRuleCollection + + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + RuleCollectionType FirewallPolicyRuleCollectionType `json:"ruleCollectionType"` +} + +func (s FirewallPolicyNatRuleCollection) FirewallPolicyRuleCollection() BaseFirewallPolicyRuleCollectionImpl { + return BaseFirewallPolicyRuleCollectionImpl{ + Name: s.Name, + Priority: s.Priority, + RuleCollectionType: s.RuleCollectionType, + } +} + +var _ json.Marshaler = FirewallPolicyNatRuleCollection{} + +func (s FirewallPolicyNatRuleCollection) MarshalJSON() ([]byte, error) { + type wrapper FirewallPolicyNatRuleCollection + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FirewallPolicyNatRuleCollection: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FirewallPolicyNatRuleCollection: %+v", err) + } + + decoded["ruleCollectionType"] = "FirewallPolicyNatRuleCollection" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FirewallPolicyNatRuleCollection: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &FirewallPolicyNatRuleCollection{} + +func (s *FirewallPolicyNatRuleCollection) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Action *FirewallPolicyNatRuleCollectionAction `json:"action,omitempty"` + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + RuleCollectionType FirewallPolicyRuleCollectionType `json:"ruleCollectionType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Action = decoded.Action + s.Name = decoded.Name + s.Priority = decoded.Priority + s.RuleCollectionType = decoded.RuleCollectionType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling FirewallPolicyNatRuleCollection into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["rules"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling Rules into list []json.RawMessage: %+v", err) + } + + output := make([]FirewallPolicyRule, 0) + for i, val := range listTemp { + impl, err := UnmarshalFirewallPolicyRuleImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'Rules' for 'FirewallPolicyNatRuleCollection': %+v", i, err) + } + output = append(output, impl) + } + s.Rules = &output + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicynatrulecollectionaction.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicynatrulecollectionaction.go new file mode 100644 index 00000000000..0b31f5d8ffa --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicynatrulecollectionaction.go @@ -0,0 +1,8 @@ +package firewallpolicyrulecollectiongroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyNatRuleCollectionAction struct { + Type *FirewallPolicyNatRuleCollectionActionType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyrule.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyrule.go new file mode 100644 index 00000000000..01e93308b20 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyrule.go @@ -0,0 +1,93 @@ +package firewallpolicyrulecollectiongroups + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyRule interface { + FirewallPolicyRule() BaseFirewallPolicyRuleImpl +} + +var _ FirewallPolicyRule = BaseFirewallPolicyRuleImpl{} + +type BaseFirewallPolicyRuleImpl struct { + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + RuleType FirewallPolicyRuleType `json:"ruleType"` +} + +func (s BaseFirewallPolicyRuleImpl) FirewallPolicyRule() BaseFirewallPolicyRuleImpl { + return s +} + +var _ FirewallPolicyRule = RawFirewallPolicyRuleImpl{} + +// RawFirewallPolicyRuleImpl 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 RawFirewallPolicyRuleImpl struct { + firewallPolicyRule BaseFirewallPolicyRuleImpl + Type string + Values map[string]interface{} +} + +func (s RawFirewallPolicyRuleImpl) FirewallPolicyRule() BaseFirewallPolicyRuleImpl { + return s.firewallPolicyRule +} + +func UnmarshalFirewallPolicyRuleImplementation(input []byte) (FirewallPolicyRule, 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 FirewallPolicyRule into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["ruleType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "ApplicationRule") { + var out ApplicationRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ApplicationRule: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "NatRule") { + var out NatRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NatRule: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "NetworkRule") { + var out NetworkRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NetworkRule: %+v", err) + } + return out, nil + } + + var parent BaseFirewallPolicyRuleImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseFirewallPolicyRuleImpl: %+v", err) + } + + return RawFirewallPolicyRuleImpl{ + firewallPolicyRule: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyruleapplicationprotocol.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyruleapplicationprotocol.go new file mode 100644 index 00000000000..cc2db178d08 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyruleapplicationprotocol.go @@ -0,0 +1,9 @@ +package firewallpolicyrulecollectiongroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyRuleApplicationProtocol struct { + Port *int64 `json:"port,omitempty"` + ProtocolType *FirewallPolicyRuleApplicationProtocolType `json:"protocolType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyrulecollection.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyrulecollection.go new file mode 100644 index 00000000000..8f68d85c04f --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyrulecollection.go @@ -0,0 +1,85 @@ +package firewallpolicyrulecollectiongroups + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyRuleCollection interface { + FirewallPolicyRuleCollection() BaseFirewallPolicyRuleCollectionImpl +} + +var _ FirewallPolicyRuleCollection = BaseFirewallPolicyRuleCollectionImpl{} + +type BaseFirewallPolicyRuleCollectionImpl struct { + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + RuleCollectionType FirewallPolicyRuleCollectionType `json:"ruleCollectionType"` +} + +func (s BaseFirewallPolicyRuleCollectionImpl) FirewallPolicyRuleCollection() BaseFirewallPolicyRuleCollectionImpl { + return s +} + +var _ FirewallPolicyRuleCollection = RawFirewallPolicyRuleCollectionImpl{} + +// RawFirewallPolicyRuleCollectionImpl 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 RawFirewallPolicyRuleCollectionImpl struct { + firewallPolicyRuleCollection BaseFirewallPolicyRuleCollectionImpl + Type string + Values map[string]interface{} +} + +func (s RawFirewallPolicyRuleCollectionImpl) FirewallPolicyRuleCollection() BaseFirewallPolicyRuleCollectionImpl { + return s.firewallPolicyRuleCollection +} + +func UnmarshalFirewallPolicyRuleCollectionImplementation(input []byte) (FirewallPolicyRuleCollection, 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 FirewallPolicyRuleCollection into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["ruleCollectionType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "FirewallPolicyFilterRuleCollection") { + var out FirewallPolicyFilterRuleCollection + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FirewallPolicyFilterRuleCollection: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "FirewallPolicyNatRuleCollection") { + var out FirewallPolicyNatRuleCollection + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FirewallPolicyNatRuleCollection: %+v", err) + } + return out, nil + } + + var parent BaseFirewallPolicyRuleCollectionImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseFirewallPolicyRuleCollectionImpl: %+v", err) + } + + return RawFirewallPolicyRuleCollectionImpl{ + firewallPolicyRuleCollection: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyrulecollectiongroup.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyrulecollectiongroup.go new file mode 100644 index 00000000000..3cd2b948905 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyrulecollectiongroup.go @@ -0,0 +1,12 @@ +package firewallpolicyrulecollectiongroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyRuleCollectionGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FirewallPolicyRuleCollectionGroupProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyrulecollectiongroupproperties.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyrulecollectiongroupproperties.go new file mode 100644 index 00000000000..ae95dcb3fd9 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_firewallpolicyrulecollectiongroupproperties.go @@ -0,0 +1,57 @@ +package firewallpolicyrulecollectiongroups + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyRuleCollectionGroupProperties struct { + Priority *int64 `json:"priority,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RuleCollections *[]FirewallPolicyRuleCollection `json:"ruleCollections,omitempty"` + Size *string `json:"size,omitempty"` +} + +var _ json.Unmarshaler = &FirewallPolicyRuleCollectionGroupProperties{} + +func (s *FirewallPolicyRuleCollectionGroupProperties) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Priority *int64 `json:"priority,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Size *string `json:"size,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Priority = decoded.Priority + s.ProvisioningState = decoded.ProvisioningState + s.Size = decoded.Size + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling FirewallPolicyRuleCollectionGroupProperties into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["ruleCollections"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling RuleCollections into list []json.RawMessage: %+v", err) + } + + output := make([]FirewallPolicyRuleCollection, 0) + for i, val := range listTemp { + impl, err := UnmarshalFirewallPolicyRuleCollectionImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'RuleCollections' for 'FirewallPolicyRuleCollectionGroupProperties': %+v", i, err) + } + output = append(output, impl) + } + s.RuleCollections = &output + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_natrule.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_natrule.go new file mode 100644 index 00000000000..2e80421cd23 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_natrule.go @@ -0,0 +1,61 @@ +package firewallpolicyrulecollectiongroups + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FirewallPolicyRule = NatRule{} + +type NatRule struct { + DestinationAddresses *[]string `json:"destinationAddresses,omitempty"` + DestinationPorts *[]string `json:"destinationPorts,omitempty"` + IPProtocols *[]FirewallPolicyRuleNetworkProtocol `json:"ipProtocols,omitempty"` + SourceAddresses *[]string `json:"sourceAddresses,omitempty"` + SourceIPGroups *[]string `json:"sourceIpGroups,omitempty"` + TranslatedAddress *string `json:"translatedAddress,omitempty"` + TranslatedFqdn *string `json:"translatedFqdn,omitempty"` + TranslatedPort *string `json:"translatedPort,omitempty"` + + // Fields inherited from FirewallPolicyRule + + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + RuleType FirewallPolicyRuleType `json:"ruleType"` +} + +func (s NatRule) FirewallPolicyRule() BaseFirewallPolicyRuleImpl { + return BaseFirewallPolicyRuleImpl{ + Description: s.Description, + Name: s.Name, + RuleType: s.RuleType, + } +} + +var _ json.Marshaler = NatRule{} + +func (s NatRule) MarshalJSON() ([]byte, error) { + type wrapper NatRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NatRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NatRule: %+v", err) + } + + decoded["ruleType"] = "NatRule" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NatRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_networkrule.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_networkrule.go new file mode 100644 index 00000000000..90231437759 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/model_networkrule.go @@ -0,0 +1,60 @@ +package firewallpolicyrulecollectiongroups + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ FirewallPolicyRule = NetworkRule{} + +type NetworkRule struct { + DestinationAddresses *[]string `json:"destinationAddresses,omitempty"` + DestinationFqdns *[]string `json:"destinationFqdns,omitempty"` + DestinationIPGroups *[]string `json:"destinationIpGroups,omitempty"` + DestinationPorts *[]string `json:"destinationPorts,omitempty"` + IPProtocols *[]FirewallPolicyRuleNetworkProtocol `json:"ipProtocols,omitempty"` + SourceAddresses *[]string `json:"sourceAddresses,omitempty"` + SourceIPGroups *[]string `json:"sourceIpGroups,omitempty"` + + // Fields inherited from FirewallPolicyRule + + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` + RuleType FirewallPolicyRuleType `json:"ruleType"` +} + +func (s NetworkRule) FirewallPolicyRule() BaseFirewallPolicyRuleImpl { + return BaseFirewallPolicyRuleImpl{ + Description: s.Description, + Name: s.Name, + RuleType: s.RuleType, + } +} + +var _ json.Marshaler = NetworkRule{} + +func (s NetworkRule) MarshalJSON() ([]byte, error) { + type wrapper NetworkRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NetworkRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NetworkRule: %+v", err) + } + + decoded["ruleType"] = "NetworkRule" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NetworkRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/predicates.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/predicates.go new file mode 100644 index 00000000000..9762acada56 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/predicates.go @@ -0,0 +1,32 @@ +package firewallpolicyrulecollectiongroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FirewallPolicyRuleCollectionGroupOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p FirewallPolicyRuleCollectionGroupOperationPredicate) Matches(input FirewallPolicyRuleCollectionGroup) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/version.go b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/version.go new file mode 100644 index 00000000000..de6cef1d873 --- /dev/null +++ b/resource-manager/network/2024-07-01/firewallpolicyrulecollectiongroups/version.go @@ -0,0 +1,10 @@ +package firewallpolicyrulecollectiongroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/firewallpolicyrulecollectiongroups/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/flowlogs/README.md b/resource-manager/network/2024-07-01/flowlogs/README.md new file mode 100644 index 00000000000..1bb802798b3 --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/README.md @@ -0,0 +1,103 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/flowlogs` Documentation + +The `flowlogs` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/flowlogs" +``` + + +### Client Initialization + +```go +client := flowlogs.NewFlowLogsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FlowLogsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := flowlogs.NewFlowLogID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "flowLogName") + +payload := flowlogs.FlowLog{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `FlowLogsClient.Delete` + +```go +ctx := context.TODO() +id := flowlogs.NewFlowLogID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "flowLogName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `FlowLogsClient.Get` + +```go +ctx := context.TODO() +id := flowlogs.NewFlowLogID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "flowLogName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FlowLogsClient.List` + +```go +ctx := context.TODO() +id := flowlogs.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `FlowLogsClient.UpdateTags` + +```go +ctx := context.TODO() +id := flowlogs.NewFlowLogID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "flowLogName") + +payload := flowlogs.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/flowlogs/client.go b/resource-manager/network/2024-07-01/flowlogs/client.go new file mode 100644 index 00000000000..6294aac5774 --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/client.go @@ -0,0 +1,26 @@ +package flowlogs + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogsClient struct { + Client *resourcemanager.Client +} + +func NewFlowLogsClientWithBaseURI(sdkApi sdkEnv.Api) (*FlowLogsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "flowlogs", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FlowLogsClient: %+v", err) + } + + return &FlowLogsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/flowlogs/constants.go b/resource-manager/network/2024-07-01/flowlogs/constants.go new file mode 100644 index 00000000000..e5e97eea109 --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/constants.go @@ -0,0 +1,95 @@ +package flowlogs + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/flowlogs/id_flowlog.go b/resource-manager/network/2024-07-01/flowlogs/id_flowlog.go new file mode 100644 index 00000000000..17a0f248d39 --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/id_flowlog.go @@ -0,0 +1,139 @@ +package flowlogs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&FlowLogId{}) +} + +var _ resourceids.ResourceId = &FlowLogId{} + +// FlowLogId is a struct representing the Resource ID for a Flow Log +type FlowLogId struct { + SubscriptionId string + ResourceGroupName string + NetworkWatcherName string + FlowLogName string +} + +// NewFlowLogID returns a new FlowLogId struct +func NewFlowLogID(subscriptionId string, resourceGroupName string, networkWatcherName string, flowLogName string) FlowLogId { + return FlowLogId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkWatcherName: networkWatcherName, + FlowLogName: flowLogName, + } +} + +// ParseFlowLogID parses 'input' into a FlowLogId +func ParseFlowLogID(input string) (*FlowLogId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlowLogId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlowLogId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFlowLogIDInsensitively parses 'input' case-insensitively into a FlowLogId +// note: this method should only be used for API response data and not user input +func ParseFlowLogIDInsensitively(input string) (*FlowLogId, error) { + parser := resourceids.NewParserFromResourceIdType(&FlowLogId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FlowLogId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FlowLogId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkWatcherName, ok = input.Parsed["networkWatcherName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkWatcherName", input) + } + + if id.FlowLogName, ok = input.Parsed["flowLogName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "flowLogName", input) + } + + return nil +} + +// ValidateFlowLogID checks that 'input' can be parsed as a Flow Log ID +func ValidateFlowLogID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseFlowLogID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Flow Log ID +func (id FlowLogId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkWatchers/%s/flowLogs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkWatcherName, id.FlowLogName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Flow Log ID +func (id FlowLogId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkWatchers", "networkWatchers", "networkWatchers"), + resourceids.UserSpecifiedSegment("networkWatcherName", "networkWatcherName"), + resourceids.StaticSegment("staticFlowLogs", "flowLogs", "flowLogs"), + resourceids.UserSpecifiedSegment("flowLogName", "flowLogName"), + } +} + +// String returns a human-readable description of this Flow Log ID +func (id FlowLogId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Watcher Name: %q", id.NetworkWatcherName), + fmt.Sprintf("Flow Log Name: %q", id.FlowLogName), + } + return fmt.Sprintf("Flow Log (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/flowlogs/id_flowlog_test.go b/resource-manager/network/2024-07-01/flowlogs/id_flowlog_test.go new file mode 100644 index 00000000000..fe0ac7b4087 --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/id_flowlog_test.go @@ -0,0 +1,327 @@ +package flowlogs + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &FlowLogId{} + +func TestNewFlowLogID(t *testing.T) { + id := NewFlowLogID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "flowLogName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkWatcherName != "networkWatcherName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkWatcherName'", id.NetworkWatcherName, "networkWatcherName") + } + + if id.FlowLogName != "flowLogName" { + t.Fatalf("Expected %q but got %q for Segment 'FlowLogName'", id.FlowLogName, "flowLogName") + } +} + +func TestFormatFlowLogID(t *testing.T) { + actual := NewFlowLogID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "flowLogName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/flowLogs/flowLogName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFlowLogID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlowLogId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/flowLogs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/flowLogs/flowLogName", + Expected: &FlowLogId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkWatcherName: "networkWatcherName", + FlowLogName: "flowLogName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/flowLogs/flowLogName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlowLogID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkWatcherName != v.Expected.NetworkWatcherName { + t.Fatalf("Expected %q but got %q for NetworkWatcherName", v.Expected.NetworkWatcherName, actual.NetworkWatcherName) + } + + if actual.FlowLogName != v.Expected.FlowLogName { + t.Fatalf("Expected %q but got %q for FlowLogName", v.Expected.FlowLogName, actual.FlowLogName) + } + + } +} + +func TestParseFlowLogIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FlowLogId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/flowLogs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE/fLoWlOgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/flowLogs/flowLogName", + Expected: &FlowLogId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkWatcherName: "networkWatcherName", + FlowLogName: "flowLogName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/flowLogs/flowLogName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE/fLoWlOgS/fLoWlOgNaMe", + Expected: &FlowLogId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkWatcherName: "nEtWoRkWaTcHeRnAmE", + FlowLogName: "fLoWlOgNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE/fLoWlOgS/fLoWlOgNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFlowLogIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkWatcherName != v.Expected.NetworkWatcherName { + t.Fatalf("Expected %q but got %q for NetworkWatcherName", v.Expected.NetworkWatcherName, actual.NetworkWatcherName) + } + + if actual.FlowLogName != v.Expected.FlowLogName { + t.Fatalf("Expected %q but got %q for FlowLogName", v.Expected.FlowLogName, actual.FlowLogName) + } + + } +} + +func TestSegmentsForFlowLogId(t *testing.T) { + segments := FlowLogId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FlowLogId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/flowlogs/id_networkwatcher.go b/resource-manager/network/2024-07-01/flowlogs/id_networkwatcher.go new file mode 100644 index 00000000000..2862a3cc6b0 --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/id_networkwatcher.go @@ -0,0 +1,130 @@ +package flowlogs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkWatcherId{}) +} + +var _ resourceids.ResourceId = &NetworkWatcherId{} + +// NetworkWatcherId is a struct representing the Resource ID for a Network Watcher +type NetworkWatcherId struct { + SubscriptionId string + ResourceGroupName string + NetworkWatcherName string +} + +// NewNetworkWatcherID returns a new NetworkWatcherId struct +func NewNetworkWatcherID(subscriptionId string, resourceGroupName string, networkWatcherName string) NetworkWatcherId { + return NetworkWatcherId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkWatcherName: networkWatcherName, + } +} + +// ParseNetworkWatcherID parses 'input' into a NetworkWatcherId +func ParseNetworkWatcherID(input string) (*NetworkWatcherId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkWatcherId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkWatcherId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkWatcherIDInsensitively parses 'input' case-insensitively into a NetworkWatcherId +// note: this method should only be used for API response data and not user input +func ParseNetworkWatcherIDInsensitively(input string) (*NetworkWatcherId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkWatcherId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkWatcherId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkWatcherId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkWatcherName, ok = input.Parsed["networkWatcherName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkWatcherName", input) + } + + return nil +} + +// ValidateNetworkWatcherID checks that 'input' can be parsed as a Network Watcher ID +func ValidateNetworkWatcherID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkWatcherID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Watcher ID +func (id NetworkWatcherId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkWatchers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkWatcherName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Watcher ID +func (id NetworkWatcherId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkWatchers", "networkWatchers", "networkWatchers"), + resourceids.UserSpecifiedSegment("networkWatcherName", "networkWatcherName"), + } +} + +// String returns a human-readable description of this Network Watcher ID +func (id NetworkWatcherId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Watcher Name: %q", id.NetworkWatcherName), + } + return fmt.Sprintf("Network Watcher (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/flowlogs/id_networkwatcher_test.go b/resource-manager/network/2024-07-01/flowlogs/id_networkwatcher_test.go new file mode 100644 index 00000000000..4c33ae031e7 --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/id_networkwatcher_test.go @@ -0,0 +1,282 @@ +package flowlogs + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkWatcherId{} + +func TestNewNetworkWatcherID(t *testing.T) { + id := NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkWatcherName != "networkWatcherName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkWatcherName'", id.NetworkWatcherName, "networkWatcherName") + } +} + +func TestFormatNetworkWatcherID(t *testing.T) { + actual := NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkWatcherID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkWatcherId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName", + Expected: &NetworkWatcherId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkWatcherName: "networkWatcherName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkWatcherID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkWatcherName != v.Expected.NetworkWatcherName { + t.Fatalf("Expected %q but got %q for NetworkWatcherName", v.Expected.NetworkWatcherName, actual.NetworkWatcherName) + } + + } +} + +func TestParseNetworkWatcherIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkWatcherId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName", + Expected: &NetworkWatcherId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkWatcherName: "networkWatcherName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE", + Expected: &NetworkWatcherId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkWatcherName: "nEtWoRkWaTcHeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkWatcherIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkWatcherName != v.Expected.NetworkWatcherName { + t.Fatalf("Expected %q but got %q for NetworkWatcherName", v.Expected.NetworkWatcherName, actual.NetworkWatcherName) + } + + } +} + +func TestSegmentsForNetworkWatcherId(t *testing.T) { + segments := NetworkWatcherId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkWatcherId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/flowlogs/method_createorupdate.go b/resource-manager/network/2024-07-01/flowlogs/method_createorupdate.go new file mode 100644 index 00000000000..9469b674d32 --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/method_createorupdate.go @@ -0,0 +1,75 @@ +package flowlogs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *FlowLog +} + +// CreateOrUpdate ... +func (c FlowLogsClient) CreateOrUpdate(ctx context.Context, id FlowLogId, input FlowLog) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c FlowLogsClient) CreateOrUpdateThenPoll(ctx context.Context, id FlowLogId, input FlowLog) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/flowlogs/method_delete.go b/resource-manager/network/2024-07-01/flowlogs/method_delete.go new file mode 100644 index 00000000000..1ff7776fa73 --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/method_delete.go @@ -0,0 +1,70 @@ +package flowlogs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c FlowLogsClient) Delete(ctx context.Context, id FlowLogId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c FlowLogsClient) DeleteThenPoll(ctx context.Context, id FlowLogId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/flowlogs/method_get.go b/resource-manager/network/2024-07-01/flowlogs/method_get.go new file mode 100644 index 00000000000..8677d660354 --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/method_get.go @@ -0,0 +1,53 @@ +package flowlogs + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FlowLog +} + +// Get ... +func (c FlowLogsClient) Get(ctx context.Context, id FlowLogId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FlowLog + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/flowlogs/method_list.go b/resource-manager/network/2024-07-01/flowlogs/method_list.go new file mode 100644 index 00000000000..6652ea30f55 --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/method_list.go @@ -0,0 +1,105 @@ +package flowlogs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FlowLog +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []FlowLog +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c FlowLogsClient) List(ctx context.Context, id NetworkWatcherId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/flowLogs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FlowLog `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c FlowLogsClient) ListComplete(ctx context.Context, id NetworkWatcherId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, FlowLogOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FlowLogsClient) ListCompleteMatchingPredicate(ctx context.Context, id NetworkWatcherId, predicate FlowLogOperationPredicate) (result ListCompleteResult, err error) { + items := make([]FlowLog, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/flowlogs/method_updatetags.go b/resource-manager/network/2024-07-01/flowlogs/method_updatetags.go new file mode 100644 index 00000000000..1f7aec16871 --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/method_updatetags.go @@ -0,0 +1,57 @@ +package flowlogs + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FlowLog +} + +// UpdateTags ... +func (c FlowLogsClient) UpdateTags(ctx context.Context, id FlowLogId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FlowLog + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/flowlogs/model_flowlog.go b/resource-manager/network/2024-07-01/flowlogs/model_flowlog.go new file mode 100644 index 00000000000..b379e613ed9 --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/model_flowlog.go @@ -0,0 +1,19 @@ +package flowlogs + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/flowlogs/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/flowlogs/model_flowlogformatparameters.go new file mode 100644 index 00000000000..16ca58e95a3 --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package flowlogs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/flowlogs/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/flowlogs/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..7ef17d630e6 --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package flowlogs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/flowlogs/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/flowlogs/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..37f07668bea --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package flowlogs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/flowlogs/model_tagsobject.go b/resource-manager/network/2024-07-01/flowlogs/model_tagsobject.go new file mode 100644 index 00000000000..c5cd354ef29 --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/model_tagsobject.go @@ -0,0 +1,8 @@ +package flowlogs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/flowlogs/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/flowlogs/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..5b935e5f27b --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package flowlogs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/flowlogs/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/flowlogs/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..d6d9faede4b --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package flowlogs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/flowlogs/predicates.go b/resource-manager/network/2024-07-01/flowlogs/predicates.go new file mode 100644 index 00000000000..746df2611cc --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/predicates.go @@ -0,0 +1,37 @@ +package flowlogs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p FlowLogOperationPredicate) Matches(input FlowLog) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/flowlogs/version.go b/resource-manager/network/2024-07-01/flowlogs/version.go new file mode 100644 index 00000000000..8eb22c041b1 --- /dev/null +++ b/resource-manager/network/2024-07-01/flowlogs/version.go @@ -0,0 +1,10 @@ +package flowlogs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/flowlogs/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/ipallocations/README.md b/resource-manager/network/2024-07-01/ipallocations/README.md new file mode 100644 index 00000000000..f0919ced8f4 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipallocations/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/ipallocations` Documentation + +The `ipallocations` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/ipallocations" +``` + + +### Client Initialization + +```go +client := ipallocations.NewIPAllocationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `IPAllocationsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := ipallocations.NewIPAllocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ipAllocationName") + +payload := ipallocations.IPAllocation{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `IPAllocationsClient.Delete` + +```go +ctx := context.TODO() +id := ipallocations.NewIPAllocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ipAllocationName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `IPAllocationsClient.Get` + +```go +ctx := context.TODO() +id := ipallocations.NewIPAllocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ipAllocationName") + +read, err := client.Get(ctx, id, ipallocations.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `IPAllocationsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `IPAllocationsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `IPAllocationsClient.UpdateTags` + +```go +ctx := context.TODO() +id := ipallocations.NewIPAllocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ipAllocationName") + +payload := ipallocations.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/ipallocations/client.go b/resource-manager/network/2024-07-01/ipallocations/client.go new file mode 100644 index 00000000000..05538bf07b7 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipallocations/client.go @@ -0,0 +1,26 @@ +package ipallocations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAllocationsClient struct { + Client *resourcemanager.Client +} + +func NewIPAllocationsClientWithBaseURI(sdkApi sdkEnv.Api) (*IPAllocationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "ipallocations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating IPAllocationsClient: %+v", err) + } + + return &IPAllocationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/ipallocations/constants.go b/resource-manager/network/2024-07-01/ipallocations/constants.go new file mode 100644 index 00000000000..da0323d2ad0 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipallocations/constants.go @@ -0,0 +1,92 @@ +package ipallocations + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAllocationType string + +const ( + IPAllocationTypeHypernet IPAllocationType = "Hypernet" + IPAllocationTypeUndefined IPAllocationType = "Undefined" +) + +func PossibleValuesForIPAllocationType() []string { + return []string{ + string(IPAllocationTypeHypernet), + string(IPAllocationTypeUndefined), + } +} + +func (s *IPAllocationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationType(input string) (*IPAllocationType, error) { + vals := map[string]IPAllocationType{ + "hypernet": IPAllocationTypeHypernet, + "undefined": IPAllocationTypeUndefined, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationType(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/ipallocations/id_ipallocation.go b/resource-manager/network/2024-07-01/ipallocations/id_ipallocation.go new file mode 100644 index 00000000000..da61235dccb --- /dev/null +++ b/resource-manager/network/2024-07-01/ipallocations/id_ipallocation.go @@ -0,0 +1,130 @@ +package ipallocations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&IPAllocationId{}) +} + +var _ resourceids.ResourceId = &IPAllocationId{} + +// IPAllocationId is a struct representing the Resource ID for a I P Allocation +type IPAllocationId struct { + SubscriptionId string + ResourceGroupName string + IpAllocationName string +} + +// NewIPAllocationID returns a new IPAllocationId struct +func NewIPAllocationID(subscriptionId string, resourceGroupName string, ipAllocationName string) IPAllocationId { + return IPAllocationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + IpAllocationName: ipAllocationName, + } +} + +// ParseIPAllocationID parses 'input' into a IPAllocationId +func ParseIPAllocationID(input string) (*IPAllocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&IPAllocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := IPAllocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseIPAllocationIDInsensitively parses 'input' case-insensitively into a IPAllocationId +// note: this method should only be used for API response data and not user input +func ParseIPAllocationIDInsensitively(input string) (*IPAllocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&IPAllocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := IPAllocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *IPAllocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.IpAllocationName, ok = input.Parsed["ipAllocationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ipAllocationName", input) + } + + return nil +} + +// ValidateIPAllocationID checks that 'input' can be parsed as a I P Allocation ID +func ValidateIPAllocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseIPAllocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted I P Allocation ID +func (id IPAllocationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/ipAllocations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.IpAllocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this I P Allocation ID +func (id IPAllocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticIpAllocations", "ipAllocations", "ipAllocations"), + resourceids.UserSpecifiedSegment("ipAllocationName", "ipAllocationName"), + } +} + +// String returns a human-readable description of this I P Allocation ID +func (id IPAllocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Ip Allocation Name: %q", id.IpAllocationName), + } + return fmt.Sprintf("I P Allocation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/ipallocations/id_ipallocation_test.go b/resource-manager/network/2024-07-01/ipallocations/id_ipallocation_test.go new file mode 100644 index 00000000000..132f6f6c4bd --- /dev/null +++ b/resource-manager/network/2024-07-01/ipallocations/id_ipallocation_test.go @@ -0,0 +1,282 @@ +package ipallocations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &IPAllocationId{} + +func TestNewIPAllocationID(t *testing.T) { + id := NewIPAllocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ipAllocationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.IpAllocationName != "ipAllocationName" { + t.Fatalf("Expected %q but got %q for Segment 'IpAllocationName'", id.IpAllocationName, "ipAllocationName") + } +} + +func TestFormatIPAllocationID(t *testing.T) { + actual := NewIPAllocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ipAllocationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ipAllocations/ipAllocationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseIPAllocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IPAllocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ipAllocations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ipAllocations/ipAllocationName", + Expected: &IPAllocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + IpAllocationName: "ipAllocationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ipAllocations/ipAllocationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIPAllocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.IpAllocationName != v.Expected.IpAllocationName { + t.Fatalf("Expected %q but got %q for IpAllocationName", v.Expected.IpAllocationName, actual.IpAllocationName) + } + + } +} + +func TestParseIPAllocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IPAllocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ipAllocations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/iPaLlOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ipAllocations/ipAllocationName", + Expected: &IPAllocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + IpAllocationName: "ipAllocationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ipAllocations/ipAllocationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/iPaLlOcAtIoNs/iPaLlOcAtIoNnAmE", + Expected: &IPAllocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + IpAllocationName: "iPaLlOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/iPaLlOcAtIoNs/iPaLlOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIPAllocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.IpAllocationName != v.Expected.IpAllocationName { + t.Fatalf("Expected %q but got %q for IpAllocationName", v.Expected.IpAllocationName, actual.IpAllocationName) + } + + } +} + +func TestSegmentsForIPAllocationId(t *testing.T) { + segments := IPAllocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("IPAllocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/ipallocations/method_createorupdate.go b/resource-manager/network/2024-07-01/ipallocations/method_createorupdate.go new file mode 100644 index 00000000000..6b097aa0b1a --- /dev/null +++ b/resource-manager/network/2024-07-01/ipallocations/method_createorupdate.go @@ -0,0 +1,75 @@ +package ipallocations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *IPAllocation +} + +// CreateOrUpdate ... +func (c IPAllocationsClient) CreateOrUpdate(ctx context.Context, id IPAllocationId, input IPAllocation) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c IPAllocationsClient) CreateOrUpdateThenPoll(ctx context.Context, id IPAllocationId, input IPAllocation) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/ipallocations/method_delete.go b/resource-manager/network/2024-07-01/ipallocations/method_delete.go new file mode 100644 index 00000000000..2e272e0b823 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipallocations/method_delete.go @@ -0,0 +1,71 @@ +package ipallocations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c IPAllocationsClient) Delete(ctx context.Context, id IPAllocationId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c IPAllocationsClient) DeleteThenPoll(ctx context.Context, id IPAllocationId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/ipallocations/method_get.go b/resource-manager/network/2024-07-01/ipallocations/method_get.go new file mode 100644 index 00000000000..d7ccc3afb37 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipallocations/method_get.go @@ -0,0 +1,83 @@ +package ipallocations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IPAllocation +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c IPAllocationsClient) Get(ctx context.Context, id IPAllocationId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model IPAllocation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/ipallocations/method_list.go b/resource-manager/network/2024-07-01/ipallocations/method_list.go new file mode 100644 index 00000000000..4fa34481651 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipallocations/method_list.go @@ -0,0 +1,106 @@ +package ipallocations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IPAllocation +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []IPAllocation +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c IPAllocationsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/ipAllocations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]IPAllocation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c IPAllocationsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, IPAllocationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IPAllocationsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate IPAllocationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]IPAllocation, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/ipallocations/method_listbyresourcegroup.go b/resource-manager/network/2024-07-01/ipallocations/method_listbyresourcegroup.go new file mode 100644 index 00000000000..85abe9a21cd --- /dev/null +++ b/resource-manager/network/2024-07-01/ipallocations/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package ipallocations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IPAllocation +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []IPAllocation +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c IPAllocationsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/ipAllocations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]IPAllocation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c IPAllocationsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, IPAllocationOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IPAllocationsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate IPAllocationOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]IPAllocation, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/ipallocations/method_updatetags.go b/resource-manager/network/2024-07-01/ipallocations/method_updatetags.go new file mode 100644 index 00000000000..f6fe36ff651 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipallocations/method_updatetags.go @@ -0,0 +1,57 @@ +package ipallocations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IPAllocation +} + +// UpdateTags ... +func (c IPAllocationsClient) UpdateTags(ctx context.Context, id IPAllocationId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model IPAllocation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/ipallocations/model_ipallocation.go b/resource-manager/network/2024-07-01/ipallocations/model_ipallocation.go new file mode 100644 index 00000000000..d59b8140ce3 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipallocations/model_ipallocation.go @@ -0,0 +1,14 @@ +package ipallocations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAllocation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPAllocationPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ipallocations/model_ipallocationpropertiesformat.go b/resource-manager/network/2024-07-01/ipallocations/model_ipallocationpropertiesformat.go new file mode 100644 index 00000000000..ee1eec041ee --- /dev/null +++ b/resource-manager/network/2024-07-01/ipallocations/model_ipallocationpropertiesformat.go @@ -0,0 +1,15 @@ +package ipallocations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAllocationPropertiesFormat struct { + AllocationTags *map[string]string `json:"allocationTags,omitempty"` + IPamAllocationId *string `json:"ipamAllocationId,omitempty"` + Prefix *string `json:"prefix,omitempty"` + PrefixLength *int64 `json:"prefixLength,omitempty"` + PrefixType *IPVersion `json:"prefixType,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + Type *IPAllocationType `json:"type,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ipallocations/model_subresource.go b/resource-manager/network/2024-07-01/ipallocations/model_subresource.go new file mode 100644 index 00000000000..3d4e1d6d386 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipallocations/model_subresource.go @@ -0,0 +1,8 @@ +package ipallocations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ipallocations/model_tagsobject.go b/resource-manager/network/2024-07-01/ipallocations/model_tagsobject.go new file mode 100644 index 00000000000..e07b18f03bb --- /dev/null +++ b/resource-manager/network/2024-07-01/ipallocations/model_tagsobject.go @@ -0,0 +1,8 @@ +package ipallocations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ipallocations/predicates.go b/resource-manager/network/2024-07-01/ipallocations/predicates.go new file mode 100644 index 00000000000..5f4e136ae66 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipallocations/predicates.go @@ -0,0 +1,37 @@ +package ipallocations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAllocationOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p IPAllocationOperationPredicate) Matches(input IPAllocation) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/ipallocations/version.go b/resource-manager/network/2024-07-01/ipallocations/version.go new file mode 100644 index 00000000000..88429a40d04 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipallocations/version.go @@ -0,0 +1,10 @@ +package ipallocations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/ipallocations/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/ipampools/README.md b/resource-manager/network/2024-07-01/ipampools/README.md new file mode 100644 index 00000000000..95a5a3622dd --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/README.md @@ -0,0 +1,136 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/ipampools` Documentation + +The `ipampools` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/ipampools" +``` + + +### Client Initialization + +```go +client := ipampools.NewIPamPoolsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `IPamPoolsClient.Create` + +```go +ctx := context.TODO() +id := ipampools.NewIPamPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "ipamPoolName") + +payload := ipampools.IPamPool{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload, ipampools.DefaultCreateOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `IPamPoolsClient.Delete` + +```go +ctx := context.TODO() +id := ipampools.NewIPamPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "ipamPoolName") + +if err := client.DeleteThenPoll(ctx, id, ipampools.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `IPamPoolsClient.Get` + +```go +ctx := context.TODO() +id := ipampools.NewIPamPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "ipamPoolName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `IPamPoolsClient.GetPoolUsage` + +```go +ctx := context.TODO() +id := ipampools.NewIPamPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "ipamPoolName") + +read, err := client.GetPoolUsage(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `IPamPoolsClient.List` + +```go +ctx := context.TODO() +id := ipampools.NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + +// alternatively `client.List(ctx, id, ipampools.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, ipampools.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `IPamPoolsClient.ListAssociatedResources` + +```go +ctx := context.TODO() +id := ipampools.NewIPamPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "ipamPoolName") + +// alternatively `client.ListAssociatedResources(ctx, id)` can be used to do batched pagination +items, err := client.ListAssociatedResourcesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `IPamPoolsClient.Update` + +```go +ctx := context.TODO() +id := ipampools.NewIPamPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "ipamPoolName") + +payload := ipampools.IPamPoolUpdate{ + // ... +} + + +read, err := client.Update(ctx, id, payload, ipampools.DefaultUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/ipampools/client.go b/resource-manager/network/2024-07-01/ipampools/client.go new file mode 100644 index 00000000000..06278ffc53e --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/client.go @@ -0,0 +1,26 @@ +package ipampools + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolsClient struct { + Client *resourcemanager.Client +} + +func NewIPamPoolsClientWithBaseURI(sdkApi sdkEnv.Api) (*IPamPoolsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "ipampools", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating IPamPoolsClient: %+v", err) + } + + return &IPamPoolsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/ipampools/constants.go b/resource-manager/network/2024-07-01/ipampools/constants.go new file mode 100644 index 00000000000..ea1084faf7d --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/constants.go @@ -0,0 +1,104 @@ +package ipampools + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPType string + +const ( + IPTypeIPvFour IPType = "IPv4" + IPTypeIPvSix IPType = "IPv6" +) + +func PossibleValuesForIPType() []string { + return []string{ + string(IPTypeIPvFour), + string(IPTypeIPvSix), + } +} + +func (s *IPType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPType(input string) (*IPType, error) { + vals := map[string]IPType{ + "ipv4": IPTypeIPvFour, + "ipv6": IPTypeIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/ipampools/id_ipampool.go b/resource-manager/network/2024-07-01/ipampools/id_ipampool.go new file mode 100644 index 00000000000..034af2b3cf0 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/id_ipampool.go @@ -0,0 +1,139 @@ +package ipampools + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&IPamPoolId{}) +} + +var _ resourceids.ResourceId = &IPamPoolId{} + +// IPamPoolId is a struct representing the Resource ID for a I Pam Pool +type IPamPoolId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + IpamPoolName string +} + +// NewIPamPoolID returns a new IPamPoolId struct +func NewIPamPoolID(subscriptionId string, resourceGroupName string, networkManagerName string, ipamPoolName string) IPamPoolId { + return IPamPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + IpamPoolName: ipamPoolName, + } +} + +// ParseIPamPoolID parses 'input' into a IPamPoolId +func ParseIPamPoolID(input string) (*IPamPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&IPamPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := IPamPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseIPamPoolIDInsensitively parses 'input' case-insensitively into a IPamPoolId +// note: this method should only be used for API response data and not user input +func ParseIPamPoolIDInsensitively(input string) (*IPamPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&IPamPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := IPamPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *IPamPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.IpamPoolName, ok = input.Parsed["ipamPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ipamPoolName", input) + } + + return nil +} + +// ValidateIPamPoolID checks that 'input' can be parsed as a I Pam Pool ID +func ValidateIPamPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseIPamPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted I Pam Pool ID +func (id IPamPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/ipamPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.IpamPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this I Pam Pool ID +func (id IPamPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticIpamPools", "ipamPools", "ipamPools"), + resourceids.UserSpecifiedSegment("ipamPoolName", "ipamPoolName"), + } +} + +// String returns a human-readable description of this I Pam Pool ID +func (id IPamPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Ipam Pool Name: %q", id.IpamPoolName), + } + return fmt.Sprintf("I Pam Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/ipampools/id_ipampool_test.go b/resource-manager/network/2024-07-01/ipampools/id_ipampool_test.go new file mode 100644 index 00000000000..435427cc818 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/id_ipampool_test.go @@ -0,0 +1,327 @@ +package ipampools + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &IPamPoolId{} + +func TestNewIPamPoolID(t *testing.T) { + id := NewIPamPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "ipamPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.IpamPoolName != "ipamPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'IpamPoolName'", id.IpamPoolName, "ipamPoolName") + } +} + +func TestFormatIPamPoolID(t *testing.T) { + actual := NewIPamPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "ipamPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseIPamPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IPamPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName", + Expected: &IPamPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + IpamPoolName: "ipamPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIPamPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.IpamPoolName != v.Expected.IpamPoolName { + t.Fatalf("Expected %q but got %q for IpamPoolName", v.Expected.IpamPoolName, actual.IpamPoolName) + } + + } +} + +func TestParseIPamPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IPamPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/iPaMpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName", + Expected: &IPamPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + IpamPoolName: "ipamPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/iPaMpOoLs/iPaMpOoLnAmE", + Expected: &IPamPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + IpamPoolName: "iPaMpOoLnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/iPaMpOoLs/iPaMpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIPamPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.IpamPoolName != v.Expected.IpamPoolName { + t.Fatalf("Expected %q but got %q for IpamPoolName", v.Expected.IpamPoolName, actual.IpamPoolName) + } + + } +} + +func TestSegmentsForIPamPoolId(t *testing.T) { + segments := IPamPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("IPamPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/ipampools/id_networkmanager.go b/resource-manager/network/2024-07-01/ipampools/id_networkmanager.go new file mode 100644 index 00000000000..e2bc0d72a2e --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/id_networkmanager.go @@ -0,0 +1,130 @@ +package ipampools + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkManagerId{}) +} + +var _ resourceids.ResourceId = &NetworkManagerId{} + +// NetworkManagerId is a struct representing the Resource ID for a Network Manager +type NetworkManagerId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string +} + +// NewNetworkManagerID returns a new NetworkManagerId struct +func NewNetworkManagerID(subscriptionId string, resourceGroupName string, networkManagerName string) NetworkManagerId { + return NetworkManagerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + } +} + +// ParseNetworkManagerID parses 'input' into a NetworkManagerId +func ParseNetworkManagerID(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkManagerIDInsensitively parses 'input' case-insensitively into a NetworkManagerId +// note: this method should only be used for API response data and not user input +func ParseNetworkManagerIDInsensitively(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkManagerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + return nil +} + +// ValidateNetworkManagerID checks that 'input' can be parsed as a Network Manager ID +func ValidateNetworkManagerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkManagerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Manager ID +func (id NetworkManagerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Manager ID +func (id NetworkManagerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + } +} + +// String returns a human-readable description of this Network Manager ID +func (id NetworkManagerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + } + return fmt.Sprintf("Network Manager (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/ipampools/id_networkmanager_test.go b/resource-manager/network/2024-07-01/ipampools/id_networkmanager_test.go new file mode 100644 index 00000000000..1c3d31ce85e --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/id_networkmanager_test.go @@ -0,0 +1,282 @@ +package ipampools + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkManagerId{} + +func TestNewNetworkManagerID(t *testing.T) { + id := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } +} + +func TestFormatNetworkManagerID(t *testing.T) { + actual := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkManagerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestParseNetworkManagerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestSegmentsForNetworkManagerId(t *testing.T) { + segments := NetworkManagerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkManagerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/ipampools/method_create.go b/resource-manager/network/2024-07-01/ipampools/method_create.go new file mode 100644 index 00000000000..83b0dc72d09 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/method_create.go @@ -0,0 +1,104 @@ +package ipampools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *IPamPool +} + +type CreateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOperationOptions() CreateOperationOptions { + return CreateOperationOptions{} +} + +func (o CreateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CreateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Create ... +func (c IPamPoolsClient) Create(ctx context.Context, id IPamPoolId, input IPamPool, options CreateOperationOptions) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c IPamPoolsClient) CreateThenPoll(ctx context.Context, id IPamPoolId, input IPamPool, options CreateOperationOptions) error { + result, err := c.Create(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/ipampools/method_delete.go b/resource-manager/network/2024-07-01/ipampools/method_delete.go new file mode 100644 index 00000000000..d994cf73794 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/method_delete.go @@ -0,0 +1,99 @@ +package ipampools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c IPamPoolsClient) Delete(ctx context.Context, id IPamPoolId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c IPamPoolsClient) DeleteThenPoll(ctx context.Context, id IPamPoolId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/ipampools/method_get.go b/resource-manager/network/2024-07-01/ipampools/method_get.go new file mode 100644 index 00000000000..157e4a5704a --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/method_get.go @@ -0,0 +1,53 @@ +package ipampools + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IPamPool +} + +// Get ... +func (c IPamPoolsClient) Get(ctx context.Context, id IPamPoolId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model IPamPool + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/ipampools/method_getpoolusage.go b/resource-manager/network/2024-07-01/ipampools/method_getpoolusage.go new file mode 100644 index 00000000000..2f69f7b3603 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/method_getpoolusage.go @@ -0,0 +1,54 @@ +package ipampools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPoolUsageOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PoolUsage +} + +// GetPoolUsage ... +func (c IPamPoolsClient) GetPoolUsage(ctx context.Context, id IPamPoolId) (result GetPoolUsageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getPoolUsage", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PoolUsage + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/ipampools/method_list.go b/resource-manager/network/2024-07-01/ipampools/method_list.go new file mode 100644 index 00000000000..2d3e47cc9da --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/method_list.go @@ -0,0 +1,150 @@ +package ipampools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IPamPool +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []IPamPool +} + +type ListOperationOptions struct { + Skip *int64 + SkipToken *string + SortKey *string + SortValue *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skip != nil { + out.Append("skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + if o.SortKey != nil { + out.Append("sortKey", fmt.Sprintf("%v", *o.SortKey)) + } + if o.SortValue != nil { + out.Append("sortValue", fmt.Sprintf("%v", *o.SortValue)) + } + if o.Top != nil { + out.Append("top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c IPamPoolsClient) List(ctx context.Context, id NetworkManagerId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/ipamPools", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]IPamPool `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c IPamPoolsClient) ListComplete(ctx context.Context, id NetworkManagerId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, IPamPoolOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IPamPoolsClient) ListCompleteMatchingPredicate(ctx context.Context, id NetworkManagerId, options ListOperationOptions, predicate IPamPoolOperationPredicate) (result ListCompleteResult, err error) { + items := make([]IPamPool, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/ipampools/method_listassociatedresources.go b/resource-manager/network/2024-07-01/ipampools/method_listassociatedresources.go new file mode 100644 index 00000000000..7483ea74b5d --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/method_listassociatedresources.go @@ -0,0 +1,105 @@ +package ipampools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAssociatedResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PoolAssociation +} + +type ListAssociatedResourcesCompleteResult struct { + LatestHttpResponse *http.Response + Items []PoolAssociation +} + +type ListAssociatedResourcesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAssociatedResourcesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAssociatedResources ... +func (c IPamPoolsClient) ListAssociatedResources(ctx context.Context, id IPamPoolId) (result ListAssociatedResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListAssociatedResourcesCustomPager{}, + Path: fmt.Sprintf("%s/listAssociatedResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PoolAssociation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAssociatedResourcesComplete retrieves all the results into a single object +func (c IPamPoolsClient) ListAssociatedResourcesComplete(ctx context.Context, id IPamPoolId) (ListAssociatedResourcesCompleteResult, error) { + return c.ListAssociatedResourcesCompleteMatchingPredicate(ctx, id, PoolAssociationOperationPredicate{}) +} + +// ListAssociatedResourcesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IPamPoolsClient) ListAssociatedResourcesCompleteMatchingPredicate(ctx context.Context, id IPamPoolId, predicate PoolAssociationOperationPredicate) (result ListAssociatedResourcesCompleteResult, err error) { + items := make([]PoolAssociation, 0) + + resp, err := c.ListAssociatedResources(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAssociatedResourcesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/ipampools/method_update.go b/resource-manager/network/2024-07-01/ipampools/method_update.go new file mode 100644 index 00000000000..7ae2e6c891e --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/method_update.go @@ -0,0 +1,87 @@ +package ipampools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IPamPool +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c IPamPoolsClient) Update(ctx context.Context, id IPamPoolId, input IPamPoolUpdate, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model IPamPool + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/ipampools/model_ipampool.go b/resource-manager/network/2024-07-01/ipampools/model_ipampool.go new file mode 100644 index 00000000000..0e687aa0d0f --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/model_ipampool.go @@ -0,0 +1,19 @@ +package ipampools + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties IPamPoolProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ipampools/model_ipampoolproperties.go b/resource-manager/network/2024-07-01/ipampools/model_ipampoolproperties.go new file mode 100644 index 00000000000..430ab9b0025 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/model_ipampoolproperties.go @@ -0,0 +1,13 @@ +package ipampools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolProperties struct { + AddressPrefixes []string `json:"addressPrefixes"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + IPAddressType *[]IPType `json:"ipAddressType,omitempty"` + ParentPoolName *string `json:"parentPoolName,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ipampools/model_ipampoolupdate.go b/resource-manager/network/2024-07-01/ipampools/model_ipampoolupdate.go new file mode 100644 index 00000000000..4f97d1735f0 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/model_ipampoolupdate.go @@ -0,0 +1,9 @@ +package ipampools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolUpdate struct { + Properties *IPamPoolUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ipampools/model_ipampoolupdateproperties.go b/resource-manager/network/2024-07-01/ipampools/model_ipampoolupdateproperties.go new file mode 100644 index 00000000000..7ae29805315 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/model_ipampoolupdateproperties.go @@ -0,0 +1,9 @@ +package ipampools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolUpdateProperties struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ipampools/model_poolassociation.go b/resource-manager/network/2024-07-01/ipampools/model_poolassociation.go new file mode 100644 index 00000000000..8d231fb7c33 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/model_poolassociation.go @@ -0,0 +1,46 @@ +package ipampools + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoolAssociation struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + CreatedAt *string `json:"createdAt,omitempty"` + Description *string `json:"description,omitempty"` + NumberOfReservedIPAddresses *string `json:"numberOfReservedIPAddresses,omitempty"` + PoolId *string `json:"poolId,omitempty"` + ReservationExpiresAt *string `json:"reservationExpiresAt,omitempty"` + ReservedPrefixes *[]string `json:"reservedPrefixes,omitempty"` + ResourceId string `json:"resourceId"` + TotalNumberOfIPAddresses *string `json:"totalNumberOfIPAddresses,omitempty"` +} + +func (o *PoolAssociation) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *PoolAssociation) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} + +func (o *PoolAssociation) GetReservationExpiresAtAsTime() (*time.Time, error) { + if o.ReservationExpiresAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ReservationExpiresAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *PoolAssociation) SetReservationExpiresAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ReservationExpiresAt = &formatted +} diff --git a/resource-manager/network/2024-07-01/ipampools/model_poolusage.go b/resource-manager/network/2024-07-01/ipampools/model_poolusage.go new file mode 100644 index 00000000000..8445f551042 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/model_poolusage.go @@ -0,0 +1,16 @@ +package ipampools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PoolUsage struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + AvailableAddressPrefixes *[]string `json:"availableAddressPrefixes,omitempty"` + ChildPools *[]ResourceBasics `json:"childPools,omitempty"` + NumberOfAllocatedIPAddresses *string `json:"numberOfAllocatedIPAddresses,omitempty"` + NumberOfAvailableIPAddresses *string `json:"numberOfAvailableIPAddresses,omitempty"` + NumberOfReservedIPAddresses *string `json:"numberOfReservedIPAddresses,omitempty"` + ReservedAddressPrefixes *[]string `json:"reservedAddressPrefixes,omitempty"` + TotalNumberOfIPAddresses *string `json:"totalNumberOfIPAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ipampools/model_resourcebasics.go b/resource-manager/network/2024-07-01/ipampools/model_resourcebasics.go new file mode 100644 index 00000000000..f3b7a10e061 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/model_resourcebasics.go @@ -0,0 +1,9 @@ +package ipampools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceBasics struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ipampools/predicates.go b/resource-manager/network/2024-07-01/ipampools/predicates.go new file mode 100644 index 00000000000..83d64959e37 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/predicates.go @@ -0,0 +1,80 @@ +package ipampools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p IPamPoolOperationPredicate) Matches(input IPamPool) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type PoolAssociationOperationPredicate struct { + CreatedAt *string + Description *string + NumberOfReservedIPAddresses *string + PoolId *string + ReservationExpiresAt *string + ResourceId *string + TotalNumberOfIPAddresses *string +} + +func (p PoolAssociationOperationPredicate) Matches(input PoolAssociation) bool { + + if p.CreatedAt != nil && (input.CreatedAt == nil || *p.CreatedAt != *input.CreatedAt) { + return false + } + + if p.Description != nil && (input.Description == nil || *p.Description != *input.Description) { + return false + } + + if p.NumberOfReservedIPAddresses != nil && (input.NumberOfReservedIPAddresses == nil || *p.NumberOfReservedIPAddresses != *input.NumberOfReservedIPAddresses) { + return false + } + + if p.PoolId != nil && (input.PoolId == nil || *p.PoolId != *input.PoolId) { + return false + } + + if p.ReservationExpiresAt != nil && (input.ReservationExpiresAt == nil || *p.ReservationExpiresAt != *input.ReservationExpiresAt) { + return false + } + + if p.ResourceId != nil && *p.ResourceId != input.ResourceId { + return false + } + + if p.TotalNumberOfIPAddresses != nil && (input.TotalNumberOfIPAddresses == nil || *p.TotalNumberOfIPAddresses != *input.TotalNumberOfIPAddresses) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/ipampools/version.go b/resource-manager/network/2024-07-01/ipampools/version.go new file mode 100644 index 00000000000..edfcbf47510 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipampools/version.go @@ -0,0 +1,10 @@ +package ipampools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/ipampools/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/ipgroups/README.md b/resource-manager/network/2024-07-01/ipgroups/README.md new file mode 100644 index 00000000000..f53e2358b5e --- /dev/null +++ b/resource-manager/network/2024-07-01/ipgroups/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/ipgroups` Documentation + +The `ipgroups` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/ipgroups" +``` + + +### Client Initialization + +```go +client := ipgroups.NewIPGroupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `IPGroupsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := ipgroups.NewIPGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ipGroupName") + +payload := ipgroups.IPGroup{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `IPGroupsClient.Delete` + +```go +ctx := context.TODO() +id := ipgroups.NewIPGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ipGroupName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `IPGroupsClient.Get` + +```go +ctx := context.TODO() +id := ipgroups.NewIPGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ipGroupName") + +read, err := client.Get(ctx, id, ipgroups.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `IPGroupsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `IPGroupsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `IPGroupsClient.UpdateGroups` + +```go +ctx := context.TODO() +id := ipgroups.NewIPGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ipGroupName") + +payload := ipgroups.TagsObject{ + // ... +} + + +read, err := client.UpdateGroups(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/ipgroups/client.go b/resource-manager/network/2024-07-01/ipgroups/client.go new file mode 100644 index 00000000000..2e7f5ae8116 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipgroups/client.go @@ -0,0 +1,26 @@ +package ipgroups + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPGroupsClient struct { + Client *resourcemanager.Client +} + +func NewIPGroupsClientWithBaseURI(sdkApi sdkEnv.Api) (*IPGroupsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "ipgroups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating IPGroupsClient: %+v", err) + } + + return &IPGroupsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/ipgroups/constants.go b/resource-manager/network/2024-07-01/ipgroups/constants.go new file mode 100644 index 00000000000..a50092f263a --- /dev/null +++ b/resource-manager/network/2024-07-01/ipgroups/constants.go @@ -0,0 +1,57 @@ +package ipgroups + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/ipgroups/id_ipgroup.go b/resource-manager/network/2024-07-01/ipgroups/id_ipgroup.go new file mode 100644 index 00000000000..441c7301b56 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipgroups/id_ipgroup.go @@ -0,0 +1,130 @@ +package ipgroups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&IPGroupId{}) +} + +var _ resourceids.ResourceId = &IPGroupId{} + +// IPGroupId is a struct representing the Resource ID for a I P Group +type IPGroupId struct { + SubscriptionId string + ResourceGroupName string + IpGroupName string +} + +// NewIPGroupID returns a new IPGroupId struct +func NewIPGroupID(subscriptionId string, resourceGroupName string, ipGroupName string) IPGroupId { + return IPGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + IpGroupName: ipGroupName, + } +} + +// ParseIPGroupID parses 'input' into a IPGroupId +func ParseIPGroupID(input string) (*IPGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&IPGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := IPGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseIPGroupIDInsensitively parses 'input' case-insensitively into a IPGroupId +// note: this method should only be used for API response data and not user input +func ParseIPGroupIDInsensitively(input string) (*IPGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&IPGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := IPGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *IPGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.IpGroupName, ok = input.Parsed["ipGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ipGroupName", input) + } + + return nil +} + +// ValidateIPGroupID checks that 'input' can be parsed as a I P Group ID +func ValidateIPGroupID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseIPGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted I P Group ID +func (id IPGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/ipGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.IpGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this I P Group ID +func (id IPGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticIpGroups", "ipGroups", "ipGroups"), + resourceids.UserSpecifiedSegment("ipGroupName", "ipGroupName"), + } +} + +// String returns a human-readable description of this I P Group ID +func (id IPGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Ip Group Name: %q", id.IpGroupName), + } + return fmt.Sprintf("I P Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/ipgroups/id_ipgroup_test.go b/resource-manager/network/2024-07-01/ipgroups/id_ipgroup_test.go new file mode 100644 index 00000000000..e590c1f6bc7 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipgroups/id_ipgroup_test.go @@ -0,0 +1,282 @@ +package ipgroups + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &IPGroupId{} + +func TestNewIPGroupID(t *testing.T) { + id := NewIPGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ipGroupName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.IpGroupName != "ipGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'IpGroupName'", id.IpGroupName, "ipGroupName") + } +} + +func TestFormatIPGroupID(t *testing.T) { + actual := NewIPGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "ipGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ipGroups/ipGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseIPGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IPGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ipGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ipGroups/ipGroupName", + Expected: &IPGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + IpGroupName: "ipGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ipGroups/ipGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIPGroupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.IpGroupName != v.Expected.IpGroupName { + t.Fatalf("Expected %q but got %q for IpGroupName", v.Expected.IpGroupName, actual.IpGroupName) + } + + } +} + +func TestParseIPGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IPGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ipGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/iPgRoUpS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ipGroups/ipGroupName", + Expected: &IPGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + IpGroupName: "ipGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/ipGroups/ipGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/iPgRoUpS/iPgRoUpNaMe", + Expected: &IPGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + IpGroupName: "iPgRoUpNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/iPgRoUpS/iPgRoUpNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIPGroupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.IpGroupName != v.Expected.IpGroupName { + t.Fatalf("Expected %q but got %q for IpGroupName", v.Expected.IpGroupName, actual.IpGroupName) + } + + } +} + +func TestSegmentsForIPGroupId(t *testing.T) { + segments := IPGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("IPGroupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/ipgroups/method_createorupdate.go b/resource-manager/network/2024-07-01/ipgroups/method_createorupdate.go new file mode 100644 index 00000000000..fe09b1c7bf6 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipgroups/method_createorupdate.go @@ -0,0 +1,75 @@ +package ipgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *IPGroup +} + +// CreateOrUpdate ... +func (c IPGroupsClient) CreateOrUpdate(ctx context.Context, id IPGroupId, input IPGroup) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c IPGroupsClient) CreateOrUpdateThenPoll(ctx context.Context, id IPGroupId, input IPGroup) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/ipgroups/method_delete.go b/resource-manager/network/2024-07-01/ipgroups/method_delete.go new file mode 100644 index 00000000000..1e1797dd8d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipgroups/method_delete.go @@ -0,0 +1,71 @@ +package ipgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c IPGroupsClient) Delete(ctx context.Context, id IPGroupId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c IPGroupsClient) DeleteThenPoll(ctx context.Context, id IPGroupId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/ipgroups/method_get.go b/resource-manager/network/2024-07-01/ipgroups/method_get.go new file mode 100644 index 00000000000..8e06e373c58 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipgroups/method_get.go @@ -0,0 +1,83 @@ +package ipgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IPGroup +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c IPGroupsClient) Get(ctx context.Context, id IPGroupId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model IPGroup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/ipgroups/method_list.go b/resource-manager/network/2024-07-01/ipgroups/method_list.go new file mode 100644 index 00000000000..76ec56d5990 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipgroups/method_list.go @@ -0,0 +1,106 @@ +package ipgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IPGroup +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []IPGroup +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c IPGroupsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/ipGroups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]IPGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c IPGroupsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, IPGroupOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IPGroupsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate IPGroupOperationPredicate) (result ListCompleteResult, err error) { + items := make([]IPGroup, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/ipgroups/method_listbyresourcegroup.go b/resource-manager/network/2024-07-01/ipgroups/method_listbyresourcegroup.go new file mode 100644 index 00000000000..16ea08e273b --- /dev/null +++ b/resource-manager/network/2024-07-01/ipgroups/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package ipgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]IPGroup +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []IPGroup +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c IPGroupsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/ipGroups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]IPGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c IPGroupsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, IPGroupOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c IPGroupsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate IPGroupOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]IPGroup, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/ipgroups/method_updategroups.go b/resource-manager/network/2024-07-01/ipgroups/method_updategroups.go new file mode 100644 index 00000000000..bce76083d7a --- /dev/null +++ b/resource-manager/network/2024-07-01/ipgroups/method_updategroups.go @@ -0,0 +1,57 @@ +package ipgroups + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateGroupsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IPGroup +} + +// UpdateGroups ... +func (c IPGroupsClient) UpdateGroups(ctx context.Context, id IPGroupId, input TagsObject) (result UpdateGroupsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model IPGroup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/ipgroups/model_ipgroup.go b/resource-manager/network/2024-07-01/ipgroups/model_ipgroup.go new file mode 100644 index 00000000000..7f586ce2b06 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipgroups/model_ipgroup.go @@ -0,0 +1,14 @@ +package ipgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ipgroups/model_ipgrouppropertiesformat.go b/resource-manager/network/2024-07-01/ipgroups/model_ipgrouppropertiesformat.go new file mode 100644 index 00000000000..866075a1038 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipgroups/model_ipgrouppropertiesformat.go @@ -0,0 +1,11 @@ +package ipgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPGroupPropertiesFormat struct { + FirewallPolicies *[]SubResource `json:"firewallPolicies,omitempty"` + Firewalls *[]SubResource `json:"firewalls,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ipgroups/model_subresource.go b/resource-manager/network/2024-07-01/ipgroups/model_subresource.go new file mode 100644 index 00000000000..5e6c0552f0c --- /dev/null +++ b/resource-manager/network/2024-07-01/ipgroups/model_subresource.go @@ -0,0 +1,8 @@ +package ipgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ipgroups/model_tagsobject.go b/resource-manager/network/2024-07-01/ipgroups/model_tagsobject.go new file mode 100644 index 00000000000..df59e42aff4 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipgroups/model_tagsobject.go @@ -0,0 +1,8 @@ +package ipgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/ipgroups/predicates.go b/resource-manager/network/2024-07-01/ipgroups/predicates.go new file mode 100644 index 00000000000..a64e98c2290 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipgroups/predicates.go @@ -0,0 +1,37 @@ +package ipgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPGroupOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p IPGroupOperationPredicate) Matches(input IPGroup) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/ipgroups/version.go b/resource-manager/network/2024-07-01/ipgroups/version.go new file mode 100644 index 00000000000..69564b60771 --- /dev/null +++ b/resource-manager/network/2024-07-01/ipgroups/version.go @@ -0,0 +1,10 @@ +package ipgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/ipgroups/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/README.md b/resource-manager/network/2024-07-01/loadbalancers/README.md new file mode 100644 index 00000000000..639a1dd2338 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/README.md @@ -0,0 +1,461 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/loadbalancers` Documentation + +The `loadbalancers` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/loadbalancers" +``` + + +### Client Initialization + +```go +client := loadbalancers.NewLoadBalancersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `LoadBalancersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := loadbalancers.NewProviderLoadBalancerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName") + +payload := loadbalancers.LoadBalancer{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `LoadBalancersClient.Delete` + +```go +ctx := context.TODO() +id := loadbalancers.NewProviderLoadBalancerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `LoadBalancersClient.Get` + +```go +ctx := context.TODO() +id := loadbalancers.NewProviderLoadBalancerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName") + +read, err := client.Get(ctx, id, loadbalancers.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LoadBalancersClient.InboundNatRulesCreateOrUpdate` + +```go +ctx := context.TODO() +id := loadbalancers.NewInboundNatRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "inboundNatRuleName") + +payload := loadbalancers.InboundNatRule{ + // ... +} + + +if err := client.InboundNatRulesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `LoadBalancersClient.InboundNatRulesDelete` + +```go +ctx := context.TODO() +id := loadbalancers.NewInboundNatRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "inboundNatRuleName") + +if err := client.InboundNatRulesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `LoadBalancersClient.InboundNatRulesGet` + +```go +ctx := context.TODO() +id := loadbalancers.NewInboundNatRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "inboundNatRuleName") + +read, err := client.InboundNatRulesGet(ctx, id, loadbalancers.DefaultInboundNatRulesGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LoadBalancersClient.InboundNatRulesList` + +```go +ctx := context.TODO() +id := loadbalancers.NewProviderLoadBalancerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName") + +// alternatively `client.InboundNatRulesList(ctx, id)` can be used to do batched pagination +items, err := client.InboundNatRulesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `LoadBalancersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `LoadBalancersClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `LoadBalancersClient.ListInboundNatRulePortMappings` + +```go +ctx := context.TODO() +id := loadbalancers.NewBackendAddressPoolID("12345678-1234-9876-4563-123456789012", "resourceGroupName", "loadBalancerName", "backendAddressPoolName") + +payload := loadbalancers.QueryInboundNatRulePortMappingRequest{ + // ... +} + + +if err := client.ListInboundNatRulePortMappingsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `LoadBalancersClient.LoadBalancerBackendAddressPoolsCreateOrUpdate` + +```go +ctx := context.TODO() +id := loadbalancers.NewLoadBalancerBackendAddressPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "backendAddressPoolName") + +payload := loadbalancers.BackendAddressPool{ + // ... +} + + +if err := client.LoadBalancerBackendAddressPoolsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `LoadBalancersClient.LoadBalancerBackendAddressPoolsDelete` + +```go +ctx := context.TODO() +id := loadbalancers.NewLoadBalancerBackendAddressPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "backendAddressPoolName") + +if err := client.LoadBalancerBackendAddressPoolsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `LoadBalancersClient.LoadBalancerBackendAddressPoolsGet` + +```go +ctx := context.TODO() +id := loadbalancers.NewLoadBalancerBackendAddressPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "backendAddressPoolName") + +read, err := client.LoadBalancerBackendAddressPoolsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LoadBalancersClient.LoadBalancerBackendAddressPoolsList` + +```go +ctx := context.TODO() +id := loadbalancers.NewProviderLoadBalancerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName") + +// alternatively `client.LoadBalancerBackendAddressPoolsList(ctx, id)` can be used to do batched pagination +items, err := client.LoadBalancerBackendAddressPoolsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `LoadBalancersClient.LoadBalancerFrontendIPConfigurationsGet` + +```go +ctx := context.TODO() +id := loadbalancers.NewFrontendIPConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "frontendIPConfigurationName") + +read, err := client.LoadBalancerFrontendIPConfigurationsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LoadBalancersClient.LoadBalancerFrontendIPConfigurationsList` + +```go +ctx := context.TODO() +id := loadbalancers.NewProviderLoadBalancerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName") + +// alternatively `client.LoadBalancerFrontendIPConfigurationsList(ctx, id)` can be used to do batched pagination +items, err := client.LoadBalancerFrontendIPConfigurationsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `LoadBalancersClient.LoadBalancerLoadBalancingRulesGet` + +```go +ctx := context.TODO() +id := loadbalancers.NewLoadBalancerLoadBalancingRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "loadBalancingRuleName") + +read, err := client.LoadBalancerLoadBalancingRulesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LoadBalancersClient.LoadBalancerLoadBalancingRulesHealth` + +```go +ctx := context.TODO() +id := loadbalancers.NewLoadBalancingRuleID("12345678-1234-9876-4563-123456789012", "resourceGroupName", "loadBalancerName", "loadBalancingRuleName") + +if err := client.LoadBalancerLoadBalancingRulesHealthThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `LoadBalancersClient.LoadBalancerLoadBalancingRulesList` + +```go +ctx := context.TODO() +id := loadbalancers.NewProviderLoadBalancerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName") + +// alternatively `client.LoadBalancerLoadBalancingRulesList(ctx, id)` can be used to do batched pagination +items, err := client.LoadBalancerLoadBalancingRulesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `LoadBalancersClient.LoadBalancerNetworkInterfacesList` + +```go +ctx := context.TODO() +id := loadbalancers.NewProviderLoadBalancerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName") + +// alternatively `client.LoadBalancerNetworkInterfacesList(ctx, id)` can be used to do batched pagination +items, err := client.LoadBalancerNetworkInterfacesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `LoadBalancersClient.LoadBalancerOutboundRulesGet` + +```go +ctx := context.TODO() +id := loadbalancers.NewOutboundRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "outboundRuleName") + +read, err := client.LoadBalancerOutboundRulesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LoadBalancersClient.LoadBalancerOutboundRulesList` + +```go +ctx := context.TODO() +id := loadbalancers.NewProviderLoadBalancerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName") + +// alternatively `client.LoadBalancerOutboundRulesList(ctx, id)` can be used to do batched pagination +items, err := client.LoadBalancerOutboundRulesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `LoadBalancersClient.LoadBalancerProbesGet` + +```go +ctx := context.TODO() +id := loadbalancers.NewProbeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "probeName") + +read, err := client.LoadBalancerProbesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LoadBalancersClient.LoadBalancerProbesList` + +```go +ctx := context.TODO() +id := loadbalancers.NewProviderLoadBalancerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName") + +// alternatively `client.LoadBalancerProbesList(ctx, id)` can be used to do batched pagination +items, err := client.LoadBalancerProbesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `LoadBalancersClient.MigrateToIPBased` + +```go +ctx := context.TODO() +id := loadbalancers.NewLoadBalancerID("12345678-1234-9876-4563-123456789012", "resourceGroupName", "loadBalancerName") + +payload := loadbalancers.MigrateLoadBalancerToIPBasedRequest{ + // ... +} + + +read, err := client.MigrateToIPBased(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LoadBalancersClient.SwapPublicIPAddresses` + +```go +ctx := context.TODO() +id := loadbalancers.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := loadbalancers.LoadBalancerVipSwapRequest{ + // ... +} + + +if err := client.SwapPublicIPAddressesThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `LoadBalancersClient.UpdateTags` + +```go +ctx := context.TODO() +id := loadbalancers.NewProviderLoadBalancerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName") + +payload := loadbalancers.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/loadbalancers/client.go b/resource-manager/network/2024-07-01/loadbalancers/client.go new file mode 100644 index 00000000000..e0ea457759e --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/client.go @@ -0,0 +1,26 @@ +package loadbalancers + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancersClient struct { + Client *resourcemanager.Client +} + +func NewLoadBalancersClientWithBaseURI(sdkApi sdkEnv.Api) (*LoadBalancersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "loadbalancers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LoadBalancersClient: %+v", err) + } + + return &LoadBalancersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/constants.go b/resource-manager/network/2024-07-01/loadbalancers/constants.go new file mode 100644 index 00000000000..a9f5490107e --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/constants.go @@ -0,0 +1,1462 @@ +package loadbalancers + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type LoadBalancerOutboundRuleProtocol string + +const ( + LoadBalancerOutboundRuleProtocolAll LoadBalancerOutboundRuleProtocol = "All" + LoadBalancerOutboundRuleProtocolTcp LoadBalancerOutboundRuleProtocol = "Tcp" + LoadBalancerOutboundRuleProtocolUdp LoadBalancerOutboundRuleProtocol = "Udp" +) + +func PossibleValuesForLoadBalancerOutboundRuleProtocol() []string { + return []string{ + string(LoadBalancerOutboundRuleProtocolAll), + string(LoadBalancerOutboundRuleProtocolTcp), + string(LoadBalancerOutboundRuleProtocolUdp), + } +} + +func (s *LoadBalancerOutboundRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerOutboundRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerOutboundRuleProtocol(input string) (*LoadBalancerOutboundRuleProtocol, error) { + vals := map[string]LoadBalancerOutboundRuleProtocol{ + "all": LoadBalancerOutboundRuleProtocolAll, + "tcp": LoadBalancerOutboundRuleProtocolTcp, + "udp": LoadBalancerOutboundRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerOutboundRuleProtocol(input) + return &out, nil +} + +type LoadBalancerSkuName string + +const ( + LoadBalancerSkuNameBasic LoadBalancerSkuName = "Basic" + LoadBalancerSkuNameGateway LoadBalancerSkuName = "Gateway" + LoadBalancerSkuNameStandard LoadBalancerSkuName = "Standard" +) + +func PossibleValuesForLoadBalancerSkuName() []string { + return []string{ + string(LoadBalancerSkuNameBasic), + string(LoadBalancerSkuNameGateway), + string(LoadBalancerSkuNameStandard), + } +} + +func (s *LoadBalancerSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerSkuName(input string) (*LoadBalancerSkuName, error) { + vals := map[string]LoadBalancerSkuName{ + "basic": LoadBalancerSkuNameBasic, + "gateway": LoadBalancerSkuNameGateway, + "standard": LoadBalancerSkuNameStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerSkuName(input) + return &out, nil +} + +type LoadBalancerSkuTier string + +const ( + LoadBalancerSkuTierGlobal LoadBalancerSkuTier = "Global" + LoadBalancerSkuTierRegional LoadBalancerSkuTier = "Regional" +) + +func PossibleValuesForLoadBalancerSkuTier() []string { + return []string{ + string(LoadBalancerSkuTierGlobal), + string(LoadBalancerSkuTierRegional), + } +} + +func (s *LoadBalancerSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerSkuTier(input string) (*LoadBalancerSkuTier, error) { + vals := map[string]LoadBalancerSkuTier{ + "global": LoadBalancerSkuTierGlobal, + "regional": LoadBalancerSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerSkuTier(input) + return &out, nil +} + +type LoadDistribution string + +const ( + LoadDistributionDefault LoadDistribution = "Default" + LoadDistributionSourceIP LoadDistribution = "SourceIP" + LoadDistributionSourceIPProtocol LoadDistribution = "SourceIPProtocol" +) + +func PossibleValuesForLoadDistribution() []string { + return []string{ + string(LoadDistributionDefault), + string(LoadDistributionSourceIP), + string(LoadDistributionSourceIPProtocol), + } +} + +func (s *LoadDistribution) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadDistribution(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadDistribution(input string) (*LoadDistribution, error) { + vals := map[string]LoadDistribution{ + "default": LoadDistributionDefault, + "sourceip": LoadDistributionSourceIP, + "sourceipprotocol": LoadDistributionSourceIPProtocol, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadDistribution(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProbeNoHealthyBackendsBehavior string + +const ( + ProbeNoHealthyBackendsBehaviorAllProbedDown ProbeNoHealthyBackendsBehavior = "AllProbedDown" + ProbeNoHealthyBackendsBehaviorAllProbedUp ProbeNoHealthyBackendsBehavior = "AllProbedUp" +) + +func PossibleValuesForProbeNoHealthyBackendsBehavior() []string { + return []string{ + string(ProbeNoHealthyBackendsBehaviorAllProbedDown), + string(ProbeNoHealthyBackendsBehaviorAllProbedUp), + } +} + +func (s *ProbeNoHealthyBackendsBehavior) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProbeNoHealthyBackendsBehavior(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProbeNoHealthyBackendsBehavior(input string) (*ProbeNoHealthyBackendsBehavior, error) { + vals := map[string]ProbeNoHealthyBackendsBehavior{ + "allprobeddown": ProbeNoHealthyBackendsBehaviorAllProbedDown, + "allprobedup": ProbeNoHealthyBackendsBehaviorAllProbedUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProbeNoHealthyBackendsBehavior(input) + return &out, nil +} + +type ProbeProtocol string + +const ( + ProbeProtocolHTTP ProbeProtocol = "Http" + ProbeProtocolHTTPS ProbeProtocol = "Https" + ProbeProtocolTcp ProbeProtocol = "Tcp" +) + +func PossibleValuesForProbeProtocol() []string { + return []string{ + string(ProbeProtocolHTTP), + string(ProbeProtocolHTTPS), + string(ProbeProtocolTcp), + } +} + +func (s *ProbeProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProbeProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProbeProtocol(input string) (*ProbeProtocol, error) { + vals := map[string]ProbeProtocol{ + "http": ProbeProtocolHTTP, + "https": ProbeProtocolHTTPS, + "tcp": ProbeProtocolTcp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProbeProtocol(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_backendaddresspool.go b/resource-manager/network/2024-07-01/loadbalancers/id_backendaddresspool.go new file mode 100644 index 00000000000..9984348c234 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_backendaddresspool.go @@ -0,0 +1,139 @@ +package loadbalancers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackendAddressPoolId{}) +} + +var _ resourceids.ResourceId = &BackendAddressPoolId{} + +// BackendAddressPoolId is a struct representing the Resource ID for a Backend Address Pool +type BackendAddressPoolId struct { + SubscriptionId string + ResourceGroupName string + LoadBalancerName string + BackendAddressPoolName string +} + +// NewBackendAddressPoolID returns a new BackendAddressPoolId struct +func NewBackendAddressPoolID(subscriptionId string, resourceGroupName string, loadBalancerName string, backendAddressPoolName string) BackendAddressPoolId { + return BackendAddressPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LoadBalancerName: loadBalancerName, + BackendAddressPoolName: backendAddressPoolName, + } +} + +// ParseBackendAddressPoolID parses 'input' into a BackendAddressPoolId +func ParseBackendAddressPoolID(input string) (*BackendAddressPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackendAddressPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackendAddressPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackendAddressPoolIDInsensitively parses 'input' case-insensitively into a BackendAddressPoolId +// note: this method should only be used for API response data and not user input +func ParseBackendAddressPoolIDInsensitively(input string) (*BackendAddressPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackendAddressPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackendAddressPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackendAddressPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LoadBalancerName, ok = input.Parsed["loadBalancerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "loadBalancerName", input) + } + + if id.BackendAddressPoolName, ok = input.Parsed["backendAddressPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backendAddressPoolName", input) + } + + return nil +} + +// ValidateBackendAddressPoolID checks that 'input' can be parsed as a Backend Address Pool ID +func ValidateBackendAddressPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackendAddressPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backend Address Pool ID +func (id BackendAddressPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/loadBalancers/%s/backendAddressPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LoadBalancerName, id.BackendAddressPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backend Address Pool ID +func (id BackendAddressPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.UserSpecifiedSegment("resourceGroupName", "resourceGroupName"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLoadBalancers", "loadBalancers", "loadBalancers"), + resourceids.UserSpecifiedSegment("loadBalancerName", "loadBalancerName"), + resourceids.StaticSegment("staticBackendAddressPools", "backendAddressPools", "backendAddressPools"), + resourceids.UserSpecifiedSegment("backendAddressPoolName", "backendAddressPoolName"), + } +} + +// String returns a human-readable description of this Backend Address Pool ID +func (id BackendAddressPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Load Balancer Name: %q", id.LoadBalancerName), + fmt.Sprintf("Backend Address Pool Name: %q", id.BackendAddressPoolName), + } + return fmt.Sprintf("Backend Address Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_backendaddresspool_test.go b/resource-manager/network/2024-07-01/loadbalancers/id_backendaddresspool_test.go new file mode 100644 index 00000000000..b8334fde60c --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_backendaddresspool_test.go @@ -0,0 +1,327 @@ +package loadbalancers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackendAddressPoolId{} + +func TestNewBackendAddressPoolID(t *testing.T) { + id := NewBackendAddressPoolID("12345678-1234-9876-4563-123456789012", "resourceGroupName", "loadBalancerName", "backendAddressPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "resourceGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "resourceGroupName") + } + + if id.LoadBalancerName != "loadBalancerName" { + t.Fatalf("Expected %q but got %q for Segment 'LoadBalancerName'", id.LoadBalancerName, "loadBalancerName") + } + + if id.BackendAddressPoolName != "backendAddressPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'BackendAddressPoolName'", id.BackendAddressPoolName, "backendAddressPoolName") + } +} + +func TestFormatBackendAddressPoolID(t *testing.T) { + actual := NewBackendAddressPoolID("12345678-1234-9876-4563-123456789012", "resourceGroupName", "loadBalancerName", "backendAddressPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName/backendAddressPools/backendAddressPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackendAddressPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackendAddressPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName/backendAddressPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName/backendAddressPools/backendAddressPoolName", + Expected: &BackendAddressPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "resourceGroupName", + LoadBalancerName: "loadBalancerName", + BackendAddressPoolName: "backendAddressPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName/backendAddressPools/backendAddressPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackendAddressPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + if actual.BackendAddressPoolName != v.Expected.BackendAddressPoolName { + t.Fatalf("Expected %q but got %q for BackendAddressPoolName", v.Expected.BackendAddressPoolName, actual.BackendAddressPoolName) + } + + } +} + +func TestParseBackendAddressPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackendAddressPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName/backendAddressPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/bAcKeNdAdDrEsSpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName/backendAddressPools/backendAddressPoolName", + Expected: &BackendAddressPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "resourceGroupName", + LoadBalancerName: "loadBalancerName", + BackendAddressPoolName: "backendAddressPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName/backendAddressPools/backendAddressPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/bAcKeNdAdDrEsSpOoLs/bAcKeNdAdDrEsSpOoLnAmE", + Expected: &BackendAddressPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "rEsOuRcEgRoUpNaMe", + LoadBalancerName: "lOaDbAlAnCeRnAmE", + BackendAddressPoolName: "bAcKeNdAdDrEsSpOoLnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/bAcKeNdAdDrEsSpOoLs/bAcKeNdAdDrEsSpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackendAddressPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + if actual.BackendAddressPoolName != v.Expected.BackendAddressPoolName { + t.Fatalf("Expected %q but got %q for BackendAddressPoolName", v.Expected.BackendAddressPoolName, actual.BackendAddressPoolName) + } + + } +} + +func TestSegmentsForBackendAddressPoolId(t *testing.T) { + segments := BackendAddressPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackendAddressPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_frontendipconfiguration.go b/resource-manager/network/2024-07-01/loadbalancers/id_frontendipconfiguration.go new file mode 100644 index 00000000000..ed800474fe9 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_frontendipconfiguration.go @@ -0,0 +1,139 @@ +package loadbalancers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&FrontendIPConfigurationId{}) +} + +var _ resourceids.ResourceId = &FrontendIPConfigurationId{} + +// FrontendIPConfigurationId is a struct representing the Resource ID for a Frontend I P Configuration +type FrontendIPConfigurationId struct { + SubscriptionId string + ResourceGroupName string + LoadBalancerName string + FrontendIPConfigurationName string +} + +// NewFrontendIPConfigurationID returns a new FrontendIPConfigurationId struct +func NewFrontendIPConfigurationID(subscriptionId string, resourceGroupName string, loadBalancerName string, frontendIPConfigurationName string) FrontendIPConfigurationId { + return FrontendIPConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LoadBalancerName: loadBalancerName, + FrontendIPConfigurationName: frontendIPConfigurationName, + } +} + +// ParseFrontendIPConfigurationID parses 'input' into a FrontendIPConfigurationId +func ParseFrontendIPConfigurationID(input string) (*FrontendIPConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&FrontendIPConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FrontendIPConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFrontendIPConfigurationIDInsensitively parses 'input' case-insensitively into a FrontendIPConfigurationId +// note: this method should only be used for API response data and not user input +func ParseFrontendIPConfigurationIDInsensitively(input string) (*FrontendIPConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&FrontendIPConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FrontendIPConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FrontendIPConfigurationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LoadBalancerName, ok = input.Parsed["loadBalancerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "loadBalancerName", input) + } + + if id.FrontendIPConfigurationName, ok = input.Parsed["frontendIPConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "frontendIPConfigurationName", input) + } + + return nil +} + +// ValidateFrontendIPConfigurationID checks that 'input' can be parsed as a Frontend I P Configuration ID +func ValidateFrontendIPConfigurationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseFrontendIPConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Frontend I P Configuration ID +func (id FrontendIPConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/loadBalancers/%s/frontendIPConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LoadBalancerName, id.FrontendIPConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Frontend I P Configuration ID +func (id FrontendIPConfigurationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLoadBalancers", "loadBalancers", "loadBalancers"), + resourceids.UserSpecifiedSegment("loadBalancerName", "loadBalancerName"), + resourceids.StaticSegment("staticFrontendIPConfigurations", "frontendIPConfigurations", "frontendIPConfigurations"), + resourceids.UserSpecifiedSegment("frontendIPConfigurationName", "frontendIPConfigurationName"), + } +} + +// String returns a human-readable description of this Frontend I P Configuration ID +func (id FrontendIPConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Load Balancer Name: %q", id.LoadBalancerName), + fmt.Sprintf("Frontend I P Configuration Name: %q", id.FrontendIPConfigurationName), + } + return fmt.Sprintf("Frontend I P Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_frontendipconfiguration_test.go b/resource-manager/network/2024-07-01/loadbalancers/id_frontendipconfiguration_test.go new file mode 100644 index 00000000000..31f0760aa8d --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_frontendipconfiguration_test.go @@ -0,0 +1,327 @@ +package loadbalancers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &FrontendIPConfigurationId{} + +func TestNewFrontendIPConfigurationID(t *testing.T) { + id := NewFrontendIPConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "frontendIPConfigurationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LoadBalancerName != "loadBalancerName" { + t.Fatalf("Expected %q but got %q for Segment 'LoadBalancerName'", id.LoadBalancerName, "loadBalancerName") + } + + if id.FrontendIPConfigurationName != "frontendIPConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'FrontendIPConfigurationName'", id.FrontendIPConfigurationName, "frontendIPConfigurationName") + } +} + +func TestFormatFrontendIPConfigurationID(t *testing.T) { + actual := NewFrontendIPConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "frontendIPConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/frontendIPConfigurations/frontendIPConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFrontendIPConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FrontendIPConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/frontendIPConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/frontendIPConfigurations/frontendIPConfigurationName", + Expected: &FrontendIPConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LoadBalancerName: "loadBalancerName", + FrontendIPConfigurationName: "frontendIPConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/frontendIPConfigurations/frontendIPConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFrontendIPConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + if actual.FrontendIPConfigurationName != v.Expected.FrontendIPConfigurationName { + t.Fatalf("Expected %q but got %q for FrontendIPConfigurationName", v.Expected.FrontendIPConfigurationName, actual.FrontendIPConfigurationName) + } + + } +} + +func TestParseFrontendIPConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FrontendIPConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/frontendIPConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/fRoNtEnDiPcOnFiGuRaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/frontendIPConfigurations/frontendIPConfigurationName", + Expected: &FrontendIPConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LoadBalancerName: "loadBalancerName", + FrontendIPConfigurationName: "frontendIPConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/frontendIPConfigurations/frontendIPConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/fRoNtEnDiPcOnFiGuRaTiOnS/fRoNtEnDiPcOnFiGuRaTiOnNaMe", + Expected: &FrontendIPConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LoadBalancerName: "lOaDbAlAnCeRnAmE", + FrontendIPConfigurationName: "fRoNtEnDiPcOnFiGuRaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/fRoNtEnDiPcOnFiGuRaTiOnS/fRoNtEnDiPcOnFiGuRaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFrontendIPConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + if actual.FrontendIPConfigurationName != v.Expected.FrontendIPConfigurationName { + t.Fatalf("Expected %q but got %q for FrontendIPConfigurationName", v.Expected.FrontendIPConfigurationName, actual.FrontendIPConfigurationName) + } + + } +} + +func TestSegmentsForFrontendIPConfigurationId(t *testing.T) { + segments := FrontendIPConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FrontendIPConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_inboundnatrule.go b/resource-manager/network/2024-07-01/loadbalancers/id_inboundnatrule.go new file mode 100644 index 00000000000..0e4b79cc619 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_inboundnatrule.go @@ -0,0 +1,139 @@ +package loadbalancers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&InboundNatRuleId{}) +} + +var _ resourceids.ResourceId = &InboundNatRuleId{} + +// InboundNatRuleId is a struct representing the Resource ID for a Inbound Nat Rule +type InboundNatRuleId struct { + SubscriptionId string + ResourceGroupName string + LoadBalancerName string + InboundNatRuleName string +} + +// NewInboundNatRuleID returns a new InboundNatRuleId struct +func NewInboundNatRuleID(subscriptionId string, resourceGroupName string, loadBalancerName string, inboundNatRuleName string) InboundNatRuleId { + return InboundNatRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LoadBalancerName: loadBalancerName, + InboundNatRuleName: inboundNatRuleName, + } +} + +// ParseInboundNatRuleID parses 'input' into a InboundNatRuleId +func ParseInboundNatRuleID(input string) (*InboundNatRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&InboundNatRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InboundNatRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseInboundNatRuleIDInsensitively parses 'input' case-insensitively into a InboundNatRuleId +// note: this method should only be used for API response data and not user input +func ParseInboundNatRuleIDInsensitively(input string) (*InboundNatRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&InboundNatRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InboundNatRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *InboundNatRuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LoadBalancerName, ok = input.Parsed["loadBalancerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "loadBalancerName", input) + } + + if id.InboundNatRuleName, ok = input.Parsed["inboundNatRuleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "inboundNatRuleName", input) + } + + return nil +} + +// ValidateInboundNatRuleID checks that 'input' can be parsed as a Inbound Nat Rule ID +func ValidateInboundNatRuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseInboundNatRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Inbound Nat Rule ID +func (id InboundNatRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/loadBalancers/%s/inboundNatRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LoadBalancerName, id.InboundNatRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Inbound Nat Rule ID +func (id InboundNatRuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLoadBalancers", "loadBalancers", "loadBalancers"), + resourceids.UserSpecifiedSegment("loadBalancerName", "loadBalancerName"), + resourceids.StaticSegment("staticInboundNatRules", "inboundNatRules", "inboundNatRules"), + resourceids.UserSpecifiedSegment("inboundNatRuleName", "inboundNatRuleName"), + } +} + +// String returns a human-readable description of this Inbound Nat Rule ID +func (id InboundNatRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Load Balancer Name: %q", id.LoadBalancerName), + fmt.Sprintf("Inbound Nat Rule Name: %q", id.InboundNatRuleName), + } + return fmt.Sprintf("Inbound Nat Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_inboundnatrule_test.go b/resource-manager/network/2024-07-01/loadbalancers/id_inboundnatrule_test.go new file mode 100644 index 00000000000..cfc5c66b6c5 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_inboundnatrule_test.go @@ -0,0 +1,327 @@ +package loadbalancers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &InboundNatRuleId{} + +func TestNewInboundNatRuleID(t *testing.T) { + id := NewInboundNatRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "inboundNatRuleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LoadBalancerName != "loadBalancerName" { + t.Fatalf("Expected %q but got %q for Segment 'LoadBalancerName'", id.LoadBalancerName, "loadBalancerName") + } + + if id.InboundNatRuleName != "inboundNatRuleName" { + t.Fatalf("Expected %q but got %q for Segment 'InboundNatRuleName'", id.InboundNatRuleName, "inboundNatRuleName") + } +} + +func TestFormatInboundNatRuleID(t *testing.T) { + actual := NewInboundNatRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "inboundNatRuleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/inboundNatRules/inboundNatRuleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseInboundNatRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InboundNatRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/inboundNatRules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/inboundNatRules/inboundNatRuleName", + Expected: &InboundNatRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LoadBalancerName: "loadBalancerName", + InboundNatRuleName: "inboundNatRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/inboundNatRules/inboundNatRuleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInboundNatRuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + if actual.InboundNatRuleName != v.Expected.InboundNatRuleName { + t.Fatalf("Expected %q but got %q for InboundNatRuleName", v.Expected.InboundNatRuleName, actual.InboundNatRuleName) + } + + } +} + +func TestParseInboundNatRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InboundNatRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/inboundNatRules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/iNbOuNdNaTrUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/inboundNatRules/inboundNatRuleName", + Expected: &InboundNatRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LoadBalancerName: "loadBalancerName", + InboundNatRuleName: "inboundNatRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/inboundNatRules/inboundNatRuleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/iNbOuNdNaTrUlEs/iNbOuNdNaTrUlEnAmE", + Expected: &InboundNatRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LoadBalancerName: "lOaDbAlAnCeRnAmE", + InboundNatRuleName: "iNbOuNdNaTrUlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/iNbOuNdNaTrUlEs/iNbOuNdNaTrUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInboundNatRuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + if actual.InboundNatRuleName != v.Expected.InboundNatRuleName { + t.Fatalf("Expected %q but got %q for InboundNatRuleName", v.Expected.InboundNatRuleName, actual.InboundNatRuleName) + } + + } +} + +func TestSegmentsForInboundNatRuleId(t *testing.T) { + segments := InboundNatRuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("InboundNatRuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancer.go b/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancer.go new file mode 100644 index 00000000000..61207d17d8d --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancer.go @@ -0,0 +1,130 @@ +package loadbalancers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LoadBalancerId{}) +} + +var _ resourceids.ResourceId = &LoadBalancerId{} + +// LoadBalancerId is a struct representing the Resource ID for a Load Balancer +type LoadBalancerId struct { + SubscriptionId string + ResourceGroupName string + LoadBalancerName string +} + +// NewLoadBalancerID returns a new LoadBalancerId struct +func NewLoadBalancerID(subscriptionId string, resourceGroupName string, loadBalancerName string) LoadBalancerId { + return LoadBalancerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LoadBalancerName: loadBalancerName, + } +} + +// ParseLoadBalancerID parses 'input' into a LoadBalancerId +func ParseLoadBalancerID(input string) (*LoadBalancerId, error) { + parser := resourceids.NewParserFromResourceIdType(&LoadBalancerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LoadBalancerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLoadBalancerIDInsensitively parses 'input' case-insensitively into a LoadBalancerId +// note: this method should only be used for API response data and not user input +func ParseLoadBalancerIDInsensitively(input string) (*LoadBalancerId, error) { + parser := resourceids.NewParserFromResourceIdType(&LoadBalancerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LoadBalancerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LoadBalancerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LoadBalancerName, ok = input.Parsed["loadBalancerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "loadBalancerName", input) + } + + return nil +} + +// ValidateLoadBalancerID checks that 'input' can be parsed as a Load Balancer ID +func ValidateLoadBalancerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLoadBalancerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Load Balancer ID +func (id LoadBalancerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/loadBalancers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LoadBalancerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Load Balancer ID +func (id LoadBalancerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.UserSpecifiedSegment("resourceGroupName", "resourceGroupName"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLoadBalancers", "loadBalancers", "loadBalancers"), + resourceids.UserSpecifiedSegment("loadBalancerName", "loadBalancerName"), + } +} + +// String returns a human-readable description of this Load Balancer ID +func (id LoadBalancerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Load Balancer Name: %q", id.LoadBalancerName), + } + return fmt.Sprintf("Load Balancer (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancer_test.go b/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancer_test.go new file mode 100644 index 00000000000..5e02836d140 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancer_test.go @@ -0,0 +1,282 @@ +package loadbalancers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LoadBalancerId{} + +func TestNewLoadBalancerID(t *testing.T) { + id := NewLoadBalancerID("12345678-1234-9876-4563-123456789012", "resourceGroupName", "loadBalancerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "resourceGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "resourceGroupName") + } + + if id.LoadBalancerName != "loadBalancerName" { + t.Fatalf("Expected %q but got %q for Segment 'LoadBalancerName'", id.LoadBalancerName, "loadBalancerName") + } +} + +func TestFormatLoadBalancerID(t *testing.T) { + actual := NewLoadBalancerID("12345678-1234-9876-4563-123456789012", "resourceGroupName", "loadBalancerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLoadBalancerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LoadBalancerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Expected: &LoadBalancerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "resourceGroupName", + LoadBalancerName: "loadBalancerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLoadBalancerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + } +} + +func TestParseLoadBalancerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LoadBalancerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Expected: &LoadBalancerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "resourceGroupName", + LoadBalancerName: "loadBalancerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE", + Expected: &LoadBalancerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "rEsOuRcEgRoUpNaMe", + LoadBalancerName: "lOaDbAlAnCeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLoadBalancerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + } +} + +func TestSegmentsForLoadBalancerId(t *testing.T) { + segments := LoadBalancerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LoadBalancerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancerbackendaddresspool.go b/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancerbackendaddresspool.go new file mode 100644 index 00000000000..f50fa912ccd --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancerbackendaddresspool.go @@ -0,0 +1,139 @@ +package loadbalancers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LoadBalancerBackendAddressPoolId{}) +} + +var _ resourceids.ResourceId = &LoadBalancerBackendAddressPoolId{} + +// LoadBalancerBackendAddressPoolId is a struct representing the Resource ID for a Load Balancer Backend Address Pool +type LoadBalancerBackendAddressPoolId struct { + SubscriptionId string + ResourceGroupName string + LoadBalancerName string + BackendAddressPoolName string +} + +// NewLoadBalancerBackendAddressPoolID returns a new LoadBalancerBackendAddressPoolId struct +func NewLoadBalancerBackendAddressPoolID(subscriptionId string, resourceGroupName string, loadBalancerName string, backendAddressPoolName string) LoadBalancerBackendAddressPoolId { + return LoadBalancerBackendAddressPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LoadBalancerName: loadBalancerName, + BackendAddressPoolName: backendAddressPoolName, + } +} + +// ParseLoadBalancerBackendAddressPoolID parses 'input' into a LoadBalancerBackendAddressPoolId +func ParseLoadBalancerBackendAddressPoolID(input string) (*LoadBalancerBackendAddressPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&LoadBalancerBackendAddressPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LoadBalancerBackendAddressPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLoadBalancerBackendAddressPoolIDInsensitively parses 'input' case-insensitively into a LoadBalancerBackendAddressPoolId +// note: this method should only be used for API response data and not user input +func ParseLoadBalancerBackendAddressPoolIDInsensitively(input string) (*LoadBalancerBackendAddressPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&LoadBalancerBackendAddressPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LoadBalancerBackendAddressPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LoadBalancerBackendAddressPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LoadBalancerName, ok = input.Parsed["loadBalancerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "loadBalancerName", input) + } + + if id.BackendAddressPoolName, ok = input.Parsed["backendAddressPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backendAddressPoolName", input) + } + + return nil +} + +// ValidateLoadBalancerBackendAddressPoolID checks that 'input' can be parsed as a Load Balancer Backend Address Pool ID +func ValidateLoadBalancerBackendAddressPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLoadBalancerBackendAddressPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Load Balancer Backend Address Pool ID +func (id LoadBalancerBackendAddressPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/loadBalancers/%s/backendAddressPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LoadBalancerName, id.BackendAddressPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Load Balancer Backend Address Pool ID +func (id LoadBalancerBackendAddressPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLoadBalancers", "loadBalancers", "loadBalancers"), + resourceids.UserSpecifiedSegment("loadBalancerName", "loadBalancerName"), + resourceids.StaticSegment("staticBackendAddressPools", "backendAddressPools", "backendAddressPools"), + resourceids.UserSpecifiedSegment("backendAddressPoolName", "backendAddressPoolName"), + } +} + +// String returns a human-readable description of this Load Balancer Backend Address Pool ID +func (id LoadBalancerBackendAddressPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Load Balancer Name: %q", id.LoadBalancerName), + fmt.Sprintf("Backend Address Pool Name: %q", id.BackendAddressPoolName), + } + return fmt.Sprintf("Load Balancer Backend Address Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancerbackendaddresspool_test.go b/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancerbackendaddresspool_test.go new file mode 100644 index 00000000000..23c51050c0b --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancerbackendaddresspool_test.go @@ -0,0 +1,327 @@ +package loadbalancers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LoadBalancerBackendAddressPoolId{} + +func TestNewLoadBalancerBackendAddressPoolID(t *testing.T) { + id := NewLoadBalancerBackendAddressPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "backendAddressPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LoadBalancerName != "loadBalancerName" { + t.Fatalf("Expected %q but got %q for Segment 'LoadBalancerName'", id.LoadBalancerName, "loadBalancerName") + } + + if id.BackendAddressPoolName != "backendAddressPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'BackendAddressPoolName'", id.BackendAddressPoolName, "backendAddressPoolName") + } +} + +func TestFormatLoadBalancerBackendAddressPoolID(t *testing.T) { + actual := NewLoadBalancerBackendAddressPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "backendAddressPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/backendAddressPools/backendAddressPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLoadBalancerBackendAddressPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LoadBalancerBackendAddressPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/backendAddressPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/backendAddressPools/backendAddressPoolName", + Expected: &LoadBalancerBackendAddressPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LoadBalancerName: "loadBalancerName", + BackendAddressPoolName: "backendAddressPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/backendAddressPools/backendAddressPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLoadBalancerBackendAddressPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + if actual.BackendAddressPoolName != v.Expected.BackendAddressPoolName { + t.Fatalf("Expected %q but got %q for BackendAddressPoolName", v.Expected.BackendAddressPoolName, actual.BackendAddressPoolName) + } + + } +} + +func TestParseLoadBalancerBackendAddressPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LoadBalancerBackendAddressPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/backendAddressPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/bAcKeNdAdDrEsSpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/backendAddressPools/backendAddressPoolName", + Expected: &LoadBalancerBackendAddressPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LoadBalancerName: "loadBalancerName", + BackendAddressPoolName: "backendAddressPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/backendAddressPools/backendAddressPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/bAcKeNdAdDrEsSpOoLs/bAcKeNdAdDrEsSpOoLnAmE", + Expected: &LoadBalancerBackendAddressPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LoadBalancerName: "lOaDbAlAnCeRnAmE", + BackendAddressPoolName: "bAcKeNdAdDrEsSpOoLnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/bAcKeNdAdDrEsSpOoLs/bAcKeNdAdDrEsSpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLoadBalancerBackendAddressPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + if actual.BackendAddressPoolName != v.Expected.BackendAddressPoolName { + t.Fatalf("Expected %q but got %q for BackendAddressPoolName", v.Expected.BackendAddressPoolName, actual.BackendAddressPoolName) + } + + } +} + +func TestSegmentsForLoadBalancerBackendAddressPoolId(t *testing.T) { + segments := LoadBalancerBackendAddressPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LoadBalancerBackendAddressPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancerloadbalancingrule.go b/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancerloadbalancingrule.go new file mode 100644 index 00000000000..2fb46e7ba9a --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancerloadbalancingrule.go @@ -0,0 +1,139 @@ +package loadbalancers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LoadBalancerLoadBalancingRuleId{}) +} + +var _ resourceids.ResourceId = &LoadBalancerLoadBalancingRuleId{} + +// LoadBalancerLoadBalancingRuleId is a struct representing the Resource ID for a Load Balancer Load Balancing Rule +type LoadBalancerLoadBalancingRuleId struct { + SubscriptionId string + ResourceGroupName string + LoadBalancerName string + LoadBalancingRuleName string +} + +// NewLoadBalancerLoadBalancingRuleID returns a new LoadBalancerLoadBalancingRuleId struct +func NewLoadBalancerLoadBalancingRuleID(subscriptionId string, resourceGroupName string, loadBalancerName string, loadBalancingRuleName string) LoadBalancerLoadBalancingRuleId { + return LoadBalancerLoadBalancingRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LoadBalancerName: loadBalancerName, + LoadBalancingRuleName: loadBalancingRuleName, + } +} + +// ParseLoadBalancerLoadBalancingRuleID parses 'input' into a LoadBalancerLoadBalancingRuleId +func ParseLoadBalancerLoadBalancingRuleID(input string) (*LoadBalancerLoadBalancingRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&LoadBalancerLoadBalancingRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LoadBalancerLoadBalancingRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLoadBalancerLoadBalancingRuleIDInsensitively parses 'input' case-insensitively into a LoadBalancerLoadBalancingRuleId +// note: this method should only be used for API response data and not user input +func ParseLoadBalancerLoadBalancingRuleIDInsensitively(input string) (*LoadBalancerLoadBalancingRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&LoadBalancerLoadBalancingRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LoadBalancerLoadBalancingRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LoadBalancerLoadBalancingRuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LoadBalancerName, ok = input.Parsed["loadBalancerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "loadBalancerName", input) + } + + if id.LoadBalancingRuleName, ok = input.Parsed["loadBalancingRuleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "loadBalancingRuleName", input) + } + + return nil +} + +// ValidateLoadBalancerLoadBalancingRuleID checks that 'input' can be parsed as a Load Balancer Load Balancing Rule ID +func ValidateLoadBalancerLoadBalancingRuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLoadBalancerLoadBalancingRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Load Balancer Load Balancing Rule ID +func (id LoadBalancerLoadBalancingRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/loadBalancers/%s/loadBalancingRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LoadBalancerName, id.LoadBalancingRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Load Balancer Load Balancing Rule ID +func (id LoadBalancerLoadBalancingRuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLoadBalancers", "loadBalancers", "loadBalancers"), + resourceids.UserSpecifiedSegment("loadBalancerName", "loadBalancerName"), + resourceids.StaticSegment("staticLoadBalancingRules", "loadBalancingRules", "loadBalancingRules"), + resourceids.UserSpecifiedSegment("loadBalancingRuleName", "loadBalancingRuleName"), + } +} + +// String returns a human-readable description of this Load Balancer Load Balancing Rule ID +func (id LoadBalancerLoadBalancingRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Load Balancer Name: %q", id.LoadBalancerName), + fmt.Sprintf("Load Balancing Rule Name: %q", id.LoadBalancingRuleName), + } + return fmt.Sprintf("Load Balancer Load Balancing Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancerloadbalancingrule_test.go b/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancerloadbalancingrule_test.go new file mode 100644 index 00000000000..cdbf4241651 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancerloadbalancingrule_test.go @@ -0,0 +1,327 @@ +package loadbalancers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LoadBalancerLoadBalancingRuleId{} + +func TestNewLoadBalancerLoadBalancingRuleID(t *testing.T) { + id := NewLoadBalancerLoadBalancingRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "loadBalancingRuleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LoadBalancerName != "loadBalancerName" { + t.Fatalf("Expected %q but got %q for Segment 'LoadBalancerName'", id.LoadBalancerName, "loadBalancerName") + } + + if id.LoadBalancingRuleName != "loadBalancingRuleName" { + t.Fatalf("Expected %q but got %q for Segment 'LoadBalancingRuleName'", id.LoadBalancingRuleName, "loadBalancingRuleName") + } +} + +func TestFormatLoadBalancerLoadBalancingRuleID(t *testing.T) { + actual := NewLoadBalancerLoadBalancingRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "loadBalancingRuleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/loadBalancingRules/loadBalancingRuleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLoadBalancerLoadBalancingRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LoadBalancerLoadBalancingRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/loadBalancingRules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/loadBalancingRules/loadBalancingRuleName", + Expected: &LoadBalancerLoadBalancingRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LoadBalancerName: "loadBalancerName", + LoadBalancingRuleName: "loadBalancingRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/loadBalancingRules/loadBalancingRuleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLoadBalancerLoadBalancingRuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + if actual.LoadBalancingRuleName != v.Expected.LoadBalancingRuleName { + t.Fatalf("Expected %q but got %q for LoadBalancingRuleName", v.Expected.LoadBalancingRuleName, actual.LoadBalancingRuleName) + } + + } +} + +func TestParseLoadBalancerLoadBalancingRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LoadBalancerLoadBalancingRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/loadBalancingRules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/lOaDbAlAnCiNgRuLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/loadBalancingRules/loadBalancingRuleName", + Expected: &LoadBalancerLoadBalancingRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LoadBalancerName: "loadBalancerName", + LoadBalancingRuleName: "loadBalancingRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/loadBalancingRules/loadBalancingRuleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/lOaDbAlAnCiNgRuLeS/lOaDbAlAnCiNgRuLeNaMe", + Expected: &LoadBalancerLoadBalancingRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LoadBalancerName: "lOaDbAlAnCeRnAmE", + LoadBalancingRuleName: "lOaDbAlAnCiNgRuLeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/lOaDbAlAnCiNgRuLeS/lOaDbAlAnCiNgRuLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLoadBalancerLoadBalancingRuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + if actual.LoadBalancingRuleName != v.Expected.LoadBalancingRuleName { + t.Fatalf("Expected %q but got %q for LoadBalancingRuleName", v.Expected.LoadBalancingRuleName, actual.LoadBalancingRuleName) + } + + } +} + +func TestSegmentsForLoadBalancerLoadBalancingRuleId(t *testing.T) { + segments := LoadBalancerLoadBalancingRuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LoadBalancerLoadBalancingRuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancingrule.go b/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancingrule.go new file mode 100644 index 00000000000..26daab4937c --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancingrule.go @@ -0,0 +1,139 @@ +package loadbalancers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LoadBalancingRuleId{}) +} + +var _ resourceids.ResourceId = &LoadBalancingRuleId{} + +// LoadBalancingRuleId is a struct representing the Resource ID for a Load Balancing Rule +type LoadBalancingRuleId struct { + SubscriptionId string + ResourceGroupName string + LoadBalancerName string + LoadBalancingRuleName string +} + +// NewLoadBalancingRuleID returns a new LoadBalancingRuleId struct +func NewLoadBalancingRuleID(subscriptionId string, resourceGroupName string, loadBalancerName string, loadBalancingRuleName string) LoadBalancingRuleId { + return LoadBalancingRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LoadBalancerName: loadBalancerName, + LoadBalancingRuleName: loadBalancingRuleName, + } +} + +// ParseLoadBalancingRuleID parses 'input' into a LoadBalancingRuleId +func ParseLoadBalancingRuleID(input string) (*LoadBalancingRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&LoadBalancingRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LoadBalancingRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLoadBalancingRuleIDInsensitively parses 'input' case-insensitively into a LoadBalancingRuleId +// note: this method should only be used for API response data and not user input +func ParseLoadBalancingRuleIDInsensitively(input string) (*LoadBalancingRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&LoadBalancingRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LoadBalancingRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LoadBalancingRuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LoadBalancerName, ok = input.Parsed["loadBalancerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "loadBalancerName", input) + } + + if id.LoadBalancingRuleName, ok = input.Parsed["loadBalancingRuleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "loadBalancingRuleName", input) + } + + return nil +} + +// ValidateLoadBalancingRuleID checks that 'input' can be parsed as a Load Balancing Rule ID +func ValidateLoadBalancingRuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLoadBalancingRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Load Balancing Rule ID +func (id LoadBalancingRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/loadBalancers/%s/loadBalancingRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LoadBalancerName, id.LoadBalancingRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Load Balancing Rule ID +func (id LoadBalancingRuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.UserSpecifiedSegment("resourceGroupName", "resourceGroupName"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLoadBalancers", "loadBalancers", "loadBalancers"), + resourceids.UserSpecifiedSegment("loadBalancerName", "loadBalancerName"), + resourceids.StaticSegment("staticLoadBalancingRules", "loadBalancingRules", "loadBalancingRules"), + resourceids.UserSpecifiedSegment("loadBalancingRuleName", "loadBalancingRuleName"), + } +} + +// String returns a human-readable description of this Load Balancing Rule ID +func (id LoadBalancingRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Load Balancer Name: %q", id.LoadBalancerName), + fmt.Sprintf("Load Balancing Rule Name: %q", id.LoadBalancingRuleName), + } + return fmt.Sprintf("Load Balancing Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancingrule_test.go b/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancingrule_test.go new file mode 100644 index 00000000000..3627d2502ec --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_loadbalancingrule_test.go @@ -0,0 +1,327 @@ +package loadbalancers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LoadBalancingRuleId{} + +func TestNewLoadBalancingRuleID(t *testing.T) { + id := NewLoadBalancingRuleID("12345678-1234-9876-4563-123456789012", "resourceGroupName", "loadBalancerName", "loadBalancingRuleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "resourceGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "resourceGroupName") + } + + if id.LoadBalancerName != "loadBalancerName" { + t.Fatalf("Expected %q but got %q for Segment 'LoadBalancerName'", id.LoadBalancerName, "loadBalancerName") + } + + if id.LoadBalancingRuleName != "loadBalancingRuleName" { + t.Fatalf("Expected %q but got %q for Segment 'LoadBalancingRuleName'", id.LoadBalancingRuleName, "loadBalancingRuleName") + } +} + +func TestFormatLoadBalancingRuleID(t *testing.T) { + actual := NewLoadBalancingRuleID("12345678-1234-9876-4563-123456789012", "resourceGroupName", "loadBalancerName", "loadBalancingRuleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName/loadBalancingRules/loadBalancingRuleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLoadBalancingRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LoadBalancingRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName/loadBalancingRules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName/loadBalancingRules/loadBalancingRuleName", + Expected: &LoadBalancingRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "resourceGroupName", + LoadBalancerName: "loadBalancerName", + LoadBalancingRuleName: "loadBalancingRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName/loadBalancingRules/loadBalancingRuleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLoadBalancingRuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + if actual.LoadBalancingRuleName != v.Expected.LoadBalancingRuleName { + t.Fatalf("Expected %q but got %q for LoadBalancingRuleName", v.Expected.LoadBalancingRuleName, actual.LoadBalancingRuleName) + } + + } +} + +func TestParseLoadBalancingRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LoadBalancingRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName/loadBalancingRules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/lOaDbAlAnCiNgRuLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName/loadBalancingRules/loadBalancingRuleName", + Expected: &LoadBalancingRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "resourceGroupName", + LoadBalancerName: "loadBalancerName", + LoadBalancingRuleName: "loadBalancingRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Network/loadBalancers/loadBalancerName/loadBalancingRules/loadBalancingRuleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/lOaDbAlAnCiNgRuLeS/lOaDbAlAnCiNgRuLeNaMe", + Expected: &LoadBalancingRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "rEsOuRcEgRoUpNaMe", + LoadBalancerName: "lOaDbAlAnCeRnAmE", + LoadBalancingRuleName: "lOaDbAlAnCiNgRuLeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/lOaDbAlAnCiNgRuLeS/lOaDbAlAnCiNgRuLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLoadBalancingRuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + if actual.LoadBalancingRuleName != v.Expected.LoadBalancingRuleName { + t.Fatalf("Expected %q but got %q for LoadBalancingRuleName", v.Expected.LoadBalancingRuleName, actual.LoadBalancingRuleName) + } + + } +} + +func TestSegmentsForLoadBalancingRuleId(t *testing.T) { + segments := LoadBalancingRuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LoadBalancingRuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_location.go b/resource-manager/network/2024-07-01/loadbalancers/id_location.go new file mode 100644 index 00000000000..b6cfa4c67ba --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_location.go @@ -0,0 +1,121 @@ +package loadbalancers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Network/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_location_test.go b/resource-manager/network/2024-07-01/loadbalancers/id_location_test.go new file mode 100644 index 00000000000..c15a4a4b124 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_location_test.go @@ -0,0 +1,237 @@ +package loadbalancers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_outboundrule.go b/resource-manager/network/2024-07-01/loadbalancers/id_outboundrule.go new file mode 100644 index 00000000000..8b262df0308 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_outboundrule.go @@ -0,0 +1,139 @@ +package loadbalancers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) 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 + LoadBalancerName string + OutboundRuleName string +} + +// NewOutboundRuleID returns a new OutboundRuleId struct +func NewOutboundRuleID(subscriptionId string, resourceGroupName string, loadBalancerName string, outboundRuleName string) OutboundRuleId { + return OutboundRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LoadBalancerName: loadBalancerName, + 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.LoadBalancerName, ok = input.Parsed["loadBalancerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "loadBalancerName", 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.Network/loadBalancers/%s/outboundRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LoadBalancerName, 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("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLoadBalancers", "loadBalancers", "loadBalancers"), + resourceids.UserSpecifiedSegment("loadBalancerName", "loadBalancerName"), + resourceids.StaticSegment("staticOutboundRules", "outboundRules", "outboundRules"), + resourceids.UserSpecifiedSegment("outboundRuleName", "outboundRuleName"), + } +} + +// String returns a human-readable description of this Outbound Rule ID +func (id OutboundRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Load Balancer Name: %q", id.LoadBalancerName), + fmt.Sprintf("Outbound Rule Name: %q", id.OutboundRuleName), + } + return fmt.Sprintf("Outbound Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_outboundrule_test.go b/resource-manager/network/2024-07-01/loadbalancers/id_outboundrule_test.go new file mode 100644 index 00000000000..50eb9e50a14 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_outboundrule_test.go @@ -0,0 +1,327 @@ +package loadbalancers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &OutboundRuleId{} + +func TestNewOutboundRuleID(t *testing.T) { + id := NewOutboundRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "outboundRuleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LoadBalancerName != "loadBalancerName" { + t.Fatalf("Expected %q but got %q for Segment 'LoadBalancerName'", id.LoadBalancerName, "loadBalancerName") + } + + if id.OutboundRuleName != "outboundRuleName" { + t.Fatalf("Expected %q but got %q for Segment 'OutboundRuleName'", id.OutboundRuleName, "outboundRuleName") + } +} + +func TestFormatOutboundRuleID(t *testing.T) { + actual := NewOutboundRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "outboundRuleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/outboundRules/outboundRuleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseOutboundRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OutboundRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/outboundRules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/outboundRules/outboundRuleName", + Expected: &OutboundRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LoadBalancerName: "loadBalancerName", + OutboundRuleName: "outboundRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/outboundRules/outboundRuleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOutboundRuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + if actual.OutboundRuleName != v.Expected.OutboundRuleName { + t.Fatalf("Expected %q but got %q for OutboundRuleName", v.Expected.OutboundRuleName, actual.OutboundRuleName) + } + + } +} + +func TestParseOutboundRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OutboundRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/outboundRules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/oUtBoUnDrUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/outboundRules/outboundRuleName", + Expected: &OutboundRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LoadBalancerName: "loadBalancerName", + OutboundRuleName: "outboundRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/outboundRules/outboundRuleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/oUtBoUnDrUlEs/oUtBoUnDrUlEnAmE", + Expected: &OutboundRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LoadBalancerName: "lOaDbAlAnCeRnAmE", + OutboundRuleName: "oUtBoUnDrUlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/oUtBoUnDrUlEs/oUtBoUnDrUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOutboundRuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + if actual.OutboundRuleName != v.Expected.OutboundRuleName { + t.Fatalf("Expected %q but got %q for OutboundRuleName", v.Expected.OutboundRuleName, actual.OutboundRuleName) + } + + } +} + +func TestSegmentsForOutboundRuleId(t *testing.T) { + segments := OutboundRuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("OutboundRuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_probe.go b/resource-manager/network/2024-07-01/loadbalancers/id_probe.go new file mode 100644 index 00000000000..4cc4bf66c11 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_probe.go @@ -0,0 +1,139 @@ +package loadbalancers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProbeId{}) +} + +var _ resourceids.ResourceId = &ProbeId{} + +// ProbeId is a struct representing the Resource ID for a Probe +type ProbeId struct { + SubscriptionId string + ResourceGroupName string + LoadBalancerName string + ProbeName string +} + +// NewProbeID returns a new ProbeId struct +func NewProbeID(subscriptionId string, resourceGroupName string, loadBalancerName string, probeName string) ProbeId { + return ProbeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LoadBalancerName: loadBalancerName, + ProbeName: probeName, + } +} + +// ParseProbeID parses 'input' into a ProbeId +func ParseProbeID(input string) (*ProbeId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProbeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProbeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProbeIDInsensitively parses 'input' case-insensitively into a ProbeId +// note: this method should only be used for API response data and not user input +func ParseProbeIDInsensitively(input string) (*ProbeId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProbeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProbeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProbeId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LoadBalancerName, ok = input.Parsed["loadBalancerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "loadBalancerName", input) + } + + if id.ProbeName, ok = input.Parsed["probeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "probeName", input) + } + + return nil +} + +// ValidateProbeID checks that 'input' can be parsed as a Probe ID +func ValidateProbeID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProbeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Probe ID +func (id ProbeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/loadBalancers/%s/probes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LoadBalancerName, id.ProbeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Probe ID +func (id ProbeId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLoadBalancers", "loadBalancers", "loadBalancers"), + resourceids.UserSpecifiedSegment("loadBalancerName", "loadBalancerName"), + resourceids.StaticSegment("staticProbes", "probes", "probes"), + resourceids.UserSpecifiedSegment("probeName", "probeName"), + } +} + +// String returns a human-readable description of this Probe ID +func (id ProbeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Load Balancer Name: %q", id.LoadBalancerName), + fmt.Sprintf("Probe Name: %q", id.ProbeName), + } + return fmt.Sprintf("Probe (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_probe_test.go b/resource-manager/network/2024-07-01/loadbalancers/id_probe_test.go new file mode 100644 index 00000000000..39c9e9cb3b9 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_probe_test.go @@ -0,0 +1,327 @@ +package loadbalancers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProbeId{} + +func TestNewProbeID(t *testing.T) { + id := NewProbeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "probeName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LoadBalancerName != "loadBalancerName" { + t.Fatalf("Expected %q but got %q for Segment 'LoadBalancerName'", id.LoadBalancerName, "loadBalancerName") + } + + if id.ProbeName != "probeName" { + t.Fatalf("Expected %q but got %q for Segment 'ProbeName'", id.ProbeName, "probeName") + } +} + +func TestFormatProbeID(t *testing.T) { + actual := NewProbeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName", "probeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/probes/probeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProbeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProbeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/probes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/probes/probeName", + Expected: &ProbeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LoadBalancerName: "loadBalancerName", + ProbeName: "probeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/probes/probeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProbeID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + if actual.ProbeName != v.Expected.ProbeName { + t.Fatalf("Expected %q but got %q for ProbeName", v.Expected.ProbeName, actual.ProbeName) + } + + } +} + +func TestParseProbeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProbeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/probes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/pRoBeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/probes/probeName", + Expected: &ProbeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LoadBalancerName: "loadBalancerName", + ProbeName: "probeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/probes/probeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/pRoBeS/pRoBeNaMe", + Expected: &ProbeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LoadBalancerName: "lOaDbAlAnCeRnAmE", + ProbeName: "pRoBeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/pRoBeS/pRoBeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProbeIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + if actual.ProbeName != v.Expected.ProbeName { + t.Fatalf("Expected %q but got %q for ProbeName", v.Expected.ProbeName, actual.ProbeName) + } + + } +} + +func TestSegmentsForProbeId(t *testing.T) { + segments := ProbeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProbeId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_providerloadbalancer.go b/resource-manager/network/2024-07-01/loadbalancers/id_providerloadbalancer.go new file mode 100644 index 00000000000..54e6f1dc4ec --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_providerloadbalancer.go @@ -0,0 +1,130 @@ +package loadbalancers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderLoadBalancerId{}) +} + +var _ resourceids.ResourceId = &ProviderLoadBalancerId{} + +// ProviderLoadBalancerId is a struct representing the Resource ID for a Provider Load Balancer +type ProviderLoadBalancerId struct { + SubscriptionId string + ResourceGroupName string + LoadBalancerName string +} + +// NewProviderLoadBalancerID returns a new ProviderLoadBalancerId struct +func NewProviderLoadBalancerID(subscriptionId string, resourceGroupName string, loadBalancerName string) ProviderLoadBalancerId { + return ProviderLoadBalancerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LoadBalancerName: loadBalancerName, + } +} + +// ParseProviderLoadBalancerID parses 'input' into a ProviderLoadBalancerId +func ParseProviderLoadBalancerID(input string) (*ProviderLoadBalancerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLoadBalancerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLoadBalancerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLoadBalancerIDInsensitively parses 'input' case-insensitively into a ProviderLoadBalancerId +// note: this method should only be used for API response data and not user input +func ParseProviderLoadBalancerIDInsensitively(input string) (*ProviderLoadBalancerId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLoadBalancerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLoadBalancerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLoadBalancerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LoadBalancerName, ok = input.Parsed["loadBalancerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "loadBalancerName", input) + } + + return nil +} + +// ValidateProviderLoadBalancerID checks that 'input' can be parsed as a Provider Load Balancer ID +func ValidateProviderLoadBalancerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderLoadBalancerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Load Balancer ID +func (id ProviderLoadBalancerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/loadBalancers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LoadBalancerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Load Balancer ID +func (id ProviderLoadBalancerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLoadBalancers", "loadBalancers", "loadBalancers"), + resourceids.UserSpecifiedSegment("loadBalancerName", "loadBalancerName"), + } +} + +// String returns a human-readable description of this Provider Load Balancer ID +func (id ProviderLoadBalancerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Load Balancer Name: %q", id.LoadBalancerName), + } + return fmt.Sprintf("Provider Load Balancer (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/id_providerloadbalancer_test.go b/resource-manager/network/2024-07-01/loadbalancers/id_providerloadbalancer_test.go new file mode 100644 index 00000000000..6c38bb96b9e --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/id_providerloadbalancer_test.go @@ -0,0 +1,282 @@ +package loadbalancers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderLoadBalancerId{} + +func TestNewProviderLoadBalancerID(t *testing.T) { + id := NewProviderLoadBalancerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LoadBalancerName != "loadBalancerName" { + t.Fatalf("Expected %q but got %q for Segment 'LoadBalancerName'", id.LoadBalancerName, "loadBalancerName") + } +} + +func TestFormatProviderLoadBalancerID(t *testing.T) { + actual := NewProviderLoadBalancerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "loadBalancerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLoadBalancerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLoadBalancerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Expected: &ProviderLoadBalancerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LoadBalancerName: "loadBalancerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLoadBalancerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + } +} + +func TestParseProviderLoadBalancerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLoadBalancerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName", + Expected: &ProviderLoadBalancerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LoadBalancerName: "loadBalancerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/loadBalancers/loadBalancerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE", + Expected: &ProviderLoadBalancerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LoadBalancerName: "lOaDbAlAnCeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOaDbAlAnCeRs/lOaDbAlAnCeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLoadBalancerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LoadBalancerName != v.Expected.LoadBalancerName { + t.Fatalf("Expected %q but got %q for LoadBalancerName", v.Expected.LoadBalancerName, actual.LoadBalancerName) + } + + } +} + +func TestSegmentsForProviderLoadBalancerId(t *testing.T) { + segments := ProviderLoadBalancerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLoadBalancerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_createorupdate.go b/resource-manager/network/2024-07-01/loadbalancers/method_createorupdate.go new file mode 100644 index 00000000000..891038c3395 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_createorupdate.go @@ -0,0 +1,75 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *LoadBalancer +} + +// CreateOrUpdate ... +func (c LoadBalancersClient) CreateOrUpdate(ctx context.Context, id ProviderLoadBalancerId, input LoadBalancer) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c LoadBalancersClient) CreateOrUpdateThenPoll(ctx context.Context, id ProviderLoadBalancerId, input LoadBalancer) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_delete.go b/resource-manager/network/2024-07-01/loadbalancers/method_delete.go new file mode 100644 index 00000000000..bf7acc08d90 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_delete.go @@ -0,0 +1,71 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c LoadBalancersClient) Delete(ctx context.Context, id ProviderLoadBalancerId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c LoadBalancersClient) DeleteThenPoll(ctx context.Context, id ProviderLoadBalancerId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_get.go b/resource-manager/network/2024-07-01/loadbalancers/method_get.go new file mode 100644 index 00000000000..50fdc569bc4 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_get.go @@ -0,0 +1,83 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LoadBalancer +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c LoadBalancersClient) Get(ctx context.Context, id ProviderLoadBalancerId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model LoadBalancer + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_inboundnatrulescreateorupdate.go b/resource-manager/network/2024-07-01/loadbalancers/method_inboundnatrulescreateorupdate.go new file mode 100644 index 00000000000..e052f632164 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_inboundnatrulescreateorupdate.go @@ -0,0 +1,75 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *InboundNatRule +} + +// InboundNatRulesCreateOrUpdate ... +func (c LoadBalancersClient) InboundNatRulesCreateOrUpdate(ctx context.Context, id InboundNatRuleId, input InboundNatRule) (result InboundNatRulesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// InboundNatRulesCreateOrUpdateThenPoll performs InboundNatRulesCreateOrUpdate then polls until it's completed +func (c LoadBalancersClient) InboundNatRulesCreateOrUpdateThenPoll(ctx context.Context, id InboundNatRuleId, input InboundNatRule) error { + result, err := c.InboundNatRulesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing InboundNatRulesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after InboundNatRulesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_inboundnatrulesdelete.go b/resource-manager/network/2024-07-01/loadbalancers/method_inboundnatrulesdelete.go new file mode 100644 index 00000000000..2d19b62f757 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_inboundnatrulesdelete.go @@ -0,0 +1,71 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// InboundNatRulesDelete ... +func (c LoadBalancersClient) InboundNatRulesDelete(ctx context.Context, id InboundNatRuleId) (result InboundNatRulesDeleteOperationResponse, 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 +} + +// InboundNatRulesDeleteThenPoll performs InboundNatRulesDelete then polls until it's completed +func (c LoadBalancersClient) InboundNatRulesDeleteThenPoll(ctx context.Context, id InboundNatRuleId) error { + result, err := c.InboundNatRulesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing InboundNatRulesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after InboundNatRulesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_inboundnatrulesget.go b/resource-manager/network/2024-07-01/loadbalancers/method_inboundnatrulesget.go new file mode 100644 index 00000000000..d925ef58b2c --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_inboundnatrulesget.go @@ -0,0 +1,83 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *InboundNatRule +} + +type InboundNatRulesGetOperationOptions struct { + Expand *string +} + +func DefaultInboundNatRulesGetOperationOptions() InboundNatRulesGetOperationOptions { + return InboundNatRulesGetOperationOptions{} +} + +func (o InboundNatRulesGetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o InboundNatRulesGetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o InboundNatRulesGetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// InboundNatRulesGet ... +func (c LoadBalancersClient) InboundNatRulesGet(ctx context.Context, id InboundNatRuleId, options InboundNatRulesGetOperationOptions) (result InboundNatRulesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model InboundNatRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_inboundnatruleslist.go b/resource-manager/network/2024-07-01/loadbalancers/method_inboundnatruleslist.go new file mode 100644 index 00000000000..2bdb2af0a6e --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_inboundnatruleslist.go @@ -0,0 +1,105 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]InboundNatRule +} + +type InboundNatRulesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []InboundNatRule +} + +type InboundNatRulesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *InboundNatRulesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// InboundNatRulesList ... +func (c LoadBalancersClient) InboundNatRulesList(ctx context.Context, id ProviderLoadBalancerId) (result InboundNatRulesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &InboundNatRulesListCustomPager{}, + Path: fmt.Sprintf("%s/inboundNatRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]InboundNatRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// InboundNatRulesListComplete retrieves all the results into a single object +func (c LoadBalancersClient) InboundNatRulesListComplete(ctx context.Context, id ProviderLoadBalancerId) (InboundNatRulesListCompleteResult, error) { + return c.InboundNatRulesListCompleteMatchingPredicate(ctx, id, InboundNatRuleOperationPredicate{}) +} + +// InboundNatRulesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LoadBalancersClient) InboundNatRulesListCompleteMatchingPredicate(ctx context.Context, id ProviderLoadBalancerId, predicate InboundNatRuleOperationPredicate) (result InboundNatRulesListCompleteResult, err error) { + items := make([]InboundNatRule, 0) + + resp, err := c.InboundNatRulesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = InboundNatRulesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_list.go b/resource-manager/network/2024-07-01/loadbalancers/method_list.go new file mode 100644 index 00000000000..74ca3569c7b --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_list.go @@ -0,0 +1,106 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LoadBalancer +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []LoadBalancer +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c LoadBalancersClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/loadBalancers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]LoadBalancer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c LoadBalancersClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, LoadBalancerOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LoadBalancersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate LoadBalancerOperationPredicate) (result ListCompleteResult, err error) { + items := make([]LoadBalancer, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_listall.go b/resource-manager/network/2024-07-01/loadbalancers/method_listall.go new file mode 100644 index 00000000000..74f6c49784a --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_listall.go @@ -0,0 +1,106 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LoadBalancer +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []LoadBalancer +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c LoadBalancersClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/loadBalancers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]LoadBalancer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c LoadBalancersClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, LoadBalancerOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LoadBalancersClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate LoadBalancerOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]LoadBalancer, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_listinboundnatruleportmappings.go b/resource-manager/network/2024-07-01/loadbalancers/method_listinboundnatruleportmappings.go new file mode 100644 index 00000000000..967f42debed --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_listinboundnatruleportmappings.go @@ -0,0 +1,75 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListInboundNatRulePortMappingsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BackendAddressInboundNatRulePortMappings +} + +// ListInboundNatRulePortMappings ... +func (c LoadBalancersClient) ListInboundNatRulePortMappings(ctx context.Context, id BackendAddressPoolId, input QueryInboundNatRulePortMappingRequest) (result ListInboundNatRulePortMappingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/queryInboundNatRulePortMapping", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ListInboundNatRulePortMappingsThenPoll performs ListInboundNatRulePortMappings then polls until it's completed +func (c LoadBalancersClient) ListInboundNatRulePortMappingsThenPoll(ctx context.Context, id BackendAddressPoolId, input QueryInboundNatRulePortMappingRequest) error { + result, err := c.ListInboundNatRulePortMappings(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ListInboundNatRulePortMappings: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ListInboundNatRulePortMappings: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerbackendaddresspoolscreateorupdate.go b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerbackendaddresspoolscreateorupdate.go new file mode 100644 index 00000000000..3f34a765cbf --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerbackendaddresspoolscreateorupdate.go @@ -0,0 +1,75 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPoolsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BackendAddressPool +} + +// LoadBalancerBackendAddressPoolsCreateOrUpdate ... +func (c LoadBalancersClient) LoadBalancerBackendAddressPoolsCreateOrUpdate(ctx context.Context, id LoadBalancerBackendAddressPoolId, input BackendAddressPool) (result LoadBalancerBackendAddressPoolsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// LoadBalancerBackendAddressPoolsCreateOrUpdateThenPoll performs LoadBalancerBackendAddressPoolsCreateOrUpdate then polls until it's completed +func (c LoadBalancersClient) LoadBalancerBackendAddressPoolsCreateOrUpdateThenPoll(ctx context.Context, id LoadBalancerBackendAddressPoolId, input BackendAddressPool) error { + result, err := c.LoadBalancerBackendAddressPoolsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing LoadBalancerBackendAddressPoolsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after LoadBalancerBackendAddressPoolsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerbackendaddresspoolsdelete.go b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerbackendaddresspoolsdelete.go new file mode 100644 index 00000000000..748b8b97657 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerbackendaddresspoolsdelete.go @@ -0,0 +1,71 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPoolsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// LoadBalancerBackendAddressPoolsDelete ... +func (c LoadBalancersClient) LoadBalancerBackendAddressPoolsDelete(ctx context.Context, id LoadBalancerBackendAddressPoolId) (result LoadBalancerBackendAddressPoolsDeleteOperationResponse, 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 +} + +// LoadBalancerBackendAddressPoolsDeleteThenPoll performs LoadBalancerBackendAddressPoolsDelete then polls until it's completed +func (c LoadBalancersClient) LoadBalancerBackendAddressPoolsDeleteThenPoll(ctx context.Context, id LoadBalancerBackendAddressPoolId) error { + result, err := c.LoadBalancerBackendAddressPoolsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing LoadBalancerBackendAddressPoolsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after LoadBalancerBackendAddressPoolsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerbackendaddresspoolsget.go b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerbackendaddresspoolsget.go new file mode 100644 index 00000000000..7fef83148f3 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerbackendaddresspoolsget.go @@ -0,0 +1,53 @@ +package loadbalancers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPoolsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackendAddressPool +} + +// LoadBalancerBackendAddressPoolsGet ... +func (c LoadBalancersClient) LoadBalancerBackendAddressPoolsGet(ctx context.Context, id LoadBalancerBackendAddressPoolId) (result LoadBalancerBackendAddressPoolsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackendAddressPool + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerbackendaddresspoolslist.go b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerbackendaddresspoolslist.go new file mode 100644 index 00000000000..42470d88640 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerbackendaddresspoolslist.go @@ -0,0 +1,105 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPoolsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackendAddressPool +} + +type LoadBalancerBackendAddressPoolsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackendAddressPool +} + +type LoadBalancerBackendAddressPoolsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *LoadBalancerBackendAddressPoolsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// LoadBalancerBackendAddressPoolsList ... +func (c LoadBalancersClient) LoadBalancerBackendAddressPoolsList(ctx context.Context, id ProviderLoadBalancerId) (result LoadBalancerBackendAddressPoolsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &LoadBalancerBackendAddressPoolsListCustomPager{}, + Path: fmt.Sprintf("%s/backendAddressPools", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BackendAddressPool `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// LoadBalancerBackendAddressPoolsListComplete retrieves all the results into a single object +func (c LoadBalancersClient) LoadBalancerBackendAddressPoolsListComplete(ctx context.Context, id ProviderLoadBalancerId) (LoadBalancerBackendAddressPoolsListCompleteResult, error) { + return c.LoadBalancerBackendAddressPoolsListCompleteMatchingPredicate(ctx, id, BackendAddressPoolOperationPredicate{}) +} + +// LoadBalancerBackendAddressPoolsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LoadBalancersClient) LoadBalancerBackendAddressPoolsListCompleteMatchingPredicate(ctx context.Context, id ProviderLoadBalancerId, predicate BackendAddressPoolOperationPredicate) (result LoadBalancerBackendAddressPoolsListCompleteResult, err error) { + items := make([]BackendAddressPool, 0) + + resp, err := c.LoadBalancerBackendAddressPoolsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = LoadBalancerBackendAddressPoolsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerfrontendipconfigurationsget.go b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerfrontendipconfigurationsget.go new file mode 100644 index 00000000000..6c16550699b --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerfrontendipconfigurationsget.go @@ -0,0 +1,53 @@ +package loadbalancers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerFrontendIPConfigurationsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FrontendIPConfiguration +} + +// LoadBalancerFrontendIPConfigurationsGet ... +func (c LoadBalancersClient) LoadBalancerFrontendIPConfigurationsGet(ctx context.Context, id FrontendIPConfigurationId) (result LoadBalancerFrontendIPConfigurationsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FrontendIPConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerfrontendipconfigurationslist.go b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerfrontendipconfigurationslist.go new file mode 100644 index 00000000000..c0a472f598c --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerfrontendipconfigurationslist.go @@ -0,0 +1,105 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerFrontendIPConfigurationsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FrontendIPConfiguration +} + +type LoadBalancerFrontendIPConfigurationsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []FrontendIPConfiguration +} + +type LoadBalancerFrontendIPConfigurationsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *LoadBalancerFrontendIPConfigurationsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// LoadBalancerFrontendIPConfigurationsList ... +func (c LoadBalancersClient) LoadBalancerFrontendIPConfigurationsList(ctx context.Context, id ProviderLoadBalancerId) (result LoadBalancerFrontendIPConfigurationsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &LoadBalancerFrontendIPConfigurationsListCustomPager{}, + Path: fmt.Sprintf("%s/frontendIPConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FrontendIPConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// LoadBalancerFrontendIPConfigurationsListComplete retrieves all the results into a single object +func (c LoadBalancersClient) LoadBalancerFrontendIPConfigurationsListComplete(ctx context.Context, id ProviderLoadBalancerId) (LoadBalancerFrontendIPConfigurationsListCompleteResult, error) { + return c.LoadBalancerFrontendIPConfigurationsListCompleteMatchingPredicate(ctx, id, FrontendIPConfigurationOperationPredicate{}) +} + +// LoadBalancerFrontendIPConfigurationsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LoadBalancersClient) LoadBalancerFrontendIPConfigurationsListCompleteMatchingPredicate(ctx context.Context, id ProviderLoadBalancerId, predicate FrontendIPConfigurationOperationPredicate) (result LoadBalancerFrontendIPConfigurationsListCompleteResult, err error) { + items := make([]FrontendIPConfiguration, 0) + + resp, err := c.LoadBalancerFrontendIPConfigurationsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = LoadBalancerFrontendIPConfigurationsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerloadbalancingrulesget.go b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerloadbalancingrulesget.go new file mode 100644 index 00000000000..edc0e5ceaeb --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerloadbalancingrulesget.go @@ -0,0 +1,53 @@ +package loadbalancers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerLoadBalancingRulesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LoadBalancingRule +} + +// LoadBalancerLoadBalancingRulesGet ... +func (c LoadBalancersClient) LoadBalancerLoadBalancingRulesGet(ctx context.Context, id LoadBalancerLoadBalancingRuleId) (result LoadBalancerLoadBalancingRulesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model LoadBalancingRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerloadbalancingruleshealth.go b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerloadbalancingruleshealth.go new file mode 100644 index 00000000000..6393491c724 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerloadbalancingruleshealth.go @@ -0,0 +1,71 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerLoadBalancingRulesHealthOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *LoadBalancerHealthPerRule +} + +// LoadBalancerLoadBalancingRulesHealth ... +func (c LoadBalancersClient) LoadBalancerLoadBalancingRulesHealth(ctx context.Context, id LoadBalancingRuleId) (result LoadBalancerLoadBalancingRulesHealthOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/health", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// LoadBalancerLoadBalancingRulesHealthThenPoll performs LoadBalancerLoadBalancingRulesHealth then polls until it's completed +func (c LoadBalancersClient) LoadBalancerLoadBalancingRulesHealthThenPoll(ctx context.Context, id LoadBalancingRuleId) error { + result, err := c.LoadBalancerLoadBalancingRulesHealth(ctx, id) + if err != nil { + return fmt.Errorf("performing LoadBalancerLoadBalancingRulesHealth: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after LoadBalancerLoadBalancingRulesHealth: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerloadbalancingruleslist.go b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerloadbalancingruleslist.go new file mode 100644 index 00000000000..e0c52282a3e --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerloadbalancingruleslist.go @@ -0,0 +1,105 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerLoadBalancingRulesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LoadBalancingRule +} + +type LoadBalancerLoadBalancingRulesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []LoadBalancingRule +} + +type LoadBalancerLoadBalancingRulesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *LoadBalancerLoadBalancingRulesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// LoadBalancerLoadBalancingRulesList ... +func (c LoadBalancersClient) LoadBalancerLoadBalancingRulesList(ctx context.Context, id ProviderLoadBalancerId) (result LoadBalancerLoadBalancingRulesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &LoadBalancerLoadBalancingRulesListCustomPager{}, + Path: fmt.Sprintf("%s/loadBalancingRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]LoadBalancingRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// LoadBalancerLoadBalancingRulesListComplete retrieves all the results into a single object +func (c LoadBalancersClient) LoadBalancerLoadBalancingRulesListComplete(ctx context.Context, id ProviderLoadBalancerId) (LoadBalancerLoadBalancingRulesListCompleteResult, error) { + return c.LoadBalancerLoadBalancingRulesListCompleteMatchingPredicate(ctx, id, LoadBalancingRuleOperationPredicate{}) +} + +// LoadBalancerLoadBalancingRulesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LoadBalancersClient) LoadBalancerLoadBalancingRulesListCompleteMatchingPredicate(ctx context.Context, id ProviderLoadBalancerId, predicate LoadBalancingRuleOperationPredicate) (result LoadBalancerLoadBalancingRulesListCompleteResult, err error) { + items := make([]LoadBalancingRule, 0) + + resp, err := c.LoadBalancerLoadBalancingRulesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = LoadBalancerLoadBalancingRulesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancernetworkinterfaceslist.go b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancernetworkinterfaceslist.go new file mode 100644 index 00000000000..eed7f61c64b --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancernetworkinterfaceslist.go @@ -0,0 +1,105 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerNetworkInterfacesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkInterface +} + +type LoadBalancerNetworkInterfacesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkInterface +} + +type LoadBalancerNetworkInterfacesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *LoadBalancerNetworkInterfacesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// LoadBalancerNetworkInterfacesList ... +func (c LoadBalancersClient) LoadBalancerNetworkInterfacesList(ctx context.Context, id ProviderLoadBalancerId) (result LoadBalancerNetworkInterfacesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &LoadBalancerNetworkInterfacesListCustomPager{}, + Path: fmt.Sprintf("%s/networkInterfaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkInterface `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// LoadBalancerNetworkInterfacesListComplete retrieves all the results into a single object +func (c LoadBalancersClient) LoadBalancerNetworkInterfacesListComplete(ctx context.Context, id ProviderLoadBalancerId) (LoadBalancerNetworkInterfacesListCompleteResult, error) { + return c.LoadBalancerNetworkInterfacesListCompleteMatchingPredicate(ctx, id, NetworkInterfaceOperationPredicate{}) +} + +// LoadBalancerNetworkInterfacesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LoadBalancersClient) LoadBalancerNetworkInterfacesListCompleteMatchingPredicate(ctx context.Context, id ProviderLoadBalancerId, predicate NetworkInterfaceOperationPredicate) (result LoadBalancerNetworkInterfacesListCompleteResult, err error) { + items := make([]NetworkInterface, 0) + + resp, err := c.LoadBalancerNetworkInterfacesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = LoadBalancerNetworkInterfacesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_loadbalanceroutboundrulesget.go b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalanceroutboundrulesget.go new file mode 100644 index 00000000000..7d54de6e71d --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalanceroutboundrulesget.go @@ -0,0 +1,53 @@ +package loadbalancers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerOutboundRulesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OutboundRule +} + +// LoadBalancerOutboundRulesGet ... +func (c LoadBalancersClient) LoadBalancerOutboundRulesGet(ctx context.Context, id OutboundRuleId) (result LoadBalancerOutboundRulesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model OutboundRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_loadbalanceroutboundruleslist.go b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalanceroutboundruleslist.go new file mode 100644 index 00000000000..c522e068844 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalanceroutboundruleslist.go @@ -0,0 +1,105 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerOutboundRulesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OutboundRule +} + +type LoadBalancerOutboundRulesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []OutboundRule +} + +type LoadBalancerOutboundRulesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *LoadBalancerOutboundRulesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// LoadBalancerOutboundRulesList ... +func (c LoadBalancersClient) LoadBalancerOutboundRulesList(ctx context.Context, id ProviderLoadBalancerId) (result LoadBalancerOutboundRulesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &LoadBalancerOutboundRulesListCustomPager{}, + 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 *[]OutboundRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// LoadBalancerOutboundRulesListComplete retrieves all the results into a single object +func (c LoadBalancersClient) LoadBalancerOutboundRulesListComplete(ctx context.Context, id ProviderLoadBalancerId) (LoadBalancerOutboundRulesListCompleteResult, error) { + return c.LoadBalancerOutboundRulesListCompleteMatchingPredicate(ctx, id, OutboundRuleOperationPredicate{}) +} + +// LoadBalancerOutboundRulesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LoadBalancersClient) LoadBalancerOutboundRulesListCompleteMatchingPredicate(ctx context.Context, id ProviderLoadBalancerId, predicate OutboundRuleOperationPredicate) (result LoadBalancerOutboundRulesListCompleteResult, err error) { + items := make([]OutboundRule, 0) + + resp, err := c.LoadBalancerOutboundRulesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = LoadBalancerOutboundRulesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerprobesget.go b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerprobesget.go new file mode 100644 index 00000000000..d67e998c327 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerprobesget.go @@ -0,0 +1,53 @@ +package loadbalancers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerProbesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Probe +} + +// LoadBalancerProbesGet ... +func (c LoadBalancersClient) LoadBalancerProbesGet(ctx context.Context, id ProbeId) (result LoadBalancerProbesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Probe + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerprobeslist.go b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerprobeslist.go new file mode 100644 index 00000000000..c92e1df89f6 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_loadbalancerprobeslist.go @@ -0,0 +1,105 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerProbesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Probe +} + +type LoadBalancerProbesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Probe +} + +type LoadBalancerProbesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *LoadBalancerProbesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// LoadBalancerProbesList ... +func (c LoadBalancersClient) LoadBalancerProbesList(ctx context.Context, id ProviderLoadBalancerId) (result LoadBalancerProbesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &LoadBalancerProbesListCustomPager{}, + Path: fmt.Sprintf("%s/probes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Probe `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// LoadBalancerProbesListComplete retrieves all the results into a single object +func (c LoadBalancersClient) LoadBalancerProbesListComplete(ctx context.Context, id ProviderLoadBalancerId) (LoadBalancerProbesListCompleteResult, error) { + return c.LoadBalancerProbesListCompleteMatchingPredicate(ctx, id, ProbeOperationPredicate{}) +} + +// LoadBalancerProbesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LoadBalancersClient) LoadBalancerProbesListCompleteMatchingPredicate(ctx context.Context, id ProviderLoadBalancerId, predicate ProbeOperationPredicate) (result LoadBalancerProbesListCompleteResult, err error) { + items := make([]Probe, 0) + + resp, err := c.LoadBalancerProbesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = LoadBalancerProbesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_migratetoipbased.go b/resource-manager/network/2024-07-01/loadbalancers/method_migratetoipbased.go new file mode 100644 index 00000000000..6474ae09f76 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_migratetoipbased.go @@ -0,0 +1,58 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateToIPBasedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MigratedPools +} + +// MigrateToIPBased ... +func (c LoadBalancersClient) MigrateToIPBased(ctx context.Context, id LoadBalancerId, input MigrateLoadBalancerToIPBasedRequest) (result MigrateToIPBasedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migrateToIpBased", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MigratedPools + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_swappublicipaddresses.go b/resource-manager/network/2024-07-01/loadbalancers/method_swappublicipaddresses.go new file mode 100644 index 00000000000..ea34d09163d --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_swappublicipaddresses.go @@ -0,0 +1,74 @@ +package loadbalancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwapPublicIPAddressesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SwapPublicIPAddresses ... +func (c LoadBalancersClient) SwapPublicIPAddresses(ctx context.Context, id LocationId, input LoadBalancerVipSwapRequest) (result SwapPublicIPAddressesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/setLoadBalancerFrontendPublicIpAddresses", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SwapPublicIPAddressesThenPoll performs SwapPublicIPAddresses then polls until it's completed +func (c LoadBalancersClient) SwapPublicIPAddressesThenPoll(ctx context.Context, id LocationId, input LoadBalancerVipSwapRequest) error { + result, err := c.SwapPublicIPAddresses(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SwapPublicIPAddresses: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SwapPublicIPAddresses: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/method_updatetags.go b/resource-manager/network/2024-07-01/loadbalancers/method_updatetags.go new file mode 100644 index 00000000000..d3fc584efb2 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/method_updatetags.go @@ -0,0 +1,57 @@ +package loadbalancers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LoadBalancer +} + +// UpdateTags ... +func (c LoadBalancersClient) UpdateTags(ctx context.Context, id ProviderLoadBalancerId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model LoadBalancer + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/loadbalancers/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..ba8ecb73101 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/loadbalancers/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..ae525920084 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..339eab474ad --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/loadbalancers/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..85af1e99371 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..ba22dcca046 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/loadbalancers/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..a39478d2c00 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..6ab25279d91 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_backendaddressinboundnatruleportmappings.go b/resource-manager/network/2024-07-01/loadbalancers/model_backendaddressinboundnatruleportmappings.go new file mode 100644 index 00000000000..4e124f8b471 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_backendaddressinboundnatruleportmappings.go @@ -0,0 +1,8 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressInboundNatRulePortMappings struct { + InboundNatRulePortMappings *[]InboundNatRulePortMapping `json:"inboundNatRulePortMappings,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_backendaddresspool.go b/resource-manager/network/2024-07-01/loadbalancers/model_backendaddresspool.go new file mode 100644 index 00000000000..f21aa313263 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..6ce42b19e79 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..bdb38484c9a --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_ddossettings.go b/resource-manager/network/2024-07-01/loadbalancers/model_ddossettings.go new file mode 100644 index 00000000000..49f08256215 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_ddossettings.go @@ -0,0 +1,9 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_delegation.go b/resource-manager/network/2024-07-01/loadbalancers/model_delegation.go new file mode 100644 index 00000000000..ca1a156ae30 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_delegation.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_flowlog.go b/resource-manager/network/2024-07-01/loadbalancers/model_flowlog.go new file mode 100644 index 00000000000..dff0db44f47 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_flowlog.go @@ -0,0 +1,19 @@ +package loadbalancers + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/loadbalancers/model_flowlogformatparameters.go new file mode 100644 index 00000000000..fa0c6c067e8 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..93c3d725116 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/loadbalancers/model_frontendipconfiguration.go new file mode 100644 index 00000000000..aee3ea162e5 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package loadbalancers + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..3ec56d01ffe --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/loadbalancers/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..0b58f57fe92 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_inboundnatpool.go b/resource-manager/network/2024-07-01/loadbalancers/model_inboundnatpool.go new file mode 100644 index 00000000000..d89dc6f5777 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_inboundnatpool.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_inboundnatpoolpropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_inboundnatpoolpropertiesformat.go new file mode 100644 index 00000000000..df78a1ed77a --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_inboundnatpoolpropertiesformat.go @@ -0,0 +1,16 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatPoolPropertiesFormat struct { + BackendPort int64 `json:"backendPort"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPortRangeEnd int64 `json:"frontendPortRangeEnd"` + FrontendPortRangeStart int64 `json:"frontendPortRangeStart"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol TransportProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_inboundnatrule.go b/resource-manager/network/2024-07-01/loadbalancers/model_inboundnatrule.go new file mode 100644 index 00000000000..adb4dbeea97 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_inboundnatruleportmapping.go b/resource-manager/network/2024-07-01/loadbalancers/model_inboundnatruleportmapping.go new file mode 100644 index 00000000000..f2e3789517f --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_inboundnatruleportmapping.go @@ -0,0 +1,11 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..3e2eb61ad03 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/loadbalancers/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..0c769acb9cd --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/loadbalancers/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..eb4d68c640c --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_ipconfiguration.go b/resource-manager/network/2024-07-01/loadbalancers/model_ipconfiguration.go new file mode 100644 index 00000000000..8d6200049ae --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/loadbalancers/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..96c0f6e1f83 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..42790e1043c --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..4d288c5dd29 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_iptag.go b/resource-manager/network/2024-07-01/loadbalancers/model_iptag.go new file mode 100644 index 00000000000..bf32e63b59f --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_iptag.go @@ -0,0 +1,9 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancer.go b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancer.go new file mode 100644 index 00000000000..76572914bb6 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancer.go @@ -0,0 +1,20 @@ +package loadbalancers + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancer struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *LoadBalancerPropertiesFormat `json:"properties,omitempty"` + Sku *LoadBalancerSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..c85572e3101 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..92e1899840b --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancerhealthperrule.go b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancerhealthperrule.go new file mode 100644 index 00000000000..3be9adc88a0 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancerhealthperrule.go @@ -0,0 +1,10 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerHealthPerRule struct { + Down *int64 `json:"down,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerHealthPerRulePerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + Up *int64 `json:"up,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancerhealthperruleperbackendaddress.go b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancerhealthperruleperbackendaddress.go new file mode 100644 index 00000000000..aa593f8cb9a --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancerhealthperruleperbackendaddress.go @@ -0,0 +1,11 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerHealthPerRulePerBackendAddress struct { + IPAddress *string `json:"ipAddress,omitempty"` + NetworkInterfaceIPConfigurationId *string `json:"networkInterfaceIPConfigurationId,omitempty"` + Reason *string `json:"reason,omitempty"` + State *string `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancerpropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancerpropertiesformat.go new file mode 100644 index 00000000000..7ffa00517b8 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancerpropertiesformat.go @@ -0,0 +1,16 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerPropertiesFormat struct { + BackendAddressPools *[]BackendAddressPool `json:"backendAddressPools,omitempty"` + FrontendIPConfigurations *[]FrontendIPConfiguration `json:"frontendIPConfigurations,omitempty"` + InboundNatPools *[]InboundNatPool `json:"inboundNatPools,omitempty"` + InboundNatRules *[]InboundNatRule `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]LoadBalancingRule `json:"loadBalancingRules,omitempty"` + OutboundRules *[]OutboundRule `json:"outboundRules,omitempty"` + Probes *[]Probe `json:"probes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancersku.go b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancersku.go new file mode 100644 index 00000000000..1575eae78c5 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancersku.go @@ -0,0 +1,9 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerSku struct { + Name *LoadBalancerSkuName `json:"name,omitempty"` + Tier *LoadBalancerSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancervipswaprequest.go b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancervipswaprequest.go new file mode 100644 index 00000000000..8bea43b7a0d --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancervipswaprequest.go @@ -0,0 +1,8 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerVipSwapRequest struct { + FrontendIPConfigurations *[]LoadBalancerVipSwapRequestFrontendIPConfiguration `json:"frontendIPConfigurations,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancervipswaprequestfrontendipconfiguration.go b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancervipswaprequestfrontendipconfiguration.go new file mode 100644 index 00000000000..fd4e68458a9 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancervipswaprequestfrontendipconfiguration.go @@ -0,0 +1,9 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerVipSwapRequestFrontendIPConfiguration struct { + Id *string `json:"id,omitempty"` + Properties *LoadBalancerVipSwapRequestFrontendIPConfigurationProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancervipswaprequestfrontendipconfigurationproperties.go b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancervipswaprequestfrontendipconfigurationproperties.go new file mode 100644 index 00000000000..56e8c5d7e4e --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancervipswaprequestfrontendipconfigurationproperties.go @@ -0,0 +1,8 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerVipSwapRequestFrontendIPConfigurationProperties struct { + PublicIPAddress *SubResource `json:"publicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancingrule.go b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancingrule.go new file mode 100644 index 00000000000..ff651417937 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancingrule.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancingRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *LoadBalancingRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancingrulepropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancingrulepropertiesformat.go new file mode 100644 index 00000000000..fdea08f9360 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_loadbalancingrulepropertiesformat.go @@ -0,0 +1,21 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancingRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendAddressPools *[]SubResource `json:"backendAddressPools,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + DisableOutboundSnat *bool `json:"disableOutboundSnat,omitempty"` + EnableConnectionTracking *bool `json:"enableConnectionTracking,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort int64 `json:"frontendPort"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LoadDistribution *LoadDistribution `json:"loadDistribution,omitempty"` + Probe *SubResource `json:"probe,omitempty"` + Protocol TransportProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_migratedpools.go b/resource-manager/network/2024-07-01/loadbalancers/model_migratedpools.go new file mode 100644 index 00000000000..043a11e0729 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_migratedpools.go @@ -0,0 +1,8 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigratedPools struct { + MigratedPools *[]string `json:"migratedPools,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_migrateloadbalancertoipbasedrequest.go b/resource-manager/network/2024-07-01/loadbalancers/model_migrateloadbalancertoipbasedrequest.go new file mode 100644 index 00000000000..7b22e45af7d --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_migrateloadbalancertoipbasedrequest.go @@ -0,0 +1,8 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateLoadBalancerToIPBasedRequest struct { + Pools *[]string `json:"pools,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_natgateway.go b/resource-manager/network/2024-07-01/loadbalancers/model_natgateway.go new file mode 100644 index 00000000000..0eb10d867d8 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_natgateway.go @@ -0,0 +1,20 @@ +package loadbalancers + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..dbd30f4ffc0 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_natgatewaysku.go b/resource-manager/network/2024-07-01/loadbalancers/model_natgatewaysku.go new file mode 100644 index 00000000000..d503f4fbbfb --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_natruleportmapping.go b/resource-manager/network/2024-07-01/loadbalancers/model_natruleportmapping.go new file mode 100644 index 00000000000..d0afcac5584 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_networkinterface.go b/resource-manager/network/2024-07-01/loadbalancers/model_networkinterface.go new file mode 100644 index 00000000000..3a7fc490368 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_networkinterface.go @@ -0,0 +1,19 @@ +package loadbalancers + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..91dbc787d0a --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..60978bfaf56 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..6dcb491a3d7 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..a7d7345eb3e --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..83b4dc30fdf --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..86c1f45766f --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..60f5f46a243 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/loadbalancers/model_networksecuritygroup.go new file mode 100644 index 00000000000..e4baa9839d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..a3c43420ed8 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_outboundrule.go b/resource-manager/network/2024-07-01/loadbalancers/model_outboundrule.go new file mode 100644 index 00000000000..1dfd6977a6a --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_outboundrule.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *OutboundRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_outboundrulepropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_outboundrulepropertiesformat.go new file mode 100644 index 00000000000..3c7b13886c0 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_outboundrulepropertiesformat.go @@ -0,0 +1,14 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundRulePropertiesFormat struct { + AllocatedOutboundPorts *int64 `json:"allocatedOutboundPorts,omitempty"` + BackendAddressPool SubResource `json:"backendAddressPool"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfigurations []SubResource `json:"frontendIPConfigurations"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol LoadBalancerOutboundRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_privateendpoint.go b/resource-manager/network/2024-07-01/loadbalancers/model_privateendpoint.go new file mode 100644 index 00000000000..1b7d03d287c --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_privateendpoint.go @@ -0,0 +1,19 @@ +package loadbalancers + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/loadbalancers/model_privateendpointconnection.go new file mode 100644 index 00000000000..4324f758e00 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/loadbalancers/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..0db98da1f3a --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/loadbalancers/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..5bae49165b4 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/loadbalancers/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..7b4d544edd6 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/loadbalancers/model_privateendpointproperties.go new file mode 100644 index 00000000000..b949c31f69e --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkservice.go b/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkservice.go new file mode 100644 index 00000000000..90ac8b3e5ca --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package loadbalancers + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..7657685128f --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..047e30a886a --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..a4eb6e38f9b --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..fef899c9ed5 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..0209c2ffc37 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..177e188eb3e --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_probe.go b/resource-manager/network/2024-07-01/loadbalancers/model_probe.go new file mode 100644 index 00000000000..07c805bf4b6 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_probe.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Probe struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProbePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_probepropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_probepropertiesformat.go new file mode 100644 index 00000000000..1ff1fd360c0 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_probepropertiesformat.go @@ -0,0 +1,16 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProbePropertiesFormat struct { + IntervalInSeconds *int64 `json:"intervalInSeconds,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + NoHealthyBackendsBehavior *ProbeNoHealthyBackendsBehavior `json:"noHealthyBackendsBehavior,omitempty"` + NumberOfProbes *int64 `json:"numberOfProbes,omitempty"` + Port int64 `json:"port"` + ProbeThreshold *int64 `json:"probeThreshold,omitempty"` + Protocol ProbeProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestPath *string `json:"requestPath,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_publicipaddress.go b/resource-manager/network/2024-07-01/loadbalancers/model_publicipaddress.go new file mode 100644 index 00000000000..bdc0de0a218 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_publicipaddress.go @@ -0,0 +1,22 @@ +package loadbalancers + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/loadbalancers/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..270d14db8a5 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..5a73a6d016d --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/loadbalancers/model_publicipaddresssku.go new file mode 100644 index 00000000000..b15c3f179cf --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_queryinboundnatruleportmappingrequest.go b/resource-manager/network/2024-07-01/loadbalancers/model_queryinboundnatruleportmappingrequest.go new file mode 100644 index 00000000000..537750e7e89 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_queryinboundnatruleportmappingrequest.go @@ -0,0 +1,9 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryInboundNatRulePortMappingRequest struct { + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *SubResource `json:"ipConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/loadbalancers/model_resourcenavigationlink.go new file mode 100644 index 00000000000..264f22dde08 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..4b34d1eca84 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_resourceset.go b/resource-manager/network/2024-07-01/loadbalancers/model_resourceset.go new file mode 100644 index 00000000000..6d37b1b6861 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_resourceset.go @@ -0,0 +1,8 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/loadbalancers/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..36d6b05e540 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_route.go b/resource-manager/network/2024-07-01/loadbalancers/model_route.go new file mode 100644 index 00000000000..60ee56ca15b --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_route.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_routepropertiesformat.go new file mode 100644 index 00000000000..dad41f27203 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_routetable.go b/resource-manager/network/2024-07-01/loadbalancers/model_routetable.go new file mode 100644 index 00000000000..e6d4f4faa3d --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_routetable.go @@ -0,0 +1,14 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..1169823e36a --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_securityrule.go b/resource-manager/network/2024-07-01/loadbalancers/model_securityrule.go new file mode 100644 index 00000000000..1bd37068862 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_securityrule.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..000a9d8a16f --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/loadbalancers/model_serviceassociationlink.go new file mode 100644 index 00000000000..880f8a061c0 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..5984df7dfe6 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..18a1fb457e6 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/loadbalancers/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..00941b4063a --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/loadbalancers/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..b1f2f8e3300 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..0f54d85448c --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..74afcc602fc --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..f6f73f34673 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_subnet.go b/resource-manager/network/2024-07-01/loadbalancers/model_subnet.go new file mode 100644 index 00000000000..802fd17a35b --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_subnet.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..48667d5dd89 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_subresource.go b/resource-manager/network/2024-07-01/loadbalancers/model_subresource.go new file mode 100644 index 00000000000..e288e1dcb19 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_subresource.go @@ -0,0 +1,8 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_tagsobject.go b/resource-manager/network/2024-07-01/loadbalancers/model_tagsobject.go new file mode 100644 index 00000000000..6b83deef865 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_tagsobject.go @@ -0,0 +1,8 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/loadbalancers/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..ecbf7509a1e --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/loadbalancers/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..2503ab90312 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/loadbalancers/model_virtualnetworktap.go new file mode 100644 index 00000000000..ca9e2389b65 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/loadbalancers/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..5cac0b1e63a --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/predicates.go b/resource-manager/network/2024-07-01/loadbalancers/predicates.go new file mode 100644 index 00000000000..82f247704c6 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/predicates.go @@ -0,0 +1,238 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p BackendAddressPoolOperationPredicate) Matches(input BackendAddressPool) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type FrontendIPConfigurationOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p FrontendIPConfigurationOperationPredicate) Matches(input FrontendIPConfiguration) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type InboundNatRuleOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p InboundNatRuleOperationPredicate) Matches(input InboundNatRule) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type LoadBalancerOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p LoadBalancerOperationPredicate) Matches(input LoadBalancer) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type LoadBalancingRuleOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p LoadBalancingRuleOperationPredicate) Matches(input LoadBalancingRule) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type NetworkInterfaceOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p NetworkInterfaceOperationPredicate) Matches(input NetworkInterface) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type OutboundRuleOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p OutboundRuleOperationPredicate) Matches(input OutboundRule) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type ProbeOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p ProbeOperationPredicate) Matches(input Probe) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/loadbalancers/version.go b/resource-manager/network/2024-07-01/loadbalancers/version.go new file mode 100644 index 00000000000..a35376f3201 --- /dev/null +++ b/resource-manager/network/2024-07-01/loadbalancers/version.go @@ -0,0 +1,10 @@ +package loadbalancers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/loadbalancers/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/README.md b/resource-manager/network/2024-07-01/localnetworkgateways/README.md new file mode 100644 index 00000000000..f814fd17ce8 --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/README.md @@ -0,0 +1,104 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/localnetworkgateways` Documentation + +The `localnetworkgateways` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/localnetworkgateways" +``` + + +### Client Initialization + +```go +client := localnetworkgateways.NewLocalNetworkGatewaysClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `LocalNetworkGatewaysClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := localnetworkgateways.NewLocalNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "localNetworkGatewayName") + +payload := localnetworkgateways.LocalNetworkGateway{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `LocalNetworkGatewaysClient.Delete` + +```go +ctx := context.TODO() +id := localnetworkgateways.NewLocalNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "localNetworkGatewayName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `LocalNetworkGatewaysClient.Get` + +```go +ctx := context.TODO() +id := localnetworkgateways.NewLocalNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "localNetworkGatewayName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `LocalNetworkGatewaysClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `LocalNetworkGatewaysClient.UpdateTags` + +```go +ctx := context.TODO() +id := localnetworkgateways.NewLocalNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "localNetworkGatewayName") + +payload := localnetworkgateways.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/client.go b/resource-manager/network/2024-07-01/localnetworkgateways/client.go new file mode 100644 index 00000000000..c821de0dcf3 --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/client.go @@ -0,0 +1,26 @@ +package localnetworkgateways + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalNetworkGatewaysClient struct { + Client *resourcemanager.Client +} + +func NewLocalNetworkGatewaysClientWithBaseURI(sdkApi sdkEnv.Api) (*LocalNetworkGatewaysClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "localnetworkgateways", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating LocalNetworkGatewaysClient: %+v", err) + } + + return &LocalNetworkGatewaysClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/constants.go b/resource-manager/network/2024-07-01/localnetworkgateways/constants.go new file mode 100644 index 00000000000..f82efef3b1f --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/constants.go @@ -0,0 +1,57 @@ +package localnetworkgateways + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/id_localnetworkgateway.go b/resource-manager/network/2024-07-01/localnetworkgateways/id_localnetworkgateway.go new file mode 100644 index 00000000000..1b8d0c5ae7a --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/id_localnetworkgateway.go @@ -0,0 +1,130 @@ +package localnetworkgateways + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocalNetworkGatewayId{}) +} + +var _ resourceids.ResourceId = &LocalNetworkGatewayId{} + +// LocalNetworkGatewayId is a struct representing the Resource ID for a Local Network Gateway +type LocalNetworkGatewayId struct { + SubscriptionId string + ResourceGroupName string + LocalNetworkGatewayName string +} + +// NewLocalNetworkGatewayID returns a new LocalNetworkGatewayId struct +func NewLocalNetworkGatewayID(subscriptionId string, resourceGroupName string, localNetworkGatewayName string) LocalNetworkGatewayId { + return LocalNetworkGatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LocalNetworkGatewayName: localNetworkGatewayName, + } +} + +// ParseLocalNetworkGatewayID parses 'input' into a LocalNetworkGatewayId +func ParseLocalNetworkGatewayID(input string) (*LocalNetworkGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocalNetworkGatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocalNetworkGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocalNetworkGatewayIDInsensitively parses 'input' case-insensitively into a LocalNetworkGatewayId +// note: this method should only be used for API response data and not user input +func ParseLocalNetworkGatewayIDInsensitively(input string) (*LocalNetworkGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocalNetworkGatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocalNetworkGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocalNetworkGatewayId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LocalNetworkGatewayName, ok = input.Parsed["localNetworkGatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "localNetworkGatewayName", input) + } + + return nil +} + +// ValidateLocalNetworkGatewayID checks that 'input' can be parsed as a Local Network Gateway ID +func ValidateLocalNetworkGatewayID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocalNetworkGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Local Network Gateway ID +func (id LocalNetworkGatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/localNetworkGateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LocalNetworkGatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Local Network Gateway ID +func (id LocalNetworkGatewayId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLocalNetworkGateways", "localNetworkGateways", "localNetworkGateways"), + resourceids.UserSpecifiedSegment("localNetworkGatewayName", "localNetworkGatewayName"), + } +} + +// String returns a human-readable description of this Local Network Gateway ID +func (id LocalNetworkGatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Local Network Gateway Name: %q", id.LocalNetworkGatewayName), + } + return fmt.Sprintf("Local Network Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/id_localnetworkgateway_test.go b/resource-manager/network/2024-07-01/localnetworkgateways/id_localnetworkgateway_test.go new file mode 100644 index 00000000000..d6b7ac58f38 --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/id_localnetworkgateway_test.go @@ -0,0 +1,282 @@ +package localnetworkgateways + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocalNetworkGatewayId{} + +func TestNewLocalNetworkGatewayID(t *testing.T) { + id := NewLocalNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "localNetworkGatewayName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LocalNetworkGatewayName != "localNetworkGatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'LocalNetworkGatewayName'", id.LocalNetworkGatewayName, "localNetworkGatewayName") + } +} + +func TestFormatLocalNetworkGatewayID(t *testing.T) { + actual := NewLocalNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "localNetworkGatewayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/localNetworkGateways/localNetworkGatewayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocalNetworkGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocalNetworkGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/localNetworkGateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/localNetworkGateways/localNetworkGatewayName", + Expected: &LocalNetworkGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocalNetworkGatewayName: "localNetworkGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/localNetworkGateways/localNetworkGatewayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocalNetworkGatewayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocalNetworkGatewayName != v.Expected.LocalNetworkGatewayName { + t.Fatalf("Expected %q but got %q for LocalNetworkGatewayName", v.Expected.LocalNetworkGatewayName, actual.LocalNetworkGatewayName) + } + + } +} + +func TestParseLocalNetworkGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocalNetworkGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/localNetworkGateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAlNeTwOrKgAtEwAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/localNetworkGateways/localNetworkGatewayName", + Expected: &LocalNetworkGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocalNetworkGatewayName: "localNetworkGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/localNetworkGateways/localNetworkGatewayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAlNeTwOrKgAtEwAyS/lOcAlNeTwOrKgAtEwAyNaMe", + Expected: &LocalNetworkGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LocalNetworkGatewayName: "lOcAlNeTwOrKgAtEwAyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAlNeTwOrKgAtEwAyS/lOcAlNeTwOrKgAtEwAyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocalNetworkGatewayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocalNetworkGatewayName != v.Expected.LocalNetworkGatewayName { + t.Fatalf("Expected %q but got %q for LocalNetworkGatewayName", v.Expected.LocalNetworkGatewayName, actual.LocalNetworkGatewayName) + } + + } +} + +func TestSegmentsForLocalNetworkGatewayId(t *testing.T) { + segments := LocalNetworkGatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocalNetworkGatewayId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/method_createorupdate.go b/resource-manager/network/2024-07-01/localnetworkgateways/method_createorupdate.go new file mode 100644 index 00000000000..1b41558abaa --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/method_createorupdate.go @@ -0,0 +1,75 @@ +package localnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *LocalNetworkGateway +} + +// CreateOrUpdate ... +func (c LocalNetworkGatewaysClient) CreateOrUpdate(ctx context.Context, id LocalNetworkGatewayId, input LocalNetworkGateway) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c LocalNetworkGatewaysClient) CreateOrUpdateThenPoll(ctx context.Context, id LocalNetworkGatewayId, input LocalNetworkGateway) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/method_delete.go b/resource-manager/network/2024-07-01/localnetworkgateways/method_delete.go new file mode 100644 index 00000000000..2b155d2b9e7 --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/method_delete.go @@ -0,0 +1,71 @@ +package localnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c LocalNetworkGatewaysClient) Delete(ctx context.Context, id LocalNetworkGatewayId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c LocalNetworkGatewaysClient) DeleteThenPoll(ctx context.Context, id LocalNetworkGatewayId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/method_get.go b/resource-manager/network/2024-07-01/localnetworkgateways/method_get.go new file mode 100644 index 00000000000..678e40b0064 --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/method_get.go @@ -0,0 +1,53 @@ +package localnetworkgateways + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LocalNetworkGateway +} + +// Get ... +func (c LocalNetworkGatewaysClient) Get(ctx context.Context, id LocalNetworkGatewayId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model LocalNetworkGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/method_list.go b/resource-manager/network/2024-07-01/localnetworkgateways/method_list.go new file mode 100644 index 00000000000..528ccebe955 --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/method_list.go @@ -0,0 +1,106 @@ +package localnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LocalNetworkGateway +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []LocalNetworkGateway +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c LocalNetworkGatewaysClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/localNetworkGateways", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]LocalNetworkGateway `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c LocalNetworkGatewaysClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, LocalNetworkGatewayOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c LocalNetworkGatewaysClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate LocalNetworkGatewayOperationPredicate) (result ListCompleteResult, err error) { + items := make([]LocalNetworkGateway, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/method_updatetags.go b/resource-manager/network/2024-07-01/localnetworkgateways/method_updatetags.go new file mode 100644 index 00000000000..cacff76aaeb --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/method_updatetags.go @@ -0,0 +1,57 @@ +package localnetworkgateways + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *LocalNetworkGateway +} + +// UpdateTags ... +func (c LocalNetworkGatewaysClient) UpdateTags(ctx context.Context, id LocalNetworkGatewayId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model LocalNetworkGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/model_addressspace.go b/resource-manager/network/2024-07-01/localnetworkgateways/model_addressspace.go new file mode 100644 index 00000000000..ad2d790e76d --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/model_addressspace.go @@ -0,0 +1,9 @@ +package localnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressSpace struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/model_bgpsettings.go b/resource-manager/network/2024-07-01/localnetworkgateways/model_bgpsettings.go new file mode 100644 index 00000000000..9d3dfccb4b1 --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/model_bgpsettings.go @@ -0,0 +1,11 @@ +package localnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BgpSettings struct { + Asn *int64 `json:"asn,omitempty"` + BgpPeeringAddress *string `json:"bgpPeeringAddress,omitempty"` + BgpPeeringAddresses *[]IPConfigurationBgpPeeringAddress `json:"bgpPeeringAddresses,omitempty"` + PeerWeight *int64 `json:"peerWeight,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/localnetworkgateways/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..93c2d352633 --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package localnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/localnetworkgateways/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..137416d7a98 --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package localnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/model_ipconfigurationbgppeeringaddress.go b/resource-manager/network/2024-07-01/localnetworkgateways/model_ipconfigurationbgppeeringaddress.go new file mode 100644 index 00000000000..4778a80b432 --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/model_ipconfigurationbgppeeringaddress.go @@ -0,0 +1,11 @@ +package localnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationBgpPeeringAddress struct { + CustomBgpIPAddresses *[]string `json:"customBgpIpAddresses,omitempty"` + DefaultBgpIPAddresses *[]string `json:"defaultBgpIpAddresses,omitempty"` + IPconfigurationId *string `json:"ipconfigurationId,omitempty"` + TunnelIPAddresses *[]string `json:"tunnelIpAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/model_localnetworkgateway.go b/resource-manager/network/2024-07-01/localnetworkgateways/model_localnetworkgateway.go new file mode 100644 index 00000000000..684fe705afc --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/model_localnetworkgateway.go @@ -0,0 +1,14 @@ +package localnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalNetworkGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties LocalNetworkGatewayPropertiesFormat `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/model_localnetworkgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/localnetworkgateways/model_localnetworkgatewaypropertiesformat.go new file mode 100644 index 00000000000..fb7a91a8c71 --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/model_localnetworkgatewaypropertiesformat.go @@ -0,0 +1,13 @@ +package localnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalNetworkGatewayPropertiesFormat struct { + BgpSettings *BgpSettings `json:"bgpSettings,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + GatewayIPAddress *string `json:"gatewayIpAddress,omitempty"` + LocalNetworkAddressSpace *AddressSpace `json:"localNetworkAddressSpace,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/model_tagsobject.go b/resource-manager/network/2024-07-01/localnetworkgateways/model_tagsobject.go new file mode 100644 index 00000000000..214a0886d9b --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/model_tagsobject.go @@ -0,0 +1,8 @@ +package localnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/predicates.go b/resource-manager/network/2024-07-01/localnetworkgateways/predicates.go new file mode 100644 index 00000000000..d4e529f8a9c --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/predicates.go @@ -0,0 +1,37 @@ +package localnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalNetworkGatewayOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p LocalNetworkGatewayOperationPredicate) Matches(input LocalNetworkGateway) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/localnetworkgateways/version.go b/resource-manager/network/2024-07-01/localnetworkgateways/version.go new file mode 100644 index 00000000000..4aef7aa5ead --- /dev/null +++ b/resource-manager/network/2024-07-01/localnetworkgateways/version.go @@ -0,0 +1,10 @@ +package localnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/localnetworkgateways/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/natgateways/README.md b/resource-manager/network/2024-07-01/natgateways/README.md new file mode 100644 index 00000000000..f504acf7457 --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/natgateways` Documentation + +The `natgateways` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/natgateways" +``` + + +### Client Initialization + +```go +client := natgateways.NewNatGatewaysClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NatGatewaysClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := natgateways.NewNatGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "natGatewayName") + +payload := natgateways.NatGateway{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NatGatewaysClient.Delete` + +```go +ctx := context.TODO() +id := natgateways.NewNatGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "natGatewayName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NatGatewaysClient.Get` + +```go +ctx := context.TODO() +id := natgateways.NewNatGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "natGatewayName") + +read, err := client.Get(ctx, id, natgateways.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NatGatewaysClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NatGatewaysClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NatGatewaysClient.UpdateTags` + +```go +ctx := context.TODO() +id := natgateways.NewNatGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "natGatewayName") + +payload := natgateways.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/natgateways/client.go b/resource-manager/network/2024-07-01/natgateways/client.go new file mode 100644 index 00000000000..13334ca10a1 --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/client.go @@ -0,0 +1,26 @@ +package natgateways + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaysClient struct { + Client *resourcemanager.Client +} + +func NewNatGatewaysClientWithBaseURI(sdkApi sdkEnv.Api) (*NatGatewaysClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "natgateways", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NatGatewaysClient: %+v", err) + } + + return &NatGatewaysClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/natgateways/constants.go b/resource-manager/network/2024-07-01/natgateways/constants.go new file mode 100644 index 00000000000..1fd193450b4 --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/constants.go @@ -0,0 +1,98 @@ +package natgateways + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/natgateways/id_natgateway.go b/resource-manager/network/2024-07-01/natgateways/id_natgateway.go new file mode 100644 index 00000000000..f830790bd5d --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/id_natgateway.go @@ -0,0 +1,130 @@ +package natgateways + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NatGatewayId{}) +} + +var _ resourceids.ResourceId = &NatGatewayId{} + +// NatGatewayId is a struct representing the Resource ID for a Nat Gateway +type NatGatewayId struct { + SubscriptionId string + ResourceGroupName string + NatGatewayName string +} + +// NewNatGatewayID returns a new NatGatewayId struct +func NewNatGatewayID(subscriptionId string, resourceGroupName string, natGatewayName string) NatGatewayId { + return NatGatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NatGatewayName: natGatewayName, + } +} + +// ParseNatGatewayID parses 'input' into a NatGatewayId +func ParseNatGatewayID(input string) (*NatGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&NatGatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NatGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNatGatewayIDInsensitively parses 'input' case-insensitively into a NatGatewayId +// note: this method should only be used for API response data and not user input +func ParseNatGatewayIDInsensitively(input string) (*NatGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&NatGatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NatGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NatGatewayId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NatGatewayName, ok = input.Parsed["natGatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "natGatewayName", input) + } + + return nil +} + +// ValidateNatGatewayID checks that 'input' can be parsed as a Nat Gateway ID +func ValidateNatGatewayID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNatGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Nat Gateway ID +func (id NatGatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/natGateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NatGatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Nat Gateway ID +func (id NatGatewayId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNatGateways", "natGateways", "natGateways"), + resourceids.UserSpecifiedSegment("natGatewayName", "natGatewayName"), + } +} + +// String returns a human-readable description of this Nat Gateway ID +func (id NatGatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Nat Gateway Name: %q", id.NatGatewayName), + } + return fmt.Sprintf("Nat Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/natgateways/id_natgateway_test.go b/resource-manager/network/2024-07-01/natgateways/id_natgateway_test.go new file mode 100644 index 00000000000..f4148d83e6c --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/id_natgateway_test.go @@ -0,0 +1,282 @@ +package natgateways + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NatGatewayId{} + +func TestNewNatGatewayID(t *testing.T) { + id := NewNatGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "natGatewayName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NatGatewayName != "natGatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'NatGatewayName'", id.NatGatewayName, "natGatewayName") + } +} + +func TestFormatNatGatewayID(t *testing.T) { + actual := NewNatGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "natGatewayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/natGateways/natGatewayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNatGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NatGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/natGateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/natGateways/natGatewayName", + Expected: &NatGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NatGatewayName: "natGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/natGateways/natGatewayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNatGatewayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NatGatewayName != v.Expected.NatGatewayName { + t.Fatalf("Expected %q but got %q for NatGatewayName", v.Expected.NatGatewayName, actual.NatGatewayName) + } + + } +} + +func TestParseNatGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NatGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/natGateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nAtGaTeWaYs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/natGateways/natGatewayName", + Expected: &NatGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NatGatewayName: "natGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/natGateways/natGatewayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nAtGaTeWaYs/nAtGaTeWaYnAmE", + Expected: &NatGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NatGatewayName: "nAtGaTeWaYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nAtGaTeWaYs/nAtGaTeWaYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNatGatewayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NatGatewayName != v.Expected.NatGatewayName { + t.Fatalf("Expected %q but got %q for NatGatewayName", v.Expected.NatGatewayName, actual.NatGatewayName) + } + + } +} + +func TestSegmentsForNatGatewayId(t *testing.T) { + segments := NatGatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NatGatewayId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/natgateways/method_createorupdate.go b/resource-manager/network/2024-07-01/natgateways/method_createorupdate.go new file mode 100644 index 00000000000..34a53aff5ac --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/method_createorupdate.go @@ -0,0 +1,76 @@ +package natgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NatGateway +} + +// CreateOrUpdate ... +func (c NatGatewaysClient) CreateOrUpdate(ctx context.Context, id NatGatewayId, input NatGateway) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c NatGatewaysClient) CreateOrUpdateThenPoll(ctx context.Context, id NatGatewayId, input NatGateway) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/natgateways/method_delete.go b/resource-manager/network/2024-07-01/natgateways/method_delete.go new file mode 100644 index 00000000000..d03d142add6 --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/method_delete.go @@ -0,0 +1,71 @@ +package natgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c NatGatewaysClient) Delete(ctx context.Context, id NatGatewayId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c NatGatewaysClient) DeleteThenPoll(ctx context.Context, id NatGatewayId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/natgateways/method_get.go b/resource-manager/network/2024-07-01/natgateways/method_get.go new file mode 100644 index 00000000000..3997df407c6 --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/method_get.go @@ -0,0 +1,83 @@ +package natgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NatGateway +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c NatGatewaysClient) Get(ctx context.Context, id NatGatewayId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NatGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/natgateways/method_list.go b/resource-manager/network/2024-07-01/natgateways/method_list.go new file mode 100644 index 00000000000..cf6c19572e2 --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/method_list.go @@ -0,0 +1,106 @@ +package natgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NatGateway +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NatGateway +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c NatGatewaysClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/natGateways", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NatGateway `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NatGatewaysClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, NatGatewayOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NatGatewaysClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate NatGatewayOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NatGateway, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/natgateways/method_listall.go b/resource-manager/network/2024-07-01/natgateways/method_listall.go new file mode 100644 index 00000000000..c417f6a9c19 --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/method_listall.go @@ -0,0 +1,106 @@ +package natgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NatGateway +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []NatGateway +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c NatGatewaysClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/natGateways", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NatGateway `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c NatGatewaysClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, NatGatewayOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NatGatewaysClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate NatGatewayOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]NatGateway, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/natgateways/method_updatetags.go b/resource-manager/network/2024-07-01/natgateways/method_updatetags.go new file mode 100644 index 00000000000..2480442d1cd --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/method_updatetags.go @@ -0,0 +1,57 @@ +package natgateways + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NatGateway +} + +// UpdateTags ... +func (c NatGatewaysClient) UpdateTags(ctx context.Context, id NatGatewayId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NatGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/natgateways/model_natgateway.go b/resource-manager/network/2024-07-01/natgateways/model_natgateway.go new file mode 100644 index 00000000000..0aabf1ead87 --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/model_natgateway.go @@ -0,0 +1,20 @@ +package natgateways + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/natgateways/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/natgateways/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..8a094d84f51 --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package natgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/natgateways/model_natgatewaysku.go b/resource-manager/network/2024-07-01/natgateways/model_natgatewaysku.go new file mode 100644 index 00000000000..962d747cc17 --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package natgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/natgateways/model_subresource.go b/resource-manager/network/2024-07-01/natgateways/model_subresource.go new file mode 100644 index 00000000000..ea00694667d --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/model_subresource.go @@ -0,0 +1,8 @@ +package natgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/natgateways/model_tagsobject.go b/resource-manager/network/2024-07-01/natgateways/model_tagsobject.go new file mode 100644 index 00000000000..c5e055c3a58 --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/model_tagsobject.go @@ -0,0 +1,8 @@ +package natgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/natgateways/predicates.go b/resource-manager/network/2024-07-01/natgateways/predicates.go new file mode 100644 index 00000000000..c0e09cf2f07 --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/predicates.go @@ -0,0 +1,37 @@ +package natgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p NatGatewayOperationPredicate) Matches(input NatGateway) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/natgateways/version.go b/resource-manager/network/2024-07-01/natgateways/version.go new file mode 100644 index 00000000000..46c4cef0302 --- /dev/null +++ b/resource-manager/network/2024-07-01/natgateways/version.go @@ -0,0 +1,10 @@ +package natgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/natgateways/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networkgroups/README.md b/resource-manager/network/2024-07-01/networkgroups/README.md new file mode 100644 index 00000000000..140298cf93b --- /dev/null +++ b/resource-manager/network/2024-07-01/networkgroups/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkgroups` Documentation + +The `networkgroups` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkgroups" +``` + + +### Client Initialization + +```go +client := networkgroups.NewNetworkGroupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkGroupsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := networkgroups.NewNetworkGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "networkGroupName") + +payload := networkgroups.NetworkGroup{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload, networkgroups.DefaultCreateOrUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkGroupsClient.Delete` + +```go +ctx := context.TODO() +id := networkgroups.NewNetworkGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "networkGroupName") + +if err := client.DeleteThenPoll(ctx, id, networkgroups.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkGroupsClient.Get` + +```go +ctx := context.TODO() +id := networkgroups.NewNetworkGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "networkGroupName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkGroupsClient.List` + +```go +ctx := context.TODO() +id := networkgroups.NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + +// alternatively `client.List(ctx, id, networkgroups.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, networkgroups.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/networkgroups/client.go b/resource-manager/network/2024-07-01/networkgroups/client.go new file mode 100644 index 00000000000..89171a64b6d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkgroups/client.go @@ -0,0 +1,26 @@ +package networkgroups + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkGroupsClient struct { + Client *resourcemanager.Client +} + +func NewNetworkGroupsClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkGroupsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networkgroups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkGroupsClient: %+v", err) + } + + return &NetworkGroupsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networkgroups/constants.go b/resource-manager/network/2024-07-01/networkgroups/constants.go new file mode 100644 index 00000000000..2418286fbc5 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkgroups/constants.go @@ -0,0 +1,98 @@ +package networkgroups + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GroupMemberType string + +const ( + GroupMemberTypeSubnet GroupMemberType = "Subnet" + GroupMemberTypeVirtualNetwork GroupMemberType = "VirtualNetwork" +) + +func PossibleValuesForGroupMemberType() []string { + return []string{ + string(GroupMemberTypeSubnet), + string(GroupMemberTypeVirtualNetwork), + } +} + +func (s *GroupMemberType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupMemberType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGroupMemberType(input string) (*GroupMemberType, error) { + vals := map[string]GroupMemberType{ + "subnet": GroupMemberTypeSubnet, + "virtualnetwork": GroupMemberTypeVirtualNetwork, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GroupMemberType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networkgroups/id_networkgroup.go b/resource-manager/network/2024-07-01/networkgroups/id_networkgroup.go new file mode 100644 index 00000000000..912a7fb25c3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkgroups/id_networkgroup.go @@ -0,0 +1,139 @@ +package networkgroups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkGroupId{}) +} + +var _ resourceids.ResourceId = &NetworkGroupId{} + +// NetworkGroupId is a struct representing the Resource ID for a Network Group +type NetworkGroupId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + NetworkGroupName string +} + +// NewNetworkGroupID returns a new NetworkGroupId struct +func NewNetworkGroupID(subscriptionId string, resourceGroupName string, networkManagerName string, networkGroupName string) NetworkGroupId { + return NetworkGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + NetworkGroupName: networkGroupName, + } +} + +// ParseNetworkGroupID parses 'input' into a NetworkGroupId +func ParseNetworkGroupID(input string) (*NetworkGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkGroupIDInsensitively parses 'input' case-insensitively into a NetworkGroupId +// note: this method should only be used for API response data and not user input +func ParseNetworkGroupIDInsensitively(input string) (*NetworkGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.NetworkGroupName, ok = input.Parsed["networkGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkGroupName", input) + } + + return nil +} + +// ValidateNetworkGroupID checks that 'input' can be parsed as a Network Group ID +func ValidateNetworkGroupID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Group ID +func (id NetworkGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/networkGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.NetworkGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Group ID +func (id NetworkGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticNetworkGroups", "networkGroups", "networkGroups"), + resourceids.UserSpecifiedSegment("networkGroupName", "networkGroupName"), + } +} + +// String returns a human-readable description of this Network Group ID +func (id NetworkGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Network Group Name: %q", id.NetworkGroupName), + } + return fmt.Sprintf("Network Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkgroups/id_networkgroup_test.go b/resource-manager/network/2024-07-01/networkgroups/id_networkgroup_test.go new file mode 100644 index 00000000000..33356b3c09c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkgroups/id_networkgroup_test.go @@ -0,0 +1,327 @@ +package networkgroups + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkGroupId{} + +func TestNewNetworkGroupID(t *testing.T) { + id := NewNetworkGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "networkGroupName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.NetworkGroupName != "networkGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkGroupName'", id.NetworkGroupName, "networkGroupName") + } +} + +func TestFormatNetworkGroupID(t *testing.T) { + actual := NewNetworkGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "networkGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName", + Expected: &NetworkGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + NetworkGroupName: "networkGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkGroupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.NetworkGroupName != v.Expected.NetworkGroupName { + t.Fatalf("Expected %q but got %q for NetworkGroupName", v.Expected.NetworkGroupName, actual.NetworkGroupName) + } + + } +} + +func TestParseNetworkGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/nEtWoRkGrOuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName", + Expected: &NetworkGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + NetworkGroupName: "networkGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/nEtWoRkGrOuPs/nEtWoRkGrOuPnAmE", + Expected: &NetworkGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + NetworkGroupName: "nEtWoRkGrOuPnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/nEtWoRkGrOuPs/nEtWoRkGrOuPnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkGroupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.NetworkGroupName != v.Expected.NetworkGroupName { + t.Fatalf("Expected %q but got %q for NetworkGroupName", v.Expected.NetworkGroupName, actual.NetworkGroupName) + } + + } +} + +func TestSegmentsForNetworkGroupId(t *testing.T) { + segments := NetworkGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkGroupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkgroups/id_networkmanager.go b/resource-manager/network/2024-07-01/networkgroups/id_networkmanager.go new file mode 100644 index 00000000000..427d707220a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkgroups/id_networkmanager.go @@ -0,0 +1,130 @@ +package networkgroups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkManagerId{}) +} + +var _ resourceids.ResourceId = &NetworkManagerId{} + +// NetworkManagerId is a struct representing the Resource ID for a Network Manager +type NetworkManagerId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string +} + +// NewNetworkManagerID returns a new NetworkManagerId struct +func NewNetworkManagerID(subscriptionId string, resourceGroupName string, networkManagerName string) NetworkManagerId { + return NetworkManagerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + } +} + +// ParseNetworkManagerID parses 'input' into a NetworkManagerId +func ParseNetworkManagerID(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkManagerIDInsensitively parses 'input' case-insensitively into a NetworkManagerId +// note: this method should only be used for API response data and not user input +func ParseNetworkManagerIDInsensitively(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkManagerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + return nil +} + +// ValidateNetworkManagerID checks that 'input' can be parsed as a Network Manager ID +func ValidateNetworkManagerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkManagerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Manager ID +func (id NetworkManagerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Manager ID +func (id NetworkManagerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + } +} + +// String returns a human-readable description of this Network Manager ID +func (id NetworkManagerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + } + return fmt.Sprintf("Network Manager (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkgroups/id_networkmanager_test.go b/resource-manager/network/2024-07-01/networkgroups/id_networkmanager_test.go new file mode 100644 index 00000000000..c1df2af44ba --- /dev/null +++ b/resource-manager/network/2024-07-01/networkgroups/id_networkmanager_test.go @@ -0,0 +1,282 @@ +package networkgroups + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkManagerId{} + +func TestNewNetworkManagerID(t *testing.T) { + id := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } +} + +func TestFormatNetworkManagerID(t *testing.T) { + actual := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkManagerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestParseNetworkManagerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestSegmentsForNetworkManagerId(t *testing.T) { + segments := NetworkManagerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkManagerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkgroups/method_createorupdate.go b/resource-manager/network/2024-07-01/networkgroups/method_createorupdate.go new file mode 100644 index 00000000000..89e0b5c2b0c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkgroups/method_createorupdate.go @@ -0,0 +1,88 @@ +package networkgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkGroup +} + +type CreateOrUpdateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// CreateOrUpdate ... +func (c NetworkGroupsClient) CreateOrUpdate(ctx context.Context, id NetworkGroupId, input NetworkGroup, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkGroup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkgroups/method_delete.go b/resource-manager/network/2024-07-01/networkgroups/method_delete.go new file mode 100644 index 00000000000..45f93907f23 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkgroups/method_delete.go @@ -0,0 +1,100 @@ +package networkgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c NetworkGroupsClient) Delete(ctx context.Context, id NetworkGroupId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c NetworkGroupsClient) DeleteThenPoll(ctx context.Context, id NetworkGroupId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkgroups/method_get.go b/resource-manager/network/2024-07-01/networkgroups/method_get.go new file mode 100644 index 00000000000..503719a73d9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkgroups/method_get.go @@ -0,0 +1,53 @@ +package networkgroups + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkGroup +} + +// Get ... +func (c NetworkGroupsClient) Get(ctx context.Context, id NetworkGroupId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkGroup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkgroups/method_list.go b/resource-manager/network/2024-07-01/networkgroups/method_list.go new file mode 100644 index 00000000000..360af82528f --- /dev/null +++ b/resource-manager/network/2024-07-01/networkgroups/method_list.go @@ -0,0 +1,134 @@ +package networkgroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkGroup +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkGroup +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c NetworkGroupsClient) List(ctx context.Context, id NetworkManagerId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/networkGroups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NetworkGroupsClient) ListComplete(ctx context.Context, id NetworkManagerId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, NetworkGroupOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkGroupsClient) ListCompleteMatchingPredicate(ctx context.Context, id NetworkManagerId, options ListOperationOptions, predicate NetworkGroupOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NetworkGroup, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkgroups/model_networkgroup.go b/resource-manager/network/2024-07-01/networkgroups/model_networkgroup.go new file mode 100644 index 00000000000..c35ded0ac80 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkgroups/model_networkgroup.go @@ -0,0 +1,17 @@ +package networkgroups + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkGroupProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkgroups/model_networkgroupproperties.go b/resource-manager/network/2024-07-01/networkgroups/model_networkgroupproperties.go new file mode 100644 index 00000000000..e964c527511 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkgroups/model_networkgroupproperties.go @@ -0,0 +1,11 @@ +package networkgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkGroupProperties struct { + Description *string `json:"description,omitempty"` + MemberType *GroupMemberType `json:"memberType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkgroups/predicates.go b/resource-manager/network/2024-07-01/networkgroups/predicates.go new file mode 100644 index 00000000000..621d0d7b40a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkgroups/predicates.go @@ -0,0 +1,32 @@ +package networkgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkGroupOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p NetworkGroupOperationPredicate) Matches(input NetworkGroup) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/networkgroups/version.go b/resource-manager/network/2024-07-01/networkgroups/version.go new file mode 100644 index 00000000000..494768bd9dc --- /dev/null +++ b/resource-manager/network/2024-07-01/networkgroups/version.go @@ -0,0 +1,10 @@ +package networkgroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networkgroups/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/README.md b/resource-manager/network/2024-07-01/networkinterfaces/README.md new file mode 100644 index 00000000000..635a7580f1f --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/README.md @@ -0,0 +1,400 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkinterfaces` Documentation + +The `networkinterfaces` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkinterfaces" +``` + + +### Client Initialization + +```go +client := networkinterfaces.NewNetworkInterfacesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkInterfacesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceName") + +payload := networkinterfaces.NetworkInterface{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkInterfacesClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkInterfacesClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceName") + +read, err := client.Get(ctx, id, networkinterfaces.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkInterfacesClient.GetCloudServiceNetworkInterface` + +```go +ctx := context.TODO() +id := networkinterfaces.NewRoleInstanceNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServiceName", "roleInstanceName", "networkInterfaceName") + +read, err := client.GetCloudServiceNetworkInterface(ctx, id, networkinterfaces.DefaultGetCloudServiceNetworkInterfaceOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkInterfacesClient.GetEffectiveRouteTable` + +```go +ctx := context.TODO() +id := commonids.NewNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceName") + +// alternatively `client.GetEffectiveRouteTable(ctx, id)` can be used to do batched pagination +items, err := client.GetEffectiveRouteTableComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkInterfacesClient.GetVirtualMachineScaleSetIPConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewVirtualMachineScaleSetIPConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineScaleSetName", "virtualMachineName", "networkInterfaceName", "ipConfigurationName") + +read, err := client.GetVirtualMachineScaleSetIPConfiguration(ctx, id, networkinterfaces.DefaultGetVirtualMachineScaleSetIPConfigurationOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkInterfacesClient.GetVirtualMachineScaleSetNetworkInterface` + +```go +ctx := context.TODO() +id := commonids.NewVirtualMachineScaleSetNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineScaleSetName", "virtualMachineName", "networkInterfaceName") + +read, err := client.GetVirtualMachineScaleSetNetworkInterface(ctx, id, networkinterfaces.DefaultGetVirtualMachineScaleSetNetworkInterfaceOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkInterfacesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkInterfacesClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkInterfacesClient.ListCloudServiceNetworkInterfaces` + +```go +ctx := context.TODO() +id := networkinterfaces.NewProviderCloudServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServiceName") + +// alternatively `client.ListCloudServiceNetworkInterfaces(ctx, id)` can be used to do batched pagination +items, err := client.ListCloudServiceNetworkInterfacesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkInterfacesClient.ListCloudServiceRoleInstanceNetworkInterfaces` + +```go +ctx := context.TODO() +id := networkinterfaces.NewRoleInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServiceName", "roleInstanceName") + +// alternatively `client.ListCloudServiceRoleInstanceNetworkInterfaces(ctx, id)` can be used to do batched pagination +items, err := client.ListCloudServiceRoleInstanceNetworkInterfacesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkInterfacesClient.ListEffectiveNetworkSecurityGroups` + +```go +ctx := context.TODO() +id := commonids.NewNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceName") + +// alternatively `client.ListEffectiveNetworkSecurityGroups(ctx, id)` can be used to do batched pagination +items, err := client.ListEffectiveNetworkSecurityGroupsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkInterfacesClient.ListVirtualMachineScaleSetIPConfigurations` + +```go +ctx := context.TODO() +id := commonids.NewVirtualMachineScaleSetNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineScaleSetName", "virtualMachineName", "networkInterfaceName") + +// alternatively `client.ListVirtualMachineScaleSetIPConfigurations(ctx, id, networkinterfaces.DefaultListVirtualMachineScaleSetIPConfigurationsOperationOptions())` can be used to do batched pagination +items, err := client.ListVirtualMachineScaleSetIPConfigurationsComplete(ctx, id, networkinterfaces.DefaultListVirtualMachineScaleSetIPConfigurationsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkInterfacesClient.ListVirtualMachineScaleSetNetworkInterfaces` + +```go +ctx := context.TODO() +id := networkinterfaces.NewVirtualMachineScaleSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineScaleSetName") + +// alternatively `client.ListVirtualMachineScaleSetNetworkInterfaces(ctx, id)` can be used to do batched pagination +items, err := client.ListVirtualMachineScaleSetNetworkInterfacesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkInterfacesClient.ListVirtualMachineScaleSetVMNetworkInterfaces` + +```go +ctx := context.TODO() +id := networkinterfaces.NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineScaleSetName", "virtualMachineName") + +// alternatively `client.ListVirtualMachineScaleSetVMNetworkInterfaces(ctx, id)` can be used to do batched pagination +items, err := client.ListVirtualMachineScaleSetVMNetworkInterfacesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkInterfacesClient.NetworkInterfaceIPConfigurationsGet` + +```go +ctx := context.TODO() +id := commonids.NewNetworkInterfaceIPConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceName", "ipConfigurationName") + +read, err := client.NetworkInterfaceIPConfigurationsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkInterfacesClient.NetworkInterfaceIPConfigurationsList` + +```go +ctx := context.TODO() +id := commonids.NewNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceName") + +// alternatively `client.NetworkInterfaceIPConfigurationsList(ctx, id)` can be used to do batched pagination +items, err := client.NetworkInterfaceIPConfigurationsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkInterfacesClient.NetworkInterfaceLoadBalancersList` + +```go +ctx := context.TODO() +id := commonids.NewNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceName") + +// alternatively `client.NetworkInterfaceLoadBalancersList(ctx, id)` can be used to do batched pagination +items, err := client.NetworkInterfaceLoadBalancersListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkInterfacesClient.NetworkInterfaceTapConfigurationsCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkinterfaces.NewTapConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceName", "tapConfigurationName") + +payload := networkinterfaces.NetworkInterfaceTapConfiguration{ + // ... +} + + +if err := client.NetworkInterfaceTapConfigurationsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkInterfacesClient.NetworkInterfaceTapConfigurationsDelete` + +```go +ctx := context.TODO() +id := networkinterfaces.NewTapConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceName", "tapConfigurationName") + +if err := client.NetworkInterfaceTapConfigurationsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkInterfacesClient.NetworkInterfaceTapConfigurationsGet` + +```go +ctx := context.TODO() +id := networkinterfaces.NewTapConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceName", "tapConfigurationName") + +read, err := client.NetworkInterfaceTapConfigurationsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkInterfacesClient.NetworkInterfaceTapConfigurationsList` + +```go +ctx := context.TODO() +id := commonids.NewNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceName") + +// alternatively `client.NetworkInterfaceTapConfigurationsList(ctx, id)` can be used to do batched pagination +items, err := client.NetworkInterfaceTapConfigurationsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkInterfacesClient.UpdateTags` + +```go +ctx := context.TODO() +id := commonids.NewNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceName") + +payload := networkinterfaces.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/networkinterfaces/client.go b/resource-manager/network/2024-07-01/networkinterfaces/client.go new file mode 100644 index 00000000000..1edd1a6838a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/client.go @@ -0,0 +1,26 @@ +package networkinterfaces + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacesClient struct { + Client *resourcemanager.Client +} + +func NewNetworkInterfacesClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkInterfacesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networkinterfaces", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkInterfacesClient: %+v", err) + } + + return &NetworkInterfacesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/constants.go b/resource-manager/network/2024-07-01/networkinterfaces/constants.go new file mode 100644 index 00000000000..5be7726bc73 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/constants.go @@ -0,0 +1,1594 @@ +package networkinterfaces + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type EffectiveRouteSource string + +const ( + EffectiveRouteSourceDefault EffectiveRouteSource = "Default" + EffectiveRouteSourceUnknown EffectiveRouteSource = "Unknown" + EffectiveRouteSourceUser EffectiveRouteSource = "User" + EffectiveRouteSourceVirtualNetworkGateway EffectiveRouteSource = "VirtualNetworkGateway" +) + +func PossibleValuesForEffectiveRouteSource() []string { + return []string{ + string(EffectiveRouteSourceDefault), + string(EffectiveRouteSourceUnknown), + string(EffectiveRouteSourceUser), + string(EffectiveRouteSourceVirtualNetworkGateway), + } +} + +func (s *EffectiveRouteSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEffectiveRouteSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEffectiveRouteSource(input string) (*EffectiveRouteSource, error) { + vals := map[string]EffectiveRouteSource{ + "default": EffectiveRouteSourceDefault, + "unknown": EffectiveRouteSourceUnknown, + "user": EffectiveRouteSourceUser, + "virtualnetworkgateway": EffectiveRouteSourceVirtualNetworkGateway, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EffectiveRouteSource(input) + return &out, nil +} + +type EffectiveRouteState string + +const ( + EffectiveRouteStateActive EffectiveRouteState = "Active" + EffectiveRouteStateInvalid EffectiveRouteState = "Invalid" +) + +func PossibleValuesForEffectiveRouteState() []string { + return []string{ + string(EffectiveRouteStateActive), + string(EffectiveRouteStateInvalid), + } +} + +func (s *EffectiveRouteState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEffectiveRouteState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEffectiveRouteState(input string) (*EffectiveRouteState, error) { + vals := map[string]EffectiveRouteState{ + "active": EffectiveRouteStateActive, + "invalid": EffectiveRouteStateInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EffectiveRouteState(input) + return &out, nil +} + +type EffectiveSecurityRuleProtocol string + +const ( + EffectiveSecurityRuleProtocolAll EffectiveSecurityRuleProtocol = "All" + EffectiveSecurityRuleProtocolTcp EffectiveSecurityRuleProtocol = "Tcp" + EffectiveSecurityRuleProtocolUdp EffectiveSecurityRuleProtocol = "Udp" +) + +func PossibleValuesForEffectiveSecurityRuleProtocol() []string { + return []string{ + string(EffectiveSecurityRuleProtocolAll), + string(EffectiveSecurityRuleProtocolTcp), + string(EffectiveSecurityRuleProtocolUdp), + } +} + +func (s *EffectiveSecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEffectiveSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEffectiveSecurityRuleProtocol(input string) (*EffectiveSecurityRuleProtocol, error) { + vals := map[string]EffectiveSecurityRuleProtocol{ + "all": EffectiveSecurityRuleProtocolAll, + "tcp": EffectiveSecurityRuleProtocolTcp, + "udp": EffectiveSecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EffectiveSecurityRuleProtocol(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type LoadBalancerOutboundRuleProtocol string + +const ( + LoadBalancerOutboundRuleProtocolAll LoadBalancerOutboundRuleProtocol = "All" + LoadBalancerOutboundRuleProtocolTcp LoadBalancerOutboundRuleProtocol = "Tcp" + LoadBalancerOutboundRuleProtocolUdp LoadBalancerOutboundRuleProtocol = "Udp" +) + +func PossibleValuesForLoadBalancerOutboundRuleProtocol() []string { + return []string{ + string(LoadBalancerOutboundRuleProtocolAll), + string(LoadBalancerOutboundRuleProtocolTcp), + string(LoadBalancerOutboundRuleProtocolUdp), + } +} + +func (s *LoadBalancerOutboundRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerOutboundRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerOutboundRuleProtocol(input string) (*LoadBalancerOutboundRuleProtocol, error) { + vals := map[string]LoadBalancerOutboundRuleProtocol{ + "all": LoadBalancerOutboundRuleProtocolAll, + "tcp": LoadBalancerOutboundRuleProtocolTcp, + "udp": LoadBalancerOutboundRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerOutboundRuleProtocol(input) + return &out, nil +} + +type LoadBalancerSkuName string + +const ( + LoadBalancerSkuNameBasic LoadBalancerSkuName = "Basic" + LoadBalancerSkuNameGateway LoadBalancerSkuName = "Gateway" + LoadBalancerSkuNameStandard LoadBalancerSkuName = "Standard" +) + +func PossibleValuesForLoadBalancerSkuName() []string { + return []string{ + string(LoadBalancerSkuNameBasic), + string(LoadBalancerSkuNameGateway), + string(LoadBalancerSkuNameStandard), + } +} + +func (s *LoadBalancerSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerSkuName(input string) (*LoadBalancerSkuName, error) { + vals := map[string]LoadBalancerSkuName{ + "basic": LoadBalancerSkuNameBasic, + "gateway": LoadBalancerSkuNameGateway, + "standard": LoadBalancerSkuNameStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerSkuName(input) + return &out, nil +} + +type LoadBalancerSkuTier string + +const ( + LoadBalancerSkuTierGlobal LoadBalancerSkuTier = "Global" + LoadBalancerSkuTierRegional LoadBalancerSkuTier = "Regional" +) + +func PossibleValuesForLoadBalancerSkuTier() []string { + return []string{ + string(LoadBalancerSkuTierGlobal), + string(LoadBalancerSkuTierRegional), + } +} + +func (s *LoadBalancerSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerSkuTier(input string) (*LoadBalancerSkuTier, error) { + vals := map[string]LoadBalancerSkuTier{ + "global": LoadBalancerSkuTierGlobal, + "regional": LoadBalancerSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerSkuTier(input) + return &out, nil +} + +type LoadDistribution string + +const ( + LoadDistributionDefault LoadDistribution = "Default" + LoadDistributionSourceIP LoadDistribution = "SourceIP" + LoadDistributionSourceIPProtocol LoadDistribution = "SourceIPProtocol" +) + +func PossibleValuesForLoadDistribution() []string { + return []string{ + string(LoadDistributionDefault), + string(LoadDistributionSourceIP), + string(LoadDistributionSourceIPProtocol), + } +} + +func (s *LoadDistribution) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadDistribution(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadDistribution(input string) (*LoadDistribution, error) { + vals := map[string]LoadDistribution{ + "default": LoadDistributionDefault, + "sourceip": LoadDistributionSourceIP, + "sourceipprotocol": LoadDistributionSourceIPProtocol, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadDistribution(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProbeNoHealthyBackendsBehavior string + +const ( + ProbeNoHealthyBackendsBehaviorAllProbedDown ProbeNoHealthyBackendsBehavior = "AllProbedDown" + ProbeNoHealthyBackendsBehaviorAllProbedUp ProbeNoHealthyBackendsBehavior = "AllProbedUp" +) + +func PossibleValuesForProbeNoHealthyBackendsBehavior() []string { + return []string{ + string(ProbeNoHealthyBackendsBehaviorAllProbedDown), + string(ProbeNoHealthyBackendsBehaviorAllProbedUp), + } +} + +func (s *ProbeNoHealthyBackendsBehavior) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProbeNoHealthyBackendsBehavior(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProbeNoHealthyBackendsBehavior(input string) (*ProbeNoHealthyBackendsBehavior, error) { + vals := map[string]ProbeNoHealthyBackendsBehavior{ + "allprobeddown": ProbeNoHealthyBackendsBehaviorAllProbedDown, + "allprobedup": ProbeNoHealthyBackendsBehaviorAllProbedUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProbeNoHealthyBackendsBehavior(input) + return &out, nil +} + +type ProbeProtocol string + +const ( + ProbeProtocolHTTP ProbeProtocol = "Http" + ProbeProtocolHTTPS ProbeProtocol = "Https" + ProbeProtocolTcp ProbeProtocol = "Tcp" +) + +func PossibleValuesForProbeProtocol() []string { + return []string{ + string(ProbeProtocolHTTP), + string(ProbeProtocolHTTPS), + string(ProbeProtocolTcp), + } +} + +func (s *ProbeProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProbeProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProbeProtocol(input string) (*ProbeProtocol, error) { + vals := map[string]ProbeProtocol{ + "http": ProbeProtocolHTTP, + "https": ProbeProtocolHTTPS, + "tcp": ProbeProtocolTcp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProbeProtocol(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/id_providercloudservice.go b/resource-manager/network/2024-07-01/networkinterfaces/id_providercloudservice.go new file mode 100644 index 00000000000..d749e9a64f3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/id_providercloudservice.go @@ -0,0 +1,130 @@ +package networkinterfaces + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderCloudServiceId{}) +} + +var _ resourceids.ResourceId = &ProviderCloudServiceId{} + +// ProviderCloudServiceId is a struct representing the Resource ID for a Provider Cloud Service +type ProviderCloudServiceId struct { + SubscriptionId string + ResourceGroupName string + CloudServiceName string +} + +// NewProviderCloudServiceID returns a new ProviderCloudServiceId struct +func NewProviderCloudServiceID(subscriptionId string, resourceGroupName string, cloudServiceName string) ProviderCloudServiceId { + return ProviderCloudServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudServiceName: cloudServiceName, + } +} + +// ParseProviderCloudServiceID parses 'input' into a ProviderCloudServiceId +func ParseProviderCloudServiceID(input string) (*ProviderCloudServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderCloudServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderCloudServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderCloudServiceIDInsensitively parses 'input' case-insensitively into a ProviderCloudServiceId +// note: this method should only be used for API response data and not user input +func ParseProviderCloudServiceIDInsensitively(input string) (*ProviderCloudServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderCloudServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderCloudServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderCloudServiceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudServiceName, ok = input.Parsed["cloudServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudServiceName", input) + } + + return nil +} + +// ValidateProviderCloudServiceID checks that 'input' can be parsed as a Provider Cloud Service ID +func ValidateProviderCloudServiceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderCloudServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Cloud Service ID +func (id ProviderCloudServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/cloudServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Cloud Service ID +func (id ProviderCloudServiceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCompute", "Microsoft.Compute", "Microsoft.Compute"), + resourceids.StaticSegment("staticCloudServices", "cloudServices", "cloudServices"), + resourceids.UserSpecifiedSegment("cloudServiceName", "cloudServiceName"), + } +} + +// String returns a human-readable description of this Provider Cloud Service ID +func (id ProviderCloudServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Service Name: %q", id.CloudServiceName), + } + return fmt.Sprintf("Provider Cloud Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/id_providercloudservice_test.go b/resource-manager/network/2024-07-01/networkinterfaces/id_providercloudservice_test.go new file mode 100644 index 00000000000..fc3e9bed798 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/id_providercloudservice_test.go @@ -0,0 +1,282 @@ +package networkinterfaces + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderCloudServiceId{} + +func TestNewProviderCloudServiceID(t *testing.T) { + id := NewProviderCloudServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServiceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudServiceName != "cloudServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudServiceName'", id.CloudServiceName, "cloudServiceName") + } +} + +func TestFormatProviderCloudServiceID(t *testing.T) { + actual := NewProviderCloudServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderCloudServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderCloudServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName", + Expected: &ProviderCloudServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudServiceName: "cloudServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderCloudServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudServiceName != v.Expected.CloudServiceName { + t.Fatalf("Expected %q but got %q for CloudServiceName", v.Expected.CloudServiceName, actual.CloudServiceName) + } + + } +} + +func TestParseProviderCloudServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderCloudServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName", + Expected: &ProviderCloudServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudServiceName: "cloudServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs/cLoUdSeRvIcEnAmE", + Expected: &ProviderCloudServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudServiceName: "cLoUdSeRvIcEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs/cLoUdSeRvIcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderCloudServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudServiceName != v.Expected.CloudServiceName { + t.Fatalf("Expected %q but got %q for CloudServiceName", v.Expected.CloudServiceName, actual.CloudServiceName) + } + + } +} + +func TestSegmentsForProviderCloudServiceId(t *testing.T) { + segments := ProviderCloudServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderCloudServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/id_roleinstance.go b/resource-manager/network/2024-07-01/networkinterfaces/id_roleinstance.go new file mode 100644 index 00000000000..49ded1dcada --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/id_roleinstance.go @@ -0,0 +1,139 @@ +package networkinterfaces + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RoleInstanceId{}) +} + +var _ resourceids.ResourceId = &RoleInstanceId{} + +// RoleInstanceId is a struct representing the Resource ID for a Role Instance +type RoleInstanceId struct { + SubscriptionId string + ResourceGroupName string + CloudServiceName string + RoleInstanceName string +} + +// NewRoleInstanceID returns a new RoleInstanceId struct +func NewRoleInstanceID(subscriptionId string, resourceGroupName string, cloudServiceName string, roleInstanceName string) RoleInstanceId { + return RoleInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudServiceName: cloudServiceName, + RoleInstanceName: roleInstanceName, + } +} + +// ParseRoleInstanceID parses 'input' into a RoleInstanceId +func ParseRoleInstanceID(input string) (*RoleInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&RoleInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RoleInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRoleInstanceIDInsensitively parses 'input' case-insensitively into a RoleInstanceId +// note: this method should only be used for API response data and not user input +func ParseRoleInstanceIDInsensitively(input string) (*RoleInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&RoleInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RoleInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RoleInstanceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudServiceName, ok = input.Parsed["cloudServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudServiceName", input) + } + + if id.RoleInstanceName, ok = input.Parsed["roleInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "roleInstanceName", input) + } + + return nil +} + +// ValidateRoleInstanceID checks that 'input' can be parsed as a Role Instance ID +func ValidateRoleInstanceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRoleInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Role Instance ID +func (id RoleInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/cloudServices/%s/roleInstances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudServiceName, id.RoleInstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Role Instance ID +func (id RoleInstanceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCompute", "Microsoft.Compute", "Microsoft.Compute"), + resourceids.StaticSegment("staticCloudServices", "cloudServices", "cloudServices"), + resourceids.UserSpecifiedSegment("cloudServiceName", "cloudServiceName"), + resourceids.StaticSegment("staticRoleInstances", "roleInstances", "roleInstances"), + resourceids.UserSpecifiedSegment("roleInstanceName", "roleInstanceName"), + } +} + +// String returns a human-readable description of this Role Instance ID +func (id RoleInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Service Name: %q", id.CloudServiceName), + fmt.Sprintf("Role Instance Name: %q", id.RoleInstanceName), + } + return fmt.Sprintf("Role Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/id_roleinstance_test.go b/resource-manager/network/2024-07-01/networkinterfaces/id_roleinstance_test.go new file mode 100644 index 00000000000..fb3858d936d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/id_roleinstance_test.go @@ -0,0 +1,327 @@ +package networkinterfaces + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RoleInstanceId{} + +func TestNewRoleInstanceID(t *testing.T) { + id := NewRoleInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServiceName", "roleInstanceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudServiceName != "cloudServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudServiceName'", id.CloudServiceName, "cloudServiceName") + } + + if id.RoleInstanceName != "roleInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'RoleInstanceName'", id.RoleInstanceName, "roleInstanceName") + } +} + +func TestFormatRoleInstanceID(t *testing.T) { + actual := NewRoleInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServiceName", "roleInstanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances/roleInstanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRoleInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RoleInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances/roleInstanceName", + Expected: &RoleInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudServiceName: "cloudServiceName", + RoleInstanceName: "roleInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances/roleInstanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRoleInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudServiceName != v.Expected.CloudServiceName { + t.Fatalf("Expected %q but got %q for CloudServiceName", v.Expected.CloudServiceName, actual.CloudServiceName) + } + + if actual.RoleInstanceName != v.Expected.RoleInstanceName { + t.Fatalf("Expected %q but got %q for RoleInstanceName", v.Expected.RoleInstanceName, actual.RoleInstanceName) + } + + } +} + +func TestParseRoleInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RoleInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs/cLoUdSeRvIcEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs/cLoUdSeRvIcEnAmE/rOlEiNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances/roleInstanceName", + Expected: &RoleInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudServiceName: "cloudServiceName", + RoleInstanceName: "roleInstanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances/roleInstanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs/cLoUdSeRvIcEnAmE/rOlEiNsTaNcEs/rOlEiNsTaNcEnAmE", + Expected: &RoleInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudServiceName: "cLoUdSeRvIcEnAmE", + RoleInstanceName: "rOlEiNsTaNcEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs/cLoUdSeRvIcEnAmE/rOlEiNsTaNcEs/rOlEiNsTaNcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRoleInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudServiceName != v.Expected.CloudServiceName { + t.Fatalf("Expected %q but got %q for CloudServiceName", v.Expected.CloudServiceName, actual.CloudServiceName) + } + + if actual.RoleInstanceName != v.Expected.RoleInstanceName { + t.Fatalf("Expected %q but got %q for RoleInstanceName", v.Expected.RoleInstanceName, actual.RoleInstanceName) + } + + } +} + +func TestSegmentsForRoleInstanceId(t *testing.T) { + segments := RoleInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RoleInstanceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/id_roleinstancenetworkinterface.go b/resource-manager/network/2024-07-01/networkinterfaces/id_roleinstancenetworkinterface.go new file mode 100644 index 00000000000..a67d978ec63 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/id_roleinstancenetworkinterface.go @@ -0,0 +1,148 @@ +package networkinterfaces + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RoleInstanceNetworkInterfaceId{}) +} + +var _ resourceids.ResourceId = &RoleInstanceNetworkInterfaceId{} + +// RoleInstanceNetworkInterfaceId is a struct representing the Resource ID for a Role Instance Network Interface +type RoleInstanceNetworkInterfaceId struct { + SubscriptionId string + ResourceGroupName string + CloudServiceName string + RoleInstanceName string + NetworkInterfaceName string +} + +// NewRoleInstanceNetworkInterfaceID returns a new RoleInstanceNetworkInterfaceId struct +func NewRoleInstanceNetworkInterfaceID(subscriptionId string, resourceGroupName string, cloudServiceName string, roleInstanceName string, networkInterfaceName string) RoleInstanceNetworkInterfaceId { + return RoleInstanceNetworkInterfaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudServiceName: cloudServiceName, + RoleInstanceName: roleInstanceName, + NetworkInterfaceName: networkInterfaceName, + } +} + +// ParseRoleInstanceNetworkInterfaceID parses 'input' into a RoleInstanceNetworkInterfaceId +func ParseRoleInstanceNetworkInterfaceID(input string) (*RoleInstanceNetworkInterfaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&RoleInstanceNetworkInterfaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RoleInstanceNetworkInterfaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRoleInstanceNetworkInterfaceIDInsensitively parses 'input' case-insensitively into a RoleInstanceNetworkInterfaceId +// note: this method should only be used for API response data and not user input +func ParseRoleInstanceNetworkInterfaceIDInsensitively(input string) (*RoleInstanceNetworkInterfaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&RoleInstanceNetworkInterfaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RoleInstanceNetworkInterfaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RoleInstanceNetworkInterfaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudServiceName, ok = input.Parsed["cloudServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudServiceName", input) + } + + if id.RoleInstanceName, ok = input.Parsed["roleInstanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "roleInstanceName", input) + } + + if id.NetworkInterfaceName, ok = input.Parsed["networkInterfaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkInterfaceName", input) + } + + return nil +} + +// ValidateRoleInstanceNetworkInterfaceID checks that 'input' can be parsed as a Role Instance Network Interface ID +func ValidateRoleInstanceNetworkInterfaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRoleInstanceNetworkInterfaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Role Instance Network Interface ID +func (id RoleInstanceNetworkInterfaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/cloudServices/%s/roleInstances/%s/networkInterfaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudServiceName, id.RoleInstanceName, id.NetworkInterfaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Role Instance Network Interface ID +func (id RoleInstanceNetworkInterfaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCompute", "Microsoft.Compute", "Microsoft.Compute"), + resourceids.StaticSegment("staticCloudServices", "cloudServices", "cloudServices"), + resourceids.UserSpecifiedSegment("cloudServiceName", "cloudServiceName"), + resourceids.StaticSegment("staticRoleInstances", "roleInstances", "roleInstances"), + resourceids.UserSpecifiedSegment("roleInstanceName", "roleInstanceName"), + resourceids.StaticSegment("staticNetworkInterfaces", "networkInterfaces", "networkInterfaces"), + resourceids.UserSpecifiedSegment("networkInterfaceName", "networkInterfaceName"), + } +} + +// String returns a human-readable description of this Role Instance Network Interface ID +func (id RoleInstanceNetworkInterfaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Service Name: %q", id.CloudServiceName), + fmt.Sprintf("Role Instance Name: %q", id.RoleInstanceName), + fmt.Sprintf("Network Interface Name: %q", id.NetworkInterfaceName), + } + return fmt.Sprintf("Role Instance Network Interface (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/id_roleinstancenetworkinterface_test.go b/resource-manager/network/2024-07-01/networkinterfaces/id_roleinstancenetworkinterface_test.go new file mode 100644 index 00000000000..1873ffdb8ad --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/id_roleinstancenetworkinterface_test.go @@ -0,0 +1,372 @@ +package networkinterfaces + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RoleInstanceNetworkInterfaceId{} + +func TestNewRoleInstanceNetworkInterfaceID(t *testing.T) { + id := NewRoleInstanceNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServiceName", "roleInstanceName", "networkInterfaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CloudServiceName != "cloudServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudServiceName'", id.CloudServiceName, "cloudServiceName") + } + + if id.RoleInstanceName != "roleInstanceName" { + t.Fatalf("Expected %q but got %q for Segment 'RoleInstanceName'", id.RoleInstanceName, "roleInstanceName") + } + + if id.NetworkInterfaceName != "networkInterfaceName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkInterfaceName'", id.NetworkInterfaceName, "networkInterfaceName") + } +} + +func TestFormatRoleInstanceNetworkInterfaceID(t *testing.T) { + actual := NewRoleInstanceNetworkInterfaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "cloudServiceName", "roleInstanceName", "networkInterfaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances/roleInstanceName/networkInterfaces/networkInterfaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRoleInstanceNetworkInterfaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RoleInstanceNetworkInterfaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances/roleInstanceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances/roleInstanceName/networkInterfaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances/roleInstanceName/networkInterfaces/networkInterfaceName", + Expected: &RoleInstanceNetworkInterfaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudServiceName: "cloudServiceName", + RoleInstanceName: "roleInstanceName", + NetworkInterfaceName: "networkInterfaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances/roleInstanceName/networkInterfaces/networkInterfaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRoleInstanceNetworkInterfaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudServiceName != v.Expected.CloudServiceName { + t.Fatalf("Expected %q but got %q for CloudServiceName", v.Expected.CloudServiceName, actual.CloudServiceName) + } + + if actual.RoleInstanceName != v.Expected.RoleInstanceName { + t.Fatalf("Expected %q but got %q for RoleInstanceName", v.Expected.RoleInstanceName, actual.RoleInstanceName) + } + + if actual.NetworkInterfaceName != v.Expected.NetworkInterfaceName { + t.Fatalf("Expected %q but got %q for NetworkInterfaceName", v.Expected.NetworkInterfaceName, actual.NetworkInterfaceName) + } + + } +} + +func TestParseRoleInstanceNetworkInterfaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RoleInstanceNetworkInterfaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs/cLoUdSeRvIcEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs/cLoUdSeRvIcEnAmE/rOlEiNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances/roleInstanceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs/cLoUdSeRvIcEnAmE/rOlEiNsTaNcEs/rOlEiNsTaNcEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances/roleInstanceName/networkInterfaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs/cLoUdSeRvIcEnAmE/rOlEiNsTaNcEs/rOlEiNsTaNcEnAmE/nEtWoRkInTeRfAcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances/roleInstanceName/networkInterfaces/networkInterfaceName", + Expected: &RoleInstanceNetworkInterfaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CloudServiceName: "cloudServiceName", + RoleInstanceName: "roleInstanceName", + NetworkInterfaceName: "networkInterfaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/cloudServices/cloudServiceName/roleInstances/roleInstanceName/networkInterfaces/networkInterfaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs/cLoUdSeRvIcEnAmE/rOlEiNsTaNcEs/rOlEiNsTaNcEnAmE/nEtWoRkInTeRfAcEs/nEtWoRkInTeRfAcEnAmE", + Expected: &RoleInstanceNetworkInterfaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CloudServiceName: "cLoUdSeRvIcEnAmE", + RoleInstanceName: "rOlEiNsTaNcEnAmE", + NetworkInterfaceName: "nEtWoRkInTeRfAcEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs/cLoUdSeRvIcEnAmE/rOlEiNsTaNcEs/rOlEiNsTaNcEnAmE/nEtWoRkInTeRfAcEs/nEtWoRkInTeRfAcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRoleInstanceNetworkInterfaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudServiceName != v.Expected.CloudServiceName { + t.Fatalf("Expected %q but got %q for CloudServiceName", v.Expected.CloudServiceName, actual.CloudServiceName) + } + + if actual.RoleInstanceName != v.Expected.RoleInstanceName { + t.Fatalf("Expected %q but got %q for RoleInstanceName", v.Expected.RoleInstanceName, actual.RoleInstanceName) + } + + if actual.NetworkInterfaceName != v.Expected.NetworkInterfaceName { + t.Fatalf("Expected %q but got %q for NetworkInterfaceName", v.Expected.NetworkInterfaceName, actual.NetworkInterfaceName) + } + + } +} + +func TestSegmentsForRoleInstanceNetworkInterfaceId(t *testing.T) { + segments := RoleInstanceNetworkInterfaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RoleInstanceNetworkInterfaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/id_tapconfiguration.go b/resource-manager/network/2024-07-01/networkinterfaces/id_tapconfiguration.go new file mode 100644 index 00000000000..b2916c52d2d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/id_tapconfiguration.go @@ -0,0 +1,139 @@ +package networkinterfaces + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&TapConfigurationId{}) +} + +var _ resourceids.ResourceId = &TapConfigurationId{} + +// TapConfigurationId is a struct representing the Resource ID for a Tap Configuration +type TapConfigurationId struct { + SubscriptionId string + ResourceGroupName string + NetworkInterfaceName string + TapConfigurationName string +} + +// NewTapConfigurationID returns a new TapConfigurationId struct +func NewTapConfigurationID(subscriptionId string, resourceGroupName string, networkInterfaceName string, tapConfigurationName string) TapConfigurationId { + return TapConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkInterfaceName: networkInterfaceName, + TapConfigurationName: tapConfigurationName, + } +} + +// ParseTapConfigurationID parses 'input' into a TapConfigurationId +func ParseTapConfigurationID(input string) (*TapConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&TapConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TapConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTapConfigurationIDInsensitively parses 'input' case-insensitively into a TapConfigurationId +// note: this method should only be used for API response data and not user input +func ParseTapConfigurationIDInsensitively(input string) (*TapConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&TapConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TapConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TapConfigurationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkInterfaceName, ok = input.Parsed["networkInterfaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkInterfaceName", input) + } + + if id.TapConfigurationName, ok = input.Parsed["tapConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "tapConfigurationName", input) + } + + return nil +} + +// ValidateTapConfigurationID checks that 'input' can be parsed as a Tap Configuration ID +func ValidateTapConfigurationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseTapConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Tap Configuration ID +func (id TapConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkInterfaces/%s/tapConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkInterfaceName, id.TapConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Tap Configuration ID +func (id TapConfigurationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkInterfaces", "networkInterfaces", "networkInterfaces"), + resourceids.UserSpecifiedSegment("networkInterfaceName", "networkInterfaceName"), + resourceids.StaticSegment("staticTapConfigurations", "tapConfigurations", "tapConfigurations"), + resourceids.UserSpecifiedSegment("tapConfigurationName", "tapConfigurationName"), + } +} + +// String returns a human-readable description of this Tap Configuration ID +func (id TapConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Interface Name: %q", id.NetworkInterfaceName), + fmt.Sprintf("Tap Configuration Name: %q", id.TapConfigurationName), + } + return fmt.Sprintf("Tap Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/id_tapconfiguration_test.go b/resource-manager/network/2024-07-01/networkinterfaces/id_tapconfiguration_test.go new file mode 100644 index 00000000000..e56e61f7371 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/id_tapconfiguration_test.go @@ -0,0 +1,327 @@ +package networkinterfaces + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &TapConfigurationId{} + +func TestNewTapConfigurationID(t *testing.T) { + id := NewTapConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceName", "tapConfigurationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkInterfaceName != "networkInterfaceName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkInterfaceName'", id.NetworkInterfaceName, "networkInterfaceName") + } + + if id.TapConfigurationName != "tapConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'TapConfigurationName'", id.TapConfigurationName, "tapConfigurationName") + } +} + +func TestFormatTapConfigurationID(t *testing.T) { + actual := NewTapConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkInterfaceName", "tapConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkInterfaces/networkInterfaceName/tapConfigurations/tapConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTapConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TapConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkInterfaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkInterfaces/networkInterfaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkInterfaces/networkInterfaceName/tapConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkInterfaces/networkInterfaceName/tapConfigurations/tapConfigurationName", + Expected: &TapConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkInterfaceName: "networkInterfaceName", + TapConfigurationName: "tapConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkInterfaces/networkInterfaceName/tapConfigurations/tapConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTapConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkInterfaceName != v.Expected.NetworkInterfaceName { + t.Fatalf("Expected %q but got %q for NetworkInterfaceName", v.Expected.NetworkInterfaceName, actual.NetworkInterfaceName) + } + + if actual.TapConfigurationName != v.Expected.TapConfigurationName { + t.Fatalf("Expected %q but got %q for TapConfigurationName", v.Expected.TapConfigurationName, actual.TapConfigurationName) + } + + } +} + +func TestParseTapConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TapConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkInterfaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkInTeRfAcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkInterfaces/networkInterfaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkInTeRfAcEs/nEtWoRkInTeRfAcEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkInterfaces/networkInterfaceName/tapConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkInTeRfAcEs/nEtWoRkInTeRfAcEnAmE/tApCoNfIgUrAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkInterfaces/networkInterfaceName/tapConfigurations/tapConfigurationName", + Expected: &TapConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkInterfaceName: "networkInterfaceName", + TapConfigurationName: "tapConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkInterfaces/networkInterfaceName/tapConfigurations/tapConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkInTeRfAcEs/nEtWoRkInTeRfAcEnAmE/tApCoNfIgUrAtIoNs/tApCoNfIgUrAtIoNnAmE", + Expected: &TapConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkInterfaceName: "nEtWoRkInTeRfAcEnAmE", + TapConfigurationName: "tApCoNfIgUrAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkInTeRfAcEs/nEtWoRkInTeRfAcEnAmE/tApCoNfIgUrAtIoNs/tApCoNfIgUrAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTapConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkInterfaceName != v.Expected.NetworkInterfaceName { + t.Fatalf("Expected %q but got %q for NetworkInterfaceName", v.Expected.NetworkInterfaceName, actual.NetworkInterfaceName) + } + + if actual.TapConfigurationName != v.Expected.TapConfigurationName { + t.Fatalf("Expected %q but got %q for TapConfigurationName", v.Expected.TapConfigurationName, actual.TapConfigurationName) + } + + } +} + +func TestSegmentsForTapConfigurationId(t *testing.T) { + segments := TapConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TapConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/id_virtualmachine.go b/resource-manager/network/2024-07-01/networkinterfaces/id_virtualmachine.go new file mode 100644 index 00000000000..ad24ef16d81 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/id_virtualmachine.go @@ -0,0 +1,139 @@ +package networkinterfaces + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualMachineId{}) +} + +var _ resourceids.ResourceId = &VirtualMachineId{} + +// VirtualMachineId is a struct representing the Resource ID for a Virtual Machine +type VirtualMachineId struct { + SubscriptionId string + ResourceGroupName string + VirtualMachineScaleSetName string + VirtualMachineName string +} + +// NewVirtualMachineID returns a new VirtualMachineId struct +func NewVirtualMachineID(subscriptionId string, resourceGroupName string, virtualMachineScaleSetName string, virtualMachineName string) VirtualMachineId { + return VirtualMachineId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualMachineScaleSetName: virtualMachineScaleSetName, + VirtualMachineName: virtualMachineName, + } +} + +// ParseVirtualMachineID parses 'input' into a VirtualMachineId +func ParseVirtualMachineID(input string) (*VirtualMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualMachineId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualMachineId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualMachineIDInsensitively parses 'input' case-insensitively into a VirtualMachineId +// note: this method should only be used for API response data and not user input +func ParseVirtualMachineIDInsensitively(input string) (*VirtualMachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualMachineId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualMachineId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualMachineId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VirtualMachineScaleSetName, ok = input.Parsed["virtualMachineScaleSetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualMachineScaleSetName", input) + } + + if id.VirtualMachineName, ok = input.Parsed["virtualMachineName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualMachineName", input) + } + + return nil +} + +// ValidateVirtualMachineID checks that 'input' can be parsed as a Virtual Machine ID +func ValidateVirtualMachineID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVirtualMachineID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Machine ID +func (id VirtualMachineId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/virtualMachineScaleSets/%s/virtualMachines/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualMachineScaleSetName, id.VirtualMachineName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Machine ID +func (id VirtualMachineId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCompute", "Microsoft.Compute", "Microsoft.Compute"), + resourceids.StaticSegment("staticVirtualMachineScaleSets", "virtualMachineScaleSets", "virtualMachineScaleSets"), + resourceids.UserSpecifiedSegment("virtualMachineScaleSetName", "virtualMachineScaleSetName"), + resourceids.StaticSegment("staticVirtualMachines", "virtualMachines", "virtualMachines"), + resourceids.UserSpecifiedSegment("virtualMachineName", "virtualMachineName"), + } +} + +// String returns a human-readable description of this Virtual Machine ID +func (id VirtualMachineId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Machine Scale Set Name: %q", id.VirtualMachineScaleSetName), + fmt.Sprintf("Virtual Machine Name: %q", id.VirtualMachineName), + } + return fmt.Sprintf("Virtual Machine (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/id_virtualmachine_test.go b/resource-manager/network/2024-07-01/networkinterfaces/id_virtualmachine_test.go new file mode 100644 index 00000000000..cb6aa2f9476 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/id_virtualmachine_test.go @@ -0,0 +1,327 @@ +package networkinterfaces + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualMachineId{} + +func TestNewVirtualMachineID(t *testing.T) { + id := NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineScaleSetName", "virtualMachineName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VirtualMachineScaleSetName != "virtualMachineScaleSetName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualMachineScaleSetName'", id.VirtualMachineScaleSetName, "virtualMachineScaleSetName") + } + + if id.VirtualMachineName != "virtualMachineName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualMachineName'", id.VirtualMachineName, "virtualMachineName") + } +} + +func TestFormatVirtualMachineID(t *testing.T) { + actual := NewVirtualMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineScaleSetName", "virtualMachineName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName/virtualMachines/virtualMachineName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualMachineID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualMachineId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName/virtualMachines", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName/virtualMachines/virtualMachineName", + Expected: &VirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualMachineScaleSetName: "virtualMachineScaleSetName", + VirtualMachineName: "virtualMachineName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName/virtualMachines/virtualMachineName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualMachineID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualMachineScaleSetName != v.Expected.VirtualMachineScaleSetName { + t.Fatalf("Expected %q but got %q for VirtualMachineScaleSetName", v.Expected.VirtualMachineScaleSetName, actual.VirtualMachineScaleSetName) + } + + if actual.VirtualMachineName != v.Expected.VirtualMachineName { + t.Fatalf("Expected %q but got %q for VirtualMachineName", v.Expected.VirtualMachineName, actual.VirtualMachineName) + } + + } +} + +func TestParseVirtualMachineIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualMachineId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/vIrTuAlMaChInEsCaLeSeTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/vIrTuAlMaChInEsCaLeSeTs/vIrTuAlMaChInEsCaLeSeTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName/virtualMachines", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/vIrTuAlMaChInEsCaLeSeTs/vIrTuAlMaChInEsCaLeSeTnAmE/vIrTuAlMaChInEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName/virtualMachines/virtualMachineName", + Expected: &VirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualMachineScaleSetName: "virtualMachineScaleSetName", + VirtualMachineName: "virtualMachineName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName/virtualMachines/virtualMachineName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/vIrTuAlMaChInEsCaLeSeTs/vIrTuAlMaChInEsCaLeSeTnAmE/vIrTuAlMaChInEs/vIrTuAlMaChInEnAmE", + Expected: &VirtualMachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualMachineScaleSetName: "vIrTuAlMaChInEsCaLeSeTnAmE", + VirtualMachineName: "vIrTuAlMaChInEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/vIrTuAlMaChInEsCaLeSeTs/vIrTuAlMaChInEsCaLeSeTnAmE/vIrTuAlMaChInEs/vIrTuAlMaChInEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualMachineIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualMachineScaleSetName != v.Expected.VirtualMachineScaleSetName { + t.Fatalf("Expected %q but got %q for VirtualMachineScaleSetName", v.Expected.VirtualMachineScaleSetName, actual.VirtualMachineScaleSetName) + } + + if actual.VirtualMachineName != v.Expected.VirtualMachineName { + t.Fatalf("Expected %q but got %q for VirtualMachineName", v.Expected.VirtualMachineName, actual.VirtualMachineName) + } + + } +} + +func TestSegmentsForVirtualMachineId(t *testing.T) { + segments := VirtualMachineId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualMachineId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/id_virtualmachinescaleset.go b/resource-manager/network/2024-07-01/networkinterfaces/id_virtualmachinescaleset.go new file mode 100644 index 00000000000..63abd7e5d6f --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/id_virtualmachinescaleset.go @@ -0,0 +1,130 @@ +package networkinterfaces + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualMachineScaleSetId{}) +} + +var _ resourceids.ResourceId = &VirtualMachineScaleSetId{} + +// VirtualMachineScaleSetId is a struct representing the Resource ID for a Virtual Machine Scale Set +type VirtualMachineScaleSetId struct { + SubscriptionId string + ResourceGroupName string + VirtualMachineScaleSetName string +} + +// NewVirtualMachineScaleSetID returns a new VirtualMachineScaleSetId struct +func NewVirtualMachineScaleSetID(subscriptionId string, resourceGroupName string, virtualMachineScaleSetName string) VirtualMachineScaleSetId { + return VirtualMachineScaleSetId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualMachineScaleSetName: virtualMachineScaleSetName, + } +} + +// ParseVirtualMachineScaleSetID parses 'input' into a VirtualMachineScaleSetId +func ParseVirtualMachineScaleSetID(input string) (*VirtualMachineScaleSetId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualMachineScaleSetId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualMachineScaleSetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualMachineScaleSetIDInsensitively parses 'input' case-insensitively into a VirtualMachineScaleSetId +// note: this method should only be used for API response data and not user input +func ParseVirtualMachineScaleSetIDInsensitively(input string) (*VirtualMachineScaleSetId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualMachineScaleSetId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualMachineScaleSetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualMachineScaleSetId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VirtualMachineScaleSetName, ok = input.Parsed["virtualMachineScaleSetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualMachineScaleSetName", input) + } + + return nil +} + +// ValidateVirtualMachineScaleSetID checks that 'input' can be parsed as a Virtual Machine Scale Set ID +func ValidateVirtualMachineScaleSetID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVirtualMachineScaleSetID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Machine Scale Set ID +func (id VirtualMachineScaleSetId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/virtualMachineScaleSets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualMachineScaleSetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Machine Scale Set ID +func (id VirtualMachineScaleSetId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCompute", "Microsoft.Compute", "Microsoft.Compute"), + resourceids.StaticSegment("staticVirtualMachineScaleSets", "virtualMachineScaleSets", "virtualMachineScaleSets"), + resourceids.UserSpecifiedSegment("virtualMachineScaleSetName", "virtualMachineScaleSetName"), + } +} + +// String returns a human-readable description of this Virtual Machine Scale Set ID +func (id VirtualMachineScaleSetId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Machine Scale Set Name: %q", id.VirtualMachineScaleSetName), + } + return fmt.Sprintf("Virtual Machine Scale Set (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/id_virtualmachinescaleset_test.go b/resource-manager/network/2024-07-01/networkinterfaces/id_virtualmachinescaleset_test.go new file mode 100644 index 00000000000..2d9e75d6fb9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/id_virtualmachinescaleset_test.go @@ -0,0 +1,282 @@ +package networkinterfaces + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualMachineScaleSetId{} + +func TestNewVirtualMachineScaleSetID(t *testing.T) { + id := NewVirtualMachineScaleSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineScaleSetName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VirtualMachineScaleSetName != "virtualMachineScaleSetName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualMachineScaleSetName'", id.VirtualMachineScaleSetName, "virtualMachineScaleSetName") + } +} + +func TestFormatVirtualMachineScaleSetID(t *testing.T) { + actual := NewVirtualMachineScaleSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineScaleSetName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualMachineScaleSetID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualMachineScaleSetId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName", + Expected: &VirtualMachineScaleSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualMachineScaleSetName: "virtualMachineScaleSetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualMachineScaleSetID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualMachineScaleSetName != v.Expected.VirtualMachineScaleSetName { + t.Fatalf("Expected %q but got %q for VirtualMachineScaleSetName", v.Expected.VirtualMachineScaleSetName, actual.VirtualMachineScaleSetName) + } + + } +} + +func TestParseVirtualMachineScaleSetIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualMachineScaleSetId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/vIrTuAlMaChInEsCaLeSeTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName", + Expected: &VirtualMachineScaleSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualMachineScaleSetName: "virtualMachineScaleSetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/vIrTuAlMaChInEsCaLeSeTs/vIrTuAlMaChInEsCaLeSeTnAmE", + Expected: &VirtualMachineScaleSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualMachineScaleSetName: "vIrTuAlMaChInEsCaLeSeTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/vIrTuAlMaChInEsCaLeSeTs/vIrTuAlMaChInEsCaLeSeTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualMachineScaleSetIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualMachineScaleSetName != v.Expected.VirtualMachineScaleSetName { + t.Fatalf("Expected %q but got %q for VirtualMachineScaleSetName", v.Expected.VirtualMachineScaleSetName, actual.VirtualMachineScaleSetName) + } + + } +} + +func TestSegmentsForVirtualMachineScaleSetId(t *testing.T) { + segments := VirtualMachineScaleSetId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualMachineScaleSetId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_createorupdate.go b/resource-manager/network/2024-07-01/networkinterfaces/method_createorupdate.go new file mode 100644 index 00000000000..5686c1db5f0 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_createorupdate.go @@ -0,0 +1,76 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NetworkInterface +} + +// CreateOrUpdate ... +func (c NetworkInterfacesClient) CreateOrUpdate(ctx context.Context, id commonids.NetworkInterfaceId, input NetworkInterface) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c NetworkInterfacesClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.NetworkInterfaceId, input NetworkInterface) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_delete.go b/resource-manager/network/2024-07-01/networkinterfaces/method_delete.go new file mode 100644 index 00000000000..99f476e3fa9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_delete.go @@ -0,0 +1,72 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c NetworkInterfacesClient) Delete(ctx context.Context, id commonids.NetworkInterfaceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c NetworkInterfacesClient) DeleteThenPoll(ctx context.Context, id commonids.NetworkInterfaceId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_get.go b/resource-manager/network/2024-07-01/networkinterfaces/method_get.go new file mode 100644 index 00000000000..5a73b976c2c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_get.go @@ -0,0 +1,84 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkInterface +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c NetworkInterfacesClient) Get(ctx context.Context, id commonids.NetworkInterfaceId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkInterface + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_getcloudservicenetworkinterface.go b/resource-manager/network/2024-07-01/networkinterfaces/method_getcloudservicenetworkinterface.go new file mode 100644 index 00000000000..be2ca6e2e39 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_getcloudservicenetworkinterface.go @@ -0,0 +1,83 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetCloudServiceNetworkInterfaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkInterface +} + +type GetCloudServiceNetworkInterfaceOperationOptions struct { + Expand *string +} + +func DefaultGetCloudServiceNetworkInterfaceOperationOptions() GetCloudServiceNetworkInterfaceOperationOptions { + return GetCloudServiceNetworkInterfaceOperationOptions{} +} + +func (o GetCloudServiceNetworkInterfaceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetCloudServiceNetworkInterfaceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetCloudServiceNetworkInterfaceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// GetCloudServiceNetworkInterface ... +func (c NetworkInterfacesClient) GetCloudServiceNetworkInterface(ctx context.Context, id RoleInstanceNetworkInterfaceId, options GetCloudServiceNetworkInterfaceOperationOptions) (result GetCloudServiceNetworkInterfaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkInterface + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_geteffectiveroutetable.go b/resource-manager/network/2024-07-01/networkinterfaces/method_geteffectiveroutetable.go new file mode 100644 index 00000000000..34e568863a2 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_geteffectiveroutetable.go @@ -0,0 +1,90 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetEffectiveRouteTableOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]EffectiveRoute +} + +type GetEffectiveRouteTableCompleteResult struct { + LatestHttpResponse *http.Response + Items []EffectiveRoute +} + +type GetEffectiveRouteTableCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetEffectiveRouteTableCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetEffectiveRouteTable ... +func (c NetworkInterfacesClient) GetEffectiveRouteTable(ctx context.Context, id commonids.NetworkInterfaceId) (result GetEffectiveRouteTableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &GetEffectiveRouteTableCustomPager{}, + Path: fmt.Sprintf("%s/effectiveRouteTable", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetEffectiveRouteTableThenPoll performs GetEffectiveRouteTable then polls until it's completed +func (c NetworkInterfacesClient) GetEffectiveRouteTableThenPoll(ctx context.Context, id commonids.NetworkInterfaceId) error { + result, err := c.GetEffectiveRouteTable(ctx, id) + if err != nil { + return fmt.Errorf("performing GetEffectiveRouteTable: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetEffectiveRouteTable: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_getvirtualmachinescalesetipconfiguration.go b/resource-manager/network/2024-07-01/networkinterfaces/method_getvirtualmachinescalesetipconfiguration.go new file mode 100644 index 00000000000..88f82856ae8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_getvirtualmachinescalesetipconfiguration.go @@ -0,0 +1,84 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetVirtualMachineScaleSetIPConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkInterfaceIPConfiguration +} + +type GetVirtualMachineScaleSetIPConfigurationOperationOptions struct { + Expand *string +} + +func DefaultGetVirtualMachineScaleSetIPConfigurationOperationOptions() GetVirtualMachineScaleSetIPConfigurationOperationOptions { + return GetVirtualMachineScaleSetIPConfigurationOperationOptions{} +} + +func (o GetVirtualMachineScaleSetIPConfigurationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetVirtualMachineScaleSetIPConfigurationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetVirtualMachineScaleSetIPConfigurationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// GetVirtualMachineScaleSetIPConfiguration ... +func (c NetworkInterfacesClient) GetVirtualMachineScaleSetIPConfiguration(ctx context.Context, id commonids.VirtualMachineScaleSetIPConfigurationId, options GetVirtualMachineScaleSetIPConfigurationOperationOptions) (result GetVirtualMachineScaleSetIPConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkInterfaceIPConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_getvirtualmachinescalesetnetworkinterface.go b/resource-manager/network/2024-07-01/networkinterfaces/method_getvirtualmachinescalesetnetworkinterface.go new file mode 100644 index 00000000000..4bad16270ba --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_getvirtualmachinescalesetnetworkinterface.go @@ -0,0 +1,84 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetVirtualMachineScaleSetNetworkInterfaceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkInterface +} + +type GetVirtualMachineScaleSetNetworkInterfaceOperationOptions struct { + Expand *string +} + +func DefaultGetVirtualMachineScaleSetNetworkInterfaceOperationOptions() GetVirtualMachineScaleSetNetworkInterfaceOperationOptions { + return GetVirtualMachineScaleSetNetworkInterfaceOperationOptions{} +} + +func (o GetVirtualMachineScaleSetNetworkInterfaceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetVirtualMachineScaleSetNetworkInterfaceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetVirtualMachineScaleSetNetworkInterfaceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// GetVirtualMachineScaleSetNetworkInterface ... +func (c NetworkInterfacesClient) GetVirtualMachineScaleSetNetworkInterface(ctx context.Context, id commonids.VirtualMachineScaleSetNetworkInterfaceId, options GetVirtualMachineScaleSetNetworkInterfaceOperationOptions) (result GetVirtualMachineScaleSetNetworkInterfaceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkInterface + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_list.go b/resource-manager/network/2024-07-01/networkinterfaces/method_list.go new file mode 100644 index 00000000000..aba8bcae0a0 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_list.go @@ -0,0 +1,106 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkInterface +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkInterface +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c NetworkInterfacesClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/networkInterfaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkInterface `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NetworkInterfacesClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, NetworkInterfaceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkInterfacesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate NetworkInterfaceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NetworkInterface, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_listall.go b/resource-manager/network/2024-07-01/networkinterfaces/method_listall.go new file mode 100644 index 00000000000..aee96a1ced3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_listall.go @@ -0,0 +1,106 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkInterface +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkInterface +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c NetworkInterfacesClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/networkInterfaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkInterface `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c NetworkInterfacesClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, NetworkInterfaceOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkInterfacesClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate NetworkInterfaceOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]NetworkInterface, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_listcloudservicenetworkinterfaces.go b/resource-manager/network/2024-07-01/networkinterfaces/method_listcloudservicenetworkinterfaces.go new file mode 100644 index 00000000000..7a16382102e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_listcloudservicenetworkinterfaces.go @@ -0,0 +1,105 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListCloudServiceNetworkInterfacesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkInterface +} + +type ListCloudServiceNetworkInterfacesCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkInterface +} + +type ListCloudServiceNetworkInterfacesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCloudServiceNetworkInterfacesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListCloudServiceNetworkInterfaces ... +func (c NetworkInterfacesClient) ListCloudServiceNetworkInterfaces(ctx context.Context, id ProviderCloudServiceId) (result ListCloudServiceNetworkInterfacesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCloudServiceNetworkInterfacesCustomPager{}, + Path: fmt.Sprintf("%s/networkInterfaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkInterface `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListCloudServiceNetworkInterfacesComplete retrieves all the results into a single object +func (c NetworkInterfacesClient) ListCloudServiceNetworkInterfacesComplete(ctx context.Context, id ProviderCloudServiceId) (ListCloudServiceNetworkInterfacesCompleteResult, error) { + return c.ListCloudServiceNetworkInterfacesCompleteMatchingPredicate(ctx, id, NetworkInterfaceOperationPredicate{}) +} + +// ListCloudServiceNetworkInterfacesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkInterfacesClient) ListCloudServiceNetworkInterfacesCompleteMatchingPredicate(ctx context.Context, id ProviderCloudServiceId, predicate NetworkInterfaceOperationPredicate) (result ListCloudServiceNetworkInterfacesCompleteResult, err error) { + items := make([]NetworkInterface, 0) + + resp, err := c.ListCloudServiceNetworkInterfaces(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCloudServiceNetworkInterfacesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_listcloudserviceroleinstancenetworkinterfaces.go b/resource-manager/network/2024-07-01/networkinterfaces/method_listcloudserviceroleinstancenetworkinterfaces.go new file mode 100644 index 00000000000..f4ae2efc987 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_listcloudserviceroleinstancenetworkinterfaces.go @@ -0,0 +1,105 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListCloudServiceRoleInstanceNetworkInterfacesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkInterface +} + +type ListCloudServiceRoleInstanceNetworkInterfacesCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkInterface +} + +type ListCloudServiceRoleInstanceNetworkInterfacesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCloudServiceRoleInstanceNetworkInterfacesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListCloudServiceRoleInstanceNetworkInterfaces ... +func (c NetworkInterfacesClient) ListCloudServiceRoleInstanceNetworkInterfaces(ctx context.Context, id RoleInstanceId) (result ListCloudServiceRoleInstanceNetworkInterfacesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCloudServiceRoleInstanceNetworkInterfacesCustomPager{}, + Path: fmt.Sprintf("%s/networkInterfaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkInterface `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListCloudServiceRoleInstanceNetworkInterfacesComplete retrieves all the results into a single object +func (c NetworkInterfacesClient) ListCloudServiceRoleInstanceNetworkInterfacesComplete(ctx context.Context, id RoleInstanceId) (ListCloudServiceRoleInstanceNetworkInterfacesCompleteResult, error) { + return c.ListCloudServiceRoleInstanceNetworkInterfacesCompleteMatchingPredicate(ctx, id, NetworkInterfaceOperationPredicate{}) +} + +// ListCloudServiceRoleInstanceNetworkInterfacesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkInterfacesClient) ListCloudServiceRoleInstanceNetworkInterfacesCompleteMatchingPredicate(ctx context.Context, id RoleInstanceId, predicate NetworkInterfaceOperationPredicate) (result ListCloudServiceRoleInstanceNetworkInterfacesCompleteResult, err error) { + items := make([]NetworkInterface, 0) + + resp, err := c.ListCloudServiceRoleInstanceNetworkInterfaces(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCloudServiceRoleInstanceNetworkInterfacesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_listeffectivenetworksecuritygroups.go b/resource-manager/network/2024-07-01/networkinterfaces/method_listeffectivenetworksecuritygroups.go new file mode 100644 index 00000000000..8316911280d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_listeffectivenetworksecuritygroups.go @@ -0,0 +1,90 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListEffectiveNetworkSecurityGroupsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]EffectiveNetworkSecurityGroup +} + +type ListEffectiveNetworkSecurityGroupsCompleteResult struct { + LatestHttpResponse *http.Response + Items []EffectiveNetworkSecurityGroup +} + +type ListEffectiveNetworkSecurityGroupsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListEffectiveNetworkSecurityGroupsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListEffectiveNetworkSecurityGroups ... +func (c NetworkInterfacesClient) ListEffectiveNetworkSecurityGroups(ctx context.Context, id commonids.NetworkInterfaceId) (result ListEffectiveNetworkSecurityGroupsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListEffectiveNetworkSecurityGroupsCustomPager{}, + Path: fmt.Sprintf("%s/effectiveNetworkSecurityGroups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ListEffectiveNetworkSecurityGroupsThenPoll performs ListEffectiveNetworkSecurityGroups then polls until it's completed +func (c NetworkInterfacesClient) ListEffectiveNetworkSecurityGroupsThenPoll(ctx context.Context, id commonids.NetworkInterfaceId) error { + result, err := c.ListEffectiveNetworkSecurityGroups(ctx, id) + if err != nil { + return fmt.Errorf("performing ListEffectiveNetworkSecurityGroups: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ListEffectiveNetworkSecurityGroups: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_listvirtualmachinescalesetipconfigurations.go b/resource-manager/network/2024-07-01/networkinterfaces/method_listvirtualmachinescalesetipconfigurations.go new file mode 100644 index 00000000000..8c1c944f6c8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_listvirtualmachinescalesetipconfigurations.go @@ -0,0 +1,135 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListVirtualMachineScaleSetIPConfigurationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkInterfaceIPConfiguration +} + +type ListVirtualMachineScaleSetIPConfigurationsCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkInterfaceIPConfiguration +} + +type ListVirtualMachineScaleSetIPConfigurationsOperationOptions struct { + Expand *string +} + +func DefaultListVirtualMachineScaleSetIPConfigurationsOperationOptions() ListVirtualMachineScaleSetIPConfigurationsOperationOptions { + return ListVirtualMachineScaleSetIPConfigurationsOperationOptions{} +} + +func (o ListVirtualMachineScaleSetIPConfigurationsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListVirtualMachineScaleSetIPConfigurationsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListVirtualMachineScaleSetIPConfigurationsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +type ListVirtualMachineScaleSetIPConfigurationsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListVirtualMachineScaleSetIPConfigurationsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListVirtualMachineScaleSetIPConfigurations ... +func (c NetworkInterfacesClient) ListVirtualMachineScaleSetIPConfigurations(ctx context.Context, id commonids.VirtualMachineScaleSetNetworkInterfaceId, options ListVirtualMachineScaleSetIPConfigurationsOperationOptions) (result ListVirtualMachineScaleSetIPConfigurationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListVirtualMachineScaleSetIPConfigurationsCustomPager{}, + Path: fmt.Sprintf("%s/ipConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkInterfaceIPConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListVirtualMachineScaleSetIPConfigurationsComplete retrieves all the results into a single object +func (c NetworkInterfacesClient) ListVirtualMachineScaleSetIPConfigurationsComplete(ctx context.Context, id commonids.VirtualMachineScaleSetNetworkInterfaceId, options ListVirtualMachineScaleSetIPConfigurationsOperationOptions) (ListVirtualMachineScaleSetIPConfigurationsCompleteResult, error) { + return c.ListVirtualMachineScaleSetIPConfigurationsCompleteMatchingPredicate(ctx, id, options, NetworkInterfaceIPConfigurationOperationPredicate{}) +} + +// ListVirtualMachineScaleSetIPConfigurationsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkInterfacesClient) ListVirtualMachineScaleSetIPConfigurationsCompleteMatchingPredicate(ctx context.Context, id commonids.VirtualMachineScaleSetNetworkInterfaceId, options ListVirtualMachineScaleSetIPConfigurationsOperationOptions, predicate NetworkInterfaceIPConfigurationOperationPredicate) (result ListVirtualMachineScaleSetIPConfigurationsCompleteResult, err error) { + items := make([]NetworkInterfaceIPConfiguration, 0) + + resp, err := c.ListVirtualMachineScaleSetIPConfigurations(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListVirtualMachineScaleSetIPConfigurationsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_listvirtualmachinescalesetnetworkinterfaces.go b/resource-manager/network/2024-07-01/networkinterfaces/method_listvirtualmachinescalesetnetworkinterfaces.go new file mode 100644 index 00000000000..968b1c8bbd5 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_listvirtualmachinescalesetnetworkinterfaces.go @@ -0,0 +1,105 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListVirtualMachineScaleSetNetworkInterfacesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkInterface +} + +type ListVirtualMachineScaleSetNetworkInterfacesCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkInterface +} + +type ListVirtualMachineScaleSetNetworkInterfacesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListVirtualMachineScaleSetNetworkInterfacesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListVirtualMachineScaleSetNetworkInterfaces ... +func (c NetworkInterfacesClient) ListVirtualMachineScaleSetNetworkInterfaces(ctx context.Context, id VirtualMachineScaleSetId) (result ListVirtualMachineScaleSetNetworkInterfacesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListVirtualMachineScaleSetNetworkInterfacesCustomPager{}, + Path: fmt.Sprintf("%s/networkInterfaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkInterface `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListVirtualMachineScaleSetNetworkInterfacesComplete retrieves all the results into a single object +func (c NetworkInterfacesClient) ListVirtualMachineScaleSetNetworkInterfacesComplete(ctx context.Context, id VirtualMachineScaleSetId) (ListVirtualMachineScaleSetNetworkInterfacesCompleteResult, error) { + return c.ListVirtualMachineScaleSetNetworkInterfacesCompleteMatchingPredicate(ctx, id, NetworkInterfaceOperationPredicate{}) +} + +// ListVirtualMachineScaleSetNetworkInterfacesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkInterfacesClient) ListVirtualMachineScaleSetNetworkInterfacesCompleteMatchingPredicate(ctx context.Context, id VirtualMachineScaleSetId, predicate NetworkInterfaceOperationPredicate) (result ListVirtualMachineScaleSetNetworkInterfacesCompleteResult, err error) { + items := make([]NetworkInterface, 0) + + resp, err := c.ListVirtualMachineScaleSetNetworkInterfaces(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListVirtualMachineScaleSetNetworkInterfacesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_listvirtualmachinescalesetvmnetworkinterfaces.go b/resource-manager/network/2024-07-01/networkinterfaces/method_listvirtualmachinescalesetvmnetworkinterfaces.go new file mode 100644 index 00000000000..433357587d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_listvirtualmachinescalesetvmnetworkinterfaces.go @@ -0,0 +1,105 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListVirtualMachineScaleSetVMNetworkInterfacesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkInterface +} + +type ListVirtualMachineScaleSetVMNetworkInterfacesCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkInterface +} + +type ListVirtualMachineScaleSetVMNetworkInterfacesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListVirtualMachineScaleSetVMNetworkInterfacesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListVirtualMachineScaleSetVMNetworkInterfaces ... +func (c NetworkInterfacesClient) ListVirtualMachineScaleSetVMNetworkInterfaces(ctx context.Context, id VirtualMachineId) (result ListVirtualMachineScaleSetVMNetworkInterfacesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListVirtualMachineScaleSetVMNetworkInterfacesCustomPager{}, + Path: fmt.Sprintf("%s/networkInterfaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkInterface `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListVirtualMachineScaleSetVMNetworkInterfacesComplete retrieves all the results into a single object +func (c NetworkInterfacesClient) ListVirtualMachineScaleSetVMNetworkInterfacesComplete(ctx context.Context, id VirtualMachineId) (ListVirtualMachineScaleSetVMNetworkInterfacesCompleteResult, error) { + return c.ListVirtualMachineScaleSetVMNetworkInterfacesCompleteMatchingPredicate(ctx, id, NetworkInterfaceOperationPredicate{}) +} + +// ListVirtualMachineScaleSetVMNetworkInterfacesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkInterfacesClient) ListVirtualMachineScaleSetVMNetworkInterfacesCompleteMatchingPredicate(ctx context.Context, id VirtualMachineId, predicate NetworkInterfaceOperationPredicate) (result ListVirtualMachineScaleSetVMNetworkInterfacesCompleteResult, err error) { + items := make([]NetworkInterface, 0) + + resp, err := c.ListVirtualMachineScaleSetVMNetworkInterfaces(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListVirtualMachineScaleSetVMNetworkInterfacesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfaceipconfigurationsget.go b/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfaceipconfigurationsget.go new file mode 100644 index 00000000000..7134fa1ab75 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfaceipconfigurationsget.go @@ -0,0 +1,54 @@ +package networkinterfaces + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkInterfaceIPConfiguration +} + +// NetworkInterfaceIPConfigurationsGet ... +func (c NetworkInterfacesClient) NetworkInterfaceIPConfigurationsGet(ctx context.Context, id commonids.NetworkInterfaceIPConfigurationId) (result NetworkInterfaceIPConfigurationsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkInterfaceIPConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfaceipconfigurationslist.go b/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfaceipconfigurationslist.go new file mode 100644 index 00000000000..00a6c20f94c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfaceipconfigurationslist.go @@ -0,0 +1,106 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkInterfaceIPConfiguration +} + +type NetworkInterfaceIPConfigurationsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkInterfaceIPConfiguration +} + +type NetworkInterfaceIPConfigurationsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *NetworkInterfaceIPConfigurationsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// NetworkInterfaceIPConfigurationsList ... +func (c NetworkInterfacesClient) NetworkInterfaceIPConfigurationsList(ctx context.Context, id commonids.NetworkInterfaceId) (result NetworkInterfaceIPConfigurationsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &NetworkInterfaceIPConfigurationsListCustomPager{}, + Path: fmt.Sprintf("%s/ipConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkInterfaceIPConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// NetworkInterfaceIPConfigurationsListComplete retrieves all the results into a single object +func (c NetworkInterfacesClient) NetworkInterfaceIPConfigurationsListComplete(ctx context.Context, id commonids.NetworkInterfaceId) (NetworkInterfaceIPConfigurationsListCompleteResult, error) { + return c.NetworkInterfaceIPConfigurationsListCompleteMatchingPredicate(ctx, id, NetworkInterfaceIPConfigurationOperationPredicate{}) +} + +// NetworkInterfaceIPConfigurationsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkInterfacesClient) NetworkInterfaceIPConfigurationsListCompleteMatchingPredicate(ctx context.Context, id commonids.NetworkInterfaceId, predicate NetworkInterfaceIPConfigurationOperationPredicate) (result NetworkInterfaceIPConfigurationsListCompleteResult, err error) { + items := make([]NetworkInterfaceIPConfiguration, 0) + + resp, err := c.NetworkInterfaceIPConfigurationsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = NetworkInterfaceIPConfigurationsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfaceloadbalancerslist.go b/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfaceloadbalancerslist.go new file mode 100644 index 00000000000..ee4b73b4d8d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfaceloadbalancerslist.go @@ -0,0 +1,106 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceLoadBalancersListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]LoadBalancer +} + +type NetworkInterfaceLoadBalancersListCompleteResult struct { + LatestHttpResponse *http.Response + Items []LoadBalancer +} + +type NetworkInterfaceLoadBalancersListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *NetworkInterfaceLoadBalancersListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// NetworkInterfaceLoadBalancersList ... +func (c NetworkInterfacesClient) NetworkInterfaceLoadBalancersList(ctx context.Context, id commonids.NetworkInterfaceId) (result NetworkInterfaceLoadBalancersListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &NetworkInterfaceLoadBalancersListCustomPager{}, + Path: fmt.Sprintf("%s/loadBalancers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]LoadBalancer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// NetworkInterfaceLoadBalancersListComplete retrieves all the results into a single object +func (c NetworkInterfacesClient) NetworkInterfaceLoadBalancersListComplete(ctx context.Context, id commonids.NetworkInterfaceId) (NetworkInterfaceLoadBalancersListCompleteResult, error) { + return c.NetworkInterfaceLoadBalancersListCompleteMatchingPredicate(ctx, id, LoadBalancerOperationPredicate{}) +} + +// NetworkInterfaceLoadBalancersListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkInterfacesClient) NetworkInterfaceLoadBalancersListCompleteMatchingPredicate(ctx context.Context, id commonids.NetworkInterfaceId, predicate LoadBalancerOperationPredicate) (result NetworkInterfaceLoadBalancersListCompleteResult, err error) { + items := make([]LoadBalancer, 0) + + resp, err := c.NetworkInterfaceLoadBalancersList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = NetworkInterfaceLoadBalancersListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfacetapconfigurationscreateorupdate.go b/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfacetapconfigurationscreateorupdate.go new file mode 100644 index 00000000000..fcece2ea104 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfacetapconfigurationscreateorupdate.go @@ -0,0 +1,75 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NetworkInterfaceTapConfiguration +} + +// NetworkInterfaceTapConfigurationsCreateOrUpdate ... +func (c NetworkInterfacesClient) NetworkInterfaceTapConfigurationsCreateOrUpdate(ctx context.Context, id TapConfigurationId, input NetworkInterfaceTapConfiguration) (result NetworkInterfaceTapConfigurationsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// NetworkInterfaceTapConfigurationsCreateOrUpdateThenPoll performs NetworkInterfaceTapConfigurationsCreateOrUpdate then polls until it's completed +func (c NetworkInterfacesClient) NetworkInterfaceTapConfigurationsCreateOrUpdateThenPoll(ctx context.Context, id TapConfigurationId, input NetworkInterfaceTapConfiguration) error { + result, err := c.NetworkInterfaceTapConfigurationsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing NetworkInterfaceTapConfigurationsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after NetworkInterfaceTapConfigurationsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfacetapconfigurationsdelete.go b/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfacetapconfigurationsdelete.go new file mode 100644 index 00000000000..263815906b2 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfacetapconfigurationsdelete.go @@ -0,0 +1,71 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// NetworkInterfaceTapConfigurationsDelete ... +func (c NetworkInterfacesClient) NetworkInterfaceTapConfigurationsDelete(ctx context.Context, id TapConfigurationId) (result NetworkInterfaceTapConfigurationsDeleteOperationResponse, 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 +} + +// NetworkInterfaceTapConfigurationsDeleteThenPoll performs NetworkInterfaceTapConfigurationsDelete then polls until it's completed +func (c NetworkInterfacesClient) NetworkInterfaceTapConfigurationsDeleteThenPoll(ctx context.Context, id TapConfigurationId) error { + result, err := c.NetworkInterfaceTapConfigurationsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing NetworkInterfaceTapConfigurationsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after NetworkInterfaceTapConfigurationsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfacetapconfigurationsget.go b/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfacetapconfigurationsget.go new file mode 100644 index 00000000000..004d700dbcd --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfacetapconfigurationsget.go @@ -0,0 +1,53 @@ +package networkinterfaces + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkInterfaceTapConfiguration +} + +// NetworkInterfaceTapConfigurationsGet ... +func (c NetworkInterfacesClient) NetworkInterfaceTapConfigurationsGet(ctx context.Context, id TapConfigurationId) (result NetworkInterfaceTapConfigurationsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkInterfaceTapConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfacetapconfigurationslist.go b/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfacetapconfigurationslist.go new file mode 100644 index 00000000000..96b11107f62 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_networkinterfacetapconfigurationslist.go @@ -0,0 +1,106 @@ +package networkinterfaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkInterfaceTapConfiguration +} + +type NetworkInterfaceTapConfigurationsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkInterfaceTapConfiguration +} + +type NetworkInterfaceTapConfigurationsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *NetworkInterfaceTapConfigurationsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// NetworkInterfaceTapConfigurationsList ... +func (c NetworkInterfacesClient) NetworkInterfaceTapConfigurationsList(ctx context.Context, id commonids.NetworkInterfaceId) (result NetworkInterfaceTapConfigurationsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &NetworkInterfaceTapConfigurationsListCustomPager{}, + Path: fmt.Sprintf("%s/tapConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkInterfaceTapConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// NetworkInterfaceTapConfigurationsListComplete retrieves all the results into a single object +func (c NetworkInterfacesClient) NetworkInterfaceTapConfigurationsListComplete(ctx context.Context, id commonids.NetworkInterfaceId) (NetworkInterfaceTapConfigurationsListCompleteResult, error) { + return c.NetworkInterfaceTapConfigurationsListCompleteMatchingPredicate(ctx, id, NetworkInterfaceTapConfigurationOperationPredicate{}) +} + +// NetworkInterfaceTapConfigurationsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkInterfacesClient) NetworkInterfaceTapConfigurationsListCompleteMatchingPredicate(ctx context.Context, id commonids.NetworkInterfaceId, predicate NetworkInterfaceTapConfigurationOperationPredicate) (result NetworkInterfaceTapConfigurationsListCompleteResult, err error) { + items := make([]NetworkInterfaceTapConfiguration, 0) + + resp, err := c.NetworkInterfaceTapConfigurationsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = NetworkInterfaceTapConfigurationsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/method_updatetags.go b/resource-manager/network/2024-07-01/networkinterfaces/method_updatetags.go new file mode 100644 index 00000000000..4365d182729 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/method_updatetags.go @@ -0,0 +1,58 @@ +package networkinterfaces + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkInterface +} + +// UpdateTags ... +func (c NetworkInterfacesClient) UpdateTags(ctx context.Context, id commonids.NetworkInterfaceId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkInterface + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/networkinterfaces/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..126f8350b09 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/networkinterfaces/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..15c656ad057 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..34912a8fcbd --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/networkinterfaces/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..3b83d83c7c9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..dd810dfed2c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/networkinterfaces/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..2948e0c794a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..aa06b33fbe1 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_backendaddresspool.go b/resource-manager/network/2024-07-01/networkinterfaces/model_backendaddresspool.go new file mode 100644 index 00000000000..bd329cce127 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..7c5d918e43a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..e0be4a6b6f6 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_ddossettings.go b/resource-manager/network/2024-07-01/networkinterfaces/model_ddossettings.go new file mode 100644 index 00000000000..4902360d689 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_ddossettings.go @@ -0,0 +1,9 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_delegation.go b/resource-manager/network/2024-07-01/networkinterfaces/model_delegation.go new file mode 100644 index 00000000000..5fb9effbb1b --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_delegation.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_effectivenetworksecuritygroup.go b/resource-manager/network/2024-07-01/networkinterfaces/model_effectivenetworksecuritygroup.go new file mode 100644 index 00000000000..5c66ee3a9b5 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_effectivenetworksecuritygroup.go @@ -0,0 +1,11 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EffectiveNetworkSecurityGroup struct { + Association *EffectiveNetworkSecurityGroupAssociation `json:"association,omitempty"` + EffectiveSecurityRules *[]EffectiveNetworkSecurityRule `json:"effectiveSecurityRules,omitempty"` + NetworkSecurityGroup *SubResource `json:"networkSecurityGroup,omitempty"` + TagMap *map[string][]string `json:"tagMap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_effectivenetworksecuritygroupassociation.go b/resource-manager/network/2024-07-01/networkinterfaces/model_effectivenetworksecuritygroupassociation.go new file mode 100644 index 00000000000..3c6248c32c9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_effectivenetworksecuritygroupassociation.go @@ -0,0 +1,10 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EffectiveNetworkSecurityGroupAssociation struct { + NetworkInterface *SubResource `json:"networkInterface,omitempty"` + NetworkManager *SubResource `json:"networkManager,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_effectivenetworksecurityrule.go b/resource-manager/network/2024-07-01/networkinterfaces/model_effectivenetworksecurityrule.go new file mode 100644 index 00000000000..9c9dd92e515 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_effectivenetworksecurityrule.go @@ -0,0 +1,22 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EffectiveNetworkSecurityRule struct { + Access *SecurityRuleAccess `json:"access,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction *SecurityRuleDirection `json:"direction,omitempty"` + ExpandedDestinationAddressPrefix *[]string `json:"expandedDestinationAddressPrefix,omitempty"` + ExpandedSourceAddressPrefix *[]string `json:"expandedSourceAddressPrefix,omitempty"` + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + Protocol *EffectiveSecurityRuleProtocol `json:"protocol,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_effectiveroute.go b/resource-manager/network/2024-07-01/networkinterfaces/model_effectiveroute.go new file mode 100644 index 00000000000..aa9dac67810 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_effectiveroute.go @@ -0,0 +1,14 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EffectiveRoute struct { + AddressPrefix *[]string `json:"addressPrefix,omitempty"` + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + Name *string `json:"name,omitempty"` + NextHopIPAddress *[]string `json:"nextHopIpAddress,omitempty"` + NextHopType *RouteNextHopType `json:"nextHopType,omitempty"` + Source *EffectiveRouteSource `json:"source,omitempty"` + State *EffectiveRouteState `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_flowlog.go b/resource-manager/network/2024-07-01/networkinterfaces/model_flowlog.go new file mode 100644 index 00000000000..6c8ab9073ec --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_flowlog.go @@ -0,0 +1,19 @@ +package networkinterfaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/networkinterfaces/model_flowlogformatparameters.go new file mode 100644 index 00000000000..43abd6c1532 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..d59ce6dc4b6 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/networkinterfaces/model_frontendipconfiguration.go new file mode 100644 index 00000000000..35c07477d52 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package networkinterfaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..174b1d44662 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/networkinterfaces/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..8562c4824fb --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_inboundnatpool.go b/resource-manager/network/2024-07-01/networkinterfaces/model_inboundnatpool.go new file mode 100644 index 00000000000..a16659ffff0 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_inboundnatpool.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_inboundnatpoolpropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_inboundnatpoolpropertiesformat.go new file mode 100644 index 00000000000..4586e6ec1dc --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_inboundnatpoolpropertiesformat.go @@ -0,0 +1,16 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatPoolPropertiesFormat struct { + BackendPort int64 `json:"backendPort"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPortRangeEnd int64 `json:"frontendPortRangeEnd"` + FrontendPortRangeStart int64 `json:"frontendPortRangeStart"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol TransportProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_inboundnatrule.go b/resource-manager/network/2024-07-01/networkinterfaces/model_inboundnatrule.go new file mode 100644 index 00000000000..a41993b3c8d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..9a882cfef22 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/networkinterfaces/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..e64e4b7508e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/networkinterfaces/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..c5e6dabe88a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_ipconfiguration.go b/resource-manager/network/2024-07-01/networkinterfaces/model_ipconfiguration.go new file mode 100644 index 00000000000..c1294125f57 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/networkinterfaces/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..b5f591fbc35 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..0027cc6adbe --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..1338f55c4e1 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_iptag.go b/resource-manager/network/2024-07-01/networkinterfaces/model_iptag.go new file mode 100644 index 00000000000..c2dc282ad0e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_iptag.go @@ -0,0 +1,9 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancer.go b/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancer.go new file mode 100644 index 00000000000..aaa7bd9d086 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancer.go @@ -0,0 +1,20 @@ +package networkinterfaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancer struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *LoadBalancerPropertiesFormat `json:"properties,omitempty"` + Sku *LoadBalancerSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..58da623122f --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..192b497dd13 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancerpropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancerpropertiesformat.go new file mode 100644 index 00000000000..b0c27be8bab --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancerpropertiesformat.go @@ -0,0 +1,16 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerPropertiesFormat struct { + BackendAddressPools *[]BackendAddressPool `json:"backendAddressPools,omitempty"` + FrontendIPConfigurations *[]FrontendIPConfiguration `json:"frontendIPConfigurations,omitempty"` + InboundNatPools *[]InboundNatPool `json:"inboundNatPools,omitempty"` + InboundNatRules *[]InboundNatRule `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]LoadBalancingRule `json:"loadBalancingRules,omitempty"` + OutboundRules *[]OutboundRule `json:"outboundRules,omitempty"` + Probes *[]Probe `json:"probes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancersku.go b/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancersku.go new file mode 100644 index 00000000000..e10cf68701b --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancersku.go @@ -0,0 +1,9 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerSku struct { + Name *LoadBalancerSkuName `json:"name,omitempty"` + Tier *LoadBalancerSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancingrule.go b/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancingrule.go new file mode 100644 index 00000000000..5ca9aca81f1 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancingrule.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancingRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *LoadBalancingRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancingrulepropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancingrulepropertiesformat.go new file mode 100644 index 00000000000..79f7be39f65 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_loadbalancingrulepropertiesformat.go @@ -0,0 +1,21 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancingRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendAddressPools *[]SubResource `json:"backendAddressPools,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + DisableOutboundSnat *bool `json:"disableOutboundSnat,omitempty"` + EnableConnectionTracking *bool `json:"enableConnectionTracking,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort int64 `json:"frontendPort"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LoadDistribution *LoadDistribution `json:"loadDistribution,omitempty"` + Probe *SubResource `json:"probe,omitempty"` + Protocol TransportProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_natgateway.go b/resource-manager/network/2024-07-01/networkinterfaces/model_natgateway.go new file mode 100644 index 00000000000..7fe571d7a74 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_natgateway.go @@ -0,0 +1,20 @@ +package networkinterfaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..e11b1486336 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_natgatewaysku.go b/resource-manager/network/2024-07-01/networkinterfaces/model_natgatewaysku.go new file mode 100644 index 00000000000..aff4514b5e7 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_natruleportmapping.go b/resource-manager/network/2024-07-01/networkinterfaces/model_natruleportmapping.go new file mode 100644 index 00000000000..05068ac7e2f --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterface.go b/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterface.go new file mode 100644 index 00000000000..286c9562aaf --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterface.go @@ -0,0 +1,19 @@ +package networkinterfaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..af3e4e75519 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..ca861570a5d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..abcc6fdfc5b --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..86aea8f6e8e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..136be7c56ae --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..e67a81616a9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..72010ae8dac --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/networkinterfaces/model_networksecuritygroup.go new file mode 100644 index 00000000000..05ed91fcd1a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..ce8a013b83a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_outboundrule.go b/resource-manager/network/2024-07-01/networkinterfaces/model_outboundrule.go new file mode 100644 index 00000000000..2afc56da4cc --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_outboundrule.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *OutboundRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_outboundrulepropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_outboundrulepropertiesformat.go new file mode 100644 index 00000000000..4cc4e2f5087 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_outboundrulepropertiesformat.go @@ -0,0 +1,14 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundRulePropertiesFormat struct { + AllocatedOutboundPorts *int64 `json:"allocatedOutboundPorts,omitempty"` + BackendAddressPool SubResource `json:"backendAddressPool"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfigurations []SubResource `json:"frontendIPConfigurations"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol LoadBalancerOutboundRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpoint.go b/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpoint.go new file mode 100644 index 00000000000..da5835bccba --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpoint.go @@ -0,0 +1,19 @@ +package networkinterfaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpointconnection.go new file mode 100644 index 00000000000..81a07962195 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..eb2204732ec --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..085039e25e2 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..802747eb32e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpointproperties.go new file mode 100644 index 00000000000..ea496b7d032 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkservice.go b/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkservice.go new file mode 100644 index 00000000000..7dcd5f985b9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package networkinterfaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..5e32cbfab8a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..355c3d254f2 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..367b48d2fd6 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..3893fd72b02 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..e1c0b0da64c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..d17376760a6 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_probe.go b/resource-manager/network/2024-07-01/networkinterfaces/model_probe.go new file mode 100644 index 00000000000..d935d63eee6 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_probe.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Probe struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProbePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_probepropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_probepropertiesformat.go new file mode 100644 index 00000000000..6c1f4d34dc8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_probepropertiesformat.go @@ -0,0 +1,16 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProbePropertiesFormat struct { + IntervalInSeconds *int64 `json:"intervalInSeconds,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + NoHealthyBackendsBehavior *ProbeNoHealthyBackendsBehavior `json:"noHealthyBackendsBehavior,omitempty"` + NumberOfProbes *int64 `json:"numberOfProbes,omitempty"` + Port int64 `json:"port"` + ProbeThreshold *int64 `json:"probeThreshold,omitempty"` + Protocol ProbeProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestPath *string `json:"requestPath,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_publicipaddress.go b/resource-manager/network/2024-07-01/networkinterfaces/model_publicipaddress.go new file mode 100644 index 00000000000..e89fe49804b --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_publicipaddress.go @@ -0,0 +1,22 @@ +package networkinterfaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/networkinterfaces/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..9a6ffc1106a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..b13efec6d42 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/networkinterfaces/model_publicipaddresssku.go new file mode 100644 index 00000000000..4f6513789bc --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/networkinterfaces/model_resourcenavigationlink.go new file mode 100644 index 00000000000..4a3f135d98d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..aa59d57de52 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_resourceset.go b/resource-manager/network/2024-07-01/networkinterfaces/model_resourceset.go new file mode 100644 index 00000000000..48356d239d8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_resourceset.go @@ -0,0 +1,8 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/networkinterfaces/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..fe69c5c3389 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_route.go b/resource-manager/network/2024-07-01/networkinterfaces/model_route.go new file mode 100644 index 00000000000..8dd1c1c5cbe --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_route.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_routepropertiesformat.go new file mode 100644 index 00000000000..b031c9a871e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_routetable.go b/resource-manager/network/2024-07-01/networkinterfaces/model_routetable.go new file mode 100644 index 00000000000..31df96e7b73 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_routetable.go @@ -0,0 +1,14 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..3c524eb8fe1 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_securityrule.go b/resource-manager/network/2024-07-01/networkinterfaces/model_securityrule.go new file mode 100644 index 00000000000..af9210ebc2f --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_securityrule.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..0ff4ba975dc --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/networkinterfaces/model_serviceassociationlink.go new file mode 100644 index 00000000000..88ebd302e70 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..538945df5d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..8444d0d495d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/networkinterfaces/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..c77c2e3460a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/networkinterfaces/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..6f523978f5b --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..ddd9db6fe47 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..2692b80393d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..f7a4a8f30f4 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_subnet.go b/resource-manager/network/2024-07-01/networkinterfaces/model_subnet.go new file mode 100644 index 00000000000..47a0e306b4a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_subnet.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..c9496598727 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_subresource.go b/resource-manager/network/2024-07-01/networkinterfaces/model_subresource.go new file mode 100644 index 00000000000..28fa931dbee --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_subresource.go @@ -0,0 +1,8 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_tagsobject.go b/resource-manager/network/2024-07-01/networkinterfaces/model_tagsobject.go new file mode 100644 index 00000000000..32bf2f0b066 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_tagsobject.go @@ -0,0 +1,8 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/networkinterfaces/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..bd0b0fa5fe0 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/networkinterfaces/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..302f5bfcc4d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/networkinterfaces/model_virtualnetworktap.go new file mode 100644 index 00000000000..315bcaef069 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/networkinterfaces/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..90ce2721f15 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/predicates.go b/resource-manager/network/2024-07-01/networkinterfaces/predicates.go new file mode 100644 index 00000000000..c58ed4a328b --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/predicates.go @@ -0,0 +1,152 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EffectiveNetworkSecurityGroupOperationPredicate struct { +} + +func (p EffectiveNetworkSecurityGroupOperationPredicate) Matches(input EffectiveNetworkSecurityGroup) bool { + + return true +} + +type EffectiveRouteOperationPredicate struct { + DisableBgpRoutePropagation *bool + Name *string +} + +func (p EffectiveRouteOperationPredicate) Matches(input EffectiveRoute) bool { + + if p.DisableBgpRoutePropagation != nil && (input.DisableBgpRoutePropagation == nil || *p.DisableBgpRoutePropagation != *input.DisableBgpRoutePropagation) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + return true +} + +type LoadBalancerOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p LoadBalancerOperationPredicate) Matches(input LoadBalancer) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type NetworkInterfaceOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p NetworkInterfaceOperationPredicate) Matches(input NetworkInterface) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type NetworkInterfaceIPConfigurationOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p NetworkInterfaceIPConfigurationOperationPredicate) Matches(input NetworkInterfaceIPConfiguration) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type NetworkInterfaceTapConfigurationOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p NetworkInterfaceTapConfigurationOperationPredicate) Matches(input NetworkInterfaceTapConfiguration) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/networkinterfaces/version.go b/resource-manager/network/2024-07-01/networkinterfaces/version.go new file mode 100644 index 00000000000..e631a40c1ad --- /dev/null +++ b/resource-manager/network/2024-07-01/networkinterfaces/version.go @@ -0,0 +1,10 @@ +package networkinterfaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networkinterfaces/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/README.md b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/README.md new file mode 100644 index 00000000000..d2274bd45d4 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanageractiveconfigurations` Documentation + +The `networkmanageractiveconfigurations` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanageractiveconfigurations" +``` + + +### Client Initialization + +```go +client := networkmanageractiveconfigurations.NewNetworkManagerActiveConfigurationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkManagerActiveConfigurationsClient.ListActiveSecurityAdminRules` + +```go +ctx := context.TODO() +id := networkmanageractiveconfigurations.NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + +payload := networkmanageractiveconfigurations.ActiveConfigurationParameter{ + // ... +} + + +read, err := client.ListActiveSecurityAdminRules(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/client.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/client.go new file mode 100644 index 00000000000..cc689379d3c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/client.go @@ -0,0 +1,26 @@ +package networkmanageractiveconfigurations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerActiveConfigurationsClient struct { + Client *resourcemanager.Client +} + +func NewNetworkManagerActiveConfigurationsClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkManagerActiveConfigurationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networkmanageractiveconfigurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkManagerActiveConfigurationsClient: %+v", err) + } + + return &NetworkManagerActiveConfigurationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/constants.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/constants.go new file mode 100644 index 00000000000..793caeabedc --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/constants.go @@ -0,0 +1,327 @@ +package networkmanageractiveconfigurations + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressPrefixType string + +const ( + AddressPrefixTypeIPPrefix AddressPrefixType = "IPPrefix" + AddressPrefixTypeNetworkGroup AddressPrefixType = "NetworkGroup" + AddressPrefixTypeServiceTag AddressPrefixType = "ServiceTag" +) + +func PossibleValuesForAddressPrefixType() []string { + return []string{ + string(AddressPrefixTypeIPPrefix), + string(AddressPrefixTypeNetworkGroup), + string(AddressPrefixTypeServiceTag), + } +} + +func (s *AddressPrefixType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAddressPrefixType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAddressPrefixType(input string) (*AddressPrefixType, error) { + vals := map[string]AddressPrefixType{ + "ipprefix": AddressPrefixTypeIPPrefix, + "networkgroup": AddressPrefixTypeNetworkGroup, + "servicetag": AddressPrefixTypeServiceTag, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AddressPrefixType(input) + return &out, nil +} + +type EffectiveAdminRuleKind string + +const ( + EffectiveAdminRuleKindCustom EffectiveAdminRuleKind = "Custom" + EffectiveAdminRuleKindDefault EffectiveAdminRuleKind = "Default" +) + +func PossibleValuesForEffectiveAdminRuleKind() []string { + return []string{ + string(EffectiveAdminRuleKindCustom), + string(EffectiveAdminRuleKindDefault), + } +} + +func (s *EffectiveAdminRuleKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEffectiveAdminRuleKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEffectiveAdminRuleKind(input string) (*EffectiveAdminRuleKind, error) { + vals := map[string]EffectiveAdminRuleKind{ + "custom": EffectiveAdminRuleKindCustom, + "default": EffectiveAdminRuleKindDefault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EffectiveAdminRuleKind(input) + return &out, nil +} + +type GroupMemberType string + +const ( + GroupMemberTypeSubnet GroupMemberType = "Subnet" + GroupMemberTypeVirtualNetwork GroupMemberType = "VirtualNetwork" +) + +func PossibleValuesForGroupMemberType() []string { + return []string{ + string(GroupMemberTypeSubnet), + string(GroupMemberTypeVirtualNetwork), + } +} + +func (s *GroupMemberType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupMemberType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGroupMemberType(input string) (*GroupMemberType, error) { + vals := map[string]GroupMemberType{ + "subnet": GroupMemberTypeSubnet, + "virtualnetwork": GroupMemberTypeVirtualNetwork, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GroupMemberType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SecurityConfigurationRuleAccess string + +const ( + SecurityConfigurationRuleAccessAllow SecurityConfigurationRuleAccess = "Allow" + SecurityConfigurationRuleAccessAlwaysAllow SecurityConfigurationRuleAccess = "AlwaysAllow" + SecurityConfigurationRuleAccessDeny SecurityConfigurationRuleAccess = "Deny" +) + +func PossibleValuesForSecurityConfigurationRuleAccess() []string { + return []string{ + string(SecurityConfigurationRuleAccessAllow), + string(SecurityConfigurationRuleAccessAlwaysAllow), + string(SecurityConfigurationRuleAccessDeny), + } +} + +func (s *SecurityConfigurationRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityConfigurationRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityConfigurationRuleAccess(input string) (*SecurityConfigurationRuleAccess, error) { + vals := map[string]SecurityConfigurationRuleAccess{ + "allow": SecurityConfigurationRuleAccessAllow, + "alwaysallow": SecurityConfigurationRuleAccessAlwaysAllow, + "deny": SecurityConfigurationRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityConfigurationRuleAccess(input) + return &out, nil +} + +type SecurityConfigurationRuleDirection string + +const ( + SecurityConfigurationRuleDirectionInbound SecurityConfigurationRuleDirection = "Inbound" + SecurityConfigurationRuleDirectionOutbound SecurityConfigurationRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityConfigurationRuleDirection() []string { + return []string{ + string(SecurityConfigurationRuleDirectionInbound), + string(SecurityConfigurationRuleDirectionOutbound), + } +} + +func (s *SecurityConfigurationRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityConfigurationRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityConfigurationRuleDirection(input string) (*SecurityConfigurationRuleDirection, error) { + vals := map[string]SecurityConfigurationRuleDirection{ + "inbound": SecurityConfigurationRuleDirectionInbound, + "outbound": SecurityConfigurationRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityConfigurationRuleDirection(input) + return &out, nil +} + +type SecurityConfigurationRuleProtocol string + +const ( + SecurityConfigurationRuleProtocolAh SecurityConfigurationRuleProtocol = "Ah" + SecurityConfigurationRuleProtocolAny SecurityConfigurationRuleProtocol = "Any" + SecurityConfigurationRuleProtocolEsp SecurityConfigurationRuleProtocol = "Esp" + SecurityConfigurationRuleProtocolIcmp SecurityConfigurationRuleProtocol = "Icmp" + SecurityConfigurationRuleProtocolTcp SecurityConfigurationRuleProtocol = "Tcp" + SecurityConfigurationRuleProtocolUdp SecurityConfigurationRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityConfigurationRuleProtocol() []string { + return []string{ + string(SecurityConfigurationRuleProtocolAh), + string(SecurityConfigurationRuleProtocolAny), + string(SecurityConfigurationRuleProtocolEsp), + string(SecurityConfigurationRuleProtocolIcmp), + string(SecurityConfigurationRuleProtocolTcp), + string(SecurityConfigurationRuleProtocolUdp), + } +} + +func (s *SecurityConfigurationRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityConfigurationRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityConfigurationRuleProtocol(input string) (*SecurityConfigurationRuleProtocol, error) { + vals := map[string]SecurityConfigurationRuleProtocol{ + "ah": SecurityConfigurationRuleProtocolAh, + "any": SecurityConfigurationRuleProtocolAny, + "esp": SecurityConfigurationRuleProtocolEsp, + "icmp": SecurityConfigurationRuleProtocolIcmp, + "tcp": SecurityConfigurationRuleProtocolTcp, + "udp": SecurityConfigurationRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityConfigurationRuleProtocol(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/id_networkmanager.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/id_networkmanager.go new file mode 100644 index 00000000000..f7d149a7e3c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/id_networkmanager.go @@ -0,0 +1,130 @@ +package networkmanageractiveconfigurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkManagerId{}) +} + +var _ resourceids.ResourceId = &NetworkManagerId{} + +// NetworkManagerId is a struct representing the Resource ID for a Network Manager +type NetworkManagerId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string +} + +// NewNetworkManagerID returns a new NetworkManagerId struct +func NewNetworkManagerID(subscriptionId string, resourceGroupName string, networkManagerName string) NetworkManagerId { + return NetworkManagerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + } +} + +// ParseNetworkManagerID parses 'input' into a NetworkManagerId +func ParseNetworkManagerID(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkManagerIDInsensitively parses 'input' case-insensitively into a NetworkManagerId +// note: this method should only be used for API response data and not user input +func ParseNetworkManagerIDInsensitively(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkManagerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + return nil +} + +// ValidateNetworkManagerID checks that 'input' can be parsed as a Network Manager ID +func ValidateNetworkManagerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkManagerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Manager ID +func (id NetworkManagerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Manager ID +func (id NetworkManagerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + } +} + +// String returns a human-readable description of this Network Manager ID +func (id NetworkManagerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + } + return fmt.Sprintf("Network Manager (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/id_networkmanager_test.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/id_networkmanager_test.go new file mode 100644 index 00000000000..af59eb306ac --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/id_networkmanager_test.go @@ -0,0 +1,282 @@ +package networkmanageractiveconfigurations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkManagerId{} + +func TestNewNetworkManagerID(t *testing.T) { + id := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } +} + +func TestFormatNetworkManagerID(t *testing.T) { + actual := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkManagerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestParseNetworkManagerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestSegmentsForNetworkManagerId(t *testing.T) { + segments := NetworkManagerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkManagerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/method_listactivesecurityadminrules.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/method_listactivesecurityadminrules.go new file mode 100644 index 00000000000..a9250ed79d9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/method_listactivesecurityadminrules.go @@ -0,0 +1,58 @@ +package networkmanageractiveconfigurations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListActiveSecurityAdminRulesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ActiveSecurityAdminRulesListResult +} + +// ListActiveSecurityAdminRules ... +func (c NetworkManagerActiveConfigurationsClient) ListActiveSecurityAdminRules(ctx context.Context, id NetworkManagerId, input ActiveConfigurationParameter) (result ListActiveSecurityAdminRulesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listActiveSecurityAdminRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ActiveSecurityAdminRulesListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_activebasesecurityadminrule.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_activebasesecurityadminrule.go new file mode 100644 index 00000000000..22920240b7d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_activebasesecurityadminrule.go @@ -0,0 +1,90 @@ +package networkmanageractiveconfigurations + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActiveBaseSecurityAdminRule interface { + ActiveBaseSecurityAdminRule() BaseActiveBaseSecurityAdminRuleImpl +} + +var _ ActiveBaseSecurityAdminRule = BaseActiveBaseSecurityAdminRuleImpl{} + +type BaseActiveBaseSecurityAdminRuleImpl struct { + CommitTime *string `json:"commitTime,omitempty"` + ConfigurationDescription *string `json:"configurationDescription,omitempty"` + Id *string `json:"id,omitempty"` + Kind EffectiveAdminRuleKind `json:"kind"` + Region *string `json:"region,omitempty"` + RuleCollectionAppliesToGroups *[]NetworkManagerSecurityGroupItem `json:"ruleCollectionAppliesToGroups,omitempty"` + RuleCollectionDescription *string `json:"ruleCollectionDescription,omitempty"` + RuleGroups *[]ConfigurationGroup `json:"ruleGroups,omitempty"` +} + +func (s BaseActiveBaseSecurityAdminRuleImpl) ActiveBaseSecurityAdminRule() BaseActiveBaseSecurityAdminRuleImpl { + return s +} + +var _ ActiveBaseSecurityAdminRule = RawActiveBaseSecurityAdminRuleImpl{} + +// RawActiveBaseSecurityAdminRuleImpl 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 RawActiveBaseSecurityAdminRuleImpl struct { + activeBaseSecurityAdminRule BaseActiveBaseSecurityAdminRuleImpl + Type string + Values map[string]interface{} +} + +func (s RawActiveBaseSecurityAdminRuleImpl) ActiveBaseSecurityAdminRule() BaseActiveBaseSecurityAdminRuleImpl { + return s.activeBaseSecurityAdminRule +} + +func UnmarshalActiveBaseSecurityAdminRuleImplementation(input []byte) (ActiveBaseSecurityAdminRule, 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 ActiveBaseSecurityAdminRule into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["kind"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Default") { + var out ActiveDefaultSecurityAdminRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ActiveDefaultSecurityAdminRule: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Custom") { + var out ActiveSecurityAdminRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ActiveSecurityAdminRule: %+v", err) + } + return out, nil + } + + var parent BaseActiveBaseSecurityAdminRuleImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseActiveBaseSecurityAdminRuleImpl: %+v", err) + } + + return RawActiveBaseSecurityAdminRuleImpl{ + activeBaseSecurityAdminRule: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_activeconfigurationparameter.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_activeconfigurationparameter.go new file mode 100644 index 00000000000..309a4998c1b --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_activeconfigurationparameter.go @@ -0,0 +1,9 @@ +package networkmanageractiveconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActiveConfigurationParameter struct { + Regions *[]string `json:"regions,omitempty"` + SkipToken *string `json:"skipToken,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_activedefaultsecurityadminrule.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_activedefaultsecurityadminrule.go new file mode 100644 index 00000000000..e708927c42d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_activedefaultsecurityadminrule.go @@ -0,0 +1,79 @@ +package networkmanageractiveconfigurations + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ActiveBaseSecurityAdminRule = ActiveDefaultSecurityAdminRule{} + +type ActiveDefaultSecurityAdminRule struct { + Properties *DefaultAdminPropertiesFormat `json:"properties,omitempty"` + + // Fields inherited from ActiveBaseSecurityAdminRule + + CommitTime *string `json:"commitTime,omitempty"` + ConfigurationDescription *string `json:"configurationDescription,omitempty"` + Id *string `json:"id,omitempty"` + Kind EffectiveAdminRuleKind `json:"kind"` + Region *string `json:"region,omitempty"` + RuleCollectionAppliesToGroups *[]NetworkManagerSecurityGroupItem `json:"ruleCollectionAppliesToGroups,omitempty"` + RuleCollectionDescription *string `json:"ruleCollectionDescription,omitempty"` + RuleGroups *[]ConfigurationGroup `json:"ruleGroups,omitempty"` +} + +func (s ActiveDefaultSecurityAdminRule) ActiveBaseSecurityAdminRule() BaseActiveBaseSecurityAdminRuleImpl { + return BaseActiveBaseSecurityAdminRuleImpl{ + CommitTime: s.CommitTime, + ConfigurationDescription: s.ConfigurationDescription, + Id: s.Id, + Kind: s.Kind, + Region: s.Region, + RuleCollectionAppliesToGroups: s.RuleCollectionAppliesToGroups, + RuleCollectionDescription: s.RuleCollectionDescription, + RuleGroups: s.RuleGroups, + } +} + +func (o *ActiveDefaultSecurityAdminRule) GetCommitTimeAsTime() (*time.Time, error) { + if o.CommitTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CommitTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ActiveDefaultSecurityAdminRule) SetCommitTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CommitTime = &formatted +} + +var _ json.Marshaler = ActiveDefaultSecurityAdminRule{} + +func (s ActiveDefaultSecurityAdminRule) MarshalJSON() ([]byte, error) { + type wrapper ActiveDefaultSecurityAdminRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ActiveDefaultSecurityAdminRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ActiveDefaultSecurityAdminRule: %+v", err) + } + + decoded["kind"] = "Default" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ActiveDefaultSecurityAdminRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_activesecurityadminrule.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_activesecurityadminrule.go new file mode 100644 index 00000000000..18ae717f1d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_activesecurityadminrule.go @@ -0,0 +1,79 @@ +package networkmanageractiveconfigurations + +import ( + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ActiveBaseSecurityAdminRule = ActiveSecurityAdminRule{} + +type ActiveSecurityAdminRule struct { + Properties *AdminPropertiesFormat `json:"properties,omitempty"` + + // Fields inherited from ActiveBaseSecurityAdminRule + + CommitTime *string `json:"commitTime,omitempty"` + ConfigurationDescription *string `json:"configurationDescription,omitempty"` + Id *string `json:"id,omitempty"` + Kind EffectiveAdminRuleKind `json:"kind"` + Region *string `json:"region,omitempty"` + RuleCollectionAppliesToGroups *[]NetworkManagerSecurityGroupItem `json:"ruleCollectionAppliesToGroups,omitempty"` + RuleCollectionDescription *string `json:"ruleCollectionDescription,omitempty"` + RuleGroups *[]ConfigurationGroup `json:"ruleGroups,omitempty"` +} + +func (s ActiveSecurityAdminRule) ActiveBaseSecurityAdminRule() BaseActiveBaseSecurityAdminRuleImpl { + return BaseActiveBaseSecurityAdminRuleImpl{ + CommitTime: s.CommitTime, + ConfigurationDescription: s.ConfigurationDescription, + Id: s.Id, + Kind: s.Kind, + Region: s.Region, + RuleCollectionAppliesToGroups: s.RuleCollectionAppliesToGroups, + RuleCollectionDescription: s.RuleCollectionDescription, + RuleGroups: s.RuleGroups, + } +} + +func (o *ActiveSecurityAdminRule) GetCommitTimeAsTime() (*time.Time, error) { + if o.CommitTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CommitTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ActiveSecurityAdminRule) SetCommitTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CommitTime = &formatted +} + +var _ json.Marshaler = ActiveSecurityAdminRule{} + +func (s ActiveSecurityAdminRule) MarshalJSON() ([]byte, error) { + type wrapper ActiveSecurityAdminRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ActiveSecurityAdminRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ActiveSecurityAdminRule: %+v", err) + } + + decoded["kind"] = "Custom" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ActiveSecurityAdminRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_activesecurityadminruleslistresult.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_activesecurityadminruleslistresult.go new file mode 100644 index 00000000000..e4419320e24 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_activesecurityadminruleslistresult.go @@ -0,0 +1,51 @@ +package networkmanageractiveconfigurations + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActiveSecurityAdminRulesListResult struct { + SkipToken *string `json:"skipToken,omitempty"` + Value *[]ActiveBaseSecurityAdminRule `json:"value,omitempty"` +} + +var _ json.Unmarshaler = &ActiveSecurityAdminRulesListResult{} + +func (s *ActiveSecurityAdminRulesListResult) UnmarshalJSON(bytes []byte) error { + var decoded struct { + SkipToken *string `json:"skipToken,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.SkipToken = decoded.SkipToken + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ActiveSecurityAdminRulesListResult into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["value"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling Value into list []json.RawMessage: %+v", err) + } + + output := make([]ActiveBaseSecurityAdminRule, 0) + for i, val := range listTemp { + impl, err := UnmarshalActiveBaseSecurityAdminRuleImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'Value' for 'ActiveSecurityAdminRulesListResult': %+v", i, err) + } + output = append(output, impl) + } + s.Value = &output + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_addressprefixitem.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_addressprefixitem.go new file mode 100644 index 00000000000..f82ae16f590 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_addressprefixitem.go @@ -0,0 +1,9 @@ +package networkmanageractiveconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressPrefixItem struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixType *AddressPrefixType `json:"addressPrefixType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_adminpropertiesformat.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_adminpropertiesformat.go new file mode 100644 index 00000000000..afc108f8ff4 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_adminpropertiesformat.go @@ -0,0 +1,18 @@ +package networkmanageractiveconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdminPropertiesFormat struct { + Access SecurityConfigurationRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Destinations *[]AddressPrefixItem `json:"destinations,omitempty"` + Direction SecurityConfigurationRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityConfigurationRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` + Sources *[]AddressPrefixItem `json:"sources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_configurationgroup.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_configurationgroup.go new file mode 100644 index 00000000000..be051a18f2d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_configurationgroup.go @@ -0,0 +1,9 @@ +package networkmanageractiveconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigurationGroup struct { + Id *string `json:"id,omitempty"` + Properties *NetworkGroupProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_defaultadminpropertiesformat.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_defaultadminpropertiesformat.go new file mode 100644 index 00000000000..665a643ae5e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_defaultadminpropertiesformat.go @@ -0,0 +1,19 @@ +package networkmanageractiveconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DefaultAdminPropertiesFormat struct { + Access *SecurityConfigurationRuleAccess `json:"access,omitempty"` + Description *string `json:"description,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Destinations *[]AddressPrefixItem `json:"destinations,omitempty"` + Direction *SecurityConfigurationRuleDirection `json:"direction,omitempty"` + Flag *string `json:"flag,omitempty"` + Priority *int64 `json:"priority,omitempty"` + Protocol *SecurityConfigurationRuleProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` + Sources *[]AddressPrefixItem `json:"sources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_networkgroupproperties.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_networkgroupproperties.go new file mode 100644 index 00000000000..0866d4d439a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_networkgroupproperties.go @@ -0,0 +1,11 @@ +package networkmanageractiveconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkGroupProperties struct { + Description *string `json:"description,omitempty"` + MemberType *GroupMemberType `json:"memberType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_networkmanagersecuritygroupitem.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_networkmanagersecuritygroupitem.go new file mode 100644 index 00000000000..6457c3d0001 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/model_networkmanagersecuritygroupitem.go @@ -0,0 +1,8 @@ +package networkmanageractiveconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerSecurityGroupItem struct { + NetworkGroupId string `json:"networkGroupId"` +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/version.go b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/version.go new file mode 100644 index 00000000000..81c6d3851ad --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconfigurations/version.go @@ -0,0 +1,10 @@ +package networkmanageractiveconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networkmanageractiveconfigurations/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/README.md b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/README.md new file mode 100644 index 00000000000..64574adeb6b --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations` Documentation + +The `networkmanageractiveconnectivityconfigurations` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations" +``` + + +### Client Initialization + +```go +client := networkmanageractiveconnectivityconfigurations.NewNetworkManagerActiveConnectivityConfigurationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkManagerActiveConnectivityConfigurationsClient.ListActiveConnectivityConfigurations` + +```go +ctx := context.TODO() +id := networkmanageractiveconnectivityconfigurations.NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + +payload := networkmanageractiveconnectivityconfigurations.ActiveConfigurationParameter{ + // ... +} + + +read, err := client.ListActiveConnectivityConfigurations(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/client.go b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/client.go new file mode 100644 index 00000000000..68760af7c25 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/client.go @@ -0,0 +1,26 @@ +package networkmanageractiveconnectivityconfigurations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerActiveConnectivityConfigurationsClient struct { + Client *resourcemanager.Client +} + +func NewNetworkManagerActiveConnectivityConfigurationsClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkManagerActiveConnectivityConfigurationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networkmanageractiveconnectivityconfigurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkManagerActiveConnectivityConfigurationsClient: %+v", err) + } + + return &NetworkManagerActiveConnectivityConfigurationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/constants.go b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/constants.go new file mode 100644 index 00000000000..451770f8cbb --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/constants.go @@ -0,0 +1,432 @@ +package networkmanageractiveconnectivityconfigurations + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectedGroupAddressOverlap string + +const ( + ConnectedGroupAddressOverlapAllowed ConnectedGroupAddressOverlap = "Allowed" + ConnectedGroupAddressOverlapDisallowed ConnectedGroupAddressOverlap = "Disallowed" +) + +func PossibleValuesForConnectedGroupAddressOverlap() []string { + return []string{ + string(ConnectedGroupAddressOverlapAllowed), + string(ConnectedGroupAddressOverlapDisallowed), + } +} + +func (s *ConnectedGroupAddressOverlap) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectedGroupAddressOverlap(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectedGroupAddressOverlap(input string) (*ConnectedGroupAddressOverlap, error) { + vals := map[string]ConnectedGroupAddressOverlap{ + "allowed": ConnectedGroupAddressOverlapAllowed, + "disallowed": ConnectedGroupAddressOverlapDisallowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectedGroupAddressOverlap(input) + return &out, nil +} + +type ConnectedGroupPrivateEndpointsScale string + +const ( + ConnectedGroupPrivateEndpointsScaleHighScale ConnectedGroupPrivateEndpointsScale = "HighScale" + ConnectedGroupPrivateEndpointsScaleStandard ConnectedGroupPrivateEndpointsScale = "Standard" +) + +func PossibleValuesForConnectedGroupPrivateEndpointsScale() []string { + return []string{ + string(ConnectedGroupPrivateEndpointsScaleHighScale), + string(ConnectedGroupPrivateEndpointsScaleStandard), + } +} + +func (s *ConnectedGroupPrivateEndpointsScale) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectedGroupPrivateEndpointsScale(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectedGroupPrivateEndpointsScale(input string) (*ConnectedGroupPrivateEndpointsScale, error) { + vals := map[string]ConnectedGroupPrivateEndpointsScale{ + "highscale": ConnectedGroupPrivateEndpointsScaleHighScale, + "standard": ConnectedGroupPrivateEndpointsScaleStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectedGroupPrivateEndpointsScale(input) + return &out, nil +} + +type ConnectivityTopology string + +const ( + ConnectivityTopologyHubAndSpoke ConnectivityTopology = "HubAndSpoke" + ConnectivityTopologyMesh ConnectivityTopology = "Mesh" +) + +func PossibleValuesForConnectivityTopology() []string { + return []string{ + string(ConnectivityTopologyHubAndSpoke), + string(ConnectivityTopologyMesh), + } +} + +func (s *ConnectivityTopology) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectivityTopology(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectivityTopology(input string) (*ConnectivityTopology, error) { + vals := map[string]ConnectivityTopology{ + "hubandspoke": ConnectivityTopologyHubAndSpoke, + "mesh": ConnectivityTopologyMesh, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectivityTopology(input) + return &out, nil +} + +type DeleteExistingPeering string + +const ( + DeleteExistingPeeringFalse DeleteExistingPeering = "False" + DeleteExistingPeeringTrue DeleteExistingPeering = "True" +) + +func PossibleValuesForDeleteExistingPeering() []string { + return []string{ + string(DeleteExistingPeeringFalse), + string(DeleteExistingPeeringTrue), + } +} + +func (s *DeleteExistingPeering) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteExistingPeering(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteExistingPeering(input string) (*DeleteExistingPeering, error) { + vals := map[string]DeleteExistingPeering{ + "false": DeleteExistingPeeringFalse, + "true": DeleteExistingPeeringTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteExistingPeering(input) + return &out, nil +} + +type GroupConnectivity string + +const ( + GroupConnectivityDirectlyConnected GroupConnectivity = "DirectlyConnected" + GroupConnectivityNone GroupConnectivity = "None" +) + +func PossibleValuesForGroupConnectivity() []string { + return []string{ + string(GroupConnectivityDirectlyConnected), + string(GroupConnectivityNone), + } +} + +func (s *GroupConnectivity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupConnectivity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGroupConnectivity(input string) (*GroupConnectivity, error) { + vals := map[string]GroupConnectivity{ + "directlyconnected": GroupConnectivityDirectlyConnected, + "none": GroupConnectivityNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GroupConnectivity(input) + return &out, nil +} + +type GroupMemberType string + +const ( + GroupMemberTypeSubnet GroupMemberType = "Subnet" + GroupMemberTypeVirtualNetwork GroupMemberType = "VirtualNetwork" +) + +func PossibleValuesForGroupMemberType() []string { + return []string{ + string(GroupMemberTypeSubnet), + string(GroupMemberTypeVirtualNetwork), + } +} + +func (s *GroupMemberType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupMemberType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGroupMemberType(input string) (*GroupMemberType, error) { + vals := map[string]GroupMemberType{ + "subnet": GroupMemberTypeSubnet, + "virtualnetwork": GroupMemberTypeVirtualNetwork, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GroupMemberType(input) + return &out, nil +} + +type IsGlobal string + +const ( + IsGlobalFalse IsGlobal = "False" + IsGlobalTrue IsGlobal = "True" +) + +func PossibleValuesForIsGlobal() []string { + return []string{ + string(IsGlobalFalse), + string(IsGlobalTrue), + } +} + +func (s *IsGlobal) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsGlobal(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIsGlobal(input string) (*IsGlobal, error) { + vals := map[string]IsGlobal{ + "false": IsGlobalFalse, + "true": IsGlobalTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IsGlobal(input) + return &out, nil +} + +type PeeringEnforcement string + +const ( + PeeringEnforcementEnforced PeeringEnforcement = "Enforced" + PeeringEnforcementUnenforced PeeringEnforcement = "Unenforced" +) + +func PossibleValuesForPeeringEnforcement() []string { + return []string{ + string(PeeringEnforcementEnforced), + string(PeeringEnforcementUnenforced), + } +} + +func (s *PeeringEnforcement) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePeeringEnforcement(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePeeringEnforcement(input string) (*PeeringEnforcement, error) { + vals := map[string]PeeringEnforcement{ + "enforced": PeeringEnforcementEnforced, + "unenforced": PeeringEnforcementUnenforced, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PeeringEnforcement(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type UseHubGateway string + +const ( + UseHubGatewayFalse UseHubGateway = "False" + UseHubGatewayTrue UseHubGateway = "True" +) + +func PossibleValuesForUseHubGateway() []string { + return []string{ + string(UseHubGatewayFalse), + string(UseHubGatewayTrue), + } +} + +func (s *UseHubGateway) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUseHubGateway(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUseHubGateway(input string) (*UseHubGateway, error) { + vals := map[string]UseHubGateway{ + "false": UseHubGatewayFalse, + "true": UseHubGatewayTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UseHubGateway(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/id_networkmanager.go b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/id_networkmanager.go new file mode 100644 index 00000000000..3fd86366eb3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/id_networkmanager.go @@ -0,0 +1,130 @@ +package networkmanageractiveconnectivityconfigurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkManagerId{}) +} + +var _ resourceids.ResourceId = &NetworkManagerId{} + +// NetworkManagerId is a struct representing the Resource ID for a Network Manager +type NetworkManagerId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string +} + +// NewNetworkManagerID returns a new NetworkManagerId struct +func NewNetworkManagerID(subscriptionId string, resourceGroupName string, networkManagerName string) NetworkManagerId { + return NetworkManagerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + } +} + +// ParseNetworkManagerID parses 'input' into a NetworkManagerId +func ParseNetworkManagerID(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkManagerIDInsensitively parses 'input' case-insensitively into a NetworkManagerId +// note: this method should only be used for API response data and not user input +func ParseNetworkManagerIDInsensitively(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkManagerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + return nil +} + +// ValidateNetworkManagerID checks that 'input' can be parsed as a Network Manager ID +func ValidateNetworkManagerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkManagerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Manager ID +func (id NetworkManagerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Manager ID +func (id NetworkManagerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + } +} + +// String returns a human-readable description of this Network Manager ID +func (id NetworkManagerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + } + return fmt.Sprintf("Network Manager (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/id_networkmanager_test.go b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/id_networkmanager_test.go new file mode 100644 index 00000000000..c0a8c9d5cea --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/id_networkmanager_test.go @@ -0,0 +1,282 @@ +package networkmanageractiveconnectivityconfigurations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkManagerId{} + +func TestNewNetworkManagerID(t *testing.T) { + id := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } +} + +func TestFormatNetworkManagerID(t *testing.T) { + actual := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkManagerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestParseNetworkManagerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestSegmentsForNetworkManagerId(t *testing.T) { + segments := NetworkManagerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkManagerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/method_listactiveconnectivityconfigurations.go b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/method_listactiveconnectivityconfigurations.go new file mode 100644 index 00000000000..023b82524c0 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/method_listactiveconnectivityconfigurations.go @@ -0,0 +1,58 @@ +package networkmanageractiveconnectivityconfigurations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListActiveConnectivityConfigurationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ActiveConnectivityConfigurationsListResult +} + +// ListActiveConnectivityConfigurations ... +func (c NetworkManagerActiveConnectivityConfigurationsClient) ListActiveConnectivityConfigurations(ctx context.Context, id NetworkManagerId, input ActiveConfigurationParameter) (result ListActiveConnectivityConfigurationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listActiveConnectivityConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ActiveConnectivityConfigurationsListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_activeconfigurationparameter.go b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_activeconfigurationparameter.go new file mode 100644 index 00000000000..835513d64ee --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_activeconfigurationparameter.go @@ -0,0 +1,9 @@ +package networkmanageractiveconnectivityconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActiveConfigurationParameter struct { + Regions *[]string `json:"regions,omitempty"` + SkipToken *string `json:"skipToken,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_activeconnectivityconfiguration.go b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_activeconnectivityconfiguration.go new file mode 100644 index 00000000000..b836614744d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_activeconnectivityconfiguration.go @@ -0,0 +1,30 @@ +package networkmanageractiveconnectivityconfigurations + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActiveConnectivityConfiguration struct { + CommitTime *string `json:"commitTime,omitempty"` + ConfigurationGroups *[]ConfigurationGroup `json:"configurationGroups,omitempty"` + Id *string `json:"id,omitempty"` + Properties *ConnectivityConfigurationProperties `json:"properties,omitempty"` + Region *string `json:"region,omitempty"` +} + +func (o *ActiveConnectivityConfiguration) GetCommitTimeAsTime() (*time.Time, error) { + if o.CommitTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CommitTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ActiveConnectivityConfiguration) SetCommitTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CommitTime = &formatted +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_activeconnectivityconfigurationslistresult.go b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_activeconnectivityconfigurationslistresult.go new file mode 100644 index 00000000000..6fbfafeb4f7 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_activeconnectivityconfigurationslistresult.go @@ -0,0 +1,9 @@ +package networkmanageractiveconnectivityconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActiveConnectivityConfigurationsListResult struct { + SkipToken *string `json:"skipToken,omitempty"` + Value *[]ActiveConnectivityConfiguration `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_configurationgroup.go b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_configurationgroup.go new file mode 100644 index 00000000000..2f7ac6eb77f --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_configurationgroup.go @@ -0,0 +1,9 @@ +package networkmanageractiveconnectivityconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigurationGroup struct { + Id *string `json:"id,omitempty"` + Properties *NetworkGroupProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_connectivityconfigurationproperties.go b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_connectivityconfigurationproperties.go new file mode 100644 index 00000000000..4dc57801c6c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_connectivityconfigurationproperties.go @@ -0,0 +1,16 @@ +package networkmanageractiveconnectivityconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivityConfigurationProperties struct { + AppliesToGroups []ConnectivityGroupItem `json:"appliesToGroups"` + ConnectivityCapabilities *ConnectivityConfigurationPropertiesConnectivityCapabilities `json:"connectivityCapabilities,omitempty"` + ConnectivityTopology ConnectivityTopology `json:"connectivityTopology"` + DeleteExistingPeering *DeleteExistingPeering `json:"deleteExistingPeering,omitempty"` + Description *string `json:"description,omitempty"` + Hubs *[]Hub `json:"hubs,omitempty"` + IsGlobal *IsGlobal `json:"isGlobal,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_connectivityconfigurationpropertiesconnectivitycapabilities.go b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_connectivityconfigurationpropertiesconnectivitycapabilities.go new file mode 100644 index 00000000000..eac8b2a8682 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_connectivityconfigurationpropertiesconnectivitycapabilities.go @@ -0,0 +1,10 @@ +package networkmanageractiveconnectivityconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivityConfigurationPropertiesConnectivityCapabilities struct { + ConnectedGroupAddressOverlap ConnectedGroupAddressOverlap `json:"connectedGroupAddressOverlap"` + ConnectedGroupPrivateEndpointsScale ConnectedGroupPrivateEndpointsScale `json:"connectedGroupPrivateEndpointsScale"` + PeeringEnforcement PeeringEnforcement `json:"peeringEnforcement"` +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_connectivitygroupitem.go b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_connectivitygroupitem.go new file mode 100644 index 00000000000..18571eaa75f --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_connectivitygroupitem.go @@ -0,0 +1,11 @@ +package networkmanageractiveconnectivityconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivityGroupItem struct { + GroupConnectivity GroupConnectivity `json:"groupConnectivity"` + IsGlobal *IsGlobal `json:"isGlobal,omitempty"` + NetworkGroupId string `json:"networkGroupId"` + UseHubGateway *UseHubGateway `json:"useHubGateway,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_hub.go b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_hub.go new file mode 100644 index 00000000000..6d2eef46795 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_hub.go @@ -0,0 +1,9 @@ +package networkmanageractiveconnectivityconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Hub struct { + ResourceId *string `json:"resourceId,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_networkgroupproperties.go b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_networkgroupproperties.go new file mode 100644 index 00000000000..3f0564d6b8d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/model_networkgroupproperties.go @@ -0,0 +1,11 @@ +package networkmanageractiveconnectivityconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkGroupProperties struct { + Description *string `json:"description,omitempty"` + MemberType *GroupMemberType `json:"memberType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/version.go b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/version.go new file mode 100644 index 00000000000..38a6790821d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanageractiveconnectivityconfigurations/version.go @@ -0,0 +1,10 @@ +package networkmanageractiveconnectivityconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networkmanageractiveconnectivityconfigurations/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/README.md b/resource-manager/network/2024-07-01/networkmanagerconnections/README.md new file mode 100644 index 00000000000..51eccda2d1b --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/README.md @@ -0,0 +1,161 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanagerconnections` Documentation + +The `networkmanagerconnections` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanagerconnections" +``` + + +### Client Initialization + +```go +client := networkmanagerconnections.NewNetworkManagerConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkManagerConnectionsClient.ManagementGroupNetworkManagerConnectionsCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkmanagerconnections.NewProviders2NetworkManagerConnectionID("managementGroupId", "networkManagerConnectionName") + +payload := networkmanagerconnections.NetworkManagerConnection{ + // ... +} + + +read, err := client.ManagementGroupNetworkManagerConnectionsCreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkManagerConnectionsClient.ManagementGroupNetworkManagerConnectionsDelete` + +```go +ctx := context.TODO() +id := networkmanagerconnections.NewProviders2NetworkManagerConnectionID("managementGroupId", "networkManagerConnectionName") + +read, err := client.ManagementGroupNetworkManagerConnectionsDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkManagerConnectionsClient.ManagementGroupNetworkManagerConnectionsGet` + +```go +ctx := context.TODO() +id := networkmanagerconnections.NewProviders2NetworkManagerConnectionID("managementGroupId", "networkManagerConnectionName") + +read, err := client.ManagementGroupNetworkManagerConnectionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkManagerConnectionsClient.ManagementGroupNetworkManagerConnectionsList` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupId") + +// alternatively `client.ManagementGroupNetworkManagerConnectionsList(ctx, id, networkmanagerconnections.DefaultManagementGroupNetworkManagerConnectionsListOperationOptions())` can be used to do batched pagination +items, err := client.ManagementGroupNetworkManagerConnectionsListComplete(ctx, id, networkmanagerconnections.DefaultManagementGroupNetworkManagerConnectionsListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkManagerConnectionsClient.SubscriptionNetworkManagerConnectionsCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkmanagerconnections.NewNetworkManagerConnectionID("12345678-1234-9876-4563-123456789012", "networkManagerConnectionName") + +payload := networkmanagerconnections.NetworkManagerConnection{ + // ... +} + + +read, err := client.SubscriptionNetworkManagerConnectionsCreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkManagerConnectionsClient.SubscriptionNetworkManagerConnectionsDelete` + +```go +ctx := context.TODO() +id := networkmanagerconnections.NewNetworkManagerConnectionID("12345678-1234-9876-4563-123456789012", "networkManagerConnectionName") + +read, err := client.SubscriptionNetworkManagerConnectionsDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkManagerConnectionsClient.SubscriptionNetworkManagerConnectionsGet` + +```go +ctx := context.TODO() +id := networkmanagerconnections.NewNetworkManagerConnectionID("12345678-1234-9876-4563-123456789012", "networkManagerConnectionName") + +read, err := client.SubscriptionNetworkManagerConnectionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkManagerConnectionsClient.SubscriptionNetworkManagerConnectionsList` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.SubscriptionNetworkManagerConnectionsList(ctx, id, networkmanagerconnections.DefaultSubscriptionNetworkManagerConnectionsListOperationOptions())` can be used to do batched pagination +items, err := client.SubscriptionNetworkManagerConnectionsListComplete(ctx, id, networkmanagerconnections.DefaultSubscriptionNetworkManagerConnectionsListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/client.go b/resource-manager/network/2024-07-01/networkmanagerconnections/client.go new file mode 100644 index 00000000000..809f42be879 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/client.go @@ -0,0 +1,26 @@ +package networkmanagerconnections + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewNetworkManagerConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkManagerConnectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networkmanagerconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkManagerConnectionsClient: %+v", err) + } + + return &NetworkManagerConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/constants.go b/resource-manager/network/2024-07-01/networkmanagerconnections/constants.go new file mode 100644 index 00000000000..47d6adfd207 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/constants.go @@ -0,0 +1,60 @@ +package networkmanagerconnections + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScopeConnectionState string + +const ( + ScopeConnectionStateConflict ScopeConnectionState = "Conflict" + ScopeConnectionStateConnected ScopeConnectionState = "Connected" + ScopeConnectionStatePending ScopeConnectionState = "Pending" + ScopeConnectionStateRejected ScopeConnectionState = "Rejected" + ScopeConnectionStateRevoked ScopeConnectionState = "Revoked" +) + +func PossibleValuesForScopeConnectionState() []string { + return []string{ + string(ScopeConnectionStateConflict), + string(ScopeConnectionStateConnected), + string(ScopeConnectionStatePending), + string(ScopeConnectionStateRejected), + string(ScopeConnectionStateRevoked), + } +} + +func (s *ScopeConnectionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScopeConnectionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScopeConnectionState(input string) (*ScopeConnectionState, error) { + vals := map[string]ScopeConnectionState{ + "conflict": ScopeConnectionStateConflict, + "connected": ScopeConnectionStateConnected, + "pending": ScopeConnectionStatePending, + "rejected": ScopeConnectionStateRejected, + "revoked": ScopeConnectionStateRevoked, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScopeConnectionState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/id_networkmanagerconnection.go b/resource-manager/network/2024-07-01/networkmanagerconnections/id_networkmanagerconnection.go new file mode 100644 index 00000000000..a3050ef7c66 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/id_networkmanagerconnection.go @@ -0,0 +1,121 @@ +package networkmanagerconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkManagerConnectionId{}) +} + +var _ resourceids.ResourceId = &NetworkManagerConnectionId{} + +// NetworkManagerConnectionId is a struct representing the Resource ID for a Network Manager Connection +type NetworkManagerConnectionId struct { + SubscriptionId string + NetworkManagerConnectionName string +} + +// NewNetworkManagerConnectionID returns a new NetworkManagerConnectionId struct +func NewNetworkManagerConnectionID(subscriptionId string, networkManagerConnectionName string) NetworkManagerConnectionId { + return NetworkManagerConnectionId{ + SubscriptionId: subscriptionId, + NetworkManagerConnectionName: networkManagerConnectionName, + } +} + +// ParseNetworkManagerConnectionID parses 'input' into a NetworkManagerConnectionId +func ParseNetworkManagerConnectionID(input string) (*NetworkManagerConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkManagerConnectionIDInsensitively parses 'input' case-insensitively into a NetworkManagerConnectionId +// note: this method should only be used for API response data and not user input +func ParseNetworkManagerConnectionIDInsensitively(input string) (*NetworkManagerConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkManagerConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.NetworkManagerConnectionName, ok = input.Parsed["networkManagerConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerConnectionName", input) + } + + return nil +} + +// ValidateNetworkManagerConnectionID checks that 'input' can be parsed as a Network Manager Connection ID +func ValidateNetworkManagerConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkManagerConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Manager Connection ID +func (id NetworkManagerConnectionId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Network/networkManagerConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.NetworkManagerConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Manager Connection ID +func (id NetworkManagerConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagerConnections", "networkManagerConnections", "networkManagerConnections"), + resourceids.UserSpecifiedSegment("networkManagerConnectionName", "networkManagerConnectionName"), + } +} + +// String returns a human-readable description of this Network Manager Connection ID +func (id NetworkManagerConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Network Manager Connection Name: %q", id.NetworkManagerConnectionName), + } + return fmt.Sprintf("Network Manager Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/id_networkmanagerconnection_test.go b/resource-manager/network/2024-07-01/networkmanagerconnections/id_networkmanagerconnection_test.go new file mode 100644 index 00000000000..36ee6bc88d9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/id_networkmanagerconnection_test.go @@ -0,0 +1,237 @@ +package networkmanagerconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkManagerConnectionId{} + +func TestNewNetworkManagerConnectionID(t *testing.T) { + id := NewNetworkManagerConnectionID("12345678-1234-9876-4563-123456789012", "networkManagerConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.NetworkManagerConnectionName != "networkManagerConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerConnectionName'", id.NetworkManagerConnectionName, "networkManagerConnectionName") + } +} + +func TestFormatNetworkManagerConnectionID(t *testing.T) { + actual := NewNetworkManagerConnectionID("12345678-1234-9876-4563-123456789012", "networkManagerConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/networkManagerConnections/networkManagerConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkManagerConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/networkManagerConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/networkManagerConnections/networkManagerConnectionName", + Expected: &NetworkManagerConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + NetworkManagerConnectionName: "networkManagerConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/networkManagerConnections/networkManagerConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.NetworkManagerConnectionName != v.Expected.NetworkManagerConnectionName { + t.Fatalf("Expected %q but got %q for NetworkManagerConnectionName", v.Expected.NetworkManagerConnectionName, actual.NetworkManagerConnectionName) + } + + } +} + +func TestParseNetworkManagerConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/networkManagerConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/networkManagerConnections/networkManagerConnectionName", + Expected: &NetworkManagerConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + NetworkManagerConnectionName: "networkManagerConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/networkManagerConnections/networkManagerConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRcOnNeCtIoNs/nEtWoRkMaNaGeRcOnNeCtIoNnAmE", + Expected: &NetworkManagerConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + NetworkManagerConnectionName: "nEtWoRkMaNaGeRcOnNeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRcOnNeCtIoNs/nEtWoRkMaNaGeRcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.NetworkManagerConnectionName != v.Expected.NetworkManagerConnectionName { + t.Fatalf("Expected %q but got %q for NetworkManagerConnectionName", v.Expected.NetworkManagerConnectionName, actual.NetworkManagerConnectionName) + } + + } +} + +func TestSegmentsForNetworkManagerConnectionId(t *testing.T) { + segments := NetworkManagerConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkManagerConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/id_providers2networkmanagerconnection.go b/resource-manager/network/2024-07-01/networkmanagerconnections/id_providers2networkmanagerconnection.go new file mode 100644 index 00000000000..a0bb33d6bc5 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/id_providers2networkmanagerconnection.go @@ -0,0 +1,123 @@ +package networkmanagerconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&Providers2NetworkManagerConnectionId{}) +} + +var _ resourceids.ResourceId = &Providers2NetworkManagerConnectionId{} + +// Providers2NetworkManagerConnectionId is a struct representing the Resource ID for a Providers 2 Network Manager Connection +type Providers2NetworkManagerConnectionId struct { + ManagementGroupId string + NetworkManagerConnectionName string +} + +// NewProviders2NetworkManagerConnectionID returns a new Providers2NetworkManagerConnectionId struct +func NewProviders2NetworkManagerConnectionID(managementGroupId string, networkManagerConnectionName string) Providers2NetworkManagerConnectionId { + return Providers2NetworkManagerConnectionId{ + ManagementGroupId: managementGroupId, + NetworkManagerConnectionName: networkManagerConnectionName, + } +} + +// ParseProviders2NetworkManagerConnectionID parses 'input' into a Providers2NetworkManagerConnectionId +func ParseProviders2NetworkManagerConnectionID(input string) (*Providers2NetworkManagerConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2NetworkManagerConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2NetworkManagerConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviders2NetworkManagerConnectionIDInsensitively parses 'input' case-insensitively into a Providers2NetworkManagerConnectionId +// note: this method should only be used for API response data and not user input +func ParseProviders2NetworkManagerConnectionIDInsensitively(input string) (*Providers2NetworkManagerConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&Providers2NetworkManagerConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := Providers2NetworkManagerConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *Providers2NetworkManagerConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.ManagementGroupId, ok = input.Parsed["managementGroupId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managementGroupId", input) + } + + if id.NetworkManagerConnectionName, ok = input.Parsed["networkManagerConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerConnectionName", input) + } + + return nil +} + +// ValidateProviders2NetworkManagerConnectionID checks that 'input' can be parsed as a Providers 2 Network Manager Connection ID +func ValidateProviders2NetworkManagerConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviders2NetworkManagerConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Providers 2 Network Manager Connection ID +func (id Providers2NetworkManagerConnectionId) ID() string { + fmtString := "/providers/Microsoft.Management/managementGroups/%s/providers/Microsoft.Network/networkManagerConnections/%s" + return fmt.Sprintf(fmtString, id.ManagementGroupId, id.NetworkManagerConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Providers 2 Network Manager Connection ID +func (id Providers2NetworkManagerConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftManagement", "Microsoft.Management", "Microsoft.Management"), + resourceids.StaticSegment("staticManagementGroups", "managementGroups", "managementGroups"), + resourceids.UserSpecifiedSegment("managementGroupId", "managementGroupId"), + resourceids.StaticSegment("staticProviders2", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagerConnections", "networkManagerConnections", "networkManagerConnections"), + resourceids.UserSpecifiedSegment("networkManagerConnectionName", "networkManagerConnectionName"), + } +} + +// String returns a human-readable description of this Providers 2 Network Manager Connection ID +func (id Providers2NetworkManagerConnectionId) String() string { + components := []string{ + fmt.Sprintf("Management Group: %q", id.ManagementGroupId), + fmt.Sprintf("Network Manager Connection Name: %q", id.NetworkManagerConnectionName), + } + return fmt.Sprintf("Providers 2 Network Manager Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/id_providers2networkmanagerconnection_test.go b/resource-manager/network/2024-07-01/networkmanagerconnections/id_providers2networkmanagerconnection_test.go new file mode 100644 index 00000000000..6876ff0e791 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/id_providers2networkmanagerconnection_test.go @@ -0,0 +1,267 @@ +package networkmanagerconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &Providers2NetworkManagerConnectionId{} + +func TestNewProviders2NetworkManagerConnectionID(t *testing.T) { + id := NewProviders2NetworkManagerConnectionID("managementGroupId", "networkManagerConnectionName") + + if id.ManagementGroupId != "managementGroupId" { + t.Fatalf("Expected %q but got %q for Segment 'ManagementGroupId'", id.ManagementGroupId, "managementGroupId") + } + + if id.NetworkManagerConnectionName != "networkManagerConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerConnectionName'", id.NetworkManagerConnectionName, "networkManagerConnectionName") + } +} + +func TestFormatProviders2NetworkManagerConnectionID(t *testing.T) { + actual := NewProviders2NetworkManagerConnectionID("managementGroupId", "networkManagerConnectionName").ID() + expected := "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.Network/networkManagerConnections/networkManagerConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviders2NetworkManagerConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2NetworkManagerConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.Network/networkManagerConnections", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.Network/networkManagerConnections/networkManagerConnectionName", + Expected: &Providers2NetworkManagerConnectionId{ + ManagementGroupId: "managementGroupId", + NetworkManagerConnectionName: "networkManagerConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.Network/networkManagerConnections/networkManagerConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2NetworkManagerConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.ManagementGroupId != v.Expected.ManagementGroupId { + t.Fatalf("Expected %q but got %q for ManagementGroupId", v.Expected.ManagementGroupId, actual.ManagementGroupId) + } + + if actual.NetworkManagerConnectionName != v.Expected.NetworkManagerConnectionName { + t.Fatalf("Expected %q but got %q for NetworkManagerConnectionName", v.Expected.NetworkManagerConnectionName, actual.NetworkManagerConnectionName) + } + + } +} + +func TestParseProviders2NetworkManagerConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *Providers2NetworkManagerConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.Network/networkManagerConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.Network/networkManagerConnections/networkManagerConnectionName", + Expected: &Providers2NetworkManagerConnectionId{ + ManagementGroupId: "managementGroupId", + NetworkManagerConnectionName: "networkManagerConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Management/managementGroups/managementGroupId/providers/Microsoft.Network/networkManagerConnections/networkManagerConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRcOnNeCtIoNs/nEtWoRkMaNaGeRcOnNeCtIoNnAmE", + Expected: &Providers2NetworkManagerConnectionId{ + ManagementGroupId: "mAnAgEmEnTgRoUpId", + NetworkManagerConnectionName: "nEtWoRkMaNaGeRcOnNeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.mAnAgEmEnT/mAnAgEmEnTgRoUpS/mAnAgEmEnTgRoUpId/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRcOnNeCtIoNs/nEtWoRkMaNaGeRcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviders2NetworkManagerConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.ManagementGroupId != v.Expected.ManagementGroupId { + t.Fatalf("Expected %q but got %q for ManagementGroupId", v.Expected.ManagementGroupId, actual.ManagementGroupId) + } + + if actual.NetworkManagerConnectionName != v.Expected.NetworkManagerConnectionName { + t.Fatalf("Expected %q but got %q for NetworkManagerConnectionName", v.Expected.NetworkManagerConnectionName, actual.NetworkManagerConnectionName) + } + + } +} + +func TestSegmentsForProviders2NetworkManagerConnectionId(t *testing.T) { + segments := Providers2NetworkManagerConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("Providers2NetworkManagerConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/method_managementgroupnetworkmanagerconnectionscreateorupdate.go b/resource-manager/network/2024-07-01/networkmanagerconnections/method_managementgroupnetworkmanagerconnectionscreateorupdate.go new file mode 100644 index 00000000000..116a8f3da7a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/method_managementgroupnetworkmanagerconnectionscreateorupdate.go @@ -0,0 +1,58 @@ +package networkmanagerconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementGroupNetworkManagerConnectionsCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkManagerConnection +} + +// ManagementGroupNetworkManagerConnectionsCreateOrUpdate ... +func (c NetworkManagerConnectionsClient) ManagementGroupNetworkManagerConnectionsCreateOrUpdate(ctx context.Context, id Providers2NetworkManagerConnectionId, input NetworkManagerConnection) (result ManagementGroupNetworkManagerConnectionsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkManagerConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/method_managementgroupnetworkmanagerconnectionsdelete.go b/resource-manager/network/2024-07-01/networkmanagerconnections/method_managementgroupnetworkmanagerconnectionsdelete.go new file mode 100644 index 00000000000..83c0e93f95b --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/method_managementgroupnetworkmanagerconnectionsdelete.go @@ -0,0 +1,47 @@ +package networkmanagerconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementGroupNetworkManagerConnectionsDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ManagementGroupNetworkManagerConnectionsDelete ... +func (c NetworkManagerConnectionsClient) ManagementGroupNetworkManagerConnectionsDelete(ctx context.Context, id Providers2NetworkManagerConnectionId) (result ManagementGroupNetworkManagerConnectionsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/method_managementgroupnetworkmanagerconnectionsget.go b/resource-manager/network/2024-07-01/networkmanagerconnections/method_managementgroupnetworkmanagerconnectionsget.go new file mode 100644 index 00000000000..c4f20220fbe --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/method_managementgroupnetworkmanagerconnectionsget.go @@ -0,0 +1,53 @@ +package networkmanagerconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementGroupNetworkManagerConnectionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkManagerConnection +} + +// ManagementGroupNetworkManagerConnectionsGet ... +func (c NetworkManagerConnectionsClient) ManagementGroupNetworkManagerConnectionsGet(ctx context.Context, id Providers2NetworkManagerConnectionId) (result ManagementGroupNetworkManagerConnectionsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkManagerConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/method_managementgroupnetworkmanagerconnectionslist.go b/resource-manager/network/2024-07-01/networkmanagerconnections/method_managementgroupnetworkmanagerconnectionslist.go new file mode 100644 index 00000000000..d8b68e162ab --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/method_managementgroupnetworkmanagerconnectionslist.go @@ -0,0 +1,135 @@ +package networkmanagerconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagementGroupNetworkManagerConnectionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkManagerConnection +} + +type ManagementGroupNetworkManagerConnectionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkManagerConnection +} + +type ManagementGroupNetworkManagerConnectionsListOperationOptions struct { + Top *int64 +} + +func DefaultManagementGroupNetworkManagerConnectionsListOperationOptions() ManagementGroupNetworkManagerConnectionsListOperationOptions { + return ManagementGroupNetworkManagerConnectionsListOperationOptions{} +} + +func (o ManagementGroupNetworkManagerConnectionsListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ManagementGroupNetworkManagerConnectionsListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ManagementGroupNetworkManagerConnectionsListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ManagementGroupNetworkManagerConnectionsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ManagementGroupNetworkManagerConnectionsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ManagementGroupNetworkManagerConnectionsList ... +func (c NetworkManagerConnectionsClient) ManagementGroupNetworkManagerConnectionsList(ctx context.Context, id commonids.ManagementGroupId, options ManagementGroupNetworkManagerConnectionsListOperationOptions) (result ManagementGroupNetworkManagerConnectionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ManagementGroupNetworkManagerConnectionsListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/networkManagerConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkManagerConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ManagementGroupNetworkManagerConnectionsListComplete retrieves all the results into a single object +func (c NetworkManagerConnectionsClient) ManagementGroupNetworkManagerConnectionsListComplete(ctx context.Context, id commonids.ManagementGroupId, options ManagementGroupNetworkManagerConnectionsListOperationOptions) (ManagementGroupNetworkManagerConnectionsListCompleteResult, error) { + return c.ManagementGroupNetworkManagerConnectionsListCompleteMatchingPredicate(ctx, id, options, NetworkManagerConnectionOperationPredicate{}) +} + +// ManagementGroupNetworkManagerConnectionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkManagerConnectionsClient) ManagementGroupNetworkManagerConnectionsListCompleteMatchingPredicate(ctx context.Context, id commonids.ManagementGroupId, options ManagementGroupNetworkManagerConnectionsListOperationOptions, predicate NetworkManagerConnectionOperationPredicate) (result ManagementGroupNetworkManagerConnectionsListCompleteResult, err error) { + items := make([]NetworkManagerConnection, 0) + + resp, err := c.ManagementGroupNetworkManagerConnectionsList(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ManagementGroupNetworkManagerConnectionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/method_subscriptionnetworkmanagerconnectionscreateorupdate.go b/resource-manager/network/2024-07-01/networkmanagerconnections/method_subscriptionnetworkmanagerconnectionscreateorupdate.go new file mode 100644 index 00000000000..2d07c99634c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/method_subscriptionnetworkmanagerconnectionscreateorupdate.go @@ -0,0 +1,58 @@ +package networkmanagerconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubscriptionNetworkManagerConnectionsCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkManagerConnection +} + +// SubscriptionNetworkManagerConnectionsCreateOrUpdate ... +func (c NetworkManagerConnectionsClient) SubscriptionNetworkManagerConnectionsCreateOrUpdate(ctx context.Context, id NetworkManagerConnectionId, input NetworkManagerConnection) (result SubscriptionNetworkManagerConnectionsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkManagerConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/method_subscriptionnetworkmanagerconnectionsdelete.go b/resource-manager/network/2024-07-01/networkmanagerconnections/method_subscriptionnetworkmanagerconnectionsdelete.go new file mode 100644 index 00000000000..43ebf8bb5e4 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/method_subscriptionnetworkmanagerconnectionsdelete.go @@ -0,0 +1,47 @@ +package networkmanagerconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubscriptionNetworkManagerConnectionsDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SubscriptionNetworkManagerConnectionsDelete ... +func (c NetworkManagerConnectionsClient) SubscriptionNetworkManagerConnectionsDelete(ctx context.Context, id NetworkManagerConnectionId) (result SubscriptionNetworkManagerConnectionsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/method_subscriptionnetworkmanagerconnectionsget.go b/resource-manager/network/2024-07-01/networkmanagerconnections/method_subscriptionnetworkmanagerconnectionsget.go new file mode 100644 index 00000000000..4b89ca96feb --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/method_subscriptionnetworkmanagerconnectionsget.go @@ -0,0 +1,53 @@ +package networkmanagerconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubscriptionNetworkManagerConnectionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkManagerConnection +} + +// SubscriptionNetworkManagerConnectionsGet ... +func (c NetworkManagerConnectionsClient) SubscriptionNetworkManagerConnectionsGet(ctx context.Context, id NetworkManagerConnectionId) (result SubscriptionNetworkManagerConnectionsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkManagerConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/method_subscriptionnetworkmanagerconnectionslist.go b/resource-manager/network/2024-07-01/networkmanagerconnections/method_subscriptionnetworkmanagerconnectionslist.go new file mode 100644 index 00000000000..a08f8b1adfc --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/method_subscriptionnetworkmanagerconnectionslist.go @@ -0,0 +1,135 @@ +package networkmanagerconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubscriptionNetworkManagerConnectionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkManagerConnection +} + +type SubscriptionNetworkManagerConnectionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkManagerConnection +} + +type SubscriptionNetworkManagerConnectionsListOperationOptions struct { + Top *int64 +} + +func DefaultSubscriptionNetworkManagerConnectionsListOperationOptions() SubscriptionNetworkManagerConnectionsListOperationOptions { + return SubscriptionNetworkManagerConnectionsListOperationOptions{} +} + +func (o SubscriptionNetworkManagerConnectionsListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o SubscriptionNetworkManagerConnectionsListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o SubscriptionNetworkManagerConnectionsListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type SubscriptionNetworkManagerConnectionsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *SubscriptionNetworkManagerConnectionsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// SubscriptionNetworkManagerConnectionsList ... +func (c NetworkManagerConnectionsClient) SubscriptionNetworkManagerConnectionsList(ctx context.Context, id commonids.SubscriptionId, options SubscriptionNetworkManagerConnectionsListOperationOptions) (result SubscriptionNetworkManagerConnectionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &SubscriptionNetworkManagerConnectionsListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/networkManagerConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkManagerConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// SubscriptionNetworkManagerConnectionsListComplete retrieves all the results into a single object +func (c NetworkManagerConnectionsClient) SubscriptionNetworkManagerConnectionsListComplete(ctx context.Context, id commonids.SubscriptionId, options SubscriptionNetworkManagerConnectionsListOperationOptions) (SubscriptionNetworkManagerConnectionsListCompleteResult, error) { + return c.SubscriptionNetworkManagerConnectionsListCompleteMatchingPredicate(ctx, id, options, NetworkManagerConnectionOperationPredicate{}) +} + +// SubscriptionNetworkManagerConnectionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkManagerConnectionsClient) SubscriptionNetworkManagerConnectionsListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options SubscriptionNetworkManagerConnectionsListOperationOptions, predicate NetworkManagerConnectionOperationPredicate) (result SubscriptionNetworkManagerConnectionsListCompleteResult, err error) { + items := make([]NetworkManagerConnection, 0) + + resp, err := c.SubscriptionNetworkManagerConnectionsList(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = SubscriptionNetworkManagerConnectionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/model_networkmanagerconnection.go b/resource-manager/network/2024-07-01/networkmanagerconnections/model_networkmanagerconnection.go new file mode 100644 index 00000000000..a7548b73699 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/model_networkmanagerconnection.go @@ -0,0 +1,17 @@ +package networkmanagerconnections + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkManagerConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/model_networkmanagerconnectionproperties.go b/resource-manager/network/2024-07-01/networkmanagerconnections/model_networkmanagerconnectionproperties.go new file mode 100644 index 00000000000..faec43c2f30 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/model_networkmanagerconnectionproperties.go @@ -0,0 +1,10 @@ +package networkmanagerconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerConnectionProperties struct { + ConnectionState *ScopeConnectionState `json:"connectionState,omitempty"` + Description *string `json:"description,omitempty"` + NetworkManagerId *string `json:"networkManagerId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/predicates.go b/resource-manager/network/2024-07-01/networkmanagerconnections/predicates.go new file mode 100644 index 00000000000..145b7b7261a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/predicates.go @@ -0,0 +1,32 @@ +package networkmanagerconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerConnectionOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p NetworkManagerConnectionOperationPredicate) Matches(input NetworkManagerConnection) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/networkmanagerconnections/version.go b/resource-manager/network/2024-07-01/networkmanagerconnections/version.go new file mode 100644 index 00000000000..a5bde4262de --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerconnections/version.go @@ -0,0 +1,10 @@ +package networkmanagerconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networkmanagerconnections/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/README.md b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/README.md new file mode 100644 index 00000000000..95a3ee6a9b8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/README.md @@ -0,0 +1,42 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration` Documentation + +The `networkmanagereffectiveconnectivityconfiguration` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration" +``` + + +### Client Initialization + +```go +client := networkmanagereffectiveconnectivityconfiguration.NewNetworkManagerEffectiveConnectivityConfigurationClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkManagerEffectiveConnectivityConfigurationClient.ListNetworkManagerEffectiveConnectivityConfigurations` + +```go +ctx := context.TODO() +id := commonids.NewVirtualNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName") + +payload := networkmanagereffectiveconnectivityconfiguration.QueryRequestOptions{ + // ... +} + + +read, err := client.ListNetworkManagerEffectiveConnectivityConfigurations(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/client.go b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/client.go new file mode 100644 index 00000000000..c6449e001fe --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/client.go @@ -0,0 +1,26 @@ +package networkmanagereffectiveconnectivityconfiguration + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerEffectiveConnectivityConfigurationClient struct { + Client *resourcemanager.Client +} + +func NewNetworkManagerEffectiveConnectivityConfigurationClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkManagerEffectiveConnectivityConfigurationClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networkmanagereffectiveconnectivityconfiguration", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkManagerEffectiveConnectivityConfigurationClient: %+v", err) + } + + return &NetworkManagerEffectiveConnectivityConfigurationClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/constants.go b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/constants.go new file mode 100644 index 00000000000..aa292723727 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/constants.go @@ -0,0 +1,426 @@ +package networkmanagereffectiveconnectivityconfiguration + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectedGroupAddressOverlap string + +const ( + ConnectedGroupAddressOverlapAllowed ConnectedGroupAddressOverlap = "Allowed" + ConnectedGroupAddressOverlapDisallowed ConnectedGroupAddressOverlap = "Disallowed" +) + +func PossibleValuesForConnectedGroupAddressOverlap() []string { + return []string{ + string(ConnectedGroupAddressOverlapAllowed), + string(ConnectedGroupAddressOverlapDisallowed), + } +} + +func (s *ConnectedGroupAddressOverlap) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectedGroupAddressOverlap(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectedGroupAddressOverlap(input string) (*ConnectedGroupAddressOverlap, error) { + vals := map[string]ConnectedGroupAddressOverlap{ + "allowed": ConnectedGroupAddressOverlapAllowed, + "disallowed": ConnectedGroupAddressOverlapDisallowed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectedGroupAddressOverlap(input) + return &out, nil +} + +type ConnectedGroupPrivateEndpointsScale string + +const ( + ConnectedGroupPrivateEndpointsScaleHighScale ConnectedGroupPrivateEndpointsScale = "HighScale" + ConnectedGroupPrivateEndpointsScaleStandard ConnectedGroupPrivateEndpointsScale = "Standard" +) + +func PossibleValuesForConnectedGroupPrivateEndpointsScale() []string { + return []string{ + string(ConnectedGroupPrivateEndpointsScaleHighScale), + string(ConnectedGroupPrivateEndpointsScaleStandard), + } +} + +func (s *ConnectedGroupPrivateEndpointsScale) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectedGroupPrivateEndpointsScale(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectedGroupPrivateEndpointsScale(input string) (*ConnectedGroupPrivateEndpointsScale, error) { + vals := map[string]ConnectedGroupPrivateEndpointsScale{ + "highscale": ConnectedGroupPrivateEndpointsScaleHighScale, + "standard": ConnectedGroupPrivateEndpointsScaleStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectedGroupPrivateEndpointsScale(input) + return &out, nil +} + +type ConnectivityTopology string + +const ( + ConnectivityTopologyHubAndSpoke ConnectivityTopology = "HubAndSpoke" + ConnectivityTopologyMesh ConnectivityTopology = "Mesh" +) + +func PossibleValuesForConnectivityTopology() []string { + return []string{ + string(ConnectivityTopologyHubAndSpoke), + string(ConnectivityTopologyMesh), + } +} + +func (s *ConnectivityTopology) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectivityTopology(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectivityTopology(input string) (*ConnectivityTopology, error) { + vals := map[string]ConnectivityTopology{ + "hubandspoke": ConnectivityTopologyHubAndSpoke, + "mesh": ConnectivityTopologyMesh, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectivityTopology(input) + return &out, nil +} + +type DeleteExistingPeering string + +const ( + DeleteExistingPeeringFalse DeleteExistingPeering = "False" + DeleteExistingPeeringTrue DeleteExistingPeering = "True" +) + +func PossibleValuesForDeleteExistingPeering() []string { + return []string{ + string(DeleteExistingPeeringFalse), + string(DeleteExistingPeeringTrue), + } +} + +func (s *DeleteExistingPeering) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteExistingPeering(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteExistingPeering(input string) (*DeleteExistingPeering, error) { + vals := map[string]DeleteExistingPeering{ + "false": DeleteExistingPeeringFalse, + "true": DeleteExistingPeeringTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteExistingPeering(input) + return &out, nil +} + +type GroupConnectivity string + +const ( + GroupConnectivityDirectlyConnected GroupConnectivity = "DirectlyConnected" + GroupConnectivityNone GroupConnectivity = "None" +) + +func PossibleValuesForGroupConnectivity() []string { + return []string{ + string(GroupConnectivityDirectlyConnected), + string(GroupConnectivityNone), + } +} + +func (s *GroupConnectivity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupConnectivity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGroupConnectivity(input string) (*GroupConnectivity, error) { + vals := map[string]GroupConnectivity{ + "directlyconnected": GroupConnectivityDirectlyConnected, + "none": GroupConnectivityNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GroupConnectivity(input) + return &out, nil +} + +type GroupMemberType string + +const ( + GroupMemberTypeSubnet GroupMemberType = "Subnet" + GroupMemberTypeVirtualNetwork GroupMemberType = "VirtualNetwork" +) + +func PossibleValuesForGroupMemberType() []string { + return []string{ + string(GroupMemberTypeSubnet), + string(GroupMemberTypeVirtualNetwork), + } +} + +func (s *GroupMemberType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupMemberType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGroupMemberType(input string) (*GroupMemberType, error) { + vals := map[string]GroupMemberType{ + "subnet": GroupMemberTypeSubnet, + "virtualnetwork": GroupMemberTypeVirtualNetwork, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GroupMemberType(input) + return &out, nil +} + +type IsGlobal string + +const ( + IsGlobalFalse IsGlobal = "False" + IsGlobalTrue IsGlobal = "True" +) + +func PossibleValuesForIsGlobal() []string { + return []string{ + string(IsGlobalFalse), + string(IsGlobalTrue), + } +} + +func (s *IsGlobal) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsGlobal(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIsGlobal(input string) (*IsGlobal, error) { + vals := map[string]IsGlobal{ + "false": IsGlobalFalse, + "true": IsGlobalTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IsGlobal(input) + return &out, nil +} + +type PeeringEnforcement string + +const ( + PeeringEnforcementEnforced PeeringEnforcement = "Enforced" + PeeringEnforcementUnenforced PeeringEnforcement = "Unenforced" +) + +func PossibleValuesForPeeringEnforcement() []string { + return []string{ + string(PeeringEnforcementEnforced), + string(PeeringEnforcementUnenforced), + } +} + +func (s *PeeringEnforcement) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePeeringEnforcement(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePeeringEnforcement(input string) (*PeeringEnforcement, error) { + vals := map[string]PeeringEnforcement{ + "enforced": PeeringEnforcementEnforced, + "unenforced": PeeringEnforcementUnenforced, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PeeringEnforcement(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type UseHubGateway string + +const ( + UseHubGatewayFalse UseHubGateway = "False" + UseHubGatewayTrue UseHubGateway = "True" +) + +func PossibleValuesForUseHubGateway() []string { + return []string{ + string(UseHubGatewayFalse), + string(UseHubGatewayTrue), + } +} + +func (s *UseHubGateway) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUseHubGateway(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUseHubGateway(input string) (*UseHubGateway, error) { + vals := map[string]UseHubGateway{ + "false": UseHubGatewayFalse, + "true": UseHubGatewayTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UseHubGateway(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/method_listnetworkmanagereffectiveconnectivityconfigurations.go b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/method_listnetworkmanagereffectiveconnectivityconfigurations.go new file mode 100644 index 00000000000..64233acc195 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/method_listnetworkmanagereffectiveconnectivityconfigurations.go @@ -0,0 +1,59 @@ +package networkmanagereffectiveconnectivityconfiguration + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListNetworkManagerEffectiveConnectivityConfigurationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkManagerEffectiveConnectivityConfigurationListResult +} + +// ListNetworkManagerEffectiveConnectivityConfigurations ... +func (c NetworkManagerEffectiveConnectivityConfigurationClient) ListNetworkManagerEffectiveConnectivityConfigurations(ctx context.Context, id commonids.VirtualNetworkId, input QueryRequestOptions) (result ListNetworkManagerEffectiveConnectivityConfigurationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listNetworkManagerEffectiveConnectivityConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkManagerEffectiveConnectivityConfigurationListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_configurationgroup.go b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_configurationgroup.go new file mode 100644 index 00000000000..219b2fe208e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_configurationgroup.go @@ -0,0 +1,9 @@ +package networkmanagereffectiveconnectivityconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigurationGroup struct { + Id *string `json:"id,omitempty"` + Properties *NetworkGroupProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_connectivityconfigurationproperties.go b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_connectivityconfigurationproperties.go new file mode 100644 index 00000000000..66cfd1b8841 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_connectivityconfigurationproperties.go @@ -0,0 +1,16 @@ +package networkmanagereffectiveconnectivityconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivityConfigurationProperties struct { + AppliesToGroups []ConnectivityGroupItem `json:"appliesToGroups"` + ConnectivityCapabilities *ConnectivityConfigurationPropertiesConnectivityCapabilities `json:"connectivityCapabilities,omitempty"` + ConnectivityTopology ConnectivityTopology `json:"connectivityTopology"` + DeleteExistingPeering *DeleteExistingPeering `json:"deleteExistingPeering,omitempty"` + Description *string `json:"description,omitempty"` + Hubs *[]Hub `json:"hubs,omitempty"` + IsGlobal *IsGlobal `json:"isGlobal,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_connectivityconfigurationpropertiesconnectivitycapabilities.go b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_connectivityconfigurationpropertiesconnectivitycapabilities.go new file mode 100644 index 00000000000..0f9c8fbcdbd --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_connectivityconfigurationpropertiesconnectivitycapabilities.go @@ -0,0 +1,10 @@ +package networkmanagereffectiveconnectivityconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivityConfigurationPropertiesConnectivityCapabilities struct { + ConnectedGroupAddressOverlap ConnectedGroupAddressOverlap `json:"connectedGroupAddressOverlap"` + ConnectedGroupPrivateEndpointsScale ConnectedGroupPrivateEndpointsScale `json:"connectedGroupPrivateEndpointsScale"` + PeeringEnforcement PeeringEnforcement `json:"peeringEnforcement"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_connectivitygroupitem.go b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_connectivitygroupitem.go new file mode 100644 index 00000000000..d034adb388c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_connectivitygroupitem.go @@ -0,0 +1,11 @@ +package networkmanagereffectiveconnectivityconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivityGroupItem struct { + GroupConnectivity GroupConnectivity `json:"groupConnectivity"` + IsGlobal *IsGlobal `json:"isGlobal,omitempty"` + NetworkGroupId string `json:"networkGroupId"` + UseHubGateway *UseHubGateway `json:"useHubGateway,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_effectiveconnectivityconfiguration.go b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_effectiveconnectivityconfiguration.go new file mode 100644 index 00000000000..ace2b882974 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_effectiveconnectivityconfiguration.go @@ -0,0 +1,10 @@ +package networkmanagereffectiveconnectivityconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EffectiveConnectivityConfiguration struct { + ConfigurationGroups *[]ConfigurationGroup `json:"configurationGroups,omitempty"` + Id *string `json:"id,omitempty"` + Properties *ConnectivityConfigurationProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_hub.go b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_hub.go new file mode 100644 index 00000000000..5564a1b1595 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_hub.go @@ -0,0 +1,9 @@ +package networkmanagereffectiveconnectivityconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Hub struct { + ResourceId *string `json:"resourceId,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_networkgroupproperties.go b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_networkgroupproperties.go new file mode 100644 index 00000000000..38a863e54e1 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_networkgroupproperties.go @@ -0,0 +1,11 @@ +package networkmanagereffectiveconnectivityconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkGroupProperties struct { + Description *string `json:"description,omitempty"` + MemberType *GroupMemberType `json:"memberType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_networkmanagereffectiveconnectivityconfigurationlistresult.go b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_networkmanagereffectiveconnectivityconfigurationlistresult.go new file mode 100644 index 00000000000..566b11872ea --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_networkmanagereffectiveconnectivityconfigurationlistresult.go @@ -0,0 +1,9 @@ +package networkmanagereffectiveconnectivityconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerEffectiveConnectivityConfigurationListResult struct { + SkipToken *string `json:"skipToken,omitempty"` + Value *[]EffectiveConnectivityConfiguration `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_queryrequestoptions.go b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_queryrequestoptions.go new file mode 100644 index 00000000000..b861fc62fb3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/model_queryrequestoptions.go @@ -0,0 +1,8 @@ +package networkmanagereffectiveconnectivityconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryRequestOptions struct { + SkipToken *string `json:"skipToken,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/version.go b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/version.go new file mode 100644 index 00000000000..cb317d4ca90 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectiveconnectivityconfiguration/version.go @@ -0,0 +1,10 @@ +package networkmanagereffectiveconnectivityconfiguration + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networkmanagereffectiveconnectivityconfiguration/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/README.md b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/README.md new file mode 100644 index 00000000000..496e81d4608 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/README.md @@ -0,0 +1,42 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules` Documentation + +The `networkmanagereffectivesecurityadminrules` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules" +``` + + +### Client Initialization + +```go +client := networkmanagereffectivesecurityadminrules.NewNetworkManagerEffectiveSecurityAdminRulesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkManagerEffectiveSecurityAdminRulesClient.ListNetworkManagerEffectiveSecurityAdminRules` + +```go +ctx := context.TODO() +id := commonids.NewVirtualNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName") + +payload := networkmanagereffectivesecurityadminrules.QueryRequestOptions{ + // ... +} + + +read, err := client.ListNetworkManagerEffectiveSecurityAdminRules(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/client.go b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/client.go new file mode 100644 index 00000000000..5685e9afd82 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/client.go @@ -0,0 +1,26 @@ +package networkmanagereffectivesecurityadminrules + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerEffectiveSecurityAdminRulesClient struct { + Client *resourcemanager.Client +} + +func NewNetworkManagerEffectiveSecurityAdminRulesClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkManagerEffectiveSecurityAdminRulesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networkmanagereffectivesecurityadminrules", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkManagerEffectiveSecurityAdminRulesClient: %+v", err) + } + + return &NetworkManagerEffectiveSecurityAdminRulesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/constants.go b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/constants.go new file mode 100644 index 00000000000..67086d778e3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/constants.go @@ -0,0 +1,321 @@ +package networkmanagereffectivesecurityadminrules + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressPrefixType string + +const ( + AddressPrefixTypeIPPrefix AddressPrefixType = "IPPrefix" + AddressPrefixTypeNetworkGroup AddressPrefixType = "NetworkGroup" + AddressPrefixTypeServiceTag AddressPrefixType = "ServiceTag" +) + +func PossibleValuesForAddressPrefixType() []string { + return []string{ + string(AddressPrefixTypeIPPrefix), + string(AddressPrefixTypeNetworkGroup), + string(AddressPrefixTypeServiceTag), + } +} + +func (s *AddressPrefixType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAddressPrefixType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAddressPrefixType(input string) (*AddressPrefixType, error) { + vals := map[string]AddressPrefixType{ + "ipprefix": AddressPrefixTypeIPPrefix, + "networkgroup": AddressPrefixTypeNetworkGroup, + "servicetag": AddressPrefixTypeServiceTag, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AddressPrefixType(input) + return &out, nil +} + +type EffectiveAdminRuleKind string + +const ( + EffectiveAdminRuleKindCustom EffectiveAdminRuleKind = "Custom" + EffectiveAdminRuleKindDefault EffectiveAdminRuleKind = "Default" +) + +func PossibleValuesForEffectiveAdminRuleKind() []string { + return []string{ + string(EffectiveAdminRuleKindCustom), + string(EffectiveAdminRuleKindDefault), + } +} + +func (s *EffectiveAdminRuleKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEffectiveAdminRuleKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEffectiveAdminRuleKind(input string) (*EffectiveAdminRuleKind, error) { + vals := map[string]EffectiveAdminRuleKind{ + "custom": EffectiveAdminRuleKindCustom, + "default": EffectiveAdminRuleKindDefault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EffectiveAdminRuleKind(input) + return &out, nil +} + +type GroupMemberType string + +const ( + GroupMemberTypeSubnet GroupMemberType = "Subnet" + GroupMemberTypeVirtualNetwork GroupMemberType = "VirtualNetwork" +) + +func PossibleValuesForGroupMemberType() []string { + return []string{ + string(GroupMemberTypeSubnet), + string(GroupMemberTypeVirtualNetwork), + } +} + +func (s *GroupMemberType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGroupMemberType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGroupMemberType(input string) (*GroupMemberType, error) { + vals := map[string]GroupMemberType{ + "subnet": GroupMemberTypeSubnet, + "virtualnetwork": GroupMemberTypeVirtualNetwork, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GroupMemberType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SecurityConfigurationRuleAccess string + +const ( + SecurityConfigurationRuleAccessAllow SecurityConfigurationRuleAccess = "Allow" + SecurityConfigurationRuleAccessAlwaysAllow SecurityConfigurationRuleAccess = "AlwaysAllow" + SecurityConfigurationRuleAccessDeny SecurityConfigurationRuleAccess = "Deny" +) + +func PossibleValuesForSecurityConfigurationRuleAccess() []string { + return []string{ + string(SecurityConfigurationRuleAccessAllow), + string(SecurityConfigurationRuleAccessAlwaysAllow), + string(SecurityConfigurationRuleAccessDeny), + } +} + +func (s *SecurityConfigurationRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityConfigurationRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityConfigurationRuleAccess(input string) (*SecurityConfigurationRuleAccess, error) { + vals := map[string]SecurityConfigurationRuleAccess{ + "allow": SecurityConfigurationRuleAccessAllow, + "alwaysallow": SecurityConfigurationRuleAccessAlwaysAllow, + "deny": SecurityConfigurationRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityConfigurationRuleAccess(input) + return &out, nil +} + +type SecurityConfigurationRuleDirection string + +const ( + SecurityConfigurationRuleDirectionInbound SecurityConfigurationRuleDirection = "Inbound" + SecurityConfigurationRuleDirectionOutbound SecurityConfigurationRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityConfigurationRuleDirection() []string { + return []string{ + string(SecurityConfigurationRuleDirectionInbound), + string(SecurityConfigurationRuleDirectionOutbound), + } +} + +func (s *SecurityConfigurationRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityConfigurationRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityConfigurationRuleDirection(input string) (*SecurityConfigurationRuleDirection, error) { + vals := map[string]SecurityConfigurationRuleDirection{ + "inbound": SecurityConfigurationRuleDirectionInbound, + "outbound": SecurityConfigurationRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityConfigurationRuleDirection(input) + return &out, nil +} + +type SecurityConfigurationRuleProtocol string + +const ( + SecurityConfigurationRuleProtocolAh SecurityConfigurationRuleProtocol = "Ah" + SecurityConfigurationRuleProtocolAny SecurityConfigurationRuleProtocol = "Any" + SecurityConfigurationRuleProtocolEsp SecurityConfigurationRuleProtocol = "Esp" + SecurityConfigurationRuleProtocolIcmp SecurityConfigurationRuleProtocol = "Icmp" + SecurityConfigurationRuleProtocolTcp SecurityConfigurationRuleProtocol = "Tcp" + SecurityConfigurationRuleProtocolUdp SecurityConfigurationRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityConfigurationRuleProtocol() []string { + return []string{ + string(SecurityConfigurationRuleProtocolAh), + string(SecurityConfigurationRuleProtocolAny), + string(SecurityConfigurationRuleProtocolEsp), + string(SecurityConfigurationRuleProtocolIcmp), + string(SecurityConfigurationRuleProtocolTcp), + string(SecurityConfigurationRuleProtocolUdp), + } +} + +func (s *SecurityConfigurationRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityConfigurationRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityConfigurationRuleProtocol(input string) (*SecurityConfigurationRuleProtocol, error) { + vals := map[string]SecurityConfigurationRuleProtocol{ + "ah": SecurityConfigurationRuleProtocolAh, + "any": SecurityConfigurationRuleProtocolAny, + "esp": SecurityConfigurationRuleProtocolEsp, + "icmp": SecurityConfigurationRuleProtocolIcmp, + "tcp": SecurityConfigurationRuleProtocolTcp, + "udp": SecurityConfigurationRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityConfigurationRuleProtocol(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/method_listnetworkmanagereffectivesecurityadminrules.go b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/method_listnetworkmanagereffectivesecurityadminrules.go new file mode 100644 index 00000000000..50c941d8756 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/method_listnetworkmanagereffectivesecurityadminrules.go @@ -0,0 +1,59 @@ +package networkmanagereffectivesecurityadminrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListNetworkManagerEffectiveSecurityAdminRulesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkManagerEffectiveSecurityAdminRulesListResult +} + +// ListNetworkManagerEffectiveSecurityAdminRules ... +func (c NetworkManagerEffectiveSecurityAdminRulesClient) ListNetworkManagerEffectiveSecurityAdminRules(ctx context.Context, id commonids.VirtualNetworkId, input QueryRequestOptions) (result ListNetworkManagerEffectiveSecurityAdminRulesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listNetworkManagerEffectiveSecurityAdminRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkManagerEffectiveSecurityAdminRulesListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_addressprefixitem.go b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_addressprefixitem.go new file mode 100644 index 00000000000..36a40aa2b75 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_addressprefixitem.go @@ -0,0 +1,9 @@ +package networkmanagereffectivesecurityadminrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressPrefixItem struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixType *AddressPrefixType `json:"addressPrefixType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_adminpropertiesformat.go b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_adminpropertiesformat.go new file mode 100644 index 00000000000..bc26b08e48e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_adminpropertiesformat.go @@ -0,0 +1,18 @@ +package networkmanagereffectivesecurityadminrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdminPropertiesFormat struct { + Access SecurityConfigurationRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Destinations *[]AddressPrefixItem `json:"destinations,omitempty"` + Direction SecurityConfigurationRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityConfigurationRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` + Sources *[]AddressPrefixItem `json:"sources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_configurationgroup.go b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_configurationgroup.go new file mode 100644 index 00000000000..bfc45b0ab70 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_configurationgroup.go @@ -0,0 +1,9 @@ +package networkmanagereffectivesecurityadminrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigurationGroup struct { + Id *string `json:"id,omitempty"` + Properties *NetworkGroupProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_defaultadminpropertiesformat.go b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_defaultadminpropertiesformat.go new file mode 100644 index 00000000000..1b0e64dbae7 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_defaultadminpropertiesformat.go @@ -0,0 +1,19 @@ +package networkmanagereffectivesecurityadminrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DefaultAdminPropertiesFormat struct { + Access *SecurityConfigurationRuleAccess `json:"access,omitempty"` + Description *string `json:"description,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Destinations *[]AddressPrefixItem `json:"destinations,omitempty"` + Direction *SecurityConfigurationRuleDirection `json:"direction,omitempty"` + Flag *string `json:"flag,omitempty"` + Priority *int64 `json:"priority,omitempty"` + Protocol *SecurityConfigurationRuleProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` + Sources *[]AddressPrefixItem `json:"sources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_effectivebasesecurityadminrule.go b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_effectivebasesecurityadminrule.go new file mode 100644 index 00000000000..d77eea3650f --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_effectivebasesecurityadminrule.go @@ -0,0 +1,88 @@ +package networkmanagereffectivesecurityadminrules + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EffectiveBaseSecurityAdminRule interface { + EffectiveBaseSecurityAdminRule() BaseEffectiveBaseSecurityAdminRuleImpl +} + +var _ EffectiveBaseSecurityAdminRule = BaseEffectiveBaseSecurityAdminRuleImpl{} + +type BaseEffectiveBaseSecurityAdminRuleImpl struct { + ConfigurationDescription *string `json:"configurationDescription,omitempty"` + Id *string `json:"id,omitempty"` + Kind EffectiveAdminRuleKind `json:"kind"` + RuleCollectionAppliesToGroups *[]NetworkManagerSecurityGroupItem `json:"ruleCollectionAppliesToGroups,omitempty"` + RuleCollectionDescription *string `json:"ruleCollectionDescription,omitempty"` + RuleGroups *[]ConfigurationGroup `json:"ruleGroups,omitempty"` +} + +func (s BaseEffectiveBaseSecurityAdminRuleImpl) EffectiveBaseSecurityAdminRule() BaseEffectiveBaseSecurityAdminRuleImpl { + return s +} + +var _ EffectiveBaseSecurityAdminRule = RawEffectiveBaseSecurityAdminRuleImpl{} + +// RawEffectiveBaseSecurityAdminRuleImpl 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 RawEffectiveBaseSecurityAdminRuleImpl struct { + effectiveBaseSecurityAdminRule BaseEffectiveBaseSecurityAdminRuleImpl + Type string + Values map[string]interface{} +} + +func (s RawEffectiveBaseSecurityAdminRuleImpl) EffectiveBaseSecurityAdminRule() BaseEffectiveBaseSecurityAdminRuleImpl { + return s.effectiveBaseSecurityAdminRule +} + +func UnmarshalEffectiveBaseSecurityAdminRuleImplementation(input []byte) (EffectiveBaseSecurityAdminRule, 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 EffectiveBaseSecurityAdminRule into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["kind"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Default") { + var out EffectiveDefaultSecurityAdminRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into EffectiveDefaultSecurityAdminRule: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Custom") { + var out EffectiveSecurityAdminRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into EffectiveSecurityAdminRule: %+v", err) + } + return out, nil + } + + var parent BaseEffectiveBaseSecurityAdminRuleImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseEffectiveBaseSecurityAdminRuleImpl: %+v", err) + } + + return RawEffectiveBaseSecurityAdminRuleImpl{ + effectiveBaseSecurityAdminRule: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_effectivedefaultsecurityadminrule.go b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_effectivedefaultsecurityadminrule.go new file mode 100644 index 00000000000..89d5f651a9f --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_effectivedefaultsecurityadminrule.go @@ -0,0 +1,60 @@ +package networkmanagereffectivesecurityadminrules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EffectiveBaseSecurityAdminRule = EffectiveDefaultSecurityAdminRule{} + +type EffectiveDefaultSecurityAdminRule struct { + Properties *DefaultAdminPropertiesFormat `json:"properties,omitempty"` + + // Fields inherited from EffectiveBaseSecurityAdminRule + + ConfigurationDescription *string `json:"configurationDescription,omitempty"` + Id *string `json:"id,omitempty"` + Kind EffectiveAdminRuleKind `json:"kind"` + RuleCollectionAppliesToGroups *[]NetworkManagerSecurityGroupItem `json:"ruleCollectionAppliesToGroups,omitempty"` + RuleCollectionDescription *string `json:"ruleCollectionDescription,omitempty"` + RuleGroups *[]ConfigurationGroup `json:"ruleGroups,omitempty"` +} + +func (s EffectiveDefaultSecurityAdminRule) EffectiveBaseSecurityAdminRule() BaseEffectiveBaseSecurityAdminRuleImpl { + return BaseEffectiveBaseSecurityAdminRuleImpl{ + ConfigurationDescription: s.ConfigurationDescription, + Id: s.Id, + Kind: s.Kind, + RuleCollectionAppliesToGroups: s.RuleCollectionAppliesToGroups, + RuleCollectionDescription: s.RuleCollectionDescription, + RuleGroups: s.RuleGroups, + } +} + +var _ json.Marshaler = EffectiveDefaultSecurityAdminRule{} + +func (s EffectiveDefaultSecurityAdminRule) MarshalJSON() ([]byte, error) { + type wrapper EffectiveDefaultSecurityAdminRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling EffectiveDefaultSecurityAdminRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling EffectiveDefaultSecurityAdminRule: %+v", err) + } + + decoded["kind"] = "Default" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling EffectiveDefaultSecurityAdminRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_effectivesecurityadminrule.go b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_effectivesecurityadminrule.go new file mode 100644 index 00000000000..8fcf50ed898 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_effectivesecurityadminrule.go @@ -0,0 +1,60 @@ +package networkmanagereffectivesecurityadminrules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EffectiveBaseSecurityAdminRule = EffectiveSecurityAdminRule{} + +type EffectiveSecurityAdminRule struct { + Properties *AdminPropertiesFormat `json:"properties,omitempty"` + + // Fields inherited from EffectiveBaseSecurityAdminRule + + ConfigurationDescription *string `json:"configurationDescription,omitempty"` + Id *string `json:"id,omitempty"` + Kind EffectiveAdminRuleKind `json:"kind"` + RuleCollectionAppliesToGroups *[]NetworkManagerSecurityGroupItem `json:"ruleCollectionAppliesToGroups,omitempty"` + RuleCollectionDescription *string `json:"ruleCollectionDescription,omitempty"` + RuleGroups *[]ConfigurationGroup `json:"ruleGroups,omitempty"` +} + +func (s EffectiveSecurityAdminRule) EffectiveBaseSecurityAdminRule() BaseEffectiveBaseSecurityAdminRuleImpl { + return BaseEffectiveBaseSecurityAdminRuleImpl{ + ConfigurationDescription: s.ConfigurationDescription, + Id: s.Id, + Kind: s.Kind, + RuleCollectionAppliesToGroups: s.RuleCollectionAppliesToGroups, + RuleCollectionDescription: s.RuleCollectionDescription, + RuleGroups: s.RuleGroups, + } +} + +var _ json.Marshaler = EffectiveSecurityAdminRule{} + +func (s EffectiveSecurityAdminRule) MarshalJSON() ([]byte, error) { + type wrapper EffectiveSecurityAdminRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling EffectiveSecurityAdminRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling EffectiveSecurityAdminRule: %+v", err) + } + + decoded["kind"] = "Custom" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling EffectiveSecurityAdminRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_networkgroupproperties.go b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_networkgroupproperties.go new file mode 100644 index 00000000000..e032fa24f5a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_networkgroupproperties.go @@ -0,0 +1,11 @@ +package networkmanagereffectivesecurityadminrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkGroupProperties struct { + Description *string `json:"description,omitempty"` + MemberType *GroupMemberType `json:"memberType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_networkmanagereffectivesecurityadminruleslistresult.go b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_networkmanagereffectivesecurityadminruleslistresult.go new file mode 100644 index 00000000000..5d6f71bcb25 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_networkmanagereffectivesecurityadminruleslistresult.go @@ -0,0 +1,51 @@ +package networkmanagereffectivesecurityadminrules + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerEffectiveSecurityAdminRulesListResult struct { + SkipToken *string `json:"skipToken,omitempty"` + Value *[]EffectiveBaseSecurityAdminRule `json:"value,omitempty"` +} + +var _ json.Unmarshaler = &NetworkManagerEffectiveSecurityAdminRulesListResult{} + +func (s *NetworkManagerEffectiveSecurityAdminRulesListResult) UnmarshalJSON(bytes []byte) error { + var decoded struct { + SkipToken *string `json:"skipToken,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.SkipToken = decoded.SkipToken + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling NetworkManagerEffectiveSecurityAdminRulesListResult into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["value"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling Value into list []json.RawMessage: %+v", err) + } + + output := make([]EffectiveBaseSecurityAdminRule, 0) + for i, val := range listTemp { + impl, err := UnmarshalEffectiveBaseSecurityAdminRuleImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'Value' for 'NetworkManagerEffectiveSecurityAdminRulesListResult': %+v", i, err) + } + output = append(output, impl) + } + s.Value = &output + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_networkmanagersecuritygroupitem.go b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_networkmanagersecuritygroupitem.go new file mode 100644 index 00000000000..47b6055e402 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_networkmanagersecuritygroupitem.go @@ -0,0 +1,8 @@ +package networkmanagereffectivesecurityadminrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerSecurityGroupItem struct { + NetworkGroupId string `json:"networkGroupId"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_queryrequestoptions.go b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_queryrequestoptions.go new file mode 100644 index 00000000000..21a08175183 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/model_queryrequestoptions.go @@ -0,0 +1,8 @@ +package networkmanagereffectivesecurityadminrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryRequestOptions struct { + SkipToken *string `json:"skipToken,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/version.go b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/version.go new file mode 100644 index 00000000000..0389edca833 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagereffectivesecurityadminrules/version.go @@ -0,0 +1,10 @@ +package networkmanagereffectivesecurityadminrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networkmanagereffectivesecurityadminrules/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/README.md b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/README.md new file mode 100644 index 00000000000..7831cef9be8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations` Documentation + +The `networkmanagerroutingconfigurations` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations" +``` + + +### Client Initialization + +```go +client := networkmanagerroutingconfigurations.NewNetworkManagerRoutingConfigurationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkManagerRoutingConfigurationsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := networkmanagerroutingconfigurations.NewRoutingConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName") + +payload := networkmanagerroutingconfigurations.NetworkManagerRoutingConfiguration{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkManagerRoutingConfigurationsClient.Delete` + +```go +ctx := context.TODO() +id := networkmanagerroutingconfigurations.NewRoutingConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName") + +if err := client.DeleteThenPoll(ctx, id, networkmanagerroutingconfigurations.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkManagerRoutingConfigurationsClient.Get` + +```go +ctx := context.TODO() +id := networkmanagerroutingconfigurations.NewRoutingConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkManagerRoutingConfigurationsClient.List` + +```go +ctx := context.TODO() +id := networkmanagerroutingconfigurations.NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + +// alternatively `client.List(ctx, id, networkmanagerroutingconfigurations.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, networkmanagerroutingconfigurations.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/client.go b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/client.go new file mode 100644 index 00000000000..cba155b1be7 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/client.go @@ -0,0 +1,26 @@ +package networkmanagerroutingconfigurations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerRoutingConfigurationsClient struct { + Client *resourcemanager.Client +} + +func NewNetworkManagerRoutingConfigurationsClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkManagerRoutingConfigurationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networkmanagerroutingconfigurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkManagerRoutingConfigurationsClient: %+v", err) + } + + return &NetworkManagerRoutingConfigurationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/constants.go b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/constants.go new file mode 100644 index 00000000000..8e6da58586c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/constants.go @@ -0,0 +1,57 @@ +package networkmanagerroutingconfigurations + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/id_networkmanager.go b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/id_networkmanager.go new file mode 100644 index 00000000000..6036bf27603 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/id_networkmanager.go @@ -0,0 +1,130 @@ +package networkmanagerroutingconfigurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkManagerId{}) +} + +var _ resourceids.ResourceId = &NetworkManagerId{} + +// NetworkManagerId is a struct representing the Resource ID for a Network Manager +type NetworkManagerId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string +} + +// NewNetworkManagerID returns a new NetworkManagerId struct +func NewNetworkManagerID(subscriptionId string, resourceGroupName string, networkManagerName string) NetworkManagerId { + return NetworkManagerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + } +} + +// ParseNetworkManagerID parses 'input' into a NetworkManagerId +func ParseNetworkManagerID(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkManagerIDInsensitively parses 'input' case-insensitively into a NetworkManagerId +// note: this method should only be used for API response data and not user input +func ParseNetworkManagerIDInsensitively(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkManagerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + return nil +} + +// ValidateNetworkManagerID checks that 'input' can be parsed as a Network Manager ID +func ValidateNetworkManagerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkManagerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Manager ID +func (id NetworkManagerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Manager ID +func (id NetworkManagerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + } +} + +// String returns a human-readable description of this Network Manager ID +func (id NetworkManagerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + } + return fmt.Sprintf("Network Manager (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/id_networkmanager_test.go b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/id_networkmanager_test.go new file mode 100644 index 00000000000..8fd49172b9d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/id_networkmanager_test.go @@ -0,0 +1,282 @@ +package networkmanagerroutingconfigurations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkManagerId{} + +func TestNewNetworkManagerID(t *testing.T) { + id := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } +} + +func TestFormatNetworkManagerID(t *testing.T) { + actual := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkManagerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestParseNetworkManagerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestSegmentsForNetworkManagerId(t *testing.T) { + segments := NetworkManagerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkManagerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/id_routingconfiguration.go b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/id_routingconfiguration.go new file mode 100644 index 00000000000..a9666fb45cd --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/id_routingconfiguration.go @@ -0,0 +1,139 @@ +package networkmanagerroutingconfigurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RoutingConfigurationId{}) +} + +var _ resourceids.ResourceId = &RoutingConfigurationId{} + +// RoutingConfigurationId is a struct representing the Resource ID for a Routing Configuration +type RoutingConfigurationId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + RoutingConfigurationName string +} + +// NewRoutingConfigurationID returns a new RoutingConfigurationId struct +func NewRoutingConfigurationID(subscriptionId string, resourceGroupName string, networkManagerName string, routingConfigurationName string) RoutingConfigurationId { + return RoutingConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + RoutingConfigurationName: routingConfigurationName, + } +} + +// ParseRoutingConfigurationID parses 'input' into a RoutingConfigurationId +func ParseRoutingConfigurationID(input string) (*RoutingConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&RoutingConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RoutingConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRoutingConfigurationIDInsensitively parses 'input' case-insensitively into a RoutingConfigurationId +// note: this method should only be used for API response data and not user input +func ParseRoutingConfigurationIDInsensitively(input string) (*RoutingConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&RoutingConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RoutingConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RoutingConfigurationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.RoutingConfigurationName, ok = input.Parsed["routingConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routingConfigurationName", input) + } + + return nil +} + +// ValidateRoutingConfigurationID checks that 'input' can be parsed as a Routing Configuration ID +func ValidateRoutingConfigurationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRoutingConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Routing Configuration ID +func (id RoutingConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/routingConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.RoutingConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Routing Configuration ID +func (id RoutingConfigurationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticRoutingConfigurations", "routingConfigurations", "routingConfigurations"), + resourceids.UserSpecifiedSegment("routingConfigurationName", "routingConfigurationName"), + } +} + +// String returns a human-readable description of this Routing Configuration ID +func (id RoutingConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Routing Configuration Name: %q", id.RoutingConfigurationName), + } + return fmt.Sprintf("Routing Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/id_routingconfiguration_test.go b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/id_routingconfiguration_test.go new file mode 100644 index 00000000000..ffe093025a3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/id_routingconfiguration_test.go @@ -0,0 +1,327 @@ +package networkmanagerroutingconfigurations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RoutingConfigurationId{} + +func TestNewRoutingConfigurationID(t *testing.T) { + id := NewRoutingConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.RoutingConfigurationName != "routingConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'RoutingConfigurationName'", id.RoutingConfigurationName, "routingConfigurationName") + } +} + +func TestFormatRoutingConfigurationID(t *testing.T) { + actual := NewRoutingConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRoutingConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RoutingConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName", + Expected: &RoutingConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + RoutingConfigurationName: "routingConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRoutingConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.RoutingConfigurationName != v.Expected.RoutingConfigurationName { + t.Fatalf("Expected %q but got %q for RoutingConfigurationName", v.Expected.RoutingConfigurationName, actual.RoutingConfigurationName) + } + + } +} + +func TestParseRoutingConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RoutingConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName", + Expected: &RoutingConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + RoutingConfigurationName: "routingConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE", + Expected: &RoutingConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + RoutingConfigurationName: "rOuTiNgCoNfIgUrAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRoutingConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.RoutingConfigurationName != v.Expected.RoutingConfigurationName { + t.Fatalf("Expected %q but got %q for RoutingConfigurationName", v.Expected.RoutingConfigurationName, actual.RoutingConfigurationName) + } + + } +} + +func TestSegmentsForRoutingConfigurationId(t *testing.T) { + segments := RoutingConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RoutingConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/method_createorupdate.go b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/method_createorupdate.go new file mode 100644 index 00000000000..ec0b2ada3f5 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/method_createorupdate.go @@ -0,0 +1,58 @@ +package networkmanagerroutingconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkManagerRoutingConfiguration +} + +// CreateOrUpdate ... +func (c NetworkManagerRoutingConfigurationsClient) CreateOrUpdate(ctx context.Context, id RoutingConfigurationId, input NetworkManagerRoutingConfiguration) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkManagerRoutingConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/method_delete.go b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/method_delete.go new file mode 100644 index 00000000000..d0b3464065a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/method_delete.go @@ -0,0 +1,100 @@ +package networkmanagerroutingconfigurations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c NetworkManagerRoutingConfigurationsClient) Delete(ctx context.Context, id RoutingConfigurationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c NetworkManagerRoutingConfigurationsClient) DeleteThenPoll(ctx context.Context, id RoutingConfigurationId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/method_get.go b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/method_get.go new file mode 100644 index 00000000000..d1be82cc918 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/method_get.go @@ -0,0 +1,53 @@ +package networkmanagerroutingconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkManagerRoutingConfiguration +} + +// Get ... +func (c NetworkManagerRoutingConfigurationsClient) Get(ctx context.Context, id RoutingConfigurationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkManagerRoutingConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/method_list.go b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/method_list.go new file mode 100644 index 00000000000..2318cf57167 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/method_list.go @@ -0,0 +1,134 @@ +package networkmanagerroutingconfigurations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkManagerRoutingConfiguration +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkManagerRoutingConfiguration +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c NetworkManagerRoutingConfigurationsClient) List(ctx context.Context, id NetworkManagerId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/routingConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkManagerRoutingConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NetworkManagerRoutingConfigurationsClient) ListComplete(ctx context.Context, id NetworkManagerId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, NetworkManagerRoutingConfigurationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkManagerRoutingConfigurationsClient) ListCompleteMatchingPredicate(ctx context.Context, id NetworkManagerId, options ListOperationOptions, predicate NetworkManagerRoutingConfigurationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NetworkManagerRoutingConfiguration, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/model_networkmanagerroutingconfiguration.go b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/model_networkmanagerroutingconfiguration.go new file mode 100644 index 00000000000..775855260e0 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/model_networkmanagerroutingconfiguration.go @@ -0,0 +1,17 @@ +package networkmanagerroutingconfigurations + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerRoutingConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkManagerRoutingConfigurationPropertiesFormat `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/model_networkmanagerroutingconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/model_networkmanagerroutingconfigurationpropertiesformat.go new file mode 100644 index 00000000000..beeb3bbf8f3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/model_networkmanagerroutingconfigurationpropertiesformat.go @@ -0,0 +1,10 @@ +package networkmanagerroutingconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerRoutingConfigurationPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/predicates.go b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/predicates.go new file mode 100644 index 00000000000..a1aaea41056 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/predicates.go @@ -0,0 +1,32 @@ +package networkmanagerroutingconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerRoutingConfigurationOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p NetworkManagerRoutingConfigurationOperationPredicate) Matches(input NetworkManagerRoutingConfiguration) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/version.go b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/version.go new file mode 100644 index 00000000000..24d3093f5e0 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagerroutingconfigurations/version.go @@ -0,0 +1,10 @@ +package networkmanagerroutingconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networkmanagerroutingconfigurations/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/README.md b/resource-manager/network/2024-07-01/networkmanagers/README.md new file mode 100644 index 00000000000..d9c4ddb7473 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/README.md @@ -0,0 +1,163 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanagers` Documentation + +The `networkmanagers` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkmanagers" +``` + + +### Client Initialization + +```go +client := networkmanagers.NewNetworkManagersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkManagersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := networkmanagers.NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + +payload := networkmanagers.NetworkManager{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkManagersClient.Delete` + +```go +ctx := context.TODO() +id := networkmanagers.NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + +if err := client.DeleteThenPoll(ctx, id, networkmanagers.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkManagersClient.Get` + +```go +ctx := context.TODO() +id := networkmanagers.NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkManagersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id, networkmanagers.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, networkmanagers.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkManagersClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id, networkmanagers.DefaultListBySubscriptionOperationOptions())` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id, networkmanagers.DefaultListBySubscriptionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkManagersClient.NetworkManagerCommitsPost` + +```go +ctx := context.TODO() +id := networkmanagers.NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + +payload := networkmanagers.NetworkManagerCommit{ + // ... +} + + +if err := client.NetworkManagerCommitsPostThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkManagersClient.NetworkManagerDeploymentStatusList` + +```go +ctx := context.TODO() +id := networkmanagers.NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + +payload := networkmanagers.NetworkManagerDeploymentStatusParameter{ + // ... +} + + +read, err := client.NetworkManagerDeploymentStatusList(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkManagersClient.Patch` + +```go +ctx := context.TODO() +id := networkmanagers.NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + +payload := networkmanagers.PatchObject{ + // ... +} + + +read, err := client.Patch(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/networkmanagers/client.go b/resource-manager/network/2024-07-01/networkmanagers/client.go new file mode 100644 index 00000000000..64a4e799646 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/client.go @@ -0,0 +1,26 @@ +package networkmanagers + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagersClient struct { + Client *resourcemanager.Client +} + +func NewNetworkManagersClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkManagersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networkmanagers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkManagersClient: %+v", err) + } + + return &NetworkManagersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/constants.go b/resource-manager/network/2024-07-01/networkmanagers/constants.go new file mode 100644 index 00000000000..03e251a6601 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/constants.go @@ -0,0 +1,151 @@ +package networkmanagers + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigurationType string + +const ( + ConfigurationTypeConnectivity ConfigurationType = "Connectivity" + ConfigurationTypeRouting ConfigurationType = "Routing" + ConfigurationTypeSecurityAdmin ConfigurationType = "SecurityAdmin" + ConfigurationTypeSecurityUser ConfigurationType = "SecurityUser" +) + +func PossibleValuesForConfigurationType() []string { + return []string{ + string(ConfigurationTypeConnectivity), + string(ConfigurationTypeRouting), + string(ConfigurationTypeSecurityAdmin), + string(ConfigurationTypeSecurityUser), + } +} + +func (s *ConfigurationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConfigurationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConfigurationType(input string) (*ConfigurationType, error) { + vals := map[string]ConfigurationType{ + "connectivity": ConfigurationTypeConnectivity, + "routing": ConfigurationTypeRouting, + "securityadmin": ConfigurationTypeSecurityAdmin, + "securityuser": ConfigurationTypeSecurityUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConfigurationType(input) + return &out, nil +} + +type DeploymentStatus string + +const ( + DeploymentStatusDeployed DeploymentStatus = "Deployed" + DeploymentStatusDeploying DeploymentStatus = "Deploying" + DeploymentStatusFailed DeploymentStatus = "Failed" + DeploymentStatusNotStarted DeploymentStatus = "NotStarted" +) + +func PossibleValuesForDeploymentStatus() []string { + return []string{ + string(DeploymentStatusDeployed), + string(DeploymentStatusDeploying), + string(DeploymentStatusFailed), + string(DeploymentStatusNotStarted), + } +} + +func (s *DeploymentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeploymentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeploymentStatus(input string) (*DeploymentStatus, error) { + vals := map[string]DeploymentStatus{ + "deployed": DeploymentStatusDeployed, + "deploying": DeploymentStatusDeploying, + "failed": DeploymentStatusFailed, + "notstarted": DeploymentStatusNotStarted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeploymentStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/id_networkmanager.go b/resource-manager/network/2024-07-01/networkmanagers/id_networkmanager.go new file mode 100644 index 00000000000..35d0899f86c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/id_networkmanager.go @@ -0,0 +1,130 @@ +package networkmanagers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkManagerId{}) +} + +var _ resourceids.ResourceId = &NetworkManagerId{} + +// NetworkManagerId is a struct representing the Resource ID for a Network Manager +type NetworkManagerId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string +} + +// NewNetworkManagerID returns a new NetworkManagerId struct +func NewNetworkManagerID(subscriptionId string, resourceGroupName string, networkManagerName string) NetworkManagerId { + return NetworkManagerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + } +} + +// ParseNetworkManagerID parses 'input' into a NetworkManagerId +func ParseNetworkManagerID(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkManagerIDInsensitively parses 'input' case-insensitively into a NetworkManagerId +// note: this method should only be used for API response data and not user input +func ParseNetworkManagerIDInsensitively(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkManagerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + return nil +} + +// ValidateNetworkManagerID checks that 'input' can be parsed as a Network Manager ID +func ValidateNetworkManagerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkManagerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Manager ID +func (id NetworkManagerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Manager ID +func (id NetworkManagerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + } +} + +// String returns a human-readable description of this Network Manager ID +func (id NetworkManagerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + } + return fmt.Sprintf("Network Manager (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/id_networkmanager_test.go b/resource-manager/network/2024-07-01/networkmanagers/id_networkmanager_test.go new file mode 100644 index 00000000000..e8461a127b6 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/id_networkmanager_test.go @@ -0,0 +1,282 @@ +package networkmanagers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkManagerId{} + +func TestNewNetworkManagerID(t *testing.T) { + id := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } +} + +func TestFormatNetworkManagerID(t *testing.T) { + actual := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkManagerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestParseNetworkManagerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestSegmentsForNetworkManagerId(t *testing.T) { + segments := NetworkManagerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkManagerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/method_createorupdate.go b/resource-manager/network/2024-07-01/networkmanagers/method_createorupdate.go new file mode 100644 index 00000000000..cdce0892e43 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/method_createorupdate.go @@ -0,0 +1,58 @@ +package networkmanagers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkManager +} + +// CreateOrUpdate ... +func (c NetworkManagersClient) CreateOrUpdate(ctx context.Context, id NetworkManagerId, input NetworkManager) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkManager + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/method_delete.go b/resource-manager/network/2024-07-01/networkmanagers/method_delete.go new file mode 100644 index 00000000000..a9619efb0e2 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/method_delete.go @@ -0,0 +1,100 @@ +package networkmanagers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c NetworkManagersClient) Delete(ctx context.Context, id NetworkManagerId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c NetworkManagersClient) DeleteThenPoll(ctx context.Context, id NetworkManagerId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/method_get.go b/resource-manager/network/2024-07-01/networkmanagers/method_get.go new file mode 100644 index 00000000000..ed6b5d9ec82 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/method_get.go @@ -0,0 +1,53 @@ +package networkmanagers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkManager +} + +// Get ... +func (c NetworkManagersClient) Get(ctx context.Context, id NetworkManagerId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkManager + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/method_list.go b/resource-manager/network/2024-07-01/networkmanagers/method_list.go new file mode 100644 index 00000000000..902c41d52b3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/method_list.go @@ -0,0 +1,135 @@ +package networkmanagers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkManager +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkManager +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c NetworkManagersClient) List(ctx context.Context, id commonids.ResourceGroupId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/networkManagers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkManager `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NetworkManagersClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, NetworkManagerOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkManagersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListOperationOptions, predicate NetworkManagerOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NetworkManager, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/method_listbysubscription.go b/resource-manager/network/2024-07-01/networkmanagers/method_listbysubscription.go new file mode 100644 index 00000000000..d1e8f2d72a3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/method_listbysubscription.go @@ -0,0 +1,135 @@ +package networkmanagers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkManager +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkManager +} + +type ListBySubscriptionOperationOptions struct { + Top *int64 +} + +func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { + return ListBySubscriptionOperationOptions{} +} + +func (o ListBySubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c NetworkManagersClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/networkManagers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkManager `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c NetworkManagersClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, NetworkManagerOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkManagersClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions, predicate NetworkManagerOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]NetworkManager, 0) + + resp, err := c.ListBySubscription(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/method_networkmanagercommitspost.go b/resource-manager/network/2024-07-01/networkmanagers/method_networkmanagercommitspost.go new file mode 100644 index 00000000000..6d93c0512d6 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/method_networkmanagercommitspost.go @@ -0,0 +1,75 @@ +package networkmanagers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerCommitsPostOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NetworkManagerCommit +} + +// NetworkManagerCommitsPost ... +func (c NetworkManagersClient) NetworkManagerCommitsPost(ctx context.Context, id NetworkManagerId, input NetworkManagerCommit) (result NetworkManagerCommitsPostOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/commit", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// NetworkManagerCommitsPostThenPoll performs NetworkManagerCommitsPost then polls until it's completed +func (c NetworkManagersClient) NetworkManagerCommitsPostThenPoll(ctx context.Context, id NetworkManagerId, input NetworkManagerCommit) error { + result, err := c.NetworkManagerCommitsPost(ctx, id, input) + if err != nil { + return fmt.Errorf("performing NetworkManagerCommitsPost: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after NetworkManagerCommitsPost: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/method_networkmanagerdeploymentstatuslist.go b/resource-manager/network/2024-07-01/networkmanagers/method_networkmanagerdeploymentstatuslist.go new file mode 100644 index 00000000000..db1a1d144ac --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/method_networkmanagerdeploymentstatuslist.go @@ -0,0 +1,58 @@ +package networkmanagers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerDeploymentStatusListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkManagerDeploymentStatusListResult +} + +// NetworkManagerDeploymentStatusList ... +func (c NetworkManagersClient) NetworkManagerDeploymentStatusList(ctx context.Context, id NetworkManagerId, input NetworkManagerDeploymentStatusParameter) (result NetworkManagerDeploymentStatusListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listDeploymentStatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkManagerDeploymentStatusListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/method_patch.go b/resource-manager/network/2024-07-01/networkmanagers/method_patch.go new file mode 100644 index 00000000000..4aae0d60709 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/method_patch.go @@ -0,0 +1,57 @@ +package networkmanagers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PatchOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkManager +} + +// Patch ... +func (c NetworkManagersClient) Patch(ctx context.Context, id NetworkManagerId, input PatchObject) (result PatchOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkManager + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/model_crosstenantscopes.go b/resource-manager/network/2024-07-01/networkmanagers/model_crosstenantscopes.go new file mode 100644 index 00000000000..537d9c70d4a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/model_crosstenantscopes.go @@ -0,0 +1,10 @@ +package networkmanagers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CrossTenantScopes struct { + ManagementGroups *[]string `json:"managementGroups,omitempty"` + Subscriptions *[]string `json:"subscriptions,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/model_networkmanager.go b/resource-manager/network/2024-07-01/networkmanagers/model_networkmanager.go new file mode 100644 index 00000000000..8f98dec3ed2 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/model_networkmanager.go @@ -0,0 +1,19 @@ +package networkmanagers + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManager struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkManagerProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagercommit.go b/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagercommit.go new file mode 100644 index 00000000000..8649d0c0da8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagercommit.go @@ -0,0 +1,11 @@ +package networkmanagers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerCommit struct { + CommitId *string `json:"commitId,omitempty"` + CommitType ConfigurationType `json:"commitType"` + ConfigurationIds *[]string `json:"configurationIds,omitempty"` + TargetLocations []string `json:"targetLocations"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagerdeploymentstatus.go b/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagerdeploymentstatus.go new file mode 100644 index 00000000000..5727d45e848 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagerdeploymentstatus.go @@ -0,0 +1,31 @@ +package networkmanagers + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerDeploymentStatus struct { + CommitTime *string `json:"commitTime,omitempty"` + ConfigurationIds *[]string `json:"configurationIds,omitempty"` + DeploymentStatus *DeploymentStatus `json:"deploymentStatus,omitempty"` + DeploymentType *ConfigurationType `json:"deploymentType,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + Region *string `json:"region,omitempty"` +} + +func (o *NetworkManagerDeploymentStatus) GetCommitTimeAsTime() (*time.Time, error) { + if o.CommitTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CommitTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *NetworkManagerDeploymentStatus) SetCommitTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CommitTime = &formatted +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagerdeploymentstatuslistresult.go b/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagerdeploymentstatuslistresult.go new file mode 100644 index 00000000000..26a44c297a2 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagerdeploymentstatuslistresult.go @@ -0,0 +1,9 @@ +package networkmanagers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerDeploymentStatusListResult struct { + SkipToken *string `json:"skipToken,omitempty"` + Value *[]NetworkManagerDeploymentStatus `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagerdeploymentstatusparameter.go b/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagerdeploymentstatusparameter.go new file mode 100644 index 00000000000..1eb70a07ac3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagerdeploymentstatusparameter.go @@ -0,0 +1,10 @@ +package networkmanagers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerDeploymentStatusParameter struct { + DeploymentTypes *[]ConfigurationType `json:"deploymentTypes,omitempty"` + Regions *[]string `json:"regions,omitempty"` + SkipToken *string `json:"skipToken,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagerproperties.go b/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagerproperties.go new file mode 100644 index 00000000000..6f1230cb90a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagerproperties.go @@ -0,0 +1,12 @@ +package networkmanagers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerProperties struct { + Description *string `json:"description,omitempty"` + NetworkManagerScopeAccesses *[]ConfigurationType `json:"networkManagerScopeAccesses,omitempty"` + NetworkManagerScopes NetworkManagerPropertiesNetworkManagerScopes `json:"networkManagerScopes"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagerpropertiesnetworkmanagerscopes.go b/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagerpropertiesnetworkmanagerscopes.go new file mode 100644 index 00000000000..2a91fc5b601 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/model_networkmanagerpropertiesnetworkmanagerscopes.go @@ -0,0 +1,10 @@ +package networkmanagers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerPropertiesNetworkManagerScopes struct { + CrossTenantScopes *[]CrossTenantScopes `json:"crossTenantScopes,omitempty"` + ManagementGroups *[]string `json:"managementGroups,omitempty"` + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/model_patchobject.go b/resource-manager/network/2024-07-01/networkmanagers/model_patchobject.go new file mode 100644 index 00000000000..775ef598685 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/model_patchobject.go @@ -0,0 +1,8 @@ +package networkmanagers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PatchObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/predicates.go b/resource-manager/network/2024-07-01/networkmanagers/predicates.go new file mode 100644 index 00000000000..7c1597c2666 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/predicates.go @@ -0,0 +1,37 @@ +package networkmanagers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p NetworkManagerOperationPredicate) Matches(input NetworkManager) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/networkmanagers/version.go b/resource-manager/network/2024-07-01/networkmanagers/version.go new file mode 100644 index 00000000000..c3ef4a69863 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkmanagers/version.go @@ -0,0 +1,10 @@ +package networkmanagers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networkmanagers/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/README.md b/resource-manager/network/2024-07-01/networkprofiles/README.md new file mode 100644 index 00000000000..60f3dd5fb7e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/README.md @@ -0,0 +1,125 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkprofiles` Documentation + +The `networkprofiles` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkprofiles" +``` + + +### Client Initialization + +```go +client := networkprofiles.NewNetworkProfilesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkProfilesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := networkprofiles.NewNetworkProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkProfileName") + +payload := networkprofiles.NetworkProfile{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkProfilesClient.Delete` + +```go +ctx := context.TODO() +id := networkprofiles.NewNetworkProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkProfileName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkProfilesClient.Get` + +```go +ctx := context.TODO() +id := networkprofiles.NewNetworkProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkProfileName") + +read, err := client.Get(ctx, id, networkprofiles.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkProfilesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkProfilesClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkProfilesClient.UpdateTags` + +```go +ctx := context.TODO() +id := networkprofiles.NewNetworkProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkProfileName") + +payload := networkprofiles.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/networkprofiles/client.go b/resource-manager/network/2024-07-01/networkprofiles/client.go new file mode 100644 index 00000000000..33a4e0626aa --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/client.go @@ -0,0 +1,26 @@ +package networkprofiles + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkProfilesClient struct { + Client *resourcemanager.Client +} + +func NewNetworkProfilesClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkProfilesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networkprofiles", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkProfilesClient: %+v", err) + } + + return &NetworkProfilesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/constants.go b/resource-manager/network/2024-07-01/networkprofiles/constants.go new file mode 100644 index 00000000000..26b2ce61491 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/constants.go @@ -0,0 +1,1204 @@ +package networkprofiles + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/id_networkprofile.go b/resource-manager/network/2024-07-01/networkprofiles/id_networkprofile.go new file mode 100644 index 00000000000..e2a16f7fdfa --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/id_networkprofile.go @@ -0,0 +1,130 @@ +package networkprofiles + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkProfileId{}) +} + +var _ resourceids.ResourceId = &NetworkProfileId{} + +// NetworkProfileId is a struct representing the Resource ID for a Network Profile +type NetworkProfileId struct { + SubscriptionId string + ResourceGroupName string + NetworkProfileName string +} + +// NewNetworkProfileID returns a new NetworkProfileId struct +func NewNetworkProfileID(subscriptionId string, resourceGroupName string, networkProfileName string) NetworkProfileId { + return NetworkProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkProfileName: networkProfileName, + } +} + +// ParseNetworkProfileID parses 'input' into a NetworkProfileId +func ParseNetworkProfileID(input string) (*NetworkProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkProfileIDInsensitively parses 'input' case-insensitively into a NetworkProfileId +// note: this method should only be used for API response data and not user input +func ParseNetworkProfileIDInsensitively(input string) (*NetworkProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkProfileId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkProfileName, ok = input.Parsed["networkProfileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkProfileName", input) + } + + return nil +} + +// ValidateNetworkProfileID checks that 'input' can be parsed as a Network Profile ID +func ValidateNetworkProfileID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Profile ID +func (id NetworkProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkProfiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Profile ID +func (id NetworkProfileId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkProfiles", "networkProfiles", "networkProfiles"), + resourceids.UserSpecifiedSegment("networkProfileName", "networkProfileName"), + } +} + +// String returns a human-readable description of this Network Profile ID +func (id NetworkProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Profile Name: %q", id.NetworkProfileName), + } + return fmt.Sprintf("Network Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/id_networkprofile_test.go b/resource-manager/network/2024-07-01/networkprofiles/id_networkprofile_test.go new file mode 100644 index 00000000000..68dcf256130 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/id_networkprofile_test.go @@ -0,0 +1,282 @@ +package networkprofiles + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkProfileId{} + +func TestNewNetworkProfileID(t *testing.T) { + id := NewNetworkProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkProfileName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkProfileName != "networkProfileName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkProfileName'", id.NetworkProfileName, "networkProfileName") + } +} + +func TestFormatNetworkProfileID(t *testing.T) { + actual := NewNetworkProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkProfileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkProfiles/networkProfileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkProfiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkProfiles/networkProfileName", + Expected: &NetworkProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkProfileName: "networkProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkProfiles/networkProfileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkProfileID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkProfileName != v.Expected.NetworkProfileName { + t.Fatalf("Expected %q but got %q for NetworkProfileName", v.Expected.NetworkProfileName, actual.NetworkProfileName) + } + + } +} + +func TestParseNetworkProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkProfiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkPrOfIlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkProfiles/networkProfileName", + Expected: &NetworkProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkProfileName: "networkProfileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkProfiles/networkProfileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkPrOfIlEs/nEtWoRkPrOfIlEnAmE", + Expected: &NetworkProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkProfileName: "nEtWoRkPrOfIlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkPrOfIlEs/nEtWoRkPrOfIlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkProfileIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkProfileName != v.Expected.NetworkProfileName { + t.Fatalf("Expected %q but got %q for NetworkProfileName", v.Expected.NetworkProfileName, actual.NetworkProfileName) + } + + } +} + +func TestSegmentsForNetworkProfileId(t *testing.T) { + segments := NetworkProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkProfileId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/method_createorupdate.go b/resource-manager/network/2024-07-01/networkprofiles/method_createorupdate.go new file mode 100644 index 00000000000..24ed5940195 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/method_createorupdate.go @@ -0,0 +1,58 @@ +package networkprofiles + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkProfile +} + +// CreateOrUpdate ... +func (c NetworkProfilesClient) CreateOrUpdate(ctx context.Context, id NetworkProfileId, input NetworkProfile) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkProfile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/method_delete.go b/resource-manager/network/2024-07-01/networkprofiles/method_delete.go new file mode 100644 index 00000000000..c5564f89c85 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/method_delete.go @@ -0,0 +1,71 @@ +package networkprofiles + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c NetworkProfilesClient) Delete(ctx context.Context, id NetworkProfileId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c NetworkProfilesClient) DeleteThenPoll(ctx context.Context, id NetworkProfileId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/method_get.go b/resource-manager/network/2024-07-01/networkprofiles/method_get.go new file mode 100644 index 00000000000..a0149c188f7 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/method_get.go @@ -0,0 +1,83 @@ +package networkprofiles + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkProfile +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c NetworkProfilesClient) Get(ctx context.Context, id NetworkProfileId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkProfile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/method_list.go b/resource-manager/network/2024-07-01/networkprofiles/method_list.go new file mode 100644 index 00000000000..e1bce2a2aa6 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/method_list.go @@ -0,0 +1,106 @@ +package networkprofiles + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkProfile +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkProfile +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c NetworkProfilesClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/networkProfiles", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NetworkProfilesClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, NetworkProfileOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkProfilesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate NetworkProfileOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NetworkProfile, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/method_listall.go b/resource-manager/network/2024-07-01/networkprofiles/method_listall.go new file mode 100644 index 00000000000..c8509368cef --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/method_listall.go @@ -0,0 +1,106 @@ +package networkprofiles + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkProfile +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkProfile +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c NetworkProfilesClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/networkProfiles", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c NetworkProfilesClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, NetworkProfileOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkProfilesClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate NetworkProfileOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]NetworkProfile, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/method_updatetags.go b/resource-manager/network/2024-07-01/networkprofiles/method_updatetags.go new file mode 100644 index 00000000000..757952def30 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/method_updatetags.go @@ -0,0 +1,57 @@ +package networkprofiles + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkProfile +} + +// UpdateTags ... +func (c NetworkProfilesClient) UpdateTags(ctx context.Context, id NetworkProfileId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkProfile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/networkprofiles/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..0452928be63 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/networkprofiles/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..03bee9ad4ae --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..7a1eea7761a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/networkprofiles/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..4e9c7a30701 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..b3a527e5678 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/networkprofiles/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..a3c9e8c4026 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..962d80f7a83 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_backendaddresspool.go b/resource-manager/network/2024-07-01/networkprofiles/model_backendaddresspool.go new file mode 100644 index 00000000000..b7491b172ed --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..d1e4d94bf27 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterface.go b/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterface.go new file mode 100644 index 00000000000..8319fdf7442 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterface.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerNetworkInterface struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ContainerNetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterfaceconfiguration.go b/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterfaceconfiguration.go new file mode 100644 index 00000000000..1d0f89e15b4 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterfaceconfiguration.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerNetworkInterfaceConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ContainerNetworkInterfaceConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterfaceconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterfaceconfigurationpropertiesformat.go new file mode 100644 index 00000000000..1e85f54153a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterfaceconfigurationpropertiesformat.go @@ -0,0 +1,10 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerNetworkInterfaceConfigurationPropertiesFormat struct { + ContainerNetworkInterfaces *[]SubResource `json:"containerNetworkInterfaces,omitempty"` + IPConfigurations *[]IPConfigurationProfile `json:"ipConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterfaceipconfiguration.go new file mode 100644 index 00000000000..e74b8c6d59e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterfaceipconfiguration.go @@ -0,0 +1,11 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerNetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ContainerNetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..07db6c62c7a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,8 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerNetworkInterfaceIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterfacepropertiesformat.go new file mode 100644 index 00000000000..1c1efc89484 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_containernetworkinterfacepropertiesformat.go @@ -0,0 +1,11 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerNetworkInterfacePropertiesFormat struct { + Container *SubResource `json:"container,omitempty"` + ContainerNetworkInterfaceConfiguration *ContainerNetworkInterfaceConfiguration `json:"containerNetworkInterfaceConfiguration,omitempty"` + IPConfigurations *[]ContainerNetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..4860aa0e2f3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_ddossettings.go b/resource-manager/network/2024-07-01/networkprofiles/model_ddossettings.go new file mode 100644 index 00000000000..c5dc78bcc06 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_ddossettings.go @@ -0,0 +1,9 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_delegation.go b/resource-manager/network/2024-07-01/networkprofiles/model_delegation.go new file mode 100644 index 00000000000..0195b7d30c3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_delegation.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_flowlog.go b/resource-manager/network/2024-07-01/networkprofiles/model_flowlog.go new file mode 100644 index 00000000000..44e961c1ca2 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_flowlog.go @@ -0,0 +1,19 @@ +package networkprofiles + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/networkprofiles/model_flowlogformatparameters.go new file mode 100644 index 00000000000..b92557232ff --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..fd435dc751c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/networkprofiles/model_frontendipconfiguration.go new file mode 100644 index 00000000000..db5d6938998 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package networkprofiles + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..82aea183299 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/networkprofiles/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..cb7a2956f0e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_inboundnatrule.go b/resource-manager/network/2024-07-01/networkprofiles/model_inboundnatrule.go new file mode 100644 index 00000000000..6b089d6c65c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..0a3a0779932 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/networkprofiles/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..8561fdb8a87 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/networkprofiles/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..618628679b9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_ipconfiguration.go b/resource-manager/network/2024-07-01/networkprofiles/model_ipconfiguration.go new file mode 100644 index 00000000000..940760b2c92 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/networkprofiles/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..373777029b1 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..ad8fa03c4f4 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..b90aa191e92 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_iptag.go b/resource-manager/network/2024-07-01/networkprofiles/model_iptag.go new file mode 100644 index 00000000000..2e45e454060 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_iptag.go @@ -0,0 +1,9 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/networkprofiles/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..4484795804f --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..203a8fab13e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_natgateway.go b/resource-manager/network/2024-07-01/networkprofiles/model_natgateway.go new file mode 100644 index 00000000000..6197c623763 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_natgateway.go @@ -0,0 +1,20 @@ +package networkprofiles + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..74b2a64e620 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_natgatewaysku.go b/resource-manager/network/2024-07-01/networkprofiles/model_natgatewaysku.go new file mode 100644 index 00000000000..c3c91d290f2 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_natruleportmapping.go b/resource-manager/network/2024-07-01/networkprofiles/model_natruleportmapping.go new file mode 100644 index 00000000000..033011c8a8b --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_networkinterface.go b/resource-manager/network/2024-07-01/networkprofiles/model_networkinterface.go new file mode 100644 index 00000000000..68e610eeff9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_networkinterface.go @@ -0,0 +1,19 @@ +package networkprofiles + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..8451913a32f --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..139342da931 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..2456f55b927 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..34110f0cec5 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..ce1a26c54a8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..daf580431c6 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..8a7e2121888 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_networkprofile.go b/resource-manager/network/2024-07-01/networkprofiles/model_networkprofile.go new file mode 100644 index 00000000000..b11865bfdd6 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_networkprofile.go @@ -0,0 +1,14 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkProfilePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_networkprofilepropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_networkprofilepropertiesformat.go new file mode 100644 index 00000000000..cf66d34892c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_networkprofilepropertiesformat.go @@ -0,0 +1,11 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkProfilePropertiesFormat struct { + ContainerNetworkInterfaceConfigurations *[]ContainerNetworkInterfaceConfiguration `json:"containerNetworkInterfaceConfigurations,omitempty"` + ContainerNetworkInterfaces *[]ContainerNetworkInterface `json:"containerNetworkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/networkprofiles/model_networksecuritygroup.go new file mode 100644 index 00000000000..b24d89a9bdf --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..4a7e6641883 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_privateendpoint.go b/resource-manager/network/2024-07-01/networkprofiles/model_privateendpoint.go new file mode 100644 index 00000000000..5fcc4823c22 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_privateendpoint.go @@ -0,0 +1,19 @@ +package networkprofiles + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/networkprofiles/model_privateendpointconnection.go new file mode 100644 index 00000000000..5ef26aa759d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/networkprofiles/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..ae03a204241 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/networkprofiles/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..eb56313d0fe --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/networkprofiles/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..c252cc443f7 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/networkprofiles/model_privateendpointproperties.go new file mode 100644 index 00000000000..d63068a30ea --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkservice.go b/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkservice.go new file mode 100644 index 00000000000..13e1f313103 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package networkprofiles + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..f7c7b981511 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..36ba1ab614d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..6c4d7083fb9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..556206b6040 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..7cdb9347d51 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..b1c8585be20 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_publicipaddress.go b/resource-manager/network/2024-07-01/networkprofiles/model_publicipaddress.go new file mode 100644 index 00000000000..040a0bb56e8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_publicipaddress.go @@ -0,0 +1,22 @@ +package networkprofiles + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/networkprofiles/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..3172667a9f8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..9e8c3ce846b --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/networkprofiles/model_publicipaddresssku.go new file mode 100644 index 00000000000..af7b63fcdc5 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/networkprofiles/model_resourcenavigationlink.go new file mode 100644 index 00000000000..d8706b6bc4d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..b9a518cd2ae --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_resourceset.go b/resource-manager/network/2024-07-01/networkprofiles/model_resourceset.go new file mode 100644 index 00000000000..028384b4467 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_resourceset.go @@ -0,0 +1,8 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/networkprofiles/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..a39da241fee --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_route.go b/resource-manager/network/2024-07-01/networkprofiles/model_route.go new file mode 100644 index 00000000000..01d1b1aee3b --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_route.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_routepropertiesformat.go new file mode 100644 index 00000000000..a0fba15da36 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_routetable.go b/resource-manager/network/2024-07-01/networkprofiles/model_routetable.go new file mode 100644 index 00000000000..e98510e4a99 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_routetable.go @@ -0,0 +1,14 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..d3d001ea19c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_securityrule.go b/resource-manager/network/2024-07-01/networkprofiles/model_securityrule.go new file mode 100644 index 00000000000..d3a303b69a8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_securityrule.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..5a6f0550760 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/networkprofiles/model_serviceassociationlink.go new file mode 100644 index 00000000000..185baa31acb --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..a8ddcda5b29 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..bbe89cb1074 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/networkprofiles/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..fc7682e49f7 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/networkprofiles/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..49d3abcfdf1 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..59c9a98a4df --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..c41bd5c801b --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..b96cc0a7ddc --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_subnet.go b/resource-manager/network/2024-07-01/networkprofiles/model_subnet.go new file mode 100644 index 00000000000..92e0d90839e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_subnet.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..dd1cb189d22 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_subresource.go b/resource-manager/network/2024-07-01/networkprofiles/model_subresource.go new file mode 100644 index 00000000000..e7710003aae --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_subresource.go @@ -0,0 +1,8 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_tagsobject.go b/resource-manager/network/2024-07-01/networkprofiles/model_tagsobject.go new file mode 100644 index 00000000000..4b300699106 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_tagsobject.go @@ -0,0 +1,8 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/networkprofiles/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..43e8bd0f29a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/networkprofiles/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..67da0952e73 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/networkprofiles/model_virtualnetworktap.go new file mode 100644 index 00000000000..21bb960f571 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/networkprofiles/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..3e8521e5beb --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/predicates.go b/resource-manager/network/2024-07-01/networkprofiles/predicates.go new file mode 100644 index 00000000000..c8b72ff46b2 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/predicates.go @@ -0,0 +1,37 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkProfileOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p NetworkProfileOperationPredicate) Matches(input NetworkProfile) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/networkprofiles/version.go b/resource-manager/network/2024-07-01/networkprofiles/version.go new file mode 100644 index 00000000000..f4798060a88 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkprofiles/version.go @@ -0,0 +1,10 @@ +package networkprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networkprofiles/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/README.md b/resource-manager/network/2024-07-01/networksecuritygroups/README.md new file mode 100644 index 00000000000..f07d8e0dcbc --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecuritygroups` Documentation + +The `networksecuritygroups` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecuritygroups" +``` + + +### Client Initialization + +```go +client := networksecuritygroups.NewNetworkSecurityGroupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkSecurityGroupsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := networksecuritygroups.NewNetworkSecurityGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName") + +payload := networksecuritygroups.NetworkSecurityGroup{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkSecurityGroupsClient.Delete` + +```go +ctx := context.TODO() +id := networksecuritygroups.NewNetworkSecurityGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkSecurityGroupsClient.Get` + +```go +ctx := context.TODO() +id := networksecuritygroups.NewNetworkSecurityGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName") + +read, err := client.Get(ctx, id, networksecuritygroups.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkSecurityGroupsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkSecurityGroupsClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkSecurityGroupsClient.UpdateTags` + +```go +ctx := context.TODO() +id := networksecuritygroups.NewNetworkSecurityGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName") + +payload := networksecuritygroups.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/client.go b/resource-manager/network/2024-07-01/networksecuritygroups/client.go new file mode 100644 index 00000000000..d490fa41c78 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/client.go @@ -0,0 +1,26 @@ +package networksecuritygroups + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupsClient struct { + Client *resourcemanager.Client +} + +func NewNetworkSecurityGroupsClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkSecurityGroupsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networksecuritygroups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkSecurityGroupsClient: %+v", err) + } + + return &NetworkSecurityGroupsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/constants.go b/resource-manager/network/2024-07-01/networksecuritygroups/constants.go new file mode 100644 index 00000000000..15d227c0883 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/constants.go @@ -0,0 +1,1204 @@ +package networksecuritygroups + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/id_networksecuritygroup.go b/resource-manager/network/2024-07-01/networksecuritygroups/id_networksecuritygroup.go new file mode 100644 index 00000000000..5b1f77f1061 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/id_networksecuritygroup.go @@ -0,0 +1,130 @@ +package networksecuritygroups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkSecurityGroupId{}) +} + +var _ resourceids.ResourceId = &NetworkSecurityGroupId{} + +// NetworkSecurityGroupId is a struct representing the Resource ID for a Network Security Group +type NetworkSecurityGroupId struct { + SubscriptionId string + ResourceGroupName string + NetworkSecurityGroupName string +} + +// NewNetworkSecurityGroupID returns a new NetworkSecurityGroupId struct +func NewNetworkSecurityGroupID(subscriptionId string, resourceGroupName string, networkSecurityGroupName string) NetworkSecurityGroupId { + return NetworkSecurityGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkSecurityGroupName: networkSecurityGroupName, + } +} + +// ParseNetworkSecurityGroupID parses 'input' into a NetworkSecurityGroupId +func ParseNetworkSecurityGroupID(input string) (*NetworkSecurityGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkSecurityGroupIDInsensitively parses 'input' case-insensitively into a NetworkSecurityGroupId +// note: this method should only be used for API response data and not user input +func ParseNetworkSecurityGroupIDInsensitively(input string) (*NetworkSecurityGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkSecurityGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkSecurityGroupName, ok = input.Parsed["networkSecurityGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityGroupName", input) + } + + return nil +} + +// ValidateNetworkSecurityGroupID checks that 'input' can be parsed as a Network Security Group ID +func ValidateNetworkSecurityGroupID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkSecurityGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Security Group ID +func (id NetworkSecurityGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkSecurityGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Security Group ID +func (id NetworkSecurityGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkSecurityGroups", "networkSecurityGroups", "networkSecurityGroups"), + resourceids.UserSpecifiedSegment("networkSecurityGroupName", "networkSecurityGroupName"), + } +} + +// String returns a human-readable description of this Network Security Group ID +func (id NetworkSecurityGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Security Group Name: %q", id.NetworkSecurityGroupName), + } + return fmt.Sprintf("Network Security Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/id_networksecuritygroup_test.go b/resource-manager/network/2024-07-01/networksecuritygroups/id_networksecuritygroup_test.go new file mode 100644 index 00000000000..e07cf240c4b --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/id_networksecuritygroup_test.go @@ -0,0 +1,282 @@ +package networksecuritygroups + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkSecurityGroupId{} + +func TestNewNetworkSecurityGroupID(t *testing.T) { + id := NewNetworkSecurityGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkSecurityGroupName != "networkSecurityGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityGroupName'", id.NetworkSecurityGroupName, "networkSecurityGroupName") + } +} + +func TestFormatNetworkSecurityGroupID(t *testing.T) { + actual := NewNetworkSecurityGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkSecurityGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName", + Expected: &NetworkSecurityGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityGroupName: "networkSecurityGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityGroupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityGroupName != v.Expected.NetworkSecurityGroupName { + t.Fatalf("Expected %q but got %q for NetworkSecurityGroupName", v.Expected.NetworkSecurityGroupName, actual.NetworkSecurityGroupName) + } + + } +} + +func TestParseNetworkSecurityGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyGrOuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName", + Expected: &NetworkSecurityGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityGroupName: "networkSecurityGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyGrOuPs/nEtWoRkSeCuRiTyGrOuPnAmE", + Expected: &NetworkSecurityGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkSecurityGroupName: "nEtWoRkSeCuRiTyGrOuPnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyGrOuPs/nEtWoRkSeCuRiTyGrOuPnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityGroupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityGroupName != v.Expected.NetworkSecurityGroupName { + t.Fatalf("Expected %q but got %q for NetworkSecurityGroupName", v.Expected.NetworkSecurityGroupName, actual.NetworkSecurityGroupName) + } + + } +} + +func TestSegmentsForNetworkSecurityGroupId(t *testing.T) { + segments := NetworkSecurityGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkSecurityGroupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/method_createorupdate.go b/resource-manager/network/2024-07-01/networksecuritygroups/method_createorupdate.go new file mode 100644 index 00000000000..cb77896aae4 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/method_createorupdate.go @@ -0,0 +1,75 @@ +package networksecuritygroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NetworkSecurityGroup +} + +// CreateOrUpdate ... +func (c NetworkSecurityGroupsClient) CreateOrUpdate(ctx context.Context, id NetworkSecurityGroupId, input NetworkSecurityGroup) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c NetworkSecurityGroupsClient) CreateOrUpdateThenPoll(ctx context.Context, id NetworkSecurityGroupId, input NetworkSecurityGroup) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/method_delete.go b/resource-manager/network/2024-07-01/networksecuritygroups/method_delete.go new file mode 100644 index 00000000000..103ca330a5b --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/method_delete.go @@ -0,0 +1,71 @@ +package networksecuritygroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c NetworkSecurityGroupsClient) Delete(ctx context.Context, id NetworkSecurityGroupId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c NetworkSecurityGroupsClient) DeleteThenPoll(ctx context.Context, id NetworkSecurityGroupId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/method_get.go b/resource-manager/network/2024-07-01/networksecuritygroups/method_get.go new file mode 100644 index 00000000000..7728917c0ec --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/method_get.go @@ -0,0 +1,83 @@ +package networksecuritygroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkSecurityGroup +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c NetworkSecurityGroupsClient) Get(ctx context.Context, id NetworkSecurityGroupId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkSecurityGroup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/method_list.go b/resource-manager/network/2024-07-01/networksecuritygroups/method_list.go new file mode 100644 index 00000000000..8ebd9f83a71 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/method_list.go @@ -0,0 +1,106 @@ +package networksecuritygroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkSecurityGroup +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkSecurityGroup +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c NetworkSecurityGroupsClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/networkSecurityGroups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkSecurityGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NetworkSecurityGroupsClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, NetworkSecurityGroupOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkSecurityGroupsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate NetworkSecurityGroupOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NetworkSecurityGroup, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/method_listall.go b/resource-manager/network/2024-07-01/networksecuritygroups/method_listall.go new file mode 100644 index 00000000000..a6440c24150 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/method_listall.go @@ -0,0 +1,106 @@ +package networksecuritygroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkSecurityGroup +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkSecurityGroup +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c NetworkSecurityGroupsClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/networkSecurityGroups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkSecurityGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c NetworkSecurityGroupsClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, NetworkSecurityGroupOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkSecurityGroupsClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate NetworkSecurityGroupOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]NetworkSecurityGroup, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/method_updatetags.go b/resource-manager/network/2024-07-01/networksecuritygroups/method_updatetags.go new file mode 100644 index 00000000000..6f4b2cd3ce6 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/method_updatetags.go @@ -0,0 +1,57 @@ +package networksecuritygroups + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkSecurityGroup +} + +// UpdateTags ... +func (c NetworkSecurityGroupsClient) UpdateTags(ctx context.Context, id NetworkSecurityGroupId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkSecurityGroup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..62c1c3109c0 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..17bf1792be8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..d96a3011a25 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..ebf65a382d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..e6f11b94c01 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..50a0b0f53a7 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..5443c32837a --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_backendaddresspool.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_backendaddresspool.go new file mode 100644 index 00000000000..0a216964329 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..80cdae2e912 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..d6dd55786fc --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_ddossettings.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_ddossettings.go new file mode 100644 index 00000000000..4b0d4e3dc9b --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_ddossettings.go @@ -0,0 +1,9 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_delegation.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_delegation.go new file mode 100644 index 00000000000..42805b01ada --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_delegation.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_flowlog.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_flowlog.go new file mode 100644 index 00000000000..88e95b6c2a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_flowlog.go @@ -0,0 +1,19 @@ +package networksecuritygroups + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_flowlogformatparameters.go new file mode 100644 index 00000000000..fdad354f6b8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..aedfa0b64ad --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_frontendipconfiguration.go new file mode 100644 index 00000000000..24b23145d47 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package networksecuritygroups + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..5322ea68f34 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..fff6be9708f --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_inboundnatrule.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_inboundnatrule.go new file mode 100644 index 00000000000..6391fbf065c --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..725fec85751 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..0b0ccf86b49 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..baed8aebae0 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_ipconfiguration.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_ipconfiguration.go new file mode 100644 index 00000000000..b9eec53b855 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..4885926d9aa --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..ec7f93c0f2b --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..ca12abb4992 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_iptag.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_iptag.go new file mode 100644 index 00000000000..3f5348f3776 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_iptag.go @@ -0,0 +1,9 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..8c8a91a5d1f --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..1843fe9fb85 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_natgateway.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_natgateway.go new file mode 100644 index 00000000000..8d6ecb14bc5 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_natgateway.go @@ -0,0 +1,20 @@ +package networksecuritygroups + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..902e5b3024c --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_natgatewaysku.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_natgatewaysku.go new file mode 100644 index 00000000000..5e842304f20 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_natruleportmapping.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_natruleportmapping.go new file mode 100644 index 00000000000..30f812c7c78 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterface.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterface.go new file mode 100644 index 00000000000..a4a62c2d6ea --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterface.go @@ -0,0 +1,19 @@ +package networksecuritygroups + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..f3819f01474 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..40cf733a9f0 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..caa03f6e413 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..248c37ca51d --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..465ad94efea --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..5e60c1bbfc4 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..d110d193645 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_networksecuritygroup.go new file mode 100644 index 00000000000..dd84b3efc89 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..704a86496f2 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpoint.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpoint.go new file mode 100644 index 00000000000..753cd13341b --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpoint.go @@ -0,0 +1,19 @@ +package networksecuritygroups + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpointconnection.go new file mode 100644 index 00000000000..b28eaa1a213 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..9649070d1a7 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..af86de8f897 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..550ef75ec1d --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpointproperties.go new file mode 100644 index 00000000000..36ad3ca4ffb --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkservice.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkservice.go new file mode 100644 index 00000000000..f880da9d89d --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package networksecuritygroups + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..3a721ae3637 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..50b8f7e352f --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..619e38d131d --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..dcbf418522b --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..abc8d2f4904 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..a0623cf7229 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_publicipaddress.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_publicipaddress.go new file mode 100644 index 00000000000..7b797b006f5 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_publicipaddress.go @@ -0,0 +1,22 @@ +package networksecuritygroups + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..2db9ef3f2c3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..cac3fce28ce --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_publicipaddresssku.go new file mode 100644 index 00000000000..24fe5573abd --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_resourcenavigationlink.go new file mode 100644 index 00000000000..8d6ec604942 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..0bf207481cb --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_resourceset.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_resourceset.go new file mode 100644 index 00000000000..751d06dd732 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_resourceset.go @@ -0,0 +1,8 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..b1e9035c2f8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_route.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_route.go new file mode 100644 index 00000000000..9b712ab4e81 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_route.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_routepropertiesformat.go new file mode 100644 index 00000000000..3225a4673f2 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_routetable.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_routetable.go new file mode 100644 index 00000000000..9aff39efe9e --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_routetable.go @@ -0,0 +1,14 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..5eee448b410 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_securityrule.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_securityrule.go new file mode 100644 index 00000000000..1119115e9eb --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_securityrule.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..01270911682 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceassociationlink.go new file mode 100644 index 00000000000..050ee6cb43f --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..81a4ac35e4a --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..089e2e1dc0c --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..6ca2d4bff53 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..2a8648b7931 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..c70380704b7 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..3000410cde3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..41b220c5194 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_subnet.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_subnet.go new file mode 100644 index 00000000000..499cc289ec3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_subnet.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..6164dfc95bb --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_subresource.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_subresource.go new file mode 100644 index 00000000000..8fa7fe6b59d --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_subresource.go @@ -0,0 +1,8 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_tagsobject.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_tagsobject.go new file mode 100644 index 00000000000..bb9ad0a6373 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_tagsobject.go @@ -0,0 +1,8 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..ddb354c4a7c --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..f74d8a12ecb --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_virtualnetworktap.go new file mode 100644 index 00000000000..cfc1b073467 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/networksecuritygroups/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..01620fae8c8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/predicates.go b/resource-manager/network/2024-07-01/networksecuritygroups/predicates.go new file mode 100644 index 00000000000..b9f6d3f3df5 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/predicates.go @@ -0,0 +1,37 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p NetworkSecurityGroupOperationPredicate) Matches(input NetworkSecurityGroup) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/networksecuritygroups/version.go b/resource-manager/network/2024-07-01/networksecuritygroups/version.go new file mode 100644 index 00000000000..45c4ab36a6f --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecuritygroups/version.go @@ -0,0 +1,10 @@ +package networksecuritygroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networksecuritygroups/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/README.md b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/README.md new file mode 100644 index 00000000000..e543da0d977 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/README.md @@ -0,0 +1,107 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules` Documentation + +The `networksecurityperimeteraccessrules` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules" +``` + + +### Client Initialization + +```go +client := networksecurityperimeteraccessrules.NewNetworkSecurityPerimeterAccessRulesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkSecurityPerimeterAccessRulesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := networksecurityperimeteraccessrules.NewAccessRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "profileName", "accessRuleName") + +payload := networksecurityperimeteraccessrules.NspAccessRule{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkSecurityPerimeterAccessRulesClient.Delete` + +```go +ctx := context.TODO() +id := networksecurityperimeteraccessrules.NewAccessRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "profileName", "accessRuleName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkSecurityPerimeterAccessRulesClient.Get` + +```go +ctx := context.TODO() +id := networksecurityperimeteraccessrules.NewAccessRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "profileName", "accessRuleName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkSecurityPerimeterAccessRulesClient.List` + +```go +ctx := context.TODO() +id := networksecurityperimeteraccessrules.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "profileName") + +// alternatively `client.List(ctx, id, networksecurityperimeteraccessrules.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, networksecurityperimeteraccessrules.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkSecurityPerimeterAccessRulesClient.Reconcile` + +```go +ctx := context.TODO() +id := networksecurityperimeteraccessrules.NewAccessRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "profileName", "accessRuleName") +var payload interface{} + +read, err := client.Reconcile(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/client.go b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/client.go new file mode 100644 index 00000000000..6d1d8c7a855 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/client.go @@ -0,0 +1,26 @@ +package networksecurityperimeteraccessrules + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimeterAccessRulesClient struct { + Client *resourcemanager.Client +} + +func NewNetworkSecurityPerimeterAccessRulesClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkSecurityPerimeterAccessRulesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networksecurityperimeteraccessrules", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkSecurityPerimeterAccessRulesClient: %+v", err) + } + + return &NetworkSecurityPerimeterAccessRulesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/constants.go b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/constants.go new file mode 100644 index 00000000000..58df66ef3f2 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/constants.go @@ -0,0 +1,104 @@ +package networksecurityperimeteraccessrules + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessRuleDirection string + +const ( + AccessRuleDirectionInbound AccessRuleDirection = "Inbound" + AccessRuleDirectionOutbound AccessRuleDirection = "Outbound" +) + +func PossibleValuesForAccessRuleDirection() []string { + return []string{ + string(AccessRuleDirectionInbound), + string(AccessRuleDirectionOutbound), + } +} + +func (s *AccessRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccessRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAccessRuleDirection(input string) (*AccessRuleDirection, error) { + vals := map[string]AccessRuleDirection{ + "inbound": AccessRuleDirectionInbound, + "outbound": AccessRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AccessRuleDirection(input) + return &out, nil +} + +type NspProvisioningState string + +const ( + NspProvisioningStateAccepted NspProvisioningState = "Accepted" + NspProvisioningStateCreating NspProvisioningState = "Creating" + NspProvisioningStateDeleting NspProvisioningState = "Deleting" + NspProvisioningStateFailed NspProvisioningState = "Failed" + NspProvisioningStateSucceeded NspProvisioningState = "Succeeded" + NspProvisioningStateUpdating NspProvisioningState = "Updating" +) + +func PossibleValuesForNspProvisioningState() []string { + return []string{ + string(NspProvisioningStateAccepted), + string(NspProvisioningStateCreating), + string(NspProvisioningStateDeleting), + string(NspProvisioningStateFailed), + string(NspProvisioningStateSucceeded), + string(NspProvisioningStateUpdating), + } +} + +func (s *NspProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNspProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNspProvisioningState(input string) (*NspProvisioningState, error) { + vals := map[string]NspProvisioningState{ + "accepted": NspProvisioningStateAccepted, + "creating": NspProvisioningStateCreating, + "deleting": NspProvisioningStateDeleting, + "failed": NspProvisioningStateFailed, + "succeeded": NspProvisioningStateSucceeded, + "updating": NspProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NspProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/id_accessrule.go b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/id_accessrule.go new file mode 100644 index 00000000000..05132ed260c --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/id_accessrule.go @@ -0,0 +1,148 @@ +package networksecurityperimeteraccessrules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AccessRuleId{}) +} + +var _ resourceids.ResourceId = &AccessRuleId{} + +// AccessRuleId is a struct representing the Resource ID for a Access Rule +type AccessRuleId struct { + SubscriptionId string + ResourceGroupName string + NetworkSecurityPerimeterName string + ProfileName string + AccessRuleName string +} + +// NewAccessRuleID returns a new AccessRuleId struct +func NewAccessRuleID(subscriptionId string, resourceGroupName string, networkSecurityPerimeterName string, profileName string, accessRuleName string) AccessRuleId { + return AccessRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkSecurityPerimeterName: networkSecurityPerimeterName, + ProfileName: profileName, + AccessRuleName: accessRuleName, + } +} + +// ParseAccessRuleID parses 'input' into a AccessRuleId +func ParseAccessRuleID(input string) (*AccessRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccessRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccessRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAccessRuleIDInsensitively parses 'input' case-insensitively into a AccessRuleId +// note: this method should only be used for API response data and not user input +func ParseAccessRuleIDInsensitively(input string) (*AccessRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccessRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccessRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AccessRuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkSecurityPerimeterName, ok = input.Parsed["networkSecurityPerimeterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityPerimeterName", input) + } + + if id.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + if id.AccessRuleName, ok = input.Parsed["accessRuleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "accessRuleName", input) + } + + return nil +} + +// ValidateAccessRuleID checks that 'input' can be parsed as a Access Rule ID +func ValidateAccessRuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseAccessRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Access Rule ID +func (id AccessRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityPerimeters/%s/profiles/%s/accessRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkSecurityPerimeterName, id.ProfileName, id.AccessRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Access Rule ID +func (id AccessRuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkSecurityPerimeters", "networkSecurityPerimeters", "networkSecurityPerimeters"), + resourceids.UserSpecifiedSegment("networkSecurityPerimeterName", "networkSecurityPerimeterName"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + resourceids.StaticSegment("staticAccessRules", "accessRules", "accessRules"), + resourceids.UserSpecifiedSegment("accessRuleName", "accessRuleName"), + } +} + +// String returns a human-readable description of this Access Rule ID +func (id AccessRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Security Perimeter Name: %q", id.NetworkSecurityPerimeterName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + fmt.Sprintf("Access Rule Name: %q", id.AccessRuleName), + } + return fmt.Sprintf("Access Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/id_accessrule_test.go b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/id_accessrule_test.go new file mode 100644 index 00000000000..5e29d5c2eaa --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/id_accessrule_test.go @@ -0,0 +1,372 @@ +package networksecurityperimeteraccessrules + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AccessRuleId{} + +func TestNewAccessRuleID(t *testing.T) { + id := NewAccessRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "profileName", "accessRuleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkSecurityPerimeterName != "networkSecurityPerimeterName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityPerimeterName'", id.NetworkSecurityPerimeterName, "networkSecurityPerimeterName") + } + + if id.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } + + if id.AccessRuleName != "accessRuleName" { + t.Fatalf("Expected %q but got %q for Segment 'AccessRuleName'", id.AccessRuleName, "accessRuleName") + } +} + +func TestFormatAccessRuleID(t *testing.T) { + actual := NewAccessRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "profileName", "accessRuleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName/accessRules/accessRuleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAccessRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AccessRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName/accessRules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName/accessRules/accessRuleName", + Expected: &AccessRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + ProfileName: "profileName", + AccessRuleName: "accessRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName/accessRules/accessRuleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAccessRuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + if actual.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.AccessRuleName != v.Expected.AccessRuleName { + t.Fatalf("Expected %q but got %q for AccessRuleName", v.Expected.AccessRuleName, actual.AccessRuleName) + } + + } +} + +func TestParseAccessRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AccessRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/pRoFiLeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/pRoFiLeS/pRoFiLeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName/accessRules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/pRoFiLeS/pRoFiLeNaMe/aCcEsSrUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName/accessRules/accessRuleName", + Expected: &AccessRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + ProfileName: "profileName", + AccessRuleName: "accessRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName/accessRules/accessRuleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/pRoFiLeS/pRoFiLeNaMe/aCcEsSrUlEs/aCcEsSrUlEnAmE", + Expected: &AccessRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkSecurityPerimeterName: "nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + ProfileName: "pRoFiLeNaMe", + AccessRuleName: "aCcEsSrUlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/pRoFiLeS/pRoFiLeNaMe/aCcEsSrUlEs/aCcEsSrUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAccessRuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + if actual.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + if actual.AccessRuleName != v.Expected.AccessRuleName { + t.Fatalf("Expected %q but got %q for AccessRuleName", v.Expected.AccessRuleName, actual.AccessRuleName) + } + + } +} + +func TestSegmentsForAccessRuleId(t *testing.T) { + segments := AccessRuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AccessRuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/id_profile.go b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/id_profile.go new file mode 100644 index 00000000000..f8a63975b9d --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/id_profile.go @@ -0,0 +1,139 @@ +package networksecurityperimeteraccessrules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProfileId{}) +} + +var _ resourceids.ResourceId = &ProfileId{} + +// ProfileId is a struct representing the Resource ID for a Profile +type ProfileId struct { + SubscriptionId string + ResourceGroupName string + NetworkSecurityPerimeterName string + ProfileName string +} + +// NewProfileID returns a new ProfileId struct +func NewProfileID(subscriptionId string, resourceGroupName string, networkSecurityPerimeterName string, profileName string) ProfileId { + return ProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkSecurityPerimeterName: networkSecurityPerimeterName, + ProfileName: profileName, + } +} + +// ParseProfileID parses 'input' into a ProfileId +func ParseProfileID(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProfileIDInsensitively parses 'input' case-insensitively into a ProfileId +// note: this method should only be used for API response data and not user input +func ParseProfileIDInsensitively(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProfileId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkSecurityPerimeterName, ok = input.Parsed["networkSecurityPerimeterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityPerimeterName", input) + } + + if id.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + return nil +} + +// ValidateProfileID checks that 'input' can be parsed as a Profile ID +func ValidateProfileID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Profile ID +func (id ProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityPerimeters/%s/profiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkSecurityPerimeterName, id.ProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Profile ID +func (id ProfileId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkSecurityPerimeters", "networkSecurityPerimeters", "networkSecurityPerimeters"), + resourceids.UserSpecifiedSegment("networkSecurityPerimeterName", "networkSecurityPerimeterName"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + } +} + +// String returns a human-readable description of this Profile ID +func (id ProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Security Perimeter Name: %q", id.NetworkSecurityPerimeterName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + } + return fmt.Sprintf("Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/id_profile_test.go b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/id_profile_test.go new file mode 100644 index 00000000000..b12437f3c96 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/id_profile_test.go @@ -0,0 +1,327 @@ +package networksecurityperimeteraccessrules + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProfileId{} + +func TestNewProfileID(t *testing.T) { + id := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "profileName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkSecurityPerimeterName != "networkSecurityPerimeterName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityPerimeterName'", id.NetworkSecurityPerimeterName, "networkSecurityPerimeterName") + } + + if id.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } +} + +func TestFormatProfileID(t *testing.T) { + actual := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "profileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + if actual.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestParseProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/pRoFiLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/pRoFiLeS/pRoFiLeNaMe", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkSecurityPerimeterName: "nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + ProfileName: "pRoFiLeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/pRoFiLeS/pRoFiLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + if actual.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestSegmentsForProfileId(t *testing.T) { + segments := ProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProfileId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/method_createorupdate.go b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/method_createorupdate.go new file mode 100644 index 00000000000..2ce0807c380 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/method_createorupdate.go @@ -0,0 +1,58 @@ +package networksecurityperimeteraccessrules + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NspAccessRule +} + +// CreateOrUpdate ... +func (c NetworkSecurityPerimeterAccessRulesClient) CreateOrUpdate(ctx context.Context, id AccessRuleId, input NspAccessRule) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NspAccessRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/method_delete.go b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/method_delete.go new file mode 100644 index 00000000000..3a876ce9e0d --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/method_delete.go @@ -0,0 +1,47 @@ +package networksecurityperimeteraccessrules + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c NetworkSecurityPerimeterAccessRulesClient) Delete(ctx context.Context, id AccessRuleId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/method_get.go b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/method_get.go new file mode 100644 index 00000000000..f5c92d31732 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/method_get.go @@ -0,0 +1,53 @@ +package networksecurityperimeteraccessrules + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NspAccessRule +} + +// Get ... +func (c NetworkSecurityPerimeterAccessRulesClient) Get(ctx context.Context, id AccessRuleId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NspAccessRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/method_list.go b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/method_list.go new file mode 100644 index 00000000000..452777de833 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/method_list.go @@ -0,0 +1,134 @@ +package networksecurityperimeteraccessrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NspAccessRule +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NspAccessRule +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c NetworkSecurityPerimeterAccessRulesClient) List(ctx context.Context, id ProfileId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/accessRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NspAccessRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NetworkSecurityPerimeterAccessRulesClient) ListComplete(ctx context.Context, id ProfileId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, NspAccessRuleOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkSecurityPerimeterAccessRulesClient) ListCompleteMatchingPredicate(ctx context.Context, id ProfileId, options ListOperationOptions, predicate NspAccessRuleOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NspAccessRule, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/method_reconcile.go b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/method_reconcile.go new file mode 100644 index 00000000000..96ff7e1bedb --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/method_reconcile.go @@ -0,0 +1,58 @@ +package networksecurityperimeteraccessrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReconcileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// Reconcile ... +func (c NetworkSecurityPerimeterAccessRulesClient) Reconcile(ctx context.Context, id AccessRuleId, input interface{}) (result ReconcileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reconcile", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model interface{} + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/model_nspaccessrule.go b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/model_nspaccessrule.go new file mode 100644 index 00000000000..7b9cc4d1e3c --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/model_nspaccessrule.go @@ -0,0 +1,16 @@ +package networksecurityperimeteraccessrules + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspAccessRule struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NspAccessRuleProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/model_nspaccessruleproperties.go b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/model_nspaccessruleproperties.go new file mode 100644 index 00000000000..d5cfc80c752 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/model_nspaccessruleproperties.go @@ -0,0 +1,16 @@ +package networksecurityperimeteraccessrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspAccessRuleProperties struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + Direction *AccessRuleDirection `json:"direction,omitempty"` + EmailAddresses *[]string `json:"emailAddresses,omitempty"` + FullyQualifiedDomainNames *[]string `json:"fullyQualifiedDomainNames,omitempty"` + NetworkSecurityPerimeters *[]PerimeterBasedAccessRule `json:"networkSecurityPerimeters,omitempty"` + PhoneNumbers *[]string `json:"phoneNumbers,omitempty"` + ProvisioningState *NspProvisioningState `json:"provisioningState,omitempty"` + ServiceTags *[]string `json:"serviceTags,omitempty"` + Subscriptions *[]SubscriptionId `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/model_perimeterbasedaccessrule.go b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/model_perimeterbasedaccessrule.go new file mode 100644 index 00000000000..e73549d60a5 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/model_perimeterbasedaccessrule.go @@ -0,0 +1,10 @@ +package networksecurityperimeteraccessrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PerimeterBasedAccessRule struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + PerimeterGuid *string `json:"perimeterGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/model_subscriptionid.go b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/model_subscriptionid.go new file mode 100644 index 00000000000..b0d36109c73 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/model_subscriptionid.go @@ -0,0 +1,8 @@ +package networksecurityperimeteraccessrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubscriptionId struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/predicates.go b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/predicates.go new file mode 100644 index 00000000000..dc98cc01ea8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/predicates.go @@ -0,0 +1,27 @@ +package networksecurityperimeteraccessrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspAccessRuleOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p NspAccessRuleOperationPredicate) Matches(input NspAccessRule) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/version.go b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/version.go new file mode 100644 index 00000000000..e36bd04bb64 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeteraccessrules/version.go @@ -0,0 +1,10 @@ +package networksecurityperimeteraccessrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networksecurityperimeteraccessrules/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/README.md b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/README.md new file mode 100644 index 00000000000..d656e9f3cb6 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes` Documentation + +The `networksecurityperimeterassociableresourcetypes` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes" +``` + + +### Client Initialization + +```go +client := networksecurityperimeterassociableresourcetypes.NewNetworkSecurityPerimeterAssociableResourceTypesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkSecurityPerimeterAssociableResourceTypesClient.List` + +```go +ctx := context.TODO() +id := networksecurityperimeterassociableresourcetypes.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/client.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/client.go new file mode 100644 index 00000000000..6387861b273 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/client.go @@ -0,0 +1,26 @@ +package networksecurityperimeterassociableresourcetypes + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimeterAssociableResourceTypesClient struct { + Client *resourcemanager.Client +} + +func NewNetworkSecurityPerimeterAssociableResourceTypesClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkSecurityPerimeterAssociableResourceTypesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networksecurityperimeterassociableresourcetypes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkSecurityPerimeterAssociableResourceTypesClient: %+v", err) + } + + return &NetworkSecurityPerimeterAssociableResourceTypesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/id_location.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/id_location.go new file mode 100644 index 00000000000..5380aa4ba13 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/id_location.go @@ -0,0 +1,121 @@ +package networksecurityperimeterassociableresourcetypes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Network/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/id_location_test.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/id_location_test.go new file mode 100644 index 00000000000..ac0476b4e49 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/id_location_test.go @@ -0,0 +1,237 @@ +package networksecurityperimeterassociableresourcetypes + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/method_list.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/method_list.go new file mode 100644 index 00000000000..04123fa8a68 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/method_list.go @@ -0,0 +1,105 @@ +package networksecurityperimeterassociableresourcetypes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PerimeterAssociableResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PerimeterAssociableResource +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c NetworkSecurityPerimeterAssociableResourceTypesClient) List(ctx context.Context, id LocationId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/perimeterAssociableResourceTypes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PerimeterAssociableResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NetworkSecurityPerimeterAssociableResourceTypesClient) ListComplete(ctx context.Context, id LocationId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, PerimeterAssociableResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkSecurityPerimeterAssociableResourceTypesClient) ListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate PerimeterAssociableResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]PerimeterAssociableResource, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/model_perimeterassociableresource.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/model_perimeterassociableresource.go new file mode 100644 index 00000000000..5ab25336b17 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/model_perimeterassociableresource.go @@ -0,0 +1,11 @@ +package networksecurityperimeterassociableresourcetypes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PerimeterAssociableResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PerimeterAssociableResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/model_perimeterassociableresourceproperties.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/model_perimeterassociableresourceproperties.go new file mode 100644 index 00000000000..4a2b241e53f --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/model_perimeterassociableresourceproperties.go @@ -0,0 +1,10 @@ +package networksecurityperimeterassociableresourcetypes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PerimeterAssociableResourceProperties struct { + DisplayName *string `json:"displayName,omitempty"` + PublicDnsZones *[]string `json:"publicDnsZones,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/predicates.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/predicates.go new file mode 100644 index 00000000000..2f0a5c166de --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/predicates.go @@ -0,0 +1,27 @@ +package networksecurityperimeterassociableresourcetypes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PerimeterAssociableResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p PerimeterAssociableResourceOperationPredicate) Matches(input PerimeterAssociableResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/version.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/version.go new file mode 100644 index 00000000000..476be740739 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociableresourcetypes/version.go @@ -0,0 +1,10 @@ +package networksecurityperimeterassociableresourcetypes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networksecurityperimeterassociableresourcetypes/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociations/README.md b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/README.md new file mode 100644 index 00000000000..39fb1933213 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterassociations` Documentation + +The `networksecurityperimeterassociations` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterassociations" +``` + + +### Client Initialization + +```go +client := networksecurityperimeterassociations.NewNetworkSecurityPerimeterAssociationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkSecurityPerimeterAssociationsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := networksecurityperimeterassociations.NewResourceAssociationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "resourceAssociationName") + +payload := networksecurityperimeterassociations.NspAssociation{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkSecurityPerimeterAssociationsClient.Delete` + +```go +ctx := context.TODO() +id := networksecurityperimeterassociations.NewResourceAssociationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "resourceAssociationName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkSecurityPerimeterAssociationsClient.Get` + +```go +ctx := context.TODO() +id := networksecurityperimeterassociations.NewResourceAssociationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "resourceAssociationName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkSecurityPerimeterAssociationsClient.List` + +```go +ctx := context.TODO() +id := networksecurityperimeterassociations.NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName") + +// alternatively `client.List(ctx, id, networksecurityperimeterassociations.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, networksecurityperimeterassociations.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkSecurityPerimeterAssociationsClient.Reconcile` + +```go +ctx := context.TODO() +id := networksecurityperimeterassociations.NewResourceAssociationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "resourceAssociationName") +var payload interface{} + +read, err := client.Reconcile(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociations/client.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/client.go new file mode 100644 index 00000000000..54570e6e2fd --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/client.go @@ -0,0 +1,26 @@ +package networksecurityperimeterassociations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimeterAssociationsClient struct { + Client *resourcemanager.Client +} + +func NewNetworkSecurityPerimeterAssociationsClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkSecurityPerimeterAssociationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networksecurityperimeterassociations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkSecurityPerimeterAssociationsClient: %+v", err) + } + + return &NetworkSecurityPerimeterAssociationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociations/constants.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/constants.go new file mode 100644 index 00000000000..550438bd502 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/constants.go @@ -0,0 +1,107 @@ +package networksecurityperimeterassociations + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssociationAccessMode string + +const ( + AssociationAccessModeAudit AssociationAccessMode = "Audit" + AssociationAccessModeEnforced AssociationAccessMode = "Enforced" + AssociationAccessModeLearning AssociationAccessMode = "Learning" +) + +func PossibleValuesForAssociationAccessMode() []string { + return []string{ + string(AssociationAccessModeAudit), + string(AssociationAccessModeEnforced), + string(AssociationAccessModeLearning), + } +} + +func (s *AssociationAccessMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssociationAccessMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAssociationAccessMode(input string) (*AssociationAccessMode, error) { + vals := map[string]AssociationAccessMode{ + "audit": AssociationAccessModeAudit, + "enforced": AssociationAccessModeEnforced, + "learning": AssociationAccessModeLearning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AssociationAccessMode(input) + return &out, nil +} + +type NspProvisioningState string + +const ( + NspProvisioningStateAccepted NspProvisioningState = "Accepted" + NspProvisioningStateCreating NspProvisioningState = "Creating" + NspProvisioningStateDeleting NspProvisioningState = "Deleting" + NspProvisioningStateFailed NspProvisioningState = "Failed" + NspProvisioningStateSucceeded NspProvisioningState = "Succeeded" + NspProvisioningStateUpdating NspProvisioningState = "Updating" +) + +func PossibleValuesForNspProvisioningState() []string { + return []string{ + string(NspProvisioningStateAccepted), + string(NspProvisioningStateCreating), + string(NspProvisioningStateDeleting), + string(NspProvisioningStateFailed), + string(NspProvisioningStateSucceeded), + string(NspProvisioningStateUpdating), + } +} + +func (s *NspProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNspProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNspProvisioningState(input string) (*NspProvisioningState, error) { + vals := map[string]NspProvisioningState{ + "accepted": NspProvisioningStateAccepted, + "creating": NspProvisioningStateCreating, + "deleting": NspProvisioningStateDeleting, + "failed": NspProvisioningStateFailed, + "succeeded": NspProvisioningStateSucceeded, + "updating": NspProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NspProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociations/id_networksecurityperimeter.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/id_networksecurityperimeter.go new file mode 100644 index 00000000000..7e98d32b1fa --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/id_networksecurityperimeter.go @@ -0,0 +1,130 @@ +package networksecurityperimeterassociations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkSecurityPerimeterId{}) +} + +var _ resourceids.ResourceId = &NetworkSecurityPerimeterId{} + +// NetworkSecurityPerimeterId is a struct representing the Resource ID for a Network Security Perimeter +type NetworkSecurityPerimeterId struct { + SubscriptionId string + ResourceGroupName string + NetworkSecurityPerimeterName string +} + +// NewNetworkSecurityPerimeterID returns a new NetworkSecurityPerimeterId struct +func NewNetworkSecurityPerimeterID(subscriptionId string, resourceGroupName string, networkSecurityPerimeterName string) NetworkSecurityPerimeterId { + return NetworkSecurityPerimeterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkSecurityPerimeterName: networkSecurityPerimeterName, + } +} + +// ParseNetworkSecurityPerimeterID parses 'input' into a NetworkSecurityPerimeterId +func ParseNetworkSecurityPerimeterID(input string) (*NetworkSecurityPerimeterId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkSecurityPerimeterIDInsensitively parses 'input' case-insensitively into a NetworkSecurityPerimeterId +// note: this method should only be used for API response data and not user input +func ParseNetworkSecurityPerimeterIDInsensitively(input string) (*NetworkSecurityPerimeterId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkSecurityPerimeterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkSecurityPerimeterName, ok = input.Parsed["networkSecurityPerimeterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityPerimeterName", input) + } + + return nil +} + +// ValidateNetworkSecurityPerimeterID checks that 'input' can be parsed as a Network Security Perimeter ID +func ValidateNetworkSecurityPerimeterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkSecurityPerimeterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityPerimeters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkSecurityPerimeterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkSecurityPerimeters", "networkSecurityPerimeters", "networkSecurityPerimeters"), + resourceids.UserSpecifiedSegment("networkSecurityPerimeterName", "networkSecurityPerimeterName"), + } +} + +// String returns a human-readable description of this Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Security Perimeter Name: %q", id.NetworkSecurityPerimeterName), + } + return fmt.Sprintf("Network Security Perimeter (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociations/id_networksecurityperimeter_test.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/id_networksecurityperimeter_test.go new file mode 100644 index 00000000000..b3baf52105d --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/id_networksecurityperimeter_test.go @@ -0,0 +1,282 @@ +package networksecurityperimeterassociations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkSecurityPerimeterId{} + +func TestNewNetworkSecurityPerimeterID(t *testing.T) { + id := NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkSecurityPerimeterName != "networkSecurityPerimeterName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityPerimeterName'", id.NetworkSecurityPerimeterName, "networkSecurityPerimeterName") + } +} + +func TestFormatNetworkSecurityPerimeterID(t *testing.T) { + actual := NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkSecurityPerimeterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + } +} + +func TestParseNetworkSecurityPerimeterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkSecurityPerimeterName: "nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + } +} + +func TestSegmentsForNetworkSecurityPerimeterId(t *testing.T) { + segments := NetworkSecurityPerimeterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkSecurityPerimeterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociations/id_resourceassociation.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/id_resourceassociation.go new file mode 100644 index 00000000000..902c8859e95 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/id_resourceassociation.go @@ -0,0 +1,139 @@ +package networksecurityperimeterassociations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ResourceAssociationId{}) +} + +var _ resourceids.ResourceId = &ResourceAssociationId{} + +// ResourceAssociationId is a struct representing the Resource ID for a Resource Association +type ResourceAssociationId struct { + SubscriptionId string + ResourceGroupName string + NetworkSecurityPerimeterName string + ResourceAssociationName string +} + +// NewResourceAssociationID returns a new ResourceAssociationId struct +func NewResourceAssociationID(subscriptionId string, resourceGroupName string, networkSecurityPerimeterName string, resourceAssociationName string) ResourceAssociationId { + return ResourceAssociationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkSecurityPerimeterName: networkSecurityPerimeterName, + ResourceAssociationName: resourceAssociationName, + } +} + +// ParseResourceAssociationID parses 'input' into a ResourceAssociationId +func ParseResourceAssociationID(input string) (*ResourceAssociationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ResourceAssociationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ResourceAssociationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseResourceAssociationIDInsensitively parses 'input' case-insensitively into a ResourceAssociationId +// note: this method should only be used for API response data and not user input +func ParseResourceAssociationIDInsensitively(input string) (*ResourceAssociationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ResourceAssociationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ResourceAssociationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ResourceAssociationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkSecurityPerimeterName, ok = input.Parsed["networkSecurityPerimeterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityPerimeterName", input) + } + + if id.ResourceAssociationName, ok = input.Parsed["resourceAssociationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceAssociationName", input) + } + + return nil +} + +// ValidateResourceAssociationID checks that 'input' can be parsed as a Resource Association ID +func ValidateResourceAssociationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseResourceAssociationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Resource Association ID +func (id ResourceAssociationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityPerimeters/%s/resourceAssociations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkSecurityPerimeterName, id.ResourceAssociationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Resource Association ID +func (id ResourceAssociationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkSecurityPerimeters", "networkSecurityPerimeters", "networkSecurityPerimeters"), + resourceids.UserSpecifiedSegment("networkSecurityPerimeterName", "networkSecurityPerimeterName"), + resourceids.StaticSegment("staticResourceAssociations", "resourceAssociations", "resourceAssociations"), + resourceids.UserSpecifiedSegment("resourceAssociationName", "resourceAssociationName"), + } +} + +// String returns a human-readable description of this Resource Association ID +func (id ResourceAssociationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Security Perimeter Name: %q", id.NetworkSecurityPerimeterName), + fmt.Sprintf("Resource Association Name: %q", id.ResourceAssociationName), + } + return fmt.Sprintf("Resource Association (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociations/id_resourceassociation_test.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/id_resourceassociation_test.go new file mode 100644 index 00000000000..5caf985ea4f --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/id_resourceassociation_test.go @@ -0,0 +1,327 @@ +package networksecurityperimeterassociations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ResourceAssociationId{} + +func TestNewResourceAssociationID(t *testing.T) { + id := NewResourceAssociationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "resourceAssociationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkSecurityPerimeterName != "networkSecurityPerimeterName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityPerimeterName'", id.NetworkSecurityPerimeterName, "networkSecurityPerimeterName") + } + + if id.ResourceAssociationName != "resourceAssociationName" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceAssociationName'", id.ResourceAssociationName, "resourceAssociationName") + } +} + +func TestFormatResourceAssociationID(t *testing.T) { + actual := NewResourceAssociationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "resourceAssociationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/resourceAssociations/resourceAssociationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseResourceAssociationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ResourceAssociationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/resourceAssociations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/resourceAssociations/resourceAssociationName", + Expected: &ResourceAssociationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + ResourceAssociationName: "resourceAssociationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/resourceAssociations/resourceAssociationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseResourceAssociationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + if actual.ResourceAssociationName != v.Expected.ResourceAssociationName { + t.Fatalf("Expected %q but got %q for ResourceAssociationName", v.Expected.ResourceAssociationName, actual.ResourceAssociationName) + } + + } +} + +func TestParseResourceAssociationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ResourceAssociationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/resourceAssociations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/rEsOuRcEaSsOcIaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/resourceAssociations/resourceAssociationName", + Expected: &ResourceAssociationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + ResourceAssociationName: "resourceAssociationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/resourceAssociations/resourceAssociationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/rEsOuRcEaSsOcIaTiOnS/rEsOuRcEaSsOcIaTiOnNaMe", + Expected: &ResourceAssociationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkSecurityPerimeterName: "nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + ResourceAssociationName: "rEsOuRcEaSsOcIaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/rEsOuRcEaSsOcIaTiOnS/rEsOuRcEaSsOcIaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseResourceAssociationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + if actual.ResourceAssociationName != v.Expected.ResourceAssociationName { + t.Fatalf("Expected %q but got %q for ResourceAssociationName", v.Expected.ResourceAssociationName, actual.ResourceAssociationName) + } + + } +} + +func TestSegmentsForResourceAssociationId(t *testing.T) { + segments := ResourceAssociationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ResourceAssociationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociations/method_createorupdate.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/method_createorupdate.go new file mode 100644 index 00000000000..f2123c05755 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/method_createorupdate.go @@ -0,0 +1,76 @@ +package networksecurityperimeterassociations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NspAssociation +} + +// CreateOrUpdate ... +func (c NetworkSecurityPerimeterAssociationsClient) CreateOrUpdate(ctx context.Context, id ResourceAssociationId, input NspAssociation) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c NetworkSecurityPerimeterAssociationsClient) CreateOrUpdateThenPoll(ctx context.Context, id ResourceAssociationId, input NspAssociation) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociations/method_delete.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/method_delete.go new file mode 100644 index 00000000000..f5a642bebb7 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/method_delete.go @@ -0,0 +1,71 @@ +package networksecurityperimeterassociations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c NetworkSecurityPerimeterAssociationsClient) Delete(ctx context.Context, id ResourceAssociationId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c NetworkSecurityPerimeterAssociationsClient) DeleteThenPoll(ctx context.Context, id ResourceAssociationId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociations/method_get.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/method_get.go new file mode 100644 index 00000000000..3927ed0a5dc --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/method_get.go @@ -0,0 +1,53 @@ +package networksecurityperimeterassociations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NspAssociation +} + +// Get ... +func (c NetworkSecurityPerimeterAssociationsClient) Get(ctx context.Context, id ResourceAssociationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NspAssociation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociations/method_list.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/method_list.go new file mode 100644 index 00000000000..e5430f44437 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/method_list.go @@ -0,0 +1,134 @@ +package networksecurityperimeterassociations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NspAssociation +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NspAssociation +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c NetworkSecurityPerimeterAssociationsClient) List(ctx context.Context, id NetworkSecurityPerimeterId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/resourceAssociations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NspAssociation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NetworkSecurityPerimeterAssociationsClient) ListComplete(ctx context.Context, id NetworkSecurityPerimeterId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, NspAssociationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkSecurityPerimeterAssociationsClient) ListCompleteMatchingPredicate(ctx context.Context, id NetworkSecurityPerimeterId, options ListOperationOptions, predicate NspAssociationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NspAssociation, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociations/method_reconcile.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/method_reconcile.go new file mode 100644 index 00000000000..1a753016b6c --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/method_reconcile.go @@ -0,0 +1,58 @@ +package networksecurityperimeterassociations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReconcileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// Reconcile ... +func (c NetworkSecurityPerimeterAssociationsClient) Reconcile(ctx context.Context, id ResourceAssociationId, input interface{}) (result ReconcileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reconcile", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model interface{} + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociations/model_nspassociation.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/model_nspassociation.go new file mode 100644 index 00000000000..d0e4895e2dc --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/model_nspassociation.go @@ -0,0 +1,16 @@ +package networksecurityperimeterassociations + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspAssociation struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NspAssociationProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociations/model_nspassociationproperties.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/model_nspassociationproperties.go new file mode 100644 index 00000000000..1c13266141a --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/model_nspassociationproperties.go @@ -0,0 +1,12 @@ +package networksecurityperimeterassociations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspAssociationProperties struct { + AccessMode *AssociationAccessMode `json:"accessMode,omitempty"` + HasProvisioningIssues *string `json:"hasProvisioningIssues,omitempty"` + PrivateLinkResource *SubResource `json:"privateLinkResource,omitempty"` + Profile *SubResource `json:"profile,omitempty"` + ProvisioningState *NspProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociations/model_subresource.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/model_subresource.go new file mode 100644 index 00000000000..21571ba35e4 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/model_subresource.go @@ -0,0 +1,8 @@ +package networksecurityperimeterassociations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociations/predicates.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/predicates.go new file mode 100644 index 00000000000..6ac4e921ae7 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/predicates.go @@ -0,0 +1,27 @@ +package networksecurityperimeterassociations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspAssociationOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p NspAssociationOperationPredicate) Matches(input NspAssociation) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterassociations/version.go b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/version.go new file mode 100644 index 00000000000..9b8bedb3244 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterassociations/version.go @@ -0,0 +1,10 @@ +package networksecurityperimeterassociations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networksecurityperimeterassociations/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/README.md b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/README.md new file mode 100644 index 00000000000..01dea70bbb6 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/README.md @@ -0,0 +1,65 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences` Documentation + +The `networksecurityperimeterlinkreferences` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences" +``` + + +### Client Initialization + +```go +client := networksecurityperimeterlinkreferences.NewNetworkSecurityPerimeterLinkReferencesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkSecurityPerimeterLinkReferencesClient.Delete` + +```go +ctx := context.TODO() +id := networksecurityperimeterlinkreferences.NewLinkReferenceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "linkReferenceName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkSecurityPerimeterLinkReferencesClient.Get` + +```go +ctx := context.TODO() +id := networksecurityperimeterlinkreferences.NewLinkReferenceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "linkReferenceName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkSecurityPerimeterLinkReferencesClient.List` + +```go +ctx := context.TODO() +id := networksecurityperimeterlinkreferences.NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName") + +// alternatively `client.List(ctx, id, networksecurityperimeterlinkreferences.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, networksecurityperimeterlinkreferences.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/client.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/client.go new file mode 100644 index 00000000000..703b1bdef78 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/client.go @@ -0,0 +1,26 @@ +package networksecurityperimeterlinkreferences + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimeterLinkReferencesClient struct { + Client *resourcemanager.Client +} + +func NewNetworkSecurityPerimeterLinkReferencesClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkSecurityPerimeterLinkReferencesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networksecurityperimeterlinkreferences", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkSecurityPerimeterLinkReferencesClient: %+v", err) + } + + return &NetworkSecurityPerimeterLinkReferencesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/constants.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/constants.go new file mode 100644 index 00000000000..19e1ad4e77a --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/constants.go @@ -0,0 +1,113 @@ +package networksecurityperimeterlinkreferences + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspLinkProvisioningState string + +const ( + NspLinkProvisioningStateAccepted NspLinkProvisioningState = "Accepted" + NspLinkProvisioningStateCreating NspLinkProvisioningState = "Creating" + NspLinkProvisioningStateDeleting NspLinkProvisioningState = "Deleting" + NspLinkProvisioningStateFailed NspLinkProvisioningState = "Failed" + NspLinkProvisioningStateSucceeded NspLinkProvisioningState = "Succeeded" + NspLinkProvisioningStateUpdating NspLinkProvisioningState = "Updating" + NspLinkProvisioningStateWaitForRemoteCompletion NspLinkProvisioningState = "WaitForRemoteCompletion" +) + +func PossibleValuesForNspLinkProvisioningState() []string { + return []string{ + string(NspLinkProvisioningStateAccepted), + string(NspLinkProvisioningStateCreating), + string(NspLinkProvisioningStateDeleting), + string(NspLinkProvisioningStateFailed), + string(NspLinkProvisioningStateSucceeded), + string(NspLinkProvisioningStateUpdating), + string(NspLinkProvisioningStateWaitForRemoteCompletion), + } +} + +func (s *NspLinkProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNspLinkProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNspLinkProvisioningState(input string) (*NspLinkProvisioningState, error) { + vals := map[string]NspLinkProvisioningState{ + "accepted": NspLinkProvisioningStateAccepted, + "creating": NspLinkProvisioningStateCreating, + "deleting": NspLinkProvisioningStateDeleting, + "failed": NspLinkProvisioningStateFailed, + "succeeded": NspLinkProvisioningStateSucceeded, + "updating": NspLinkProvisioningStateUpdating, + "waitforremotecompletion": NspLinkProvisioningStateWaitForRemoteCompletion, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NspLinkProvisioningState(input) + return &out, nil +} + +type NspLinkStatus string + +const ( + NspLinkStatusApproved NspLinkStatus = "Approved" + NspLinkStatusDisconnected NspLinkStatus = "Disconnected" + NspLinkStatusPending NspLinkStatus = "Pending" + NspLinkStatusRejected NspLinkStatus = "Rejected" +) + +func PossibleValuesForNspLinkStatus() []string { + return []string{ + string(NspLinkStatusApproved), + string(NspLinkStatusDisconnected), + string(NspLinkStatusPending), + string(NspLinkStatusRejected), + } +} + +func (s *NspLinkStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNspLinkStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNspLinkStatus(input string) (*NspLinkStatus, error) { + vals := map[string]NspLinkStatus{ + "approved": NspLinkStatusApproved, + "disconnected": NspLinkStatusDisconnected, + "pending": NspLinkStatusPending, + "rejected": NspLinkStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NspLinkStatus(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/id_linkreference.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/id_linkreference.go new file mode 100644 index 00000000000..628d37eeb93 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/id_linkreference.go @@ -0,0 +1,139 @@ +package networksecurityperimeterlinkreferences + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LinkReferenceId{}) +} + +var _ resourceids.ResourceId = &LinkReferenceId{} + +// LinkReferenceId is a struct representing the Resource ID for a Link Reference +type LinkReferenceId struct { + SubscriptionId string + ResourceGroupName string + NetworkSecurityPerimeterName string + LinkReferenceName string +} + +// NewLinkReferenceID returns a new LinkReferenceId struct +func NewLinkReferenceID(subscriptionId string, resourceGroupName string, networkSecurityPerimeterName string, linkReferenceName string) LinkReferenceId { + return LinkReferenceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkSecurityPerimeterName: networkSecurityPerimeterName, + LinkReferenceName: linkReferenceName, + } +} + +// ParseLinkReferenceID parses 'input' into a LinkReferenceId +func ParseLinkReferenceID(input string) (*LinkReferenceId, error) { + parser := resourceids.NewParserFromResourceIdType(&LinkReferenceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LinkReferenceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLinkReferenceIDInsensitively parses 'input' case-insensitively into a LinkReferenceId +// note: this method should only be used for API response data and not user input +func ParseLinkReferenceIDInsensitively(input string) (*LinkReferenceId, error) { + parser := resourceids.NewParserFromResourceIdType(&LinkReferenceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LinkReferenceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LinkReferenceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkSecurityPerimeterName, ok = input.Parsed["networkSecurityPerimeterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityPerimeterName", input) + } + + if id.LinkReferenceName, ok = input.Parsed["linkReferenceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "linkReferenceName", input) + } + + return nil +} + +// ValidateLinkReferenceID checks that 'input' can be parsed as a Link Reference ID +func ValidateLinkReferenceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLinkReferenceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Link Reference ID +func (id LinkReferenceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityPerimeters/%s/linkReferences/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkSecurityPerimeterName, id.LinkReferenceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Link Reference ID +func (id LinkReferenceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkSecurityPerimeters", "networkSecurityPerimeters", "networkSecurityPerimeters"), + resourceids.UserSpecifiedSegment("networkSecurityPerimeterName", "networkSecurityPerimeterName"), + resourceids.StaticSegment("staticLinkReferences", "linkReferences", "linkReferences"), + resourceids.UserSpecifiedSegment("linkReferenceName", "linkReferenceName"), + } +} + +// String returns a human-readable description of this Link Reference ID +func (id LinkReferenceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Security Perimeter Name: %q", id.NetworkSecurityPerimeterName), + fmt.Sprintf("Link Reference Name: %q", id.LinkReferenceName), + } + return fmt.Sprintf("Link Reference (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/id_linkreference_test.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/id_linkreference_test.go new file mode 100644 index 00000000000..86007d09ba4 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/id_linkreference_test.go @@ -0,0 +1,327 @@ +package networksecurityperimeterlinkreferences + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LinkReferenceId{} + +func TestNewLinkReferenceID(t *testing.T) { + id := NewLinkReferenceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "linkReferenceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkSecurityPerimeterName != "networkSecurityPerimeterName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityPerimeterName'", id.NetworkSecurityPerimeterName, "networkSecurityPerimeterName") + } + + if id.LinkReferenceName != "linkReferenceName" { + t.Fatalf("Expected %q but got %q for Segment 'LinkReferenceName'", id.LinkReferenceName, "linkReferenceName") + } +} + +func TestFormatLinkReferenceID(t *testing.T) { + actual := NewLinkReferenceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "linkReferenceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/linkReferences/linkReferenceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLinkReferenceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LinkReferenceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/linkReferences", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/linkReferences/linkReferenceName", + Expected: &LinkReferenceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + LinkReferenceName: "linkReferenceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/linkReferences/linkReferenceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLinkReferenceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + if actual.LinkReferenceName != v.Expected.LinkReferenceName { + t.Fatalf("Expected %q but got %q for LinkReferenceName", v.Expected.LinkReferenceName, actual.LinkReferenceName) + } + + } +} + +func TestParseLinkReferenceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LinkReferenceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/linkReferences", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/lInKrEfErEnCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/linkReferences/linkReferenceName", + Expected: &LinkReferenceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + LinkReferenceName: "linkReferenceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/linkReferences/linkReferenceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/lInKrEfErEnCeS/lInKrEfErEnCeNaMe", + Expected: &LinkReferenceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkSecurityPerimeterName: "nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + LinkReferenceName: "lInKrEfErEnCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/lInKrEfErEnCeS/lInKrEfErEnCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLinkReferenceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + if actual.LinkReferenceName != v.Expected.LinkReferenceName { + t.Fatalf("Expected %q but got %q for LinkReferenceName", v.Expected.LinkReferenceName, actual.LinkReferenceName) + } + + } +} + +func TestSegmentsForLinkReferenceId(t *testing.T) { + segments := LinkReferenceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LinkReferenceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/id_networksecurityperimeter.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/id_networksecurityperimeter.go new file mode 100644 index 00000000000..775937ebc89 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/id_networksecurityperimeter.go @@ -0,0 +1,130 @@ +package networksecurityperimeterlinkreferences + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkSecurityPerimeterId{}) +} + +var _ resourceids.ResourceId = &NetworkSecurityPerimeterId{} + +// NetworkSecurityPerimeterId is a struct representing the Resource ID for a Network Security Perimeter +type NetworkSecurityPerimeterId struct { + SubscriptionId string + ResourceGroupName string + NetworkSecurityPerimeterName string +} + +// NewNetworkSecurityPerimeterID returns a new NetworkSecurityPerimeterId struct +func NewNetworkSecurityPerimeterID(subscriptionId string, resourceGroupName string, networkSecurityPerimeterName string) NetworkSecurityPerimeterId { + return NetworkSecurityPerimeterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkSecurityPerimeterName: networkSecurityPerimeterName, + } +} + +// ParseNetworkSecurityPerimeterID parses 'input' into a NetworkSecurityPerimeterId +func ParseNetworkSecurityPerimeterID(input string) (*NetworkSecurityPerimeterId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkSecurityPerimeterIDInsensitively parses 'input' case-insensitively into a NetworkSecurityPerimeterId +// note: this method should only be used for API response data and not user input +func ParseNetworkSecurityPerimeterIDInsensitively(input string) (*NetworkSecurityPerimeterId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkSecurityPerimeterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkSecurityPerimeterName, ok = input.Parsed["networkSecurityPerimeterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityPerimeterName", input) + } + + return nil +} + +// ValidateNetworkSecurityPerimeterID checks that 'input' can be parsed as a Network Security Perimeter ID +func ValidateNetworkSecurityPerimeterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkSecurityPerimeterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityPerimeters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkSecurityPerimeterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkSecurityPerimeters", "networkSecurityPerimeters", "networkSecurityPerimeters"), + resourceids.UserSpecifiedSegment("networkSecurityPerimeterName", "networkSecurityPerimeterName"), + } +} + +// String returns a human-readable description of this Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Security Perimeter Name: %q", id.NetworkSecurityPerimeterName), + } + return fmt.Sprintf("Network Security Perimeter (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/id_networksecurityperimeter_test.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/id_networksecurityperimeter_test.go new file mode 100644 index 00000000000..5b882b8e414 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/id_networksecurityperimeter_test.go @@ -0,0 +1,282 @@ +package networksecurityperimeterlinkreferences + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkSecurityPerimeterId{} + +func TestNewNetworkSecurityPerimeterID(t *testing.T) { + id := NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkSecurityPerimeterName != "networkSecurityPerimeterName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityPerimeterName'", id.NetworkSecurityPerimeterName, "networkSecurityPerimeterName") + } +} + +func TestFormatNetworkSecurityPerimeterID(t *testing.T) { + actual := NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkSecurityPerimeterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + } +} + +func TestParseNetworkSecurityPerimeterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkSecurityPerimeterName: "nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + } +} + +func TestSegmentsForNetworkSecurityPerimeterId(t *testing.T) { + segments := NetworkSecurityPerimeterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkSecurityPerimeterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/method_delete.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/method_delete.go new file mode 100644 index 00000000000..b15c6dbc1de --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/method_delete.go @@ -0,0 +1,71 @@ +package networksecurityperimeterlinkreferences + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c NetworkSecurityPerimeterLinkReferencesClient) Delete(ctx context.Context, id LinkReferenceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c NetworkSecurityPerimeterLinkReferencesClient) DeleteThenPoll(ctx context.Context, id LinkReferenceId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/method_get.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/method_get.go new file mode 100644 index 00000000000..f809cbe8968 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/method_get.go @@ -0,0 +1,53 @@ +package networksecurityperimeterlinkreferences + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NspLinkReference +} + +// Get ... +func (c NetworkSecurityPerimeterLinkReferencesClient) Get(ctx context.Context, id LinkReferenceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NspLinkReference + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/method_list.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/method_list.go new file mode 100644 index 00000000000..e6eb32f9a33 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/method_list.go @@ -0,0 +1,134 @@ +package networksecurityperimeterlinkreferences + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NspLinkReference +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NspLinkReference +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c NetworkSecurityPerimeterLinkReferencesClient) List(ctx context.Context, id NetworkSecurityPerimeterId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/linkReferences", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NspLinkReference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NetworkSecurityPerimeterLinkReferencesClient) ListComplete(ctx context.Context, id NetworkSecurityPerimeterId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, NspLinkReferenceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkSecurityPerimeterLinkReferencesClient) ListCompleteMatchingPredicate(ctx context.Context, id NetworkSecurityPerimeterId, options ListOperationOptions, predicate NspLinkReferenceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NspLinkReference, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/model_nsplinkreference.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/model_nsplinkreference.go new file mode 100644 index 00000000000..9f28e21e4a9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/model_nsplinkreference.go @@ -0,0 +1,16 @@ +package networksecurityperimeterlinkreferences + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspLinkReference struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NspLinkReferenceProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/model_nsplinkreferenceproperties.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/model_nsplinkreferenceproperties.go new file mode 100644 index 00000000000..7a5917be983 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/model_nsplinkreferenceproperties.go @@ -0,0 +1,17 @@ +package networksecurityperimeterlinkreferences + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspLinkReferenceProperties struct { + Description *string `json:"description,omitempty"` + LocalInboundProfiles *[]string `json:"localInboundProfiles,omitempty"` + LocalOutboundProfiles *[]string `json:"localOutboundProfiles,omitempty"` + ProvisioningState *NspLinkProvisioningState `json:"provisioningState,omitempty"` + RemoteInboundProfiles *[]string `json:"remoteInboundProfiles,omitempty"` + RemoteOutboundProfiles *[]string `json:"remoteOutboundProfiles,omitempty"` + RemotePerimeterGuid *string `json:"remotePerimeterGuid,omitempty"` + RemotePerimeterLocation *string `json:"remotePerimeterLocation,omitempty"` + RemotePerimeterResourceId *string `json:"remotePerimeterResourceId,omitempty"` + Status *NspLinkStatus `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/predicates.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/predicates.go new file mode 100644 index 00000000000..314e5bb5178 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/predicates.go @@ -0,0 +1,27 @@ +package networksecurityperimeterlinkreferences + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspLinkReferenceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p NspLinkReferenceOperationPredicate) Matches(input NspLinkReference) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/version.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/version.go new file mode 100644 index 00000000000..ff7a90f0ebb --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinkreferences/version.go @@ -0,0 +1,10 @@ +package networksecurityperimeterlinkreferences + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networksecurityperimeterlinkreferences/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinks/README.md b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/README.md new file mode 100644 index 00000000000..65efdb96e77 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterlinks` Documentation + +The `networksecurityperimeterlinks` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterlinks" +``` + + +### Client Initialization + +```go +client := networksecurityperimeterlinks.NewNetworkSecurityPerimeterLinksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkSecurityPerimeterLinksClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := networksecurityperimeterlinks.NewNetworkSecurityPerimeterLinkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "linkName") + +payload := networksecurityperimeterlinks.NspLink{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkSecurityPerimeterLinksClient.Delete` + +```go +ctx := context.TODO() +id := networksecurityperimeterlinks.NewNetworkSecurityPerimeterLinkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "linkName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkSecurityPerimeterLinksClient.Get` + +```go +ctx := context.TODO() +id := networksecurityperimeterlinks.NewNetworkSecurityPerimeterLinkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "linkName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkSecurityPerimeterLinksClient.List` + +```go +ctx := context.TODO() +id := networksecurityperimeterlinks.NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName") + +// alternatively `client.List(ctx, id, networksecurityperimeterlinks.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, networksecurityperimeterlinks.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinks/client.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/client.go new file mode 100644 index 00000000000..94ef4f72f60 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/client.go @@ -0,0 +1,26 @@ +package networksecurityperimeterlinks + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimeterLinksClient struct { + Client *resourcemanager.Client +} + +func NewNetworkSecurityPerimeterLinksClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkSecurityPerimeterLinksClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networksecurityperimeterlinks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkSecurityPerimeterLinksClient: %+v", err) + } + + return &NetworkSecurityPerimeterLinksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinks/constants.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/constants.go new file mode 100644 index 00000000000..f15625afbf6 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/constants.go @@ -0,0 +1,113 @@ +package networksecurityperimeterlinks + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspLinkProvisioningState string + +const ( + NspLinkProvisioningStateAccepted NspLinkProvisioningState = "Accepted" + NspLinkProvisioningStateCreating NspLinkProvisioningState = "Creating" + NspLinkProvisioningStateDeleting NspLinkProvisioningState = "Deleting" + NspLinkProvisioningStateFailed NspLinkProvisioningState = "Failed" + NspLinkProvisioningStateSucceeded NspLinkProvisioningState = "Succeeded" + NspLinkProvisioningStateUpdating NspLinkProvisioningState = "Updating" + NspLinkProvisioningStateWaitForRemoteCompletion NspLinkProvisioningState = "WaitForRemoteCompletion" +) + +func PossibleValuesForNspLinkProvisioningState() []string { + return []string{ + string(NspLinkProvisioningStateAccepted), + string(NspLinkProvisioningStateCreating), + string(NspLinkProvisioningStateDeleting), + string(NspLinkProvisioningStateFailed), + string(NspLinkProvisioningStateSucceeded), + string(NspLinkProvisioningStateUpdating), + string(NspLinkProvisioningStateWaitForRemoteCompletion), + } +} + +func (s *NspLinkProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNspLinkProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNspLinkProvisioningState(input string) (*NspLinkProvisioningState, error) { + vals := map[string]NspLinkProvisioningState{ + "accepted": NspLinkProvisioningStateAccepted, + "creating": NspLinkProvisioningStateCreating, + "deleting": NspLinkProvisioningStateDeleting, + "failed": NspLinkProvisioningStateFailed, + "succeeded": NspLinkProvisioningStateSucceeded, + "updating": NspLinkProvisioningStateUpdating, + "waitforremotecompletion": NspLinkProvisioningStateWaitForRemoteCompletion, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NspLinkProvisioningState(input) + return &out, nil +} + +type NspLinkStatus string + +const ( + NspLinkStatusApproved NspLinkStatus = "Approved" + NspLinkStatusDisconnected NspLinkStatus = "Disconnected" + NspLinkStatusPending NspLinkStatus = "Pending" + NspLinkStatusRejected NspLinkStatus = "Rejected" +) + +func PossibleValuesForNspLinkStatus() []string { + return []string{ + string(NspLinkStatusApproved), + string(NspLinkStatusDisconnected), + string(NspLinkStatusPending), + string(NspLinkStatusRejected), + } +} + +func (s *NspLinkStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNspLinkStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNspLinkStatus(input string) (*NspLinkStatus, error) { + vals := map[string]NspLinkStatus{ + "approved": NspLinkStatusApproved, + "disconnected": NspLinkStatusDisconnected, + "pending": NspLinkStatusPending, + "rejected": NspLinkStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NspLinkStatus(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinks/id_networksecurityperimeter.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/id_networksecurityperimeter.go new file mode 100644 index 00000000000..9849c3c782c --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/id_networksecurityperimeter.go @@ -0,0 +1,130 @@ +package networksecurityperimeterlinks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkSecurityPerimeterId{}) +} + +var _ resourceids.ResourceId = &NetworkSecurityPerimeterId{} + +// NetworkSecurityPerimeterId is a struct representing the Resource ID for a Network Security Perimeter +type NetworkSecurityPerimeterId struct { + SubscriptionId string + ResourceGroupName string + NetworkSecurityPerimeterName string +} + +// NewNetworkSecurityPerimeterID returns a new NetworkSecurityPerimeterId struct +func NewNetworkSecurityPerimeterID(subscriptionId string, resourceGroupName string, networkSecurityPerimeterName string) NetworkSecurityPerimeterId { + return NetworkSecurityPerimeterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkSecurityPerimeterName: networkSecurityPerimeterName, + } +} + +// ParseNetworkSecurityPerimeterID parses 'input' into a NetworkSecurityPerimeterId +func ParseNetworkSecurityPerimeterID(input string) (*NetworkSecurityPerimeterId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkSecurityPerimeterIDInsensitively parses 'input' case-insensitively into a NetworkSecurityPerimeterId +// note: this method should only be used for API response data and not user input +func ParseNetworkSecurityPerimeterIDInsensitively(input string) (*NetworkSecurityPerimeterId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkSecurityPerimeterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkSecurityPerimeterName, ok = input.Parsed["networkSecurityPerimeterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityPerimeterName", input) + } + + return nil +} + +// ValidateNetworkSecurityPerimeterID checks that 'input' can be parsed as a Network Security Perimeter ID +func ValidateNetworkSecurityPerimeterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkSecurityPerimeterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityPerimeters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkSecurityPerimeterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkSecurityPerimeters", "networkSecurityPerimeters", "networkSecurityPerimeters"), + resourceids.UserSpecifiedSegment("networkSecurityPerimeterName", "networkSecurityPerimeterName"), + } +} + +// String returns a human-readable description of this Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Security Perimeter Name: %q", id.NetworkSecurityPerimeterName), + } + return fmt.Sprintf("Network Security Perimeter (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinks/id_networksecurityperimeter_test.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/id_networksecurityperimeter_test.go new file mode 100644 index 00000000000..5914aa68371 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/id_networksecurityperimeter_test.go @@ -0,0 +1,282 @@ +package networksecurityperimeterlinks + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkSecurityPerimeterId{} + +func TestNewNetworkSecurityPerimeterID(t *testing.T) { + id := NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkSecurityPerimeterName != "networkSecurityPerimeterName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityPerimeterName'", id.NetworkSecurityPerimeterName, "networkSecurityPerimeterName") + } +} + +func TestFormatNetworkSecurityPerimeterID(t *testing.T) { + actual := NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkSecurityPerimeterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + } +} + +func TestParseNetworkSecurityPerimeterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkSecurityPerimeterName: "nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + } +} + +func TestSegmentsForNetworkSecurityPerimeterId(t *testing.T) { + segments := NetworkSecurityPerimeterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkSecurityPerimeterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinks/id_networksecurityperimeterlink.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/id_networksecurityperimeterlink.go new file mode 100644 index 00000000000..2915ffead41 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/id_networksecurityperimeterlink.go @@ -0,0 +1,139 @@ +package networksecurityperimeterlinks + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkSecurityPerimeterLinkId{}) +} + +var _ resourceids.ResourceId = &NetworkSecurityPerimeterLinkId{} + +// NetworkSecurityPerimeterLinkId is a struct representing the Resource ID for a Network Security Perimeter Link +type NetworkSecurityPerimeterLinkId struct { + SubscriptionId string + ResourceGroupName string + NetworkSecurityPerimeterName string + LinkName string +} + +// NewNetworkSecurityPerimeterLinkID returns a new NetworkSecurityPerimeterLinkId struct +func NewNetworkSecurityPerimeterLinkID(subscriptionId string, resourceGroupName string, networkSecurityPerimeterName string, linkName string) NetworkSecurityPerimeterLinkId { + return NetworkSecurityPerimeterLinkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkSecurityPerimeterName: networkSecurityPerimeterName, + LinkName: linkName, + } +} + +// ParseNetworkSecurityPerimeterLinkID parses 'input' into a NetworkSecurityPerimeterLinkId +func ParseNetworkSecurityPerimeterLinkID(input string) (*NetworkSecurityPerimeterLinkId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterLinkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterLinkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkSecurityPerimeterLinkIDInsensitively parses 'input' case-insensitively into a NetworkSecurityPerimeterLinkId +// note: this method should only be used for API response data and not user input +func ParseNetworkSecurityPerimeterLinkIDInsensitively(input string) (*NetworkSecurityPerimeterLinkId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterLinkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterLinkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkSecurityPerimeterLinkId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkSecurityPerimeterName, ok = input.Parsed["networkSecurityPerimeterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityPerimeterName", input) + } + + if id.LinkName, ok = input.Parsed["linkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "linkName", input) + } + + return nil +} + +// ValidateNetworkSecurityPerimeterLinkID checks that 'input' can be parsed as a Network Security Perimeter Link ID +func ValidateNetworkSecurityPerimeterLinkID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkSecurityPerimeterLinkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Security Perimeter Link ID +func (id NetworkSecurityPerimeterLinkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityPerimeters/%s/links/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkSecurityPerimeterName, id.LinkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Security Perimeter Link ID +func (id NetworkSecurityPerimeterLinkId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkSecurityPerimeters", "networkSecurityPerimeters", "networkSecurityPerimeters"), + resourceids.UserSpecifiedSegment("networkSecurityPerimeterName", "networkSecurityPerimeterName"), + resourceids.StaticSegment("staticLinks", "links", "links"), + resourceids.UserSpecifiedSegment("linkName", "linkName"), + } +} + +// String returns a human-readable description of this Network Security Perimeter Link ID +func (id NetworkSecurityPerimeterLinkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Security Perimeter Name: %q", id.NetworkSecurityPerimeterName), + fmt.Sprintf("Link Name: %q", id.LinkName), + } + return fmt.Sprintf("Network Security Perimeter Link (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinks/id_networksecurityperimeterlink_test.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/id_networksecurityperimeterlink_test.go new file mode 100644 index 00000000000..b6c1d665557 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/id_networksecurityperimeterlink_test.go @@ -0,0 +1,327 @@ +package networksecurityperimeterlinks + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkSecurityPerimeterLinkId{} + +func TestNewNetworkSecurityPerimeterLinkID(t *testing.T) { + id := NewNetworkSecurityPerimeterLinkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "linkName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkSecurityPerimeterName != "networkSecurityPerimeterName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityPerimeterName'", id.NetworkSecurityPerimeterName, "networkSecurityPerimeterName") + } + + if id.LinkName != "linkName" { + t.Fatalf("Expected %q but got %q for Segment 'LinkName'", id.LinkName, "linkName") + } +} + +func TestFormatNetworkSecurityPerimeterLinkID(t *testing.T) { + actual := NewNetworkSecurityPerimeterLinkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "linkName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/links/linkName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkSecurityPerimeterLinkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterLinkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/links", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/links/linkName", + Expected: &NetworkSecurityPerimeterLinkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + LinkName: "linkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/links/linkName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterLinkID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + if actual.LinkName != v.Expected.LinkName { + t.Fatalf("Expected %q but got %q for LinkName", v.Expected.LinkName, actual.LinkName) + } + + } +} + +func TestParseNetworkSecurityPerimeterLinkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterLinkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/links", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/lInKs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/links/linkName", + Expected: &NetworkSecurityPerimeterLinkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + LinkName: "linkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/links/linkName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/lInKs/lInKnAmE", + Expected: &NetworkSecurityPerimeterLinkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkSecurityPerimeterName: "nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + LinkName: "lInKnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/lInKs/lInKnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterLinkIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + if actual.LinkName != v.Expected.LinkName { + t.Fatalf("Expected %q but got %q for LinkName", v.Expected.LinkName, actual.LinkName) + } + + } +} + +func TestSegmentsForNetworkSecurityPerimeterLinkId(t *testing.T) { + segments := NetworkSecurityPerimeterLinkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkSecurityPerimeterLinkId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinks/method_createorupdate.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/method_createorupdate.go new file mode 100644 index 00000000000..a26c38f596e --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/method_createorupdate.go @@ -0,0 +1,58 @@ +package networksecurityperimeterlinks + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NspLink +} + +// CreateOrUpdate ... +func (c NetworkSecurityPerimeterLinksClient) CreateOrUpdate(ctx context.Context, id NetworkSecurityPerimeterLinkId, input NspLink) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NspLink + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinks/method_delete.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/method_delete.go new file mode 100644 index 00000000000..e3b5c941a0f --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/method_delete.go @@ -0,0 +1,71 @@ +package networksecurityperimeterlinks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c NetworkSecurityPerimeterLinksClient) Delete(ctx context.Context, id NetworkSecurityPerimeterLinkId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c NetworkSecurityPerimeterLinksClient) DeleteThenPoll(ctx context.Context, id NetworkSecurityPerimeterLinkId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinks/method_get.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/method_get.go new file mode 100644 index 00000000000..0e61d548c34 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/method_get.go @@ -0,0 +1,53 @@ +package networksecurityperimeterlinks + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NspLink +} + +// Get ... +func (c NetworkSecurityPerimeterLinksClient) Get(ctx context.Context, id NetworkSecurityPerimeterLinkId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NspLink + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinks/method_list.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/method_list.go new file mode 100644 index 00000000000..922516104cf --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/method_list.go @@ -0,0 +1,134 @@ +package networksecurityperimeterlinks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NspLink +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NspLink +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c NetworkSecurityPerimeterLinksClient) List(ctx context.Context, id NetworkSecurityPerimeterId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/links", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NspLink `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NetworkSecurityPerimeterLinksClient) ListComplete(ctx context.Context, id NetworkSecurityPerimeterId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, NspLinkOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkSecurityPerimeterLinksClient) ListCompleteMatchingPredicate(ctx context.Context, id NetworkSecurityPerimeterId, options ListOperationOptions, predicate NspLinkOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NspLink, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinks/model_nsplink.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/model_nsplink.go new file mode 100644 index 00000000000..f2c77133706 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/model_nsplink.go @@ -0,0 +1,16 @@ +package networksecurityperimeterlinks + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspLink struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NspLinkProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinks/model_nsplinkproperties.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/model_nsplinkproperties.go new file mode 100644 index 00000000000..ea2f2db2b1a --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/model_nsplinkproperties.go @@ -0,0 +1,17 @@ +package networksecurityperimeterlinks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspLinkProperties struct { + AutoApprovedRemotePerimeterResourceId *string `json:"autoApprovedRemotePerimeterResourceId,omitempty"` + Description *string `json:"description,omitempty"` + LocalInboundProfiles *[]string `json:"localInboundProfiles,omitempty"` + LocalOutboundProfiles *[]string `json:"localOutboundProfiles,omitempty"` + ProvisioningState *NspLinkProvisioningState `json:"provisioningState,omitempty"` + RemoteInboundProfiles *[]string `json:"remoteInboundProfiles,omitempty"` + RemoteOutboundProfiles *[]string `json:"remoteOutboundProfiles,omitempty"` + RemotePerimeterGuid *string `json:"remotePerimeterGuid,omitempty"` + RemotePerimeterLocation *string `json:"remotePerimeterLocation,omitempty"` + Status *NspLinkStatus `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinks/predicates.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/predicates.go new file mode 100644 index 00000000000..84db94026cb --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/predicates.go @@ -0,0 +1,27 @@ +package networksecurityperimeterlinks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspLinkOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p NspLinkOperationPredicate) Matches(input NspLink) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterlinks/version.go b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/version.go new file mode 100644 index 00000000000..73d6298c803 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterlinks/version.go @@ -0,0 +1,10 @@ +package networksecurityperimeterlinks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networksecurityperimeterlinks/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/README.md b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/README.md new file mode 100644 index 00000000000..f03d92fc4b9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations` Documentation + +The `networksecurityperimeterloggingconfigurations` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations" +``` + + +### Client Initialization + +```go +client := networksecurityperimeterloggingconfigurations.NewNetworkSecurityPerimeterLoggingConfigurationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkSecurityPerimeterLoggingConfigurationsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := networksecurityperimeterloggingconfigurations.NewLoggingConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "loggingConfigurationName") + +payload := networksecurityperimeterloggingconfigurations.NspLoggingConfiguration{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkSecurityPerimeterLoggingConfigurationsClient.Delete` + +```go +ctx := context.TODO() +id := networksecurityperimeterloggingconfigurations.NewLoggingConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "loggingConfigurationName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkSecurityPerimeterLoggingConfigurationsClient.Get` + +```go +ctx := context.TODO() +id := networksecurityperimeterloggingconfigurations.NewLoggingConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "loggingConfigurationName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkSecurityPerimeterLoggingConfigurationsClient.List` + +```go +ctx := context.TODO() +id := networksecurityperimeterloggingconfigurations.NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/client.go b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/client.go new file mode 100644 index 00000000000..cebab05a31b --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/client.go @@ -0,0 +1,26 @@ +package networksecurityperimeterloggingconfigurations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimeterLoggingConfigurationsClient struct { + Client *resourcemanager.Client +} + +func NewNetworkSecurityPerimeterLoggingConfigurationsClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkSecurityPerimeterLoggingConfigurationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networksecurityperimeterloggingconfigurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkSecurityPerimeterLoggingConfigurationsClient: %+v", err) + } + + return &NetworkSecurityPerimeterLoggingConfigurationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/id_loggingconfiguration.go b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/id_loggingconfiguration.go new file mode 100644 index 00000000000..a1053442764 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/id_loggingconfiguration.go @@ -0,0 +1,139 @@ +package networksecurityperimeterloggingconfigurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LoggingConfigurationId{}) +} + +var _ resourceids.ResourceId = &LoggingConfigurationId{} + +// LoggingConfigurationId is a struct representing the Resource ID for a Logging Configuration +type LoggingConfigurationId struct { + SubscriptionId string + ResourceGroupName string + NetworkSecurityPerimeterName string + LoggingConfigurationName string +} + +// NewLoggingConfigurationID returns a new LoggingConfigurationId struct +func NewLoggingConfigurationID(subscriptionId string, resourceGroupName string, networkSecurityPerimeterName string, loggingConfigurationName string) LoggingConfigurationId { + return LoggingConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkSecurityPerimeterName: networkSecurityPerimeterName, + LoggingConfigurationName: loggingConfigurationName, + } +} + +// ParseLoggingConfigurationID parses 'input' into a LoggingConfigurationId +func ParseLoggingConfigurationID(input string) (*LoggingConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LoggingConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LoggingConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLoggingConfigurationIDInsensitively parses 'input' case-insensitively into a LoggingConfigurationId +// note: this method should only be used for API response data and not user input +func ParseLoggingConfigurationIDInsensitively(input string) (*LoggingConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LoggingConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LoggingConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LoggingConfigurationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkSecurityPerimeterName, ok = input.Parsed["networkSecurityPerimeterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityPerimeterName", input) + } + + if id.LoggingConfigurationName, ok = input.Parsed["loggingConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "loggingConfigurationName", input) + } + + return nil +} + +// ValidateLoggingConfigurationID checks that 'input' can be parsed as a Logging Configuration ID +func ValidateLoggingConfigurationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLoggingConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Logging Configuration ID +func (id LoggingConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityPerimeters/%s/loggingConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkSecurityPerimeterName, id.LoggingConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Logging Configuration ID +func (id LoggingConfigurationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkSecurityPerimeters", "networkSecurityPerimeters", "networkSecurityPerimeters"), + resourceids.UserSpecifiedSegment("networkSecurityPerimeterName", "networkSecurityPerimeterName"), + resourceids.StaticSegment("staticLoggingConfigurations", "loggingConfigurations", "loggingConfigurations"), + resourceids.UserSpecifiedSegment("loggingConfigurationName", "loggingConfigurationName"), + } +} + +// String returns a human-readable description of this Logging Configuration ID +func (id LoggingConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Security Perimeter Name: %q", id.NetworkSecurityPerimeterName), + fmt.Sprintf("Logging Configuration Name: %q", id.LoggingConfigurationName), + } + return fmt.Sprintf("Logging Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/id_loggingconfiguration_test.go b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/id_loggingconfiguration_test.go new file mode 100644 index 00000000000..ecfee16544a --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/id_loggingconfiguration_test.go @@ -0,0 +1,327 @@ +package networksecurityperimeterloggingconfigurations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LoggingConfigurationId{} + +func TestNewLoggingConfigurationID(t *testing.T) { + id := NewLoggingConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "loggingConfigurationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkSecurityPerimeterName != "networkSecurityPerimeterName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityPerimeterName'", id.NetworkSecurityPerimeterName, "networkSecurityPerimeterName") + } + + if id.LoggingConfigurationName != "loggingConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'LoggingConfigurationName'", id.LoggingConfigurationName, "loggingConfigurationName") + } +} + +func TestFormatLoggingConfigurationID(t *testing.T) { + actual := NewLoggingConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "loggingConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/loggingConfigurations/loggingConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLoggingConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LoggingConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/loggingConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/loggingConfigurations/loggingConfigurationName", + Expected: &LoggingConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + LoggingConfigurationName: "loggingConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/loggingConfigurations/loggingConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLoggingConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + if actual.LoggingConfigurationName != v.Expected.LoggingConfigurationName { + t.Fatalf("Expected %q but got %q for LoggingConfigurationName", v.Expected.LoggingConfigurationName, actual.LoggingConfigurationName) + } + + } +} + +func TestParseLoggingConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LoggingConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/loggingConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/lOgGiNgCoNfIgUrAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/loggingConfigurations/loggingConfigurationName", + Expected: &LoggingConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + LoggingConfigurationName: "loggingConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/loggingConfigurations/loggingConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/lOgGiNgCoNfIgUrAtIoNs/lOgGiNgCoNfIgUrAtIoNnAmE", + Expected: &LoggingConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkSecurityPerimeterName: "nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + LoggingConfigurationName: "lOgGiNgCoNfIgUrAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/lOgGiNgCoNfIgUrAtIoNs/lOgGiNgCoNfIgUrAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLoggingConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + if actual.LoggingConfigurationName != v.Expected.LoggingConfigurationName { + t.Fatalf("Expected %q but got %q for LoggingConfigurationName", v.Expected.LoggingConfigurationName, actual.LoggingConfigurationName) + } + + } +} + +func TestSegmentsForLoggingConfigurationId(t *testing.T) { + segments := LoggingConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LoggingConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/id_networksecurityperimeter.go b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/id_networksecurityperimeter.go new file mode 100644 index 00000000000..310f6ba7832 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/id_networksecurityperimeter.go @@ -0,0 +1,130 @@ +package networksecurityperimeterloggingconfigurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkSecurityPerimeterId{}) +} + +var _ resourceids.ResourceId = &NetworkSecurityPerimeterId{} + +// NetworkSecurityPerimeterId is a struct representing the Resource ID for a Network Security Perimeter +type NetworkSecurityPerimeterId struct { + SubscriptionId string + ResourceGroupName string + NetworkSecurityPerimeterName string +} + +// NewNetworkSecurityPerimeterID returns a new NetworkSecurityPerimeterId struct +func NewNetworkSecurityPerimeterID(subscriptionId string, resourceGroupName string, networkSecurityPerimeterName string) NetworkSecurityPerimeterId { + return NetworkSecurityPerimeterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkSecurityPerimeterName: networkSecurityPerimeterName, + } +} + +// ParseNetworkSecurityPerimeterID parses 'input' into a NetworkSecurityPerimeterId +func ParseNetworkSecurityPerimeterID(input string) (*NetworkSecurityPerimeterId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkSecurityPerimeterIDInsensitively parses 'input' case-insensitively into a NetworkSecurityPerimeterId +// note: this method should only be used for API response data and not user input +func ParseNetworkSecurityPerimeterIDInsensitively(input string) (*NetworkSecurityPerimeterId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkSecurityPerimeterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkSecurityPerimeterName, ok = input.Parsed["networkSecurityPerimeterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityPerimeterName", input) + } + + return nil +} + +// ValidateNetworkSecurityPerimeterID checks that 'input' can be parsed as a Network Security Perimeter ID +func ValidateNetworkSecurityPerimeterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkSecurityPerimeterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityPerimeters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkSecurityPerimeterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkSecurityPerimeters", "networkSecurityPerimeters", "networkSecurityPerimeters"), + resourceids.UserSpecifiedSegment("networkSecurityPerimeterName", "networkSecurityPerimeterName"), + } +} + +// String returns a human-readable description of this Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Security Perimeter Name: %q", id.NetworkSecurityPerimeterName), + } + return fmt.Sprintf("Network Security Perimeter (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/id_networksecurityperimeter_test.go b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/id_networksecurityperimeter_test.go new file mode 100644 index 00000000000..2d95821bfd9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/id_networksecurityperimeter_test.go @@ -0,0 +1,282 @@ +package networksecurityperimeterloggingconfigurations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkSecurityPerimeterId{} + +func TestNewNetworkSecurityPerimeterID(t *testing.T) { + id := NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkSecurityPerimeterName != "networkSecurityPerimeterName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityPerimeterName'", id.NetworkSecurityPerimeterName, "networkSecurityPerimeterName") + } +} + +func TestFormatNetworkSecurityPerimeterID(t *testing.T) { + actual := NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkSecurityPerimeterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + } +} + +func TestParseNetworkSecurityPerimeterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkSecurityPerimeterName: "nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + } +} + +func TestSegmentsForNetworkSecurityPerimeterId(t *testing.T) { + segments := NetworkSecurityPerimeterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkSecurityPerimeterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/method_createorupdate.go b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/method_createorupdate.go new file mode 100644 index 00000000000..a95b494e0db --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/method_createorupdate.go @@ -0,0 +1,58 @@ +package networksecurityperimeterloggingconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NspLoggingConfiguration +} + +// CreateOrUpdate ... +func (c NetworkSecurityPerimeterLoggingConfigurationsClient) CreateOrUpdate(ctx context.Context, id LoggingConfigurationId, input NspLoggingConfiguration) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NspLoggingConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/method_delete.go b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/method_delete.go new file mode 100644 index 00000000000..6b09180891b --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/method_delete.go @@ -0,0 +1,47 @@ +package networksecurityperimeterloggingconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c NetworkSecurityPerimeterLoggingConfigurationsClient) Delete(ctx context.Context, id LoggingConfigurationId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/method_get.go b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/method_get.go new file mode 100644 index 00000000000..c9da088dff2 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/method_get.go @@ -0,0 +1,53 @@ +package networksecurityperimeterloggingconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NspLoggingConfiguration +} + +// Get ... +func (c NetworkSecurityPerimeterLoggingConfigurationsClient) Get(ctx context.Context, id LoggingConfigurationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NspLoggingConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/method_list.go b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/method_list.go new file mode 100644 index 00000000000..0b1f2b74187 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/method_list.go @@ -0,0 +1,105 @@ +package networksecurityperimeterloggingconfigurations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NspLoggingConfiguration +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NspLoggingConfiguration +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c NetworkSecurityPerimeterLoggingConfigurationsClient) List(ctx context.Context, id NetworkSecurityPerimeterId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/loggingConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NspLoggingConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NetworkSecurityPerimeterLoggingConfigurationsClient) ListComplete(ctx context.Context, id NetworkSecurityPerimeterId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, NspLoggingConfigurationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkSecurityPerimeterLoggingConfigurationsClient) ListCompleteMatchingPredicate(ctx context.Context, id NetworkSecurityPerimeterId, predicate NspLoggingConfigurationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NspLoggingConfiguration, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/model_nsploggingconfiguration.go b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/model_nsploggingconfiguration.go new file mode 100644 index 00000000000..4b8f491a2bb --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/model_nsploggingconfiguration.go @@ -0,0 +1,16 @@ +package networksecurityperimeterloggingconfigurations + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspLoggingConfiguration struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NspLoggingConfigurationProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/model_nsploggingconfigurationproperties.go b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/model_nsploggingconfigurationproperties.go new file mode 100644 index 00000000000..3525797a1f3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/model_nsploggingconfigurationproperties.go @@ -0,0 +1,9 @@ +package networksecurityperimeterloggingconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspLoggingConfigurationProperties struct { + EnabledLogCategories *[]string `json:"enabledLogCategories,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/predicates.go b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/predicates.go new file mode 100644 index 00000000000..3f55962780a --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/predicates.go @@ -0,0 +1,27 @@ +package networksecurityperimeterloggingconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspLoggingConfigurationOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p NspLoggingConfigurationOperationPredicate) Matches(input NspLoggingConfiguration) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/version.go b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/version.go new file mode 100644 index 00000000000..e6a30b430a5 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterloggingconfigurations/version.go @@ -0,0 +1,10 @@ +package networksecurityperimeterloggingconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networksecurityperimeterloggingconfigurations/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/README.md b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/README.md new file mode 100644 index 00000000000..55c441b1da3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterprofiles` Documentation + +The `networksecurityperimeterprofiles` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeterprofiles" +``` + + +### Client Initialization + +```go +client := networksecurityperimeterprofiles.NewNetworkSecurityPerimeterProfilesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkSecurityPerimeterProfilesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := networksecurityperimeterprofiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "profileName") + +payload := networksecurityperimeterprofiles.NspProfile{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkSecurityPerimeterProfilesClient.Delete` + +```go +ctx := context.TODO() +id := networksecurityperimeterprofiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "profileName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkSecurityPerimeterProfilesClient.Get` + +```go +ctx := context.TODO() +id := networksecurityperimeterprofiles.NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "profileName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkSecurityPerimeterProfilesClient.List` + +```go +ctx := context.TODO() +id := networksecurityperimeterprofiles.NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName") + +// alternatively `client.List(ctx, id, networksecurityperimeterprofiles.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, networksecurityperimeterprofiles.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/client.go b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/client.go new file mode 100644 index 00000000000..ae0fba11ede --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/client.go @@ -0,0 +1,26 @@ +package networksecurityperimeterprofiles + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimeterProfilesClient struct { + Client *resourcemanager.Client +} + +func NewNetworkSecurityPerimeterProfilesClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkSecurityPerimeterProfilesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networksecurityperimeterprofiles", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkSecurityPerimeterProfilesClient: %+v", err) + } + + return &NetworkSecurityPerimeterProfilesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/id_networksecurityperimeter.go b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/id_networksecurityperimeter.go new file mode 100644 index 00000000000..407830f4aec --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/id_networksecurityperimeter.go @@ -0,0 +1,130 @@ +package networksecurityperimeterprofiles + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkSecurityPerimeterId{}) +} + +var _ resourceids.ResourceId = &NetworkSecurityPerimeterId{} + +// NetworkSecurityPerimeterId is a struct representing the Resource ID for a Network Security Perimeter +type NetworkSecurityPerimeterId struct { + SubscriptionId string + ResourceGroupName string + NetworkSecurityPerimeterName string +} + +// NewNetworkSecurityPerimeterID returns a new NetworkSecurityPerimeterId struct +func NewNetworkSecurityPerimeterID(subscriptionId string, resourceGroupName string, networkSecurityPerimeterName string) NetworkSecurityPerimeterId { + return NetworkSecurityPerimeterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkSecurityPerimeterName: networkSecurityPerimeterName, + } +} + +// ParseNetworkSecurityPerimeterID parses 'input' into a NetworkSecurityPerimeterId +func ParseNetworkSecurityPerimeterID(input string) (*NetworkSecurityPerimeterId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkSecurityPerimeterIDInsensitively parses 'input' case-insensitively into a NetworkSecurityPerimeterId +// note: this method should only be used for API response data and not user input +func ParseNetworkSecurityPerimeterIDInsensitively(input string) (*NetworkSecurityPerimeterId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkSecurityPerimeterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkSecurityPerimeterName, ok = input.Parsed["networkSecurityPerimeterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityPerimeterName", input) + } + + return nil +} + +// ValidateNetworkSecurityPerimeterID checks that 'input' can be parsed as a Network Security Perimeter ID +func ValidateNetworkSecurityPerimeterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkSecurityPerimeterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityPerimeters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkSecurityPerimeterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkSecurityPerimeters", "networkSecurityPerimeters", "networkSecurityPerimeters"), + resourceids.UserSpecifiedSegment("networkSecurityPerimeterName", "networkSecurityPerimeterName"), + } +} + +// String returns a human-readable description of this Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Security Perimeter Name: %q", id.NetworkSecurityPerimeterName), + } + return fmt.Sprintf("Network Security Perimeter (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/id_networksecurityperimeter_test.go b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/id_networksecurityperimeter_test.go new file mode 100644 index 00000000000..d8c757b68f1 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/id_networksecurityperimeter_test.go @@ -0,0 +1,282 @@ +package networksecurityperimeterprofiles + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkSecurityPerimeterId{} + +func TestNewNetworkSecurityPerimeterID(t *testing.T) { + id := NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkSecurityPerimeterName != "networkSecurityPerimeterName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityPerimeterName'", id.NetworkSecurityPerimeterName, "networkSecurityPerimeterName") + } +} + +func TestFormatNetworkSecurityPerimeterID(t *testing.T) { + actual := NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkSecurityPerimeterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + } +} + +func TestParseNetworkSecurityPerimeterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkSecurityPerimeterName: "nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + } +} + +func TestSegmentsForNetworkSecurityPerimeterId(t *testing.T) { + segments := NetworkSecurityPerimeterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkSecurityPerimeterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/id_profile.go b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/id_profile.go new file mode 100644 index 00000000000..2f4398d752e --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/id_profile.go @@ -0,0 +1,139 @@ +package networksecurityperimeterprofiles + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProfileId{}) +} + +var _ resourceids.ResourceId = &ProfileId{} + +// ProfileId is a struct representing the Resource ID for a Profile +type ProfileId struct { + SubscriptionId string + ResourceGroupName string + NetworkSecurityPerimeterName string + ProfileName string +} + +// NewProfileID returns a new ProfileId struct +func NewProfileID(subscriptionId string, resourceGroupName string, networkSecurityPerimeterName string, profileName string) ProfileId { + return ProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkSecurityPerimeterName: networkSecurityPerimeterName, + ProfileName: profileName, + } +} + +// ParseProfileID parses 'input' into a ProfileId +func ParseProfileID(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProfileIDInsensitively parses 'input' case-insensitively into a ProfileId +// note: this method should only be used for API response data and not user input +func ParseProfileIDInsensitively(input string) (*ProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProfileId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProfileId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkSecurityPerimeterName, ok = input.Parsed["networkSecurityPerimeterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityPerimeterName", input) + } + + if id.ProfileName, ok = input.Parsed["profileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "profileName", input) + } + + return nil +} + +// ValidateProfileID checks that 'input' can be parsed as a Profile ID +func ValidateProfileID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Profile ID +func (id ProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityPerimeters/%s/profiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkSecurityPerimeterName, id.ProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Profile ID +func (id ProfileId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkSecurityPerimeters", "networkSecurityPerimeters", "networkSecurityPerimeters"), + resourceids.UserSpecifiedSegment("networkSecurityPerimeterName", "networkSecurityPerimeterName"), + resourceids.StaticSegment("staticProfiles", "profiles", "profiles"), + resourceids.UserSpecifiedSegment("profileName", "profileName"), + } +} + +// String returns a human-readable description of this Profile ID +func (id ProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Security Perimeter Name: %q", id.NetworkSecurityPerimeterName), + fmt.Sprintf("Profile Name: %q", id.ProfileName), + } + return fmt.Sprintf("Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/id_profile_test.go b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/id_profile_test.go new file mode 100644 index 00000000000..72d74f421d7 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/id_profile_test.go @@ -0,0 +1,327 @@ +package networksecurityperimeterprofiles + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProfileId{} + +func TestNewProfileID(t *testing.T) { + id := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "profileName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkSecurityPerimeterName != "networkSecurityPerimeterName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityPerimeterName'", id.NetworkSecurityPerimeterName, "networkSecurityPerimeterName") + } + + if id.ProfileName != "profileName" { + t.Fatalf("Expected %q but got %q for Segment 'ProfileName'", id.ProfileName, "profileName") + } +} + +func TestFormatProfileID(t *testing.T) { + actual := NewProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName", "profileName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + if actual.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestParseProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/pRoFiLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + ProfileName: "profileName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/profiles/profileName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/pRoFiLeS/pRoFiLeNaMe", + Expected: &ProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkSecurityPerimeterName: "nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + ProfileName: "pRoFiLeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/pRoFiLeS/pRoFiLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProfileIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + if actual.ProfileName != v.Expected.ProfileName { + t.Fatalf("Expected %q but got %q for ProfileName", v.Expected.ProfileName, actual.ProfileName) + } + + } +} + +func TestSegmentsForProfileId(t *testing.T) { + segments := ProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProfileId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/method_createorupdate.go b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/method_createorupdate.go new file mode 100644 index 00000000000..3a5e70c11e0 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/method_createorupdate.go @@ -0,0 +1,58 @@ +package networksecurityperimeterprofiles + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NspProfile +} + +// CreateOrUpdate ... +func (c NetworkSecurityPerimeterProfilesClient) CreateOrUpdate(ctx context.Context, id ProfileId, input NspProfile) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NspProfile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/method_delete.go b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/method_delete.go new file mode 100644 index 00000000000..44001b8f0e8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/method_delete.go @@ -0,0 +1,47 @@ +package networksecurityperimeterprofiles + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c NetworkSecurityPerimeterProfilesClient) Delete(ctx context.Context, id ProfileId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/method_get.go b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/method_get.go new file mode 100644 index 00000000000..569751ffcb6 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/method_get.go @@ -0,0 +1,53 @@ +package networksecurityperimeterprofiles + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NspProfile +} + +// Get ... +func (c NetworkSecurityPerimeterProfilesClient) Get(ctx context.Context, id ProfileId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NspProfile + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/method_list.go b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/method_list.go new file mode 100644 index 00000000000..b589ea4ac48 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/method_list.go @@ -0,0 +1,134 @@ +package networksecurityperimeterprofiles + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NspProfile +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NspProfile +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c NetworkSecurityPerimeterProfilesClient) List(ctx context.Context, id NetworkSecurityPerimeterId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/profiles", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NspProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NetworkSecurityPerimeterProfilesClient) ListComplete(ctx context.Context, id NetworkSecurityPerimeterId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, NspProfileOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkSecurityPerimeterProfilesClient) ListCompleteMatchingPredicate(ctx context.Context, id NetworkSecurityPerimeterId, options ListOperationOptions, predicate NspProfileOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NspProfile, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/model_nspprofile.go b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/model_nspprofile.go new file mode 100644 index 00000000000..97311b6cfbc --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/model_nspprofile.go @@ -0,0 +1,16 @@ +package networksecurityperimeterprofiles + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NspProfileProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/model_nspprofileproperties.go b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/model_nspprofileproperties.go new file mode 100644 index 00000000000..99b92f8f490 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/model_nspprofileproperties.go @@ -0,0 +1,9 @@ +package networksecurityperimeterprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspProfileProperties struct { + AccessRulesVersion *string `json:"accessRulesVersion,omitempty"` + DiagnosticSettingsVersion *string `json:"diagnosticSettingsVersion,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/predicates.go b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/predicates.go new file mode 100644 index 00000000000..de610c0d82a --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/predicates.go @@ -0,0 +1,27 @@ +package networksecurityperimeterprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspProfileOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p NspProfileOperationPredicate) Matches(input NspProfile) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/version.go b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/version.go new file mode 100644 index 00000000000..c748352dc2e --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeterprofiles/version.go @@ -0,0 +1,10 @@ +package networksecurityperimeterprofiles + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networksecurityperimeterprofiles/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeters/README.md b/resource-manager/network/2024-07-01/networksecurityperimeters/README.md new file mode 100644 index 00000000000..fe60193ab62 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeters/README.md @@ -0,0 +1,125 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeters` Documentation + +The `networksecurityperimeters` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networksecurityperimeters" +``` + + +### Client Initialization + +```go +client := networksecurityperimeters.NewNetworkSecurityPerimetersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkSecurityPerimetersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := networksecurityperimeters.NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName") + +payload := networksecurityperimeters.NetworkSecurityPerimeter{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkSecurityPerimetersClient.Delete` + +```go +ctx := context.TODO() +id := networksecurityperimeters.NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName") + +if err := client.DeleteThenPoll(ctx, id, networksecurityperimeters.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkSecurityPerimetersClient.Get` + +```go +ctx := context.TODO() +id := networksecurityperimeters.NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkSecurityPerimetersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id, networksecurityperimeters.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, networksecurityperimeters.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkSecurityPerimetersClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id, networksecurityperimeters.DefaultListBySubscriptionOperationOptions())` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id, networksecurityperimeters.DefaultListBySubscriptionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkSecurityPerimetersClient.Patch` + +```go +ctx := context.TODO() +id := networksecurityperimeters.NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName") + +payload := networksecurityperimeters.UpdateTagsRequest{ + // ... +} + + +read, err := client.Patch(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/networksecurityperimeters/client.go b/resource-manager/network/2024-07-01/networksecurityperimeters/client.go new file mode 100644 index 00000000000..f6c7dd9da13 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeters/client.go @@ -0,0 +1,26 @@ +package networksecurityperimeters + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimetersClient struct { + Client *resourcemanager.Client +} + +func NewNetworkSecurityPerimetersClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkSecurityPerimetersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networksecurityperimeters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkSecurityPerimetersClient: %+v", err) + } + + return &NetworkSecurityPerimetersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeters/constants.go b/resource-manager/network/2024-07-01/networksecurityperimeters/constants.go new file mode 100644 index 00000000000..9940a854d29 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeters/constants.go @@ -0,0 +1,63 @@ +package networksecurityperimeters + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NspProvisioningState string + +const ( + NspProvisioningStateAccepted NspProvisioningState = "Accepted" + NspProvisioningStateCreating NspProvisioningState = "Creating" + NspProvisioningStateDeleting NspProvisioningState = "Deleting" + NspProvisioningStateFailed NspProvisioningState = "Failed" + NspProvisioningStateSucceeded NspProvisioningState = "Succeeded" + NspProvisioningStateUpdating NspProvisioningState = "Updating" +) + +func PossibleValuesForNspProvisioningState() []string { + return []string{ + string(NspProvisioningStateAccepted), + string(NspProvisioningStateCreating), + string(NspProvisioningStateDeleting), + string(NspProvisioningStateFailed), + string(NspProvisioningStateSucceeded), + string(NspProvisioningStateUpdating), + } +} + +func (s *NspProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNspProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNspProvisioningState(input string) (*NspProvisioningState, error) { + vals := map[string]NspProvisioningState{ + "accepted": NspProvisioningStateAccepted, + "creating": NspProvisioningStateCreating, + "deleting": NspProvisioningStateDeleting, + "failed": NspProvisioningStateFailed, + "succeeded": NspProvisioningStateSucceeded, + "updating": NspProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NspProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeters/id_networksecurityperimeter.go b/resource-manager/network/2024-07-01/networksecurityperimeters/id_networksecurityperimeter.go new file mode 100644 index 00000000000..4e656706995 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeters/id_networksecurityperimeter.go @@ -0,0 +1,130 @@ +package networksecurityperimeters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkSecurityPerimeterId{}) +} + +var _ resourceids.ResourceId = &NetworkSecurityPerimeterId{} + +// NetworkSecurityPerimeterId is a struct representing the Resource ID for a Network Security Perimeter +type NetworkSecurityPerimeterId struct { + SubscriptionId string + ResourceGroupName string + NetworkSecurityPerimeterName string +} + +// NewNetworkSecurityPerimeterID returns a new NetworkSecurityPerimeterId struct +func NewNetworkSecurityPerimeterID(subscriptionId string, resourceGroupName string, networkSecurityPerimeterName string) NetworkSecurityPerimeterId { + return NetworkSecurityPerimeterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkSecurityPerimeterName: networkSecurityPerimeterName, + } +} + +// ParseNetworkSecurityPerimeterID parses 'input' into a NetworkSecurityPerimeterId +func ParseNetworkSecurityPerimeterID(input string) (*NetworkSecurityPerimeterId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkSecurityPerimeterIDInsensitively parses 'input' case-insensitively into a NetworkSecurityPerimeterId +// note: this method should only be used for API response data and not user input +func ParseNetworkSecurityPerimeterIDInsensitively(input string) (*NetworkSecurityPerimeterId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityPerimeterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityPerimeterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkSecurityPerimeterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkSecurityPerimeterName, ok = input.Parsed["networkSecurityPerimeterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityPerimeterName", input) + } + + return nil +} + +// ValidateNetworkSecurityPerimeterID checks that 'input' can be parsed as a Network Security Perimeter ID +func ValidateNetworkSecurityPerimeterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkSecurityPerimeterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityPerimeters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkSecurityPerimeterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkSecurityPerimeters", "networkSecurityPerimeters", "networkSecurityPerimeters"), + resourceids.UserSpecifiedSegment("networkSecurityPerimeterName", "networkSecurityPerimeterName"), + } +} + +// String returns a human-readable description of this Network Security Perimeter ID +func (id NetworkSecurityPerimeterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Security Perimeter Name: %q", id.NetworkSecurityPerimeterName), + } + return fmt.Sprintf("Network Security Perimeter (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeters/id_networksecurityperimeter_test.go b/resource-manager/network/2024-07-01/networksecurityperimeters/id_networksecurityperimeter_test.go new file mode 100644 index 00000000000..72580ec74c0 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeters/id_networksecurityperimeter_test.go @@ -0,0 +1,282 @@ +package networksecurityperimeters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkSecurityPerimeterId{} + +func TestNewNetworkSecurityPerimeterID(t *testing.T) { + id := NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkSecurityPerimeterName != "networkSecurityPerimeterName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityPerimeterName'", id.NetworkSecurityPerimeterName, "networkSecurityPerimeterName") + } +} + +func TestFormatNetworkSecurityPerimeterID(t *testing.T) { + actual := NewNetworkSecurityPerimeterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityPerimeterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkSecurityPerimeterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + } +} + +func TestParseNetworkSecurityPerimeterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityPerimeterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityPerimeterName: "networkSecurityPerimeterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityPerimeters/networkSecurityPerimeterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + Expected: &NetworkSecurityPerimeterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkSecurityPerimeterName: "nEtWoRkSeCuRiTyPeRiMeTeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyPeRiMeTeRs/nEtWoRkSeCuRiTyPeRiMeTeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityPerimeterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityPerimeterName != v.Expected.NetworkSecurityPerimeterName { + t.Fatalf("Expected %q but got %q for NetworkSecurityPerimeterName", v.Expected.NetworkSecurityPerimeterName, actual.NetworkSecurityPerimeterName) + } + + } +} + +func TestSegmentsForNetworkSecurityPerimeterId(t *testing.T) { + segments := NetworkSecurityPerimeterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkSecurityPerimeterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeters/method_createorupdate.go b/resource-manager/network/2024-07-01/networksecurityperimeters/method_createorupdate.go new file mode 100644 index 00000000000..8d0d1b5da3f --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeters/method_createorupdate.go @@ -0,0 +1,58 @@ +package networksecurityperimeters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkSecurityPerimeter +} + +// CreateOrUpdate ... +func (c NetworkSecurityPerimetersClient) CreateOrUpdate(ctx context.Context, id NetworkSecurityPerimeterId, input NetworkSecurityPerimeter) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkSecurityPerimeter + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeters/method_delete.go b/resource-manager/network/2024-07-01/networksecurityperimeters/method_delete.go new file mode 100644 index 00000000000..4fde39dee10 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeters/method_delete.go @@ -0,0 +1,100 @@ +package networksecurityperimeters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + ForceDeletion *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ForceDeletion != nil { + out.Append("forceDeletion", fmt.Sprintf("%v", *o.ForceDeletion)) + } + return &out +} + +// Delete ... +func (c NetworkSecurityPerimetersClient) Delete(ctx context.Context, id NetworkSecurityPerimeterId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c NetworkSecurityPerimetersClient) DeleteThenPoll(ctx context.Context, id NetworkSecurityPerimeterId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeters/method_get.go b/resource-manager/network/2024-07-01/networksecurityperimeters/method_get.go new file mode 100644 index 00000000000..853b9030310 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeters/method_get.go @@ -0,0 +1,53 @@ +package networksecurityperimeters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkSecurityPerimeter +} + +// Get ... +func (c NetworkSecurityPerimetersClient) Get(ctx context.Context, id NetworkSecurityPerimeterId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkSecurityPerimeter + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeters/method_list.go b/resource-manager/network/2024-07-01/networksecurityperimeters/method_list.go new file mode 100644 index 00000000000..d409c3d6445 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeters/method_list.go @@ -0,0 +1,135 @@ +package networksecurityperimeters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkSecurityPerimeter +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkSecurityPerimeter +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c NetworkSecurityPerimetersClient) List(ctx context.Context, id commonids.ResourceGroupId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/networkSecurityPerimeters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkSecurityPerimeter `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NetworkSecurityPerimetersClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, NetworkSecurityPerimeterOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkSecurityPerimetersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListOperationOptions, predicate NetworkSecurityPerimeterOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NetworkSecurityPerimeter, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeters/method_listbysubscription.go b/resource-manager/network/2024-07-01/networksecurityperimeters/method_listbysubscription.go new file mode 100644 index 00000000000..016bf7f7840 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeters/method_listbysubscription.go @@ -0,0 +1,135 @@ +package networksecurityperimeters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkSecurityPerimeter +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkSecurityPerimeter +} + +type ListBySubscriptionOperationOptions struct { + Top *int64 +} + +func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { + return ListBySubscriptionOperationOptions{} +} + +func (o ListBySubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c NetworkSecurityPerimetersClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/networkSecurityPerimeters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkSecurityPerimeter `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c NetworkSecurityPerimetersClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, NetworkSecurityPerimeterOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkSecurityPerimetersClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions, predicate NetworkSecurityPerimeterOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]NetworkSecurityPerimeter, 0) + + resp, err := c.ListBySubscription(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeters/method_patch.go b/resource-manager/network/2024-07-01/networksecurityperimeters/method_patch.go new file mode 100644 index 00000000000..6f4f0fbe80e --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeters/method_patch.go @@ -0,0 +1,57 @@ +package networksecurityperimeters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PatchOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkSecurityPerimeter +} + +// Patch ... +func (c NetworkSecurityPerimetersClient) Patch(ctx context.Context, id NetworkSecurityPerimeterId, input UpdateTagsRequest) (result PatchOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkSecurityPerimeter + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeters/model_networksecurityperimeter.go b/resource-manager/network/2024-07-01/networksecurityperimeters/model_networksecurityperimeter.go new file mode 100644 index 00000000000..18e4462a966 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeters/model_networksecurityperimeter.go @@ -0,0 +1,18 @@ +package networksecurityperimeters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimeter struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityPerimeterProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeters/model_networksecurityperimeterproperties.go b/resource-manager/network/2024-07-01/networksecurityperimeters/model_networksecurityperimeterproperties.go new file mode 100644 index 00000000000..aee0a38b02c --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeters/model_networksecurityperimeterproperties.go @@ -0,0 +1,9 @@ +package networksecurityperimeters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimeterProperties struct { + PerimeterGuid *string `json:"perimeterGuid,omitempty"` + ProvisioningState *NspProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeters/model_updatetagsrequest.go b/resource-manager/network/2024-07-01/networksecurityperimeters/model_updatetagsrequest.go new file mode 100644 index 00000000000..6f30e27bab5 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeters/model_updatetagsrequest.go @@ -0,0 +1,9 @@ +package networksecurityperimeters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsRequest struct { + Id *string `json:"id,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeters/predicates.go b/resource-manager/network/2024-07-01/networksecurityperimeters/predicates.go new file mode 100644 index 00000000000..0befc5652c8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeters/predicates.go @@ -0,0 +1,32 @@ +package networksecurityperimeters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityPerimeterOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p NetworkSecurityPerimeterOperationPredicate) Matches(input NetworkSecurityPerimeter) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/networksecurityperimeters/version.go b/resource-manager/network/2024-07-01/networksecurityperimeters/version.go new file mode 100644 index 00000000000..3fde7c9168e --- /dev/null +++ b/resource-manager/network/2024-07-01/networksecurityperimeters/version.go @@ -0,0 +1,10 @@ +package networksecurityperimeters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networksecurityperimeters/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/README.md b/resource-manager/network/2024-07-01/networkvirtualappliances/README.md new file mode 100644 index 00000000000..e91ccaaae7f --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/README.md @@ -0,0 +1,205 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkvirtualappliances` Documentation + +The `networkvirtualappliances` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkvirtualappliances" +``` + + +### Client Initialization + +```go +client := networkvirtualappliances.NewNetworkVirtualAppliancesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkVirtualAppliancesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := networkvirtualappliances.NewNetworkVirtualApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName") + +payload := networkvirtualappliances.NetworkVirtualAppliance{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkVirtualAppliancesClient.Delete` + +```go +ctx := context.TODO() +id := networkvirtualappliances.NewNetworkVirtualApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkVirtualAppliancesClient.Get` + +```go +ctx := context.TODO() +id := networkvirtualappliances.NewNetworkVirtualApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName") + +read, err := client.Get(ctx, id, networkvirtualappliances.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkVirtualAppliancesClient.GetBootDiagnosticLogs` + +```go +ctx := context.TODO() +id := networkvirtualappliances.NewNetworkVirtualApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName") + +payload := networkvirtualappliances.NetworkVirtualApplianceBootDiagnosticParameters{ + // ... +} + + +if err := client.GetBootDiagnosticLogsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkVirtualAppliancesClient.InboundSecurityRuleCreateOrUpdate` + +```go +ctx := context.TODO() +id := networkvirtualappliances.NewInboundSecurityRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName", "inboundSecurityRuleName") + +payload := networkvirtualappliances.InboundSecurityRule{ + // ... +} + + +if err := client.InboundSecurityRuleCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkVirtualAppliancesClient.InboundSecurityRuleGet` + +```go +ctx := context.TODO() +id := networkvirtualappliances.NewInboundSecurityRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName", "inboundSecurityRuleName") + +read, err := client.InboundSecurityRuleGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkVirtualAppliancesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkVirtualAppliancesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `NetworkVirtualAppliancesClient.Reimage` + +```go +ctx := context.TODO() +id := networkvirtualappliances.NewNetworkVirtualApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName") + +payload := networkvirtualappliances.NetworkVirtualApplianceInstanceIds{ + // ... +} + + +if err := client.ReimageThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkVirtualAppliancesClient.Restart` + +```go +ctx := context.TODO() +id := networkvirtualappliances.NewNetworkVirtualApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName") + +payload := networkvirtualappliances.NetworkVirtualApplianceInstanceIds{ + // ... +} + + +if err := client.RestartThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkVirtualAppliancesClient.UpdateTags` + +```go +ctx := context.TODO() +id := networkvirtualappliances.NewNetworkVirtualApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName") + +payload := networkvirtualappliances.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/client.go b/resource-manager/network/2024-07-01/networkvirtualappliances/client.go new file mode 100644 index 00000000000..ab8d70fafa5 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/client.go @@ -0,0 +1,26 @@ +package networkvirtualappliances + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualAppliancesClient struct { + Client *resourcemanager.Client +} + +func NewNetworkVirtualAppliancesClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkVirtualAppliancesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networkvirtualappliances", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkVirtualAppliancesClient: %+v", err) + } + + return &NetworkVirtualAppliancesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/constants.go b/resource-manager/network/2024-07-01/networkvirtualappliances/constants.go new file mode 100644 index 00000000000..a36e7b6985d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/constants.go @@ -0,0 +1,224 @@ +package networkvirtualappliances + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundSecurityRuleType string + +const ( + InboundSecurityRuleTypeAutoExpire InboundSecurityRuleType = "AutoExpire" + InboundSecurityRuleTypePermanent InboundSecurityRuleType = "Permanent" +) + +func PossibleValuesForInboundSecurityRuleType() []string { + return []string{ + string(InboundSecurityRuleTypeAutoExpire), + string(InboundSecurityRuleTypePermanent), + } +} + +func (s *InboundSecurityRuleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInboundSecurityRuleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInboundSecurityRuleType(input string) (*InboundSecurityRuleType, error) { + vals := map[string]InboundSecurityRuleType{ + "autoexpire": InboundSecurityRuleTypeAutoExpire, + "permanent": InboundSecurityRuleTypePermanent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InboundSecurityRuleType(input) + return &out, nil +} + +type InboundSecurityRulesProtocol string + +const ( + InboundSecurityRulesProtocolTCP InboundSecurityRulesProtocol = "TCP" + InboundSecurityRulesProtocolUDP InboundSecurityRulesProtocol = "UDP" +) + +func PossibleValuesForInboundSecurityRulesProtocol() []string { + return []string{ + string(InboundSecurityRulesProtocolTCP), + string(InboundSecurityRulesProtocolUDP), + } +} + +func (s *InboundSecurityRulesProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInboundSecurityRulesProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInboundSecurityRulesProtocol(input string) (*InboundSecurityRulesProtocol, error) { + vals := map[string]InboundSecurityRulesProtocol{ + "tcp": InboundSecurityRulesProtocolTCP, + "udp": InboundSecurityRulesProtocolUDP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InboundSecurityRulesProtocol(input) + return &out, nil +} + +type NicTypeInRequest string + +const ( + NicTypeInRequestPrivateNic NicTypeInRequest = "PrivateNic" + NicTypeInRequestPublicNic NicTypeInRequest = "PublicNic" +) + +func PossibleValuesForNicTypeInRequest() []string { + return []string{ + string(NicTypeInRequestPrivateNic), + string(NicTypeInRequestPublicNic), + } +} + +func (s *NicTypeInRequest) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNicTypeInRequest(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNicTypeInRequest(input string) (*NicTypeInRequest, error) { + vals := map[string]NicTypeInRequest{ + "privatenic": NicTypeInRequestPrivateNic, + "publicnic": NicTypeInRequestPublicNic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NicTypeInRequest(input) + return &out, nil +} + +type NicTypeInResponse string + +const ( + NicTypeInResponseAdditionalNic NicTypeInResponse = "AdditionalNic" + NicTypeInResponsePrivateNic NicTypeInResponse = "PrivateNic" + NicTypeInResponsePublicNic NicTypeInResponse = "PublicNic" +) + +func PossibleValuesForNicTypeInResponse() []string { + return []string{ + string(NicTypeInResponseAdditionalNic), + string(NicTypeInResponsePrivateNic), + string(NicTypeInResponsePublicNic), + } +} + +func (s *NicTypeInResponse) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNicTypeInResponse(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNicTypeInResponse(input string) (*NicTypeInResponse, error) { + vals := map[string]NicTypeInResponse{ + "additionalnic": NicTypeInResponseAdditionalNic, + "privatenic": NicTypeInResponsePrivateNic, + "publicnic": NicTypeInResponsePublicNic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NicTypeInResponse(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/id_inboundsecurityrule.go b/resource-manager/network/2024-07-01/networkvirtualappliances/id_inboundsecurityrule.go new file mode 100644 index 00000000000..4da7242be6d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/id_inboundsecurityrule.go @@ -0,0 +1,139 @@ +package networkvirtualappliances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&InboundSecurityRuleId{}) +} + +var _ resourceids.ResourceId = &InboundSecurityRuleId{} + +// InboundSecurityRuleId is a struct representing the Resource ID for a Inbound Security Rule +type InboundSecurityRuleId struct { + SubscriptionId string + ResourceGroupName string + NetworkVirtualApplianceName string + InboundSecurityRuleName string +} + +// NewInboundSecurityRuleID returns a new InboundSecurityRuleId struct +func NewInboundSecurityRuleID(subscriptionId string, resourceGroupName string, networkVirtualApplianceName string, inboundSecurityRuleName string) InboundSecurityRuleId { + return InboundSecurityRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkVirtualApplianceName: networkVirtualApplianceName, + InboundSecurityRuleName: inboundSecurityRuleName, + } +} + +// ParseInboundSecurityRuleID parses 'input' into a InboundSecurityRuleId +func ParseInboundSecurityRuleID(input string) (*InboundSecurityRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&InboundSecurityRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InboundSecurityRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseInboundSecurityRuleIDInsensitively parses 'input' case-insensitively into a InboundSecurityRuleId +// note: this method should only be used for API response data and not user input +func ParseInboundSecurityRuleIDInsensitively(input string) (*InboundSecurityRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&InboundSecurityRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InboundSecurityRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *InboundSecurityRuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkVirtualApplianceName, ok = input.Parsed["networkVirtualApplianceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkVirtualApplianceName", input) + } + + if id.InboundSecurityRuleName, ok = input.Parsed["inboundSecurityRuleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "inboundSecurityRuleName", input) + } + + return nil +} + +// ValidateInboundSecurityRuleID checks that 'input' can be parsed as a Inbound Security Rule ID +func ValidateInboundSecurityRuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseInboundSecurityRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Inbound Security Rule ID +func (id InboundSecurityRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkVirtualAppliances/%s/inboundSecurityRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkVirtualApplianceName, id.InboundSecurityRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Inbound Security Rule ID +func (id InboundSecurityRuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkVirtualAppliances", "networkVirtualAppliances", "networkVirtualAppliances"), + resourceids.UserSpecifiedSegment("networkVirtualApplianceName", "networkVirtualApplianceName"), + resourceids.StaticSegment("staticInboundSecurityRules", "inboundSecurityRules", "inboundSecurityRules"), + resourceids.UserSpecifiedSegment("inboundSecurityRuleName", "inboundSecurityRuleName"), + } +} + +// String returns a human-readable description of this Inbound Security Rule ID +func (id InboundSecurityRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Virtual Appliance Name: %q", id.NetworkVirtualApplianceName), + fmt.Sprintf("Inbound Security Rule Name: %q", id.InboundSecurityRuleName), + } + return fmt.Sprintf("Inbound Security Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/id_inboundsecurityrule_test.go b/resource-manager/network/2024-07-01/networkvirtualappliances/id_inboundsecurityrule_test.go new file mode 100644 index 00000000000..b953b2aa90d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/id_inboundsecurityrule_test.go @@ -0,0 +1,327 @@ +package networkvirtualappliances + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &InboundSecurityRuleId{} + +func TestNewInboundSecurityRuleID(t *testing.T) { + id := NewInboundSecurityRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName", "inboundSecurityRuleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkVirtualApplianceName != "networkVirtualApplianceName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkVirtualApplianceName'", id.NetworkVirtualApplianceName, "networkVirtualApplianceName") + } + + if id.InboundSecurityRuleName != "inboundSecurityRuleName" { + t.Fatalf("Expected %q but got %q for Segment 'InboundSecurityRuleName'", id.InboundSecurityRuleName, "inboundSecurityRuleName") + } +} + +func TestFormatInboundSecurityRuleID(t *testing.T) { + actual := NewInboundSecurityRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName", "inboundSecurityRuleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/inboundSecurityRules/inboundSecurityRuleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseInboundSecurityRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InboundSecurityRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/inboundSecurityRules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/inboundSecurityRules/inboundSecurityRuleName", + Expected: &InboundSecurityRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkVirtualApplianceName: "networkVirtualApplianceName", + InboundSecurityRuleName: "inboundSecurityRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/inboundSecurityRules/inboundSecurityRuleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInboundSecurityRuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkVirtualApplianceName != v.Expected.NetworkVirtualApplianceName { + t.Fatalf("Expected %q but got %q for NetworkVirtualApplianceName", v.Expected.NetworkVirtualApplianceName, actual.NetworkVirtualApplianceName) + } + + if actual.InboundSecurityRuleName != v.Expected.InboundSecurityRuleName { + t.Fatalf("Expected %q but got %q for InboundSecurityRuleName", v.Expected.InboundSecurityRuleName, actual.InboundSecurityRuleName) + } + + } +} + +func TestParseInboundSecurityRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InboundSecurityRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/inboundSecurityRules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe/iNbOuNdSeCuRiTyRuLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/inboundSecurityRules/inboundSecurityRuleName", + Expected: &InboundSecurityRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkVirtualApplianceName: "networkVirtualApplianceName", + InboundSecurityRuleName: "inboundSecurityRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/inboundSecurityRules/inboundSecurityRuleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe/iNbOuNdSeCuRiTyRuLeS/iNbOuNdSeCuRiTyRuLeNaMe", + Expected: &InboundSecurityRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkVirtualApplianceName: "nEtWoRkViRtUaLaPpLiAnCeNaMe", + InboundSecurityRuleName: "iNbOuNdSeCuRiTyRuLeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe/iNbOuNdSeCuRiTyRuLeS/iNbOuNdSeCuRiTyRuLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInboundSecurityRuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkVirtualApplianceName != v.Expected.NetworkVirtualApplianceName { + t.Fatalf("Expected %q but got %q for NetworkVirtualApplianceName", v.Expected.NetworkVirtualApplianceName, actual.NetworkVirtualApplianceName) + } + + if actual.InboundSecurityRuleName != v.Expected.InboundSecurityRuleName { + t.Fatalf("Expected %q but got %q for InboundSecurityRuleName", v.Expected.InboundSecurityRuleName, actual.InboundSecurityRuleName) + } + + } +} + +func TestSegmentsForInboundSecurityRuleId(t *testing.T) { + segments := InboundSecurityRuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("InboundSecurityRuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/id_networkvirtualappliance.go b/resource-manager/network/2024-07-01/networkvirtualappliances/id_networkvirtualappliance.go new file mode 100644 index 00000000000..a412e45cbba --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/id_networkvirtualappliance.go @@ -0,0 +1,130 @@ +package networkvirtualappliances + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkVirtualApplianceId{}) +} + +var _ resourceids.ResourceId = &NetworkVirtualApplianceId{} + +// NetworkVirtualApplianceId is a struct representing the Resource ID for a Network Virtual Appliance +type NetworkVirtualApplianceId struct { + SubscriptionId string + ResourceGroupName string + NetworkVirtualApplianceName string +} + +// NewNetworkVirtualApplianceID returns a new NetworkVirtualApplianceId struct +func NewNetworkVirtualApplianceID(subscriptionId string, resourceGroupName string, networkVirtualApplianceName string) NetworkVirtualApplianceId { + return NetworkVirtualApplianceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkVirtualApplianceName: networkVirtualApplianceName, + } +} + +// ParseNetworkVirtualApplianceID parses 'input' into a NetworkVirtualApplianceId +func ParseNetworkVirtualApplianceID(input string) (*NetworkVirtualApplianceId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkVirtualApplianceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkVirtualApplianceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkVirtualApplianceIDInsensitively parses 'input' case-insensitively into a NetworkVirtualApplianceId +// note: this method should only be used for API response data and not user input +func ParseNetworkVirtualApplianceIDInsensitively(input string) (*NetworkVirtualApplianceId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkVirtualApplianceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkVirtualApplianceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkVirtualApplianceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkVirtualApplianceName, ok = input.Parsed["networkVirtualApplianceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkVirtualApplianceName", input) + } + + return nil +} + +// ValidateNetworkVirtualApplianceID checks that 'input' can be parsed as a Network Virtual Appliance ID +func ValidateNetworkVirtualApplianceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkVirtualApplianceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Virtual Appliance ID +func (id NetworkVirtualApplianceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkVirtualAppliances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkVirtualApplianceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Virtual Appliance ID +func (id NetworkVirtualApplianceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkVirtualAppliances", "networkVirtualAppliances", "networkVirtualAppliances"), + resourceids.UserSpecifiedSegment("networkVirtualApplianceName", "networkVirtualApplianceName"), + } +} + +// String returns a human-readable description of this Network Virtual Appliance ID +func (id NetworkVirtualApplianceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Virtual Appliance Name: %q", id.NetworkVirtualApplianceName), + } + return fmt.Sprintf("Network Virtual Appliance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/id_networkvirtualappliance_test.go b/resource-manager/network/2024-07-01/networkvirtualappliances/id_networkvirtualappliance_test.go new file mode 100644 index 00000000000..428157b07ea --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/id_networkvirtualappliance_test.go @@ -0,0 +1,282 @@ +package networkvirtualappliances + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkVirtualApplianceId{} + +func TestNewNetworkVirtualApplianceID(t *testing.T) { + id := NewNetworkVirtualApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkVirtualApplianceName != "networkVirtualApplianceName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkVirtualApplianceName'", id.NetworkVirtualApplianceName, "networkVirtualApplianceName") + } +} + +func TestFormatNetworkVirtualApplianceID(t *testing.T) { + actual := NewNetworkVirtualApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkVirtualApplianceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkVirtualApplianceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName", + Expected: &NetworkVirtualApplianceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkVirtualApplianceName: "networkVirtualApplianceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkVirtualApplianceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkVirtualApplianceName != v.Expected.NetworkVirtualApplianceName { + t.Fatalf("Expected %q but got %q for NetworkVirtualApplianceName", v.Expected.NetworkVirtualApplianceName, actual.NetworkVirtualApplianceName) + } + + } +} + +func TestParseNetworkVirtualApplianceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkVirtualApplianceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName", + Expected: &NetworkVirtualApplianceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkVirtualApplianceName: "networkVirtualApplianceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe", + Expected: &NetworkVirtualApplianceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkVirtualApplianceName: "nEtWoRkViRtUaLaPpLiAnCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkVirtualApplianceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkVirtualApplianceName != v.Expected.NetworkVirtualApplianceName { + t.Fatalf("Expected %q but got %q for NetworkVirtualApplianceName", v.Expected.NetworkVirtualApplianceName, actual.NetworkVirtualApplianceName) + } + + } +} + +func TestSegmentsForNetworkVirtualApplianceId(t *testing.T) { + segments := NetworkVirtualApplianceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkVirtualApplianceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/method_createorupdate.go b/resource-manager/network/2024-07-01/networkvirtualappliances/method_createorupdate.go new file mode 100644 index 00000000000..aa9b339951d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/method_createorupdate.go @@ -0,0 +1,75 @@ +package networkvirtualappliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NetworkVirtualAppliance +} + +// CreateOrUpdate ... +func (c NetworkVirtualAppliancesClient) CreateOrUpdate(ctx context.Context, id NetworkVirtualApplianceId, input NetworkVirtualAppliance) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c NetworkVirtualAppliancesClient) CreateOrUpdateThenPoll(ctx context.Context, id NetworkVirtualApplianceId, input NetworkVirtualAppliance) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/method_delete.go b/resource-manager/network/2024-07-01/networkvirtualappliances/method_delete.go new file mode 100644 index 00000000000..9eb9b6f13ac --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/method_delete.go @@ -0,0 +1,71 @@ +package networkvirtualappliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c NetworkVirtualAppliancesClient) Delete(ctx context.Context, id NetworkVirtualApplianceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c NetworkVirtualAppliancesClient) DeleteThenPoll(ctx context.Context, id NetworkVirtualApplianceId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/method_get.go b/resource-manager/network/2024-07-01/networkvirtualappliances/method_get.go new file mode 100644 index 00000000000..2310883a448 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/method_get.go @@ -0,0 +1,83 @@ +package networkvirtualappliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkVirtualAppliance +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c NetworkVirtualAppliancesClient) Get(ctx context.Context, id NetworkVirtualApplianceId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkVirtualAppliance + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/method_getbootdiagnosticlogs.go b/resource-manager/network/2024-07-01/networkvirtualappliances/method_getbootdiagnosticlogs.go new file mode 100644 index 00000000000..3672ec5e71c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/method_getbootdiagnosticlogs.go @@ -0,0 +1,75 @@ +package networkvirtualappliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBootDiagnosticLogsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NetworkVirtualApplianceInstanceId +} + +// GetBootDiagnosticLogs ... +func (c NetworkVirtualAppliancesClient) GetBootDiagnosticLogs(ctx context.Context, id NetworkVirtualApplianceId, input NetworkVirtualApplianceBootDiagnosticParameters) (result GetBootDiagnosticLogsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getBootDiagnosticLogs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetBootDiagnosticLogsThenPoll performs GetBootDiagnosticLogs then polls until it's completed +func (c NetworkVirtualAppliancesClient) GetBootDiagnosticLogsThenPoll(ctx context.Context, id NetworkVirtualApplianceId, input NetworkVirtualApplianceBootDiagnosticParameters) error { + result, err := c.GetBootDiagnosticLogs(ctx, id, input) + if err != nil { + return fmt.Errorf("performing GetBootDiagnosticLogs: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetBootDiagnosticLogs: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/method_inboundsecurityrulecreateorupdate.go b/resource-manager/network/2024-07-01/networkvirtualappliances/method_inboundsecurityrulecreateorupdate.go new file mode 100644 index 00000000000..6c268a71480 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/method_inboundsecurityrulecreateorupdate.go @@ -0,0 +1,75 @@ +package networkvirtualappliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundSecurityRuleCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *InboundSecurityRule +} + +// InboundSecurityRuleCreateOrUpdate ... +func (c NetworkVirtualAppliancesClient) InboundSecurityRuleCreateOrUpdate(ctx context.Context, id InboundSecurityRuleId, input InboundSecurityRule) (result InboundSecurityRuleCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// InboundSecurityRuleCreateOrUpdateThenPoll performs InboundSecurityRuleCreateOrUpdate then polls until it's completed +func (c NetworkVirtualAppliancesClient) InboundSecurityRuleCreateOrUpdateThenPoll(ctx context.Context, id InboundSecurityRuleId, input InboundSecurityRule) error { + result, err := c.InboundSecurityRuleCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing InboundSecurityRuleCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after InboundSecurityRuleCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/method_inboundsecurityruleget.go b/resource-manager/network/2024-07-01/networkvirtualappliances/method_inboundsecurityruleget.go new file mode 100644 index 00000000000..708005f5e02 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/method_inboundsecurityruleget.go @@ -0,0 +1,53 @@ +package networkvirtualappliances + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundSecurityRuleGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *InboundSecurityRule +} + +// InboundSecurityRuleGet ... +func (c NetworkVirtualAppliancesClient) InboundSecurityRuleGet(ctx context.Context, id InboundSecurityRuleId) (result InboundSecurityRuleGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model InboundSecurityRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/method_list.go b/resource-manager/network/2024-07-01/networkvirtualappliances/method_list.go new file mode 100644 index 00000000000..35259c60e6a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/method_list.go @@ -0,0 +1,106 @@ +package networkvirtualappliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkVirtualAppliance +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkVirtualAppliance +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c NetworkVirtualAppliancesClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/networkVirtualAppliances", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkVirtualAppliance `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c NetworkVirtualAppliancesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, NetworkVirtualApplianceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkVirtualAppliancesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate NetworkVirtualApplianceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NetworkVirtualAppliance, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/method_listbyresourcegroup.go b/resource-manager/network/2024-07-01/networkvirtualappliances/method_listbyresourcegroup.go new file mode 100644 index 00000000000..fe63e8307c6 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package networkvirtualappliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkVirtualAppliance +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkVirtualAppliance +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c NetworkVirtualAppliancesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/networkVirtualAppliances", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkVirtualAppliance `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c NetworkVirtualAppliancesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, NetworkVirtualApplianceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c NetworkVirtualAppliancesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate NetworkVirtualApplianceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]NetworkVirtualAppliance, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/method_reimage.go b/resource-manager/network/2024-07-01/networkvirtualappliances/method_reimage.go new file mode 100644 index 00000000000..af44ba2b406 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/method_reimage.go @@ -0,0 +1,75 @@ +package networkvirtualappliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReimageOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NetworkVirtualApplianceInstanceIds +} + +// Reimage ... +func (c NetworkVirtualAppliancesClient) Reimage(ctx context.Context, id NetworkVirtualApplianceId, input NetworkVirtualApplianceInstanceIds) (result ReimageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reimage", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ReimageThenPoll performs Reimage then polls until it's completed +func (c NetworkVirtualAppliancesClient) ReimageThenPoll(ctx context.Context, id NetworkVirtualApplianceId, input NetworkVirtualApplianceInstanceIds) error { + result, err := c.Reimage(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Reimage: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Reimage: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/method_restart.go b/resource-manager/network/2024-07-01/networkvirtualappliances/method_restart.go new file mode 100644 index 00000000000..3a260c048e5 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/method_restart.go @@ -0,0 +1,75 @@ +package networkvirtualappliances + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NetworkVirtualApplianceInstanceIds +} + +// Restart ... +func (c NetworkVirtualAppliancesClient) Restart(ctx context.Context, id NetworkVirtualApplianceId, input NetworkVirtualApplianceInstanceIds) (result RestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestartThenPoll performs Restart then polls until it's completed +func (c NetworkVirtualAppliancesClient) RestartThenPoll(ctx context.Context, id NetworkVirtualApplianceId, input NetworkVirtualApplianceInstanceIds) error { + result, err := c.Restart(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Restart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Restart: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/method_updatetags.go b/resource-manager/network/2024-07-01/networkvirtualappliances/method_updatetags.go new file mode 100644 index 00000000000..a8a8391f4a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/method_updatetags.go @@ -0,0 +1,57 @@ +package networkvirtualappliances + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkVirtualAppliance +} + +// UpdateTags ... +func (c NetworkVirtualAppliancesClient) UpdateTags(ctx context.Context, id NetworkVirtualApplianceId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkVirtualAppliance + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_delegationproperties.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_delegationproperties.go new file mode 100644 index 00000000000..cf2170e1c38 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_delegationproperties.go @@ -0,0 +1,9 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DelegationProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_inboundsecurityrule.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_inboundsecurityrule.go new file mode 100644 index 00000000000..f921a8c6534 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_inboundsecurityrule.go @@ -0,0 +1,12 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundSecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundSecurityRuleProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_inboundsecurityruleproperties.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_inboundsecurityruleproperties.go new file mode 100644 index 00000000000..c4dafbd39cc --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_inboundsecurityruleproperties.go @@ -0,0 +1,10 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundSecurityRuleProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RuleType *InboundSecurityRuleType `json:"ruleType,omitempty"` + Rules *[]InboundSecurityRules `json:"rules,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_inboundsecurityrules.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_inboundsecurityrules.go new file mode 100644 index 00000000000..c8c2d565176 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_inboundsecurityrules.go @@ -0,0 +1,13 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundSecurityRules struct { + AppliesOn *[]string `json:"appliesOn,omitempty"` + DestinationPortRange *int64 `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Name *string `json:"name,omitempty"` + Protocol *InboundSecurityRulesProtocol `json:"protocol,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_internetingresspublicipsproperties.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_internetingresspublicipsproperties.go new file mode 100644 index 00000000000..692265ca5f9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_internetingresspublicipsproperties.go @@ -0,0 +1,8 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InternetIngressPublicIPsProperties struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualappliance.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualappliance.go new file mode 100644 index 00000000000..03612c989df --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualappliance.go @@ -0,0 +1,19 @@ +package networkvirtualappliances + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualAppliance struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkVirtualAppliancePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualappliancebootdiagnosticparameters.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualappliancebootdiagnosticparameters.go new file mode 100644 index 00000000000..1e68a9642e4 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualappliancebootdiagnosticparameters.go @@ -0,0 +1,10 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualApplianceBootDiagnosticParameters struct { + ConsoleScreenshotStorageSasURL *string `json:"consoleScreenshotStorageSasUrl,omitempty"` + InstanceId *int64 `json:"instanceId,omitempty"` + SerialConsoleStorageSasURL *string `json:"serialConsoleStorageSasUrl,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualapplianceinstanceid.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualapplianceinstanceid.go new file mode 100644 index 00000000000..ba19a4559b9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualapplianceinstanceid.go @@ -0,0 +1,8 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualApplianceInstanceId struct { + InstanceId *int64 `json:"instanceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualapplianceinstanceids.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualapplianceinstanceids.go new file mode 100644 index 00000000000..3d9d42b1694 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualapplianceinstanceids.go @@ -0,0 +1,8 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualApplianceInstanceIds struct { + InstanceIds *[]string `json:"instanceIds,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualappliancepropertiesformat.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualappliancepropertiesformat.go new file mode 100644 index 00000000000..17e239bf354 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualappliancepropertiesformat.go @@ -0,0 +1,26 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualAppliancePropertiesFormat struct { + AdditionalNics *[]VirtualApplianceAdditionalNicProperties `json:"additionalNics,omitempty"` + AddressPrefix *string `json:"addressPrefix,omitempty"` + BootStrapConfigurationBlobs *[]string `json:"bootStrapConfigurationBlobs,omitempty"` + CloudInitConfiguration *string `json:"cloudInitConfiguration,omitempty"` + CloudInitConfigurationBlobs *[]string `json:"cloudInitConfigurationBlobs,omitempty"` + Delegation *DelegationProperties `json:"delegation,omitempty"` + DeploymentType *string `json:"deploymentType,omitempty"` + InboundSecurityRules *[]SubResource `json:"inboundSecurityRules,omitempty"` + InternetIngressPublicIPs *[]InternetIngressPublicIPsProperties `json:"internetIngressPublicIps,omitempty"` + NetworkProfile *NetworkVirtualAppliancePropertiesFormatNetworkProfile `json:"networkProfile,omitempty"` + NvaSku *VirtualApplianceSkuProperties `json:"nvaSku,omitempty"` + PartnerManagedResource *PartnerManagedResourceProperties `json:"partnerManagedResource,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SshPublicKey *string `json:"sshPublicKey,omitempty"` + VirtualApplianceAsn *int64 `json:"virtualApplianceAsn,omitempty"` + VirtualApplianceConnections *[]SubResource `json:"virtualApplianceConnections,omitempty"` + VirtualApplianceNics *[]VirtualApplianceNicProperties `json:"virtualApplianceNics,omitempty"` + VirtualApplianceSites *[]SubResource `json:"virtualApplianceSites,omitempty"` + VirtualHub *SubResource `json:"virtualHub,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualappliancepropertiesformatnetworkprofile.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualappliancepropertiesformatnetworkprofile.go new file mode 100644 index 00000000000..0d4f966f36c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_networkvirtualappliancepropertiesformatnetworkprofile.go @@ -0,0 +1,8 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualAppliancePropertiesFormatNetworkProfile struct { + NetworkInterfaceConfigurations *[]VirtualApplianceNetworkInterfaceConfiguration `json:"networkInterfaceConfigurations,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_partnermanagedresourceproperties.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_partnermanagedresourceproperties.go new file mode 100644 index 00000000000..e89793be377 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_partnermanagedresourceproperties.go @@ -0,0 +1,10 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartnerManagedResourceProperties struct { + Id *string `json:"id,omitempty"` + InternalLoadBalancerId *string `json:"internalLoadBalancerId,omitempty"` + StandardLoadBalancerId *string `json:"standardLoadBalancerId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_subresource.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_subresource.go new file mode 100644 index 00000000000..8df29cf1031 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_subresource.go @@ -0,0 +1,8 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_tagsobject.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_tagsobject.go new file mode 100644 index 00000000000..3ad1ec8468c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_tagsobject.go @@ -0,0 +1,8 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualapplianceadditionalnicproperties.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualapplianceadditionalnicproperties.go new file mode 100644 index 00000000000..7eb59c309c1 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualapplianceadditionalnicproperties.go @@ -0,0 +1,9 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplianceAdditionalNicProperties struct { + HasPublicIP *bool `json:"hasPublicIp,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualapplianceipconfiguration.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualapplianceipconfiguration.go new file mode 100644 index 00000000000..1ebade78697 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualapplianceipconfiguration.go @@ -0,0 +1,9 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplianceIPConfiguration struct { + Name *string `json:"name,omitempty"` + Properties *VirtualApplianceIPConfigurationProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualapplianceipconfigurationproperties.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualapplianceipconfigurationproperties.go new file mode 100644 index 00000000000..830f6a29d9a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualapplianceipconfigurationproperties.go @@ -0,0 +1,8 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplianceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualappliancenetworkinterfaceconfiguration.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualappliancenetworkinterfaceconfiguration.go new file mode 100644 index 00000000000..de88f83ae8d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualappliancenetworkinterfaceconfiguration.go @@ -0,0 +1,9 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplianceNetworkInterfaceConfiguration struct { + Properties *VirtualApplianceNetworkInterfaceConfigurationProperties `json:"properties,omitempty"` + Type *NicTypeInRequest `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualappliancenetworkinterfaceconfigurationproperties.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualappliancenetworkinterfaceconfigurationproperties.go new file mode 100644 index 00000000000..436f144e6fc --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualappliancenetworkinterfaceconfigurationproperties.go @@ -0,0 +1,8 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplianceNetworkInterfaceConfigurationProperties struct { + IPConfigurations *[]VirtualApplianceIPConfiguration `json:"ipConfigurations,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualappliancenicproperties.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualappliancenicproperties.go new file mode 100644 index 00000000000..0823febcef5 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualappliancenicproperties.go @@ -0,0 +1,12 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplianceNicProperties struct { + InstanceName *string `json:"instanceName,omitempty"` + Name *string `json:"name,omitempty"` + NicType *NicTypeInResponse `json:"nicType,omitempty"` + PrivateIPAddress *string `json:"privateIpAddress,omitempty"` + PublicIPAddress *string `json:"publicIpAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualapplianceskuproperties.go b/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualapplianceskuproperties.go new file mode 100644 index 00000000000..b194523806f --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/model_virtualapplianceskuproperties.go @@ -0,0 +1,10 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplianceSkuProperties struct { + BundledScaleUnit *string `json:"bundledScaleUnit,omitempty"` + MarketPlaceVersion *string `json:"marketPlaceVersion,omitempty"` + Vendor *string `json:"vendor,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/predicates.go b/resource-manager/network/2024-07-01/networkvirtualappliances/predicates.go new file mode 100644 index 00000000000..676b2af6c25 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/predicates.go @@ -0,0 +1,37 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualApplianceOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p NetworkVirtualApplianceOperationPredicate) Matches(input NetworkVirtualAppliance) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/networkvirtualappliances/version.go b/resource-manager/network/2024-07-01/networkvirtualappliances/version.go new file mode 100644 index 00000000000..ad561f25ba9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkvirtualappliances/version.go @@ -0,0 +1,10 @@ +package networkvirtualappliances + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networkvirtualappliances/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/README.md b/resource-manager/network/2024-07-01/networkwatchers/README.md new file mode 100644 index 00000000000..ce10bc92491 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/README.md @@ -0,0 +1,331 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkwatchers` Documentation + +The `networkwatchers` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/networkwatchers" +``` + + +### Client Initialization + +```go +client := networkwatchers.NewNetworkWatchersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `NetworkWatchersClient.CheckConnectivity` + +```go +ctx := context.TODO() +id := networkwatchers.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +payload := networkwatchers.ConnectivityParameters{ + // ... +} + + +if err := client.CheckConnectivityThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkWatchersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := networkwatchers.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +payload := networkwatchers.NetworkWatcher{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkWatchersClient.Delete` + +```go +ctx := context.TODO() +id := networkwatchers.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkWatchersClient.Get` + +```go +ctx := context.TODO() +id := networkwatchers.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkWatchersClient.GetAzureReachabilityReport` + +```go +ctx := context.TODO() +id := networkwatchers.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +payload := networkwatchers.AzureReachabilityReportParameters{ + // ... +} + + +if err := client.GetAzureReachabilityReportThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkWatchersClient.GetFlowLogStatus` + +```go +ctx := context.TODO() +id := networkwatchers.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +payload := networkwatchers.FlowLogStatusParameters{ + // ... +} + + +if err := client.GetFlowLogStatusThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkWatchersClient.GetNetworkConfigurationDiagnostic` + +```go +ctx := context.TODO() +id := networkwatchers.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +payload := networkwatchers.NetworkConfigurationDiagnosticParameters{ + // ... +} + + +if err := client.GetNetworkConfigurationDiagnosticThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkWatchersClient.GetNextHop` + +```go +ctx := context.TODO() +id := networkwatchers.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +payload := networkwatchers.NextHopParameters{ + // ... +} + + +if err := client.GetNextHopThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkWatchersClient.GetTopology` + +```go +ctx := context.TODO() +id := networkwatchers.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +payload := networkwatchers.TopologyParameters{ + // ... +} + + +read, err := client.GetTopology(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkWatchersClient.GetTroubleshooting` + +```go +ctx := context.TODO() +id := networkwatchers.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +payload := networkwatchers.TroubleshootingParameters{ + // ... +} + + +if err := client.GetTroubleshootingThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkWatchersClient.GetTroubleshootingResult` + +```go +ctx := context.TODO() +id := networkwatchers.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +payload := networkwatchers.QueryTroubleshootingParameters{ + // ... +} + + +if err := client.GetTroubleshootingResultThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkWatchersClient.GetVMSecurityRules` + +```go +ctx := context.TODO() +id := networkwatchers.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +payload := networkwatchers.SecurityGroupViewParameters{ + // ... +} + + +if err := client.GetVMSecurityRulesThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkWatchersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkWatchersClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.ListAll(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkWatchersClient.ListAvailableProviders` + +```go +ctx := context.TODO() +id := networkwatchers.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +payload := networkwatchers.AvailableProvidersListParameters{ + // ... +} + + +if err := client.ListAvailableProvidersThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkWatchersClient.SetFlowLogConfiguration` + +```go +ctx := context.TODO() +id := networkwatchers.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +payload := networkwatchers.FlowLogInformation{ + // ... +} + + +if err := client.SetFlowLogConfigurationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `NetworkWatchersClient.UpdateTags` + +```go +ctx := context.TODO() +id := networkwatchers.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +payload := networkwatchers.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `NetworkWatchersClient.VerifyIPFlow` + +```go +ctx := context.TODO() +id := networkwatchers.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +payload := networkwatchers.VerificationIPFlowParameters{ + // ... +} + + +if err := client.VerifyIPFlowThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/network/2024-07-01/networkwatchers/client.go b/resource-manager/network/2024-07-01/networkwatchers/client.go new file mode 100644 index 00000000000..b544d19c206 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/client.go @@ -0,0 +1,26 @@ +package networkwatchers + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkWatchersClient struct { + Client *resourcemanager.Client +} + +func NewNetworkWatchersClientWithBaseURI(sdkApi sdkEnv.Api) (*NetworkWatchersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "networkwatchers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating NetworkWatchersClient: %+v", err) + } + + return &NetworkWatchersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/constants.go b/resource-manager/network/2024-07-01/networkwatchers/constants.go new file mode 100644 index 00000000000..2e400cad0f7 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/constants.go @@ -0,0 +1,855 @@ +package networkwatchers + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Access string + +const ( + AccessAllow Access = "Allow" + AccessDeny Access = "Deny" +) + +func PossibleValuesForAccess() []string { + return []string{ + string(AccessAllow), + string(AccessDeny), + } +} + +func (s *Access) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAccess(input string) (*Access, error) { + vals := map[string]Access{ + "allow": AccessAllow, + "deny": AccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Access(input) + return &out, nil +} + +type AssociationType string + +const ( + AssociationTypeAssociated AssociationType = "Associated" + AssociationTypeContains AssociationType = "Contains" +) + +func PossibleValuesForAssociationType() []string { + return []string{ + string(AssociationTypeAssociated), + string(AssociationTypeContains), + } +} + +func (s *AssociationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssociationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAssociationType(input string) (*AssociationType, error) { + vals := map[string]AssociationType{ + "associated": AssociationTypeAssociated, + "contains": AssociationTypeContains, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AssociationType(input) + return &out, nil +} + +type ConnectionStatus string + +const ( + ConnectionStatusConnected ConnectionStatus = "Connected" + ConnectionStatusDegraded ConnectionStatus = "Degraded" + ConnectionStatusDisconnected ConnectionStatus = "Disconnected" + ConnectionStatusUnknown ConnectionStatus = "Unknown" +) + +func PossibleValuesForConnectionStatus() []string { + return []string{ + string(ConnectionStatusConnected), + string(ConnectionStatusDegraded), + string(ConnectionStatusDisconnected), + string(ConnectionStatusUnknown), + } +} + +func (s *ConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionStatus(input string) (*ConnectionStatus, error) { + vals := map[string]ConnectionStatus{ + "connected": ConnectionStatusConnected, + "degraded": ConnectionStatusDegraded, + "disconnected": ConnectionStatusDisconnected, + "unknown": ConnectionStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionStatus(input) + return &out, nil +} + +type Direction string + +const ( + DirectionInbound Direction = "Inbound" + DirectionOutbound Direction = "Outbound" +) + +func PossibleValuesForDirection() []string { + return []string{ + string(DirectionInbound), + string(DirectionOutbound), + } +} + +func (s *Direction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDirection(input string) (*Direction, error) { + vals := map[string]Direction{ + "inbound": DirectionInbound, + "outbound": DirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Direction(input) + return &out, nil +} + +type EffectiveSecurityRuleProtocol string + +const ( + EffectiveSecurityRuleProtocolAll EffectiveSecurityRuleProtocol = "All" + EffectiveSecurityRuleProtocolTcp EffectiveSecurityRuleProtocol = "Tcp" + EffectiveSecurityRuleProtocolUdp EffectiveSecurityRuleProtocol = "Udp" +) + +func PossibleValuesForEffectiveSecurityRuleProtocol() []string { + return []string{ + string(EffectiveSecurityRuleProtocolAll), + string(EffectiveSecurityRuleProtocolTcp), + string(EffectiveSecurityRuleProtocolUdp), + } +} + +func (s *EffectiveSecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEffectiveSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEffectiveSecurityRuleProtocol(input string) (*EffectiveSecurityRuleProtocol, error) { + vals := map[string]EffectiveSecurityRuleProtocol{ + "all": EffectiveSecurityRuleProtocolAll, + "tcp": EffectiveSecurityRuleProtocolTcp, + "udp": EffectiveSecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EffectiveSecurityRuleProtocol(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type HTTPMethod string + +const ( + HTTPMethodGet HTTPMethod = "Get" +) + +func PossibleValuesForHTTPMethod() []string { + return []string{ + string(HTTPMethodGet), + } +} + +func (s *HTTPMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHTTPMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHTTPMethod(input string) (*HTTPMethod, error) { + vals := map[string]HTTPMethod{ + "get": HTTPMethodGet, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HTTPMethod(input) + return &out, nil +} + +type IPFlowProtocol string + +const ( + IPFlowProtocolTCP IPFlowProtocol = "TCP" + IPFlowProtocolUDP IPFlowProtocol = "UDP" +) + +func PossibleValuesForIPFlowProtocol() []string { + return []string{ + string(IPFlowProtocolTCP), + string(IPFlowProtocolUDP), + } +} + +func (s *IPFlowProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFlowProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPFlowProtocol(input string) (*IPFlowProtocol, error) { + vals := map[string]IPFlowProtocol{ + "tcp": IPFlowProtocolTCP, + "udp": IPFlowProtocolUDP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPFlowProtocol(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type IssueType string + +const ( + IssueTypeAgentStopped IssueType = "AgentStopped" + IssueTypeDnsResolution IssueType = "DnsResolution" + IssueTypeGuestFirewall IssueType = "GuestFirewall" + IssueTypeNetworkSecurityRule IssueType = "NetworkSecurityRule" + IssueTypePlatform IssueType = "Platform" + IssueTypePortThrottled IssueType = "PortThrottled" + IssueTypeSocketBind IssueType = "SocketBind" + IssueTypeUnknown IssueType = "Unknown" + IssueTypeUserDefinedRoute IssueType = "UserDefinedRoute" +) + +func PossibleValuesForIssueType() []string { + return []string{ + string(IssueTypeAgentStopped), + string(IssueTypeDnsResolution), + string(IssueTypeGuestFirewall), + string(IssueTypeNetworkSecurityRule), + string(IssueTypePlatform), + string(IssueTypePortThrottled), + string(IssueTypeSocketBind), + string(IssueTypeUnknown), + string(IssueTypeUserDefinedRoute), + } +} + +func (s *IssueType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIssueType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIssueType(input string) (*IssueType, error) { + vals := map[string]IssueType{ + "agentstopped": IssueTypeAgentStopped, + "dnsresolution": IssueTypeDnsResolution, + "guestfirewall": IssueTypeGuestFirewall, + "networksecurityrule": IssueTypeNetworkSecurityRule, + "platform": IssueTypePlatform, + "portthrottled": IssueTypePortThrottled, + "socketbind": IssueTypeSocketBind, + "unknown": IssueTypeUnknown, + "userdefinedroute": IssueTypeUserDefinedRoute, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IssueType(input) + return &out, nil +} + +type NextHopType string + +const ( + NextHopTypeHyperNetGateway NextHopType = "HyperNetGateway" + NextHopTypeInternet NextHopType = "Internet" + NextHopTypeNone NextHopType = "None" + NextHopTypeVirtualAppliance NextHopType = "VirtualAppliance" + NextHopTypeVirtualNetworkGateway NextHopType = "VirtualNetworkGateway" + NextHopTypeVnetLocal NextHopType = "VnetLocal" +) + +func PossibleValuesForNextHopType() []string { + return []string{ + string(NextHopTypeHyperNetGateway), + string(NextHopTypeInternet), + string(NextHopTypeNone), + string(NextHopTypeVirtualAppliance), + string(NextHopTypeVirtualNetworkGateway), + string(NextHopTypeVnetLocal), + } +} + +func (s *NextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNextHopType(input string) (*NextHopType, error) { + vals := map[string]NextHopType{ + "hypernetgateway": NextHopTypeHyperNetGateway, + "internet": NextHopTypeInternet, + "none": NextHopTypeNone, + "virtualappliance": NextHopTypeVirtualAppliance, + "virtualnetworkgateway": NextHopTypeVirtualNetworkGateway, + "vnetlocal": NextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NextHopType(input) + return &out, nil +} + +type Origin string + +const ( + OriginInbound Origin = "Inbound" + OriginLocal Origin = "Local" + OriginOutbound Origin = "Outbound" +) + +func PossibleValuesForOrigin() []string { + return []string{ + string(OriginInbound), + string(OriginLocal), + string(OriginOutbound), + } +} + +func (s *Origin) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOrigin(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOrigin(input string) (*Origin, error) { + vals := map[string]Origin{ + "inbound": OriginInbound, + "local": OriginLocal, + "outbound": OriginOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Origin(input) + return &out, nil +} + +type Protocol string + +const ( + ProtocolHTTP Protocol = "Http" + ProtocolHTTPS Protocol = "Https" + ProtocolIcmp Protocol = "Icmp" + ProtocolTcp Protocol = "Tcp" +) + +func PossibleValuesForProtocol() []string { + return []string{ + string(ProtocolHTTP), + string(ProtocolHTTPS), + string(ProtocolIcmp), + string(ProtocolTcp), + } +} + +func (s *Protocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtocol(input string) (*Protocol, error) { + vals := map[string]Protocol{ + "http": ProtocolHTTP, + "https": ProtocolHTTPS, + "icmp": ProtocolIcmp, + "tcp": ProtocolTcp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Protocol(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type Severity string + +const ( + SeverityError Severity = "Error" + SeverityWarning Severity = "Warning" +) + +func PossibleValuesForSeverity() []string { + return []string{ + string(SeverityError), + string(SeverityWarning), + } +} + +func (s *Severity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSeverity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSeverity(input string) (*Severity, error) { + vals := map[string]Severity{ + "error": SeverityError, + "warning": SeverityWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Severity(input) + return &out, nil +} + +type VerbosityLevel string + +const ( + VerbosityLevelFull VerbosityLevel = "Full" + VerbosityLevelMinimum VerbosityLevel = "Minimum" + VerbosityLevelNormal VerbosityLevel = "Normal" +) + +func PossibleValuesForVerbosityLevel() []string { + return []string{ + string(VerbosityLevelFull), + string(VerbosityLevelMinimum), + string(VerbosityLevelNormal), + } +} + +func (s *VerbosityLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVerbosityLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVerbosityLevel(input string) (*VerbosityLevel, error) { + vals := map[string]VerbosityLevel{ + "full": VerbosityLevelFull, + "minimum": VerbosityLevelMinimum, + "normal": VerbosityLevelNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VerbosityLevel(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/id_networkwatcher.go b/resource-manager/network/2024-07-01/networkwatchers/id_networkwatcher.go new file mode 100644 index 00000000000..2e22c948a13 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/id_networkwatcher.go @@ -0,0 +1,130 @@ +package networkwatchers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkWatcherId{}) +} + +var _ resourceids.ResourceId = &NetworkWatcherId{} + +// NetworkWatcherId is a struct representing the Resource ID for a Network Watcher +type NetworkWatcherId struct { + SubscriptionId string + ResourceGroupName string + NetworkWatcherName string +} + +// NewNetworkWatcherID returns a new NetworkWatcherId struct +func NewNetworkWatcherID(subscriptionId string, resourceGroupName string, networkWatcherName string) NetworkWatcherId { + return NetworkWatcherId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkWatcherName: networkWatcherName, + } +} + +// ParseNetworkWatcherID parses 'input' into a NetworkWatcherId +func ParseNetworkWatcherID(input string) (*NetworkWatcherId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkWatcherId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkWatcherId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkWatcherIDInsensitively parses 'input' case-insensitively into a NetworkWatcherId +// note: this method should only be used for API response data and not user input +func ParseNetworkWatcherIDInsensitively(input string) (*NetworkWatcherId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkWatcherId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkWatcherId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkWatcherId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkWatcherName, ok = input.Parsed["networkWatcherName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkWatcherName", input) + } + + return nil +} + +// ValidateNetworkWatcherID checks that 'input' can be parsed as a Network Watcher ID +func ValidateNetworkWatcherID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkWatcherID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Watcher ID +func (id NetworkWatcherId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkWatchers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkWatcherName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Watcher ID +func (id NetworkWatcherId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkWatchers", "networkWatchers", "networkWatchers"), + resourceids.UserSpecifiedSegment("networkWatcherName", "networkWatcherName"), + } +} + +// String returns a human-readable description of this Network Watcher ID +func (id NetworkWatcherId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Watcher Name: %q", id.NetworkWatcherName), + } + return fmt.Sprintf("Network Watcher (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/id_networkwatcher_test.go b/resource-manager/network/2024-07-01/networkwatchers/id_networkwatcher_test.go new file mode 100644 index 00000000000..d722c44c0c4 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/id_networkwatcher_test.go @@ -0,0 +1,282 @@ +package networkwatchers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkWatcherId{} + +func TestNewNetworkWatcherID(t *testing.T) { + id := NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkWatcherName != "networkWatcherName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkWatcherName'", id.NetworkWatcherName, "networkWatcherName") + } +} + +func TestFormatNetworkWatcherID(t *testing.T) { + actual := NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkWatcherID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkWatcherId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName", + Expected: &NetworkWatcherId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkWatcherName: "networkWatcherName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkWatcherID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkWatcherName != v.Expected.NetworkWatcherName { + t.Fatalf("Expected %q but got %q for NetworkWatcherName", v.Expected.NetworkWatcherName, actual.NetworkWatcherName) + } + + } +} + +func TestParseNetworkWatcherIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkWatcherId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName", + Expected: &NetworkWatcherId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkWatcherName: "networkWatcherName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE", + Expected: &NetworkWatcherId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkWatcherName: "nEtWoRkWaTcHeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkWatcherIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkWatcherName != v.Expected.NetworkWatcherName { + t.Fatalf("Expected %q but got %q for NetworkWatcherName", v.Expected.NetworkWatcherName, actual.NetworkWatcherName) + } + + } +} + +func TestSegmentsForNetworkWatcherId(t *testing.T) { + segments := NetworkWatcherId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkWatcherId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_checkconnectivity.go b/resource-manager/network/2024-07-01/networkwatchers/method_checkconnectivity.go new file mode 100644 index 00000000000..a41a47a9dbf --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_checkconnectivity.go @@ -0,0 +1,75 @@ +package networkwatchers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckConnectivityOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ConnectivityInformation +} + +// CheckConnectivity ... +func (c NetworkWatchersClient) CheckConnectivity(ctx context.Context, id NetworkWatcherId, input ConnectivityParameters) (result CheckConnectivityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/connectivityCheck", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CheckConnectivityThenPoll performs CheckConnectivity then polls until it's completed +func (c NetworkWatchersClient) CheckConnectivityThenPoll(ctx context.Context, id NetworkWatcherId, input ConnectivityParameters) error { + result, err := c.CheckConnectivity(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CheckConnectivity: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CheckConnectivity: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_createorupdate.go b/resource-manager/network/2024-07-01/networkwatchers/method_createorupdate.go new file mode 100644 index 00000000000..5881c4d5c10 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_createorupdate.go @@ -0,0 +1,58 @@ +package networkwatchers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkWatcher +} + +// CreateOrUpdate ... +func (c NetworkWatchersClient) CreateOrUpdate(ctx context.Context, id NetworkWatcherId, input NetworkWatcher) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkWatcher + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_delete.go b/resource-manager/network/2024-07-01/networkwatchers/method_delete.go new file mode 100644 index 00000000000..4c59058ef03 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_delete.go @@ -0,0 +1,70 @@ +package networkwatchers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c NetworkWatchersClient) Delete(ctx context.Context, id NetworkWatcherId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c NetworkWatchersClient) DeleteThenPoll(ctx context.Context, id NetworkWatcherId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_get.go b/resource-manager/network/2024-07-01/networkwatchers/method_get.go new file mode 100644 index 00000000000..1c429aeb42d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_get.go @@ -0,0 +1,53 @@ +package networkwatchers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkWatcher +} + +// Get ... +func (c NetworkWatchersClient) Get(ctx context.Context, id NetworkWatcherId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkWatcher + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_getazurereachabilityreport.go b/resource-manager/network/2024-07-01/networkwatchers/method_getazurereachabilityreport.go new file mode 100644 index 00000000000..54a23dc1c18 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_getazurereachabilityreport.go @@ -0,0 +1,75 @@ +package networkwatchers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAzureReachabilityReportOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AzureReachabilityReport +} + +// GetAzureReachabilityReport ... +func (c NetworkWatchersClient) GetAzureReachabilityReport(ctx context.Context, id NetworkWatcherId, input AzureReachabilityReportParameters) (result GetAzureReachabilityReportOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/azureReachabilityReport", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetAzureReachabilityReportThenPoll performs GetAzureReachabilityReport then polls until it's completed +func (c NetworkWatchersClient) GetAzureReachabilityReportThenPoll(ctx context.Context, id NetworkWatcherId, input AzureReachabilityReportParameters) error { + result, err := c.GetAzureReachabilityReport(ctx, id, input) + if err != nil { + return fmt.Errorf("performing GetAzureReachabilityReport: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetAzureReachabilityReport: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_getflowlogstatus.go b/resource-manager/network/2024-07-01/networkwatchers/method_getflowlogstatus.go new file mode 100644 index 00000000000..af6f975c691 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_getflowlogstatus.go @@ -0,0 +1,75 @@ +package networkwatchers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetFlowLogStatusOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *FlowLogInformation +} + +// GetFlowLogStatus ... +func (c NetworkWatchersClient) GetFlowLogStatus(ctx context.Context, id NetworkWatcherId, input FlowLogStatusParameters) (result GetFlowLogStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/queryFlowLogStatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetFlowLogStatusThenPoll performs GetFlowLogStatus then polls until it's completed +func (c NetworkWatchersClient) GetFlowLogStatusThenPoll(ctx context.Context, id NetworkWatcherId, input FlowLogStatusParameters) error { + result, err := c.GetFlowLogStatus(ctx, id, input) + if err != nil { + return fmt.Errorf("performing GetFlowLogStatus: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetFlowLogStatus: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_getnetworkconfigurationdiagnostic.go b/resource-manager/network/2024-07-01/networkwatchers/method_getnetworkconfigurationdiagnostic.go new file mode 100644 index 00000000000..de67c4ef4d4 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_getnetworkconfigurationdiagnostic.go @@ -0,0 +1,75 @@ +package networkwatchers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetNetworkConfigurationDiagnosticOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NetworkConfigurationDiagnosticResponse +} + +// GetNetworkConfigurationDiagnostic ... +func (c NetworkWatchersClient) GetNetworkConfigurationDiagnostic(ctx context.Context, id NetworkWatcherId, input NetworkConfigurationDiagnosticParameters) (result GetNetworkConfigurationDiagnosticOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/networkConfigurationDiagnostic", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetNetworkConfigurationDiagnosticThenPoll performs GetNetworkConfigurationDiagnostic then polls until it's completed +func (c NetworkWatchersClient) GetNetworkConfigurationDiagnosticThenPoll(ctx context.Context, id NetworkWatcherId, input NetworkConfigurationDiagnosticParameters) error { + result, err := c.GetNetworkConfigurationDiagnostic(ctx, id, input) + if err != nil { + return fmt.Errorf("performing GetNetworkConfigurationDiagnostic: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetNetworkConfigurationDiagnostic: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_getnexthop.go b/resource-manager/network/2024-07-01/networkwatchers/method_getnexthop.go new file mode 100644 index 00000000000..56fe43d4d11 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_getnexthop.go @@ -0,0 +1,75 @@ +package networkwatchers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetNextHopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NextHopResult +} + +// GetNextHop ... +func (c NetworkWatchersClient) GetNextHop(ctx context.Context, id NetworkWatcherId, input NextHopParameters) (result GetNextHopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/nextHop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetNextHopThenPoll performs GetNextHop then polls until it's completed +func (c NetworkWatchersClient) GetNextHopThenPoll(ctx context.Context, id NetworkWatcherId, input NextHopParameters) error { + result, err := c.GetNextHop(ctx, id, input) + if err != nil { + return fmt.Errorf("performing GetNextHop: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetNextHop: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_gettopology.go b/resource-manager/network/2024-07-01/networkwatchers/method_gettopology.go new file mode 100644 index 00000000000..68afb0d8206 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_gettopology.go @@ -0,0 +1,58 @@ +package networkwatchers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetTopologyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Topology +} + +// GetTopology ... +func (c NetworkWatchersClient) GetTopology(ctx context.Context, id NetworkWatcherId, input TopologyParameters) (result GetTopologyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/topology", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Topology + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_gettroubleshooting.go b/resource-manager/network/2024-07-01/networkwatchers/method_gettroubleshooting.go new file mode 100644 index 00000000000..9b5522b8119 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_gettroubleshooting.go @@ -0,0 +1,75 @@ +package networkwatchers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetTroubleshootingOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *TroubleshootingResult +} + +// GetTroubleshooting ... +func (c NetworkWatchersClient) GetTroubleshooting(ctx context.Context, id NetworkWatcherId, input TroubleshootingParameters) (result GetTroubleshootingOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/troubleshoot", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetTroubleshootingThenPoll performs GetTroubleshooting then polls until it's completed +func (c NetworkWatchersClient) GetTroubleshootingThenPoll(ctx context.Context, id NetworkWatcherId, input TroubleshootingParameters) error { + result, err := c.GetTroubleshooting(ctx, id, input) + if err != nil { + return fmt.Errorf("performing GetTroubleshooting: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetTroubleshooting: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_gettroubleshootingresult.go b/resource-manager/network/2024-07-01/networkwatchers/method_gettroubleshootingresult.go new file mode 100644 index 00000000000..fc9651abd21 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_gettroubleshootingresult.go @@ -0,0 +1,75 @@ +package networkwatchers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetTroubleshootingResultOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *TroubleshootingResult +} + +// GetTroubleshootingResult ... +func (c NetworkWatchersClient) GetTroubleshootingResult(ctx context.Context, id NetworkWatcherId, input QueryTroubleshootingParameters) (result GetTroubleshootingResultOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/queryTroubleshootResult", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetTroubleshootingResultThenPoll performs GetTroubleshootingResult then polls until it's completed +func (c NetworkWatchersClient) GetTroubleshootingResultThenPoll(ctx context.Context, id NetworkWatcherId, input QueryTroubleshootingParameters) error { + result, err := c.GetTroubleshootingResult(ctx, id, input) + if err != nil { + return fmt.Errorf("performing GetTroubleshootingResult: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetTroubleshootingResult: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_getvmsecurityrules.go b/resource-manager/network/2024-07-01/networkwatchers/method_getvmsecurityrules.go new file mode 100644 index 00000000000..1c8a917ab09 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_getvmsecurityrules.go @@ -0,0 +1,75 @@ +package networkwatchers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetVMSecurityRulesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SecurityGroupViewResult +} + +// GetVMSecurityRules ... +func (c NetworkWatchersClient) GetVMSecurityRules(ctx context.Context, id NetworkWatcherId, input SecurityGroupViewParameters) (result GetVMSecurityRulesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/securityGroupView", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetVMSecurityRulesThenPoll performs GetVMSecurityRules then polls until it's completed +func (c NetworkWatchersClient) GetVMSecurityRulesThenPoll(ctx context.Context, id NetworkWatcherId, input SecurityGroupViewParameters) error { + result, err := c.GetVMSecurityRules(ctx, id, input) + if err != nil { + return fmt.Errorf("performing GetVMSecurityRules: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetVMSecurityRules: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_list.go b/resource-manager/network/2024-07-01/networkwatchers/method_list.go new file mode 100644 index 00000000000..36d57f04fef --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_list.go @@ -0,0 +1,55 @@ +package networkwatchers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkWatcherListResult +} + +// List ... +func (c NetworkWatchersClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/networkWatchers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkWatcherListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_listall.go b/resource-manager/network/2024-07-01/networkwatchers/method_listall.go new file mode 100644 index 00000000000..b8bd8d8d4a6 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_listall.go @@ -0,0 +1,55 @@ +package networkwatchers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkWatcherListResult +} + +// ListAll ... +func (c NetworkWatchersClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/networkWatchers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkWatcherListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_listavailableproviders.go b/resource-manager/network/2024-07-01/networkwatchers/method_listavailableproviders.go new file mode 100644 index 00000000000..12768222c1e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_listavailableproviders.go @@ -0,0 +1,75 @@ +package networkwatchers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAvailableProvidersOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AvailableProvidersList +} + +// ListAvailableProviders ... +func (c NetworkWatchersClient) ListAvailableProviders(ctx context.Context, id NetworkWatcherId, input AvailableProvidersListParameters) (result ListAvailableProvidersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/availableProvidersList", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ListAvailableProvidersThenPoll performs ListAvailableProviders then polls until it's completed +func (c NetworkWatchersClient) ListAvailableProvidersThenPoll(ctx context.Context, id NetworkWatcherId, input AvailableProvidersListParameters) error { + result, err := c.ListAvailableProviders(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ListAvailableProviders: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ListAvailableProviders: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_setflowlogconfiguration.go b/resource-manager/network/2024-07-01/networkwatchers/method_setflowlogconfiguration.go new file mode 100644 index 00000000000..183183d38e9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_setflowlogconfiguration.go @@ -0,0 +1,75 @@ +package networkwatchers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SetFlowLogConfigurationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *FlowLogInformation +} + +// SetFlowLogConfiguration ... +func (c NetworkWatchersClient) SetFlowLogConfiguration(ctx context.Context, id NetworkWatcherId, input FlowLogInformation) (result SetFlowLogConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/configureFlowLog", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SetFlowLogConfigurationThenPoll performs SetFlowLogConfiguration then polls until it's completed +func (c NetworkWatchersClient) SetFlowLogConfigurationThenPoll(ctx context.Context, id NetworkWatcherId, input FlowLogInformation) error { + result, err := c.SetFlowLogConfiguration(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SetFlowLogConfiguration: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SetFlowLogConfiguration: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_updatetags.go b/resource-manager/network/2024-07-01/networkwatchers/method_updatetags.go new file mode 100644 index 00000000000..0ad45fd1f1a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_updatetags.go @@ -0,0 +1,57 @@ +package networkwatchers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkWatcher +} + +// UpdateTags ... +func (c NetworkWatchersClient) UpdateTags(ctx context.Context, id NetworkWatcherId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkWatcher + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/method_verifyipflow.go b/resource-manager/network/2024-07-01/networkwatchers/method_verifyipflow.go new file mode 100644 index 00000000000..1ef266cf37c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/method_verifyipflow.go @@ -0,0 +1,75 @@ +package networkwatchers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VerifyIPFlowOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VerificationIPFlowResult +} + +// VerifyIPFlow ... +func (c NetworkWatchersClient) VerifyIPFlow(ctx context.Context, id NetworkWatcherId, input VerificationIPFlowParameters) (result VerifyIPFlowOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/ipFlowVerify", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VerifyIPFlowThenPoll performs VerifyIPFlow then polls until it's completed +func (c NetworkWatchersClient) VerifyIPFlowThenPoll(ctx context.Context, id NetworkWatcherId, input VerificationIPFlowParameters) error { + result, err := c.VerifyIPFlow(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VerifyIPFlow: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VerifyIPFlow: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/networkwatchers/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..d93456b39dc --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/networkwatchers/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..1edb4c6e9fd --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_availableproviderslist.go b/resource-manager/network/2024-07-01/networkwatchers/model_availableproviderslist.go new file mode 100644 index 00000000000..f97306f3eb4 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_availableproviderslist.go @@ -0,0 +1,8 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableProvidersList struct { + Countries []AvailableProvidersListCountry `json:"countries"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_availableproviderslistcity.go b/resource-manager/network/2024-07-01/networkwatchers/model_availableproviderslistcity.go new file mode 100644 index 00000000000..ad5727a8ad0 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_availableproviderslistcity.go @@ -0,0 +1,9 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableProvidersListCity struct { + CityName *string `json:"cityName,omitempty"` + Providers *[]string `json:"providers,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_availableproviderslistcountry.go b/resource-manager/network/2024-07-01/networkwatchers/model_availableproviderslistcountry.go new file mode 100644 index 00000000000..98f3996ac17 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_availableproviderslistcountry.go @@ -0,0 +1,10 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableProvidersListCountry struct { + CountryName *string `json:"countryName,omitempty"` + Providers *[]string `json:"providers,omitempty"` + States *[]AvailableProvidersListState `json:"states,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_availableproviderslistparameters.go b/resource-manager/network/2024-07-01/networkwatchers/model_availableproviderslistparameters.go new file mode 100644 index 00000000000..e884f5cdb40 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_availableproviderslistparameters.go @@ -0,0 +1,11 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableProvidersListParameters struct { + AzureLocations *[]string `json:"azureLocations,omitempty"` + City *string `json:"city,omitempty"` + Country *string `json:"country,omitempty"` + State *string `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_availableprovidersliststate.go b/resource-manager/network/2024-07-01/networkwatchers/model_availableprovidersliststate.go new file mode 100644 index 00000000000..3504bafbcf0 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_availableprovidersliststate.go @@ -0,0 +1,10 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailableProvidersListState struct { + Cities *[]AvailableProvidersListCity `json:"cities,omitempty"` + Providers *[]string `json:"providers,omitempty"` + StateName *string `json:"stateName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_azurereachabilityreport.go b/resource-manager/network/2024-07-01/networkwatchers/model_azurereachabilityreport.go new file mode 100644 index 00000000000..e045a1522bc --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_azurereachabilityreport.go @@ -0,0 +1,10 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureReachabilityReport struct { + AggregationLevel string `json:"aggregationLevel"` + ProviderLocation AzureReachabilityReportLocation `json:"providerLocation"` + ReachabilityReport []AzureReachabilityReportItem `json:"reachabilityReport"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_azurereachabilityreportitem.go b/resource-manager/network/2024-07-01/networkwatchers/model_azurereachabilityreportitem.go new file mode 100644 index 00000000000..50e7da37b25 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_azurereachabilityreportitem.go @@ -0,0 +1,10 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureReachabilityReportItem struct { + AzureLocation *string `json:"azureLocation,omitempty"` + Latencies *[]AzureReachabilityReportLatencyInfo `json:"latencies,omitempty"` + Provider *string `json:"provider,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_azurereachabilityreportlatencyinfo.go b/resource-manager/network/2024-07-01/networkwatchers/model_azurereachabilityreportlatencyinfo.go new file mode 100644 index 00000000000..6755737d707 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_azurereachabilityreportlatencyinfo.go @@ -0,0 +1,27 @@ +package networkwatchers + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureReachabilityReportLatencyInfo struct { + Score *int64 `json:"score,omitempty"` + TimeStamp *string `json:"timeStamp,omitempty"` +} + +func (o *AzureReachabilityReportLatencyInfo) GetTimeStampAsTime() (*time.Time, error) { + if o.TimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureReachabilityReportLatencyInfo) SetTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeStamp = &formatted +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_azurereachabilityreportlocation.go b/resource-manager/network/2024-07-01/networkwatchers/model_azurereachabilityreportlocation.go new file mode 100644 index 00000000000..15b7ba2a6ee --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_azurereachabilityreportlocation.go @@ -0,0 +1,10 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureReachabilityReportLocation struct { + City *string `json:"city,omitempty"` + Country string `json:"country"` + State *string `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_azurereachabilityreportparameters.go b/resource-manager/network/2024-07-01/networkwatchers/model_azurereachabilityreportparameters.go new file mode 100644 index 00000000000..81d91ee2074 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_azurereachabilityreportparameters.go @@ -0,0 +1,36 @@ +package networkwatchers + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureReachabilityReportParameters struct { + AzureLocations *[]string `json:"azureLocations,omitempty"` + EndTime string `json:"endTime"` + ProviderLocation AzureReachabilityReportLocation `json:"providerLocation"` + Providers *[]string `json:"providers,omitempty"` + StartTime string `json:"startTime"` +} + +func (o *AzureReachabilityReportParameters) GetEndTimeAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureReachabilityReportParameters) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = formatted +} + +func (o *AzureReachabilityReportParameters) GetStartTimeAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AzureReachabilityReportParameters) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = formatted +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_connectivitydestination.go b/resource-manager/network/2024-07-01/networkwatchers/model_connectivitydestination.go new file mode 100644 index 00000000000..fd92ab947d7 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_connectivitydestination.go @@ -0,0 +1,10 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivityDestination struct { + Address *string `json:"address,omitempty"` + Port *int64 `json:"port,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_connectivityhop.go b/resource-manager/network/2024-07-01/networkwatchers/model_connectivityhop.go new file mode 100644 index 00000000000..b199aef7d99 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_connectivityhop.go @@ -0,0 +1,16 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivityHop struct { + Address *string `json:"address,omitempty"` + Id *string `json:"id,omitempty"` + Issues *[]ConnectivityIssue `json:"issues,omitempty"` + Links *[]HopLink `json:"links,omitempty"` + NextHopIds *[]string `json:"nextHopIds,omitempty"` + PreviousHopIds *[]string `json:"previousHopIds,omitempty"` + PreviousLinks *[]HopLink `json:"previousLinks,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_connectivityinformation.go b/resource-manager/network/2024-07-01/networkwatchers/model_connectivityinformation.go new file mode 100644 index 00000000000..0ce37ca8e82 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_connectivityinformation.go @@ -0,0 +1,14 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivityInformation struct { + AvgLatencyInMs *int64 `json:"avgLatencyInMs,omitempty"` + ConnectionStatus *ConnectionStatus `json:"connectionStatus,omitempty"` + Hops *[]ConnectivityHop `json:"hops,omitempty"` + MaxLatencyInMs *int64 `json:"maxLatencyInMs,omitempty"` + MinLatencyInMs *int64 `json:"minLatencyInMs,omitempty"` + ProbesFailed *int64 `json:"probesFailed,omitempty"` + ProbesSent *int64 `json:"probesSent,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_connectivityissue.go b/resource-manager/network/2024-07-01/networkwatchers/model_connectivityissue.go new file mode 100644 index 00000000000..ba9f23e149c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_connectivityissue.go @@ -0,0 +1,11 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivityIssue struct { + Context *[]map[string]string `json:"context,omitempty"` + Origin *Origin `json:"origin,omitempty"` + Severity *Severity `json:"severity,omitempty"` + Type *IssueType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_connectivityparameters.go b/resource-manager/network/2024-07-01/networkwatchers/model_connectivityparameters.go new file mode 100644 index 00000000000..2fd0eea7e96 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_connectivityparameters.go @@ -0,0 +1,12 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivityParameters struct { + Destination ConnectivityDestination `json:"destination"` + PreferredIPVersion *IPVersion `json:"preferredIPVersion,omitempty"` + Protocol *Protocol `json:"protocol,omitempty"` + ProtocolConfiguration *ProtocolConfiguration `json:"protocolConfiguration,omitempty"` + Source ConnectivitySource `json:"source"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_connectivitysource.go b/resource-manager/network/2024-07-01/networkwatchers/model_connectivitysource.go new file mode 100644 index 00000000000..471f2e79c48 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_connectivitysource.go @@ -0,0 +1,9 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectivitySource struct { + Port *int64 `json:"port,omitempty"` + ResourceId string `json:"resourceId"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_effectivenetworksecurityrule.go b/resource-manager/network/2024-07-01/networkwatchers/model_effectivenetworksecurityrule.go new file mode 100644 index 00000000000..738fb4c583d --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_effectivenetworksecurityrule.go @@ -0,0 +1,22 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EffectiveNetworkSecurityRule struct { + Access *SecurityRuleAccess `json:"access,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction *SecurityRuleDirection `json:"direction,omitempty"` + ExpandedDestinationAddressPrefix *[]string `json:"expandedDestinationAddressPrefix,omitempty"` + ExpandedSourceAddressPrefix *[]string `json:"expandedSourceAddressPrefix,omitempty"` + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + Protocol *EffectiveSecurityRuleProtocol `json:"protocol,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_evaluatednetworksecuritygroup.go b/resource-manager/network/2024-07-01/networkwatchers/model_evaluatednetworksecuritygroup.go new file mode 100644 index 00000000000..c471d60f7c3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_evaluatednetworksecuritygroup.go @@ -0,0 +1,11 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EvaluatedNetworkSecurityGroup struct { + AppliedTo *string `json:"appliedTo,omitempty"` + MatchedRule *MatchedRule `json:"matchedRule,omitempty"` + NetworkSecurityGroupId *string `json:"networkSecurityGroupId,omitempty"` + RulesEvaluationResult *[]NetworkSecurityRulesEvaluationResult `json:"rulesEvaluationResult,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/networkwatchers/model_flowlogformatparameters.go new file mode 100644 index 00000000000..804e14368ee --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_flowloginformation.go b/resource-manager/network/2024-07-01/networkwatchers/model_flowloginformation.go new file mode 100644 index 00000000000..af84bbc4202 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_flowloginformation.go @@ -0,0 +1,15 @@ +package networkwatchers + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogInformation struct { + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Properties FlowLogProperties `json:"properties"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_flowlogproperties.go b/resource-manager/network/2024-07-01/networkwatchers/model_flowlogproperties.go new file mode 100644 index 00000000000..624b13072ba --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_flowlogproperties.go @@ -0,0 +1,12 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogProperties struct { + Enabled bool `json:"enabled"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_flowlogstatusparameters.go b/resource-manager/network/2024-07-01/networkwatchers/model_flowlogstatusparameters.go new file mode 100644 index 00000000000..7adddbce138 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_flowlogstatusparameters.go @@ -0,0 +1,8 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogStatusParameters struct { + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_hoplink.go b/resource-manager/network/2024-07-01/networkwatchers/model_hoplink.go new file mode 100644 index 00000000000..ad0c1a88c32 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_hoplink.go @@ -0,0 +1,13 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HopLink struct { + Context *map[string]string `json:"context,omitempty"` + Issues *[]ConnectivityIssue `json:"issues,omitempty"` + LinkType *string `json:"linkType,omitempty"` + NextHopId *string `json:"nextHopId,omitempty"` + Properties *HopLinkProperties `json:"properties,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_hoplinkproperties.go b/resource-manager/network/2024-07-01/networkwatchers/model_hoplinkproperties.go new file mode 100644 index 00000000000..efce6d24581 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_hoplinkproperties.go @@ -0,0 +1,10 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HopLinkProperties struct { + RoundTripTimeAvg *int64 `json:"roundTripTimeAvg,omitempty"` + RoundTripTimeMax *int64 `json:"roundTripTimeMax,omitempty"` + RoundTripTimeMin *int64 `json:"roundTripTimeMin,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_httpconfiguration.go b/resource-manager/network/2024-07-01/networkwatchers/model_httpconfiguration.go new file mode 100644 index 00000000000..e469c4b2e2a --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_httpconfiguration.go @@ -0,0 +1,10 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPConfiguration struct { + Headers *[]HTTPHeader `json:"headers,omitempty"` + Method *HTTPMethod `json:"method,omitempty"` + ValidStatusCodes *[]int64 `json:"validStatusCodes,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_httpheader.go b/resource-manager/network/2024-07-01/networkwatchers/model_httpheader.go new file mode 100644 index 00000000000..5f0b41332f3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_httpheader.go @@ -0,0 +1,9 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPHeader struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_matchedrule.go b/resource-manager/network/2024-07-01/networkwatchers/model_matchedrule.go new file mode 100644 index 00000000000..7ccb0bf4ff1 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_matchedrule.go @@ -0,0 +1,9 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MatchedRule struct { + Action *string `json:"action,omitempty"` + RuleName *string `json:"ruleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_networkconfigurationdiagnosticparameters.go b/resource-manager/network/2024-07-01/networkwatchers/model_networkconfigurationdiagnosticparameters.go new file mode 100644 index 00000000000..62d57417ce8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_networkconfigurationdiagnosticparameters.go @@ -0,0 +1,10 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkConfigurationDiagnosticParameters struct { + Profiles []NetworkConfigurationDiagnosticProfile `json:"profiles"` + TargetResourceId string `json:"targetResourceId"` + VerbosityLevel *VerbosityLevel `json:"verbosityLevel,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_networkconfigurationdiagnosticprofile.go b/resource-manager/network/2024-07-01/networkwatchers/model_networkconfigurationdiagnosticprofile.go new file mode 100644 index 00000000000..2591d3cb1bc --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_networkconfigurationdiagnosticprofile.go @@ -0,0 +1,12 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkConfigurationDiagnosticProfile struct { + Destination string `json:"destination"` + DestinationPort string `json:"destinationPort"` + Direction Direction `json:"direction"` + Protocol string `json:"protocol"` + Source string `json:"source"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_networkconfigurationdiagnosticresponse.go b/resource-manager/network/2024-07-01/networkwatchers/model_networkconfigurationdiagnosticresponse.go new file mode 100644 index 00000000000..a30c9686e57 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_networkconfigurationdiagnosticresponse.go @@ -0,0 +1,8 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkConfigurationDiagnosticResponse struct { + Results *[]NetworkConfigurationDiagnosticResult `json:"results,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_networkconfigurationdiagnosticresult.go b/resource-manager/network/2024-07-01/networkwatchers/model_networkconfigurationdiagnosticresult.go new file mode 100644 index 00000000000..c0c796377f7 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_networkconfigurationdiagnosticresult.go @@ -0,0 +1,9 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkConfigurationDiagnosticResult struct { + NetworkSecurityGroupResult *NetworkSecurityGroupResult `json:"networkSecurityGroupResult,omitempty"` + Profile *NetworkConfigurationDiagnosticProfile `json:"profile,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_networkinterfaceassociation.go b/resource-manager/network/2024-07-01/networkwatchers/model_networkinterfaceassociation.go new file mode 100644 index 00000000000..0583e0225fd --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_networkinterfaceassociation.go @@ -0,0 +1,9 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceAssociation struct { + Id *string `json:"id,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_networksecuritygroupresult.go b/resource-manager/network/2024-07-01/networkwatchers/model_networksecuritygroupresult.go new file mode 100644 index 00000000000..60f125dff53 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_networksecuritygroupresult.go @@ -0,0 +1,9 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupResult struct { + EvaluatedNetworkSecurityGroups *[]EvaluatedNetworkSecurityGroup `json:"evaluatedNetworkSecurityGroups,omitempty"` + SecurityRuleAccessResult *SecurityRuleAccess `json:"securityRuleAccessResult,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_networksecurityrulesevaluationresult.go b/resource-manager/network/2024-07-01/networkwatchers/model_networksecurityrulesevaluationresult.go new file mode 100644 index 00000000000..c54e4c0dc86 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_networksecurityrulesevaluationresult.go @@ -0,0 +1,13 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityRulesEvaluationResult struct { + DestinationMatched *bool `json:"destinationMatched,omitempty"` + DestinationPortMatched *bool `json:"destinationPortMatched,omitempty"` + Name *string `json:"name,omitempty"` + ProtocolMatched *bool `json:"protocolMatched,omitempty"` + SourceMatched *bool `json:"sourceMatched,omitempty"` + SourcePortMatched *bool `json:"sourcePortMatched,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_networkwatcher.go b/resource-manager/network/2024-07-01/networkwatchers/model_networkwatcher.go new file mode 100644 index 00000000000..4f58f1863d8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_networkwatcher.go @@ -0,0 +1,14 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkWatcher struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkWatcherPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_networkwatcherlistresult.go b/resource-manager/network/2024-07-01/networkwatchers/model_networkwatcherlistresult.go new file mode 100644 index 00000000000..b78fc59bf86 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_networkwatcherlistresult.go @@ -0,0 +1,8 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkWatcherListResult struct { + Value *[]NetworkWatcher `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_networkwatcherpropertiesformat.go b/resource-manager/network/2024-07-01/networkwatchers/model_networkwatcherpropertiesformat.go new file mode 100644 index 00000000000..d0d1c07ed9e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_networkwatcherpropertiesformat.go @@ -0,0 +1,8 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkWatcherPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_nexthopparameters.go b/resource-manager/network/2024-07-01/networkwatchers/model_nexthopparameters.go new file mode 100644 index 00000000000..b8a7b00f4f3 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_nexthopparameters.go @@ -0,0 +1,11 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NextHopParameters struct { + DestinationIPAddress string `json:"destinationIPAddress"` + SourceIPAddress string `json:"sourceIPAddress"` + TargetNicResourceId *string `json:"targetNicResourceId,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_nexthopresult.go b/resource-manager/network/2024-07-01/networkwatchers/model_nexthopresult.go new file mode 100644 index 00000000000..a8a2ba32b01 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_nexthopresult.go @@ -0,0 +1,10 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NextHopResult struct { + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType *NextHopType `json:"nextHopType,omitempty"` + RouteTableId *string `json:"routeTableId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_protocolconfiguration.go b/resource-manager/network/2024-07-01/networkwatchers/model_protocolconfiguration.go new file mode 100644 index 00000000000..e4592ed2fe5 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_protocolconfiguration.go @@ -0,0 +1,8 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProtocolConfiguration struct { + HTTPConfiguration *HTTPConfiguration `json:"HTTPConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_querytroubleshootingparameters.go b/resource-manager/network/2024-07-01/networkwatchers/model_querytroubleshootingparameters.go new file mode 100644 index 00000000000..d6bf4abce2c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_querytroubleshootingparameters.go @@ -0,0 +1,8 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryTroubleshootingParameters struct { + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/networkwatchers/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..64b952abec0 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_securitygroupnetworkinterface.go b/resource-manager/network/2024-07-01/networkwatchers/model_securitygroupnetworkinterface.go new file mode 100644 index 00000000000..e22bcd0a9ed --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_securitygroupnetworkinterface.go @@ -0,0 +1,9 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityGroupNetworkInterface struct { + Id *string `json:"id,omitempty"` + SecurityRuleAssociations *SecurityRuleAssociations `json:"securityRuleAssociations,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_securitygroupviewparameters.go b/resource-manager/network/2024-07-01/networkwatchers/model_securitygroupviewparameters.go new file mode 100644 index 00000000000..9cbdf854c96 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_securitygroupviewparameters.go @@ -0,0 +1,8 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityGroupViewParameters struct { + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_securitygroupviewresult.go b/resource-manager/network/2024-07-01/networkwatchers/model_securitygroupviewresult.go new file mode 100644 index 00000000000..eff95f05919 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_securitygroupviewresult.go @@ -0,0 +1,8 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityGroupViewResult struct { + NetworkInterfaces *[]SecurityGroupNetworkInterface `json:"networkInterfaces,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_securityrule.go b/resource-manager/network/2024-07-01/networkwatchers/model_securityrule.go new file mode 100644 index 00000000000..c1dded9fca0 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_securityrule.go @@ -0,0 +1,12 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_securityruleassociations.go b/resource-manager/network/2024-07-01/networkwatchers/model_securityruleassociations.go new file mode 100644 index 00000000000..0ce7cc68a9c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_securityruleassociations.go @@ -0,0 +1,11 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRuleAssociations struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + EffectiveSecurityRules *[]EffectiveNetworkSecurityRule `json:"effectiveSecurityRules,omitempty"` + NetworkInterfaceAssociation *NetworkInterfaceAssociation `json:"networkInterfaceAssociation,omitempty"` + SubnetAssociation *SubnetAssociation `json:"subnetAssociation,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/networkwatchers/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..ae100c6915e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_subnetassociation.go b/resource-manager/network/2024-07-01/networkwatchers/model_subnetassociation.go new file mode 100644 index 00000000000..8b89222ca9e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_subnetassociation.go @@ -0,0 +1,9 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetAssociation struct { + Id *string `json:"id,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_subresource.go b/resource-manager/network/2024-07-01/networkwatchers/model_subresource.go new file mode 100644 index 00000000000..b98b68a29dd --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_subresource.go @@ -0,0 +1,8 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_tagsobject.go b/resource-manager/network/2024-07-01/networkwatchers/model_tagsobject.go new file mode 100644 index 00000000000..f022d1785d9 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_tagsobject.go @@ -0,0 +1,8 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_topology.go b/resource-manager/network/2024-07-01/networkwatchers/model_topology.go new file mode 100644 index 00000000000..c582a36ae6c --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_topology.go @@ -0,0 +1,41 @@ +package networkwatchers + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Topology struct { + CreatedDateTime *string `json:"createdDateTime,omitempty"` + Id *string `json:"id,omitempty"` + LastModified *string `json:"lastModified,omitempty"` + Resources *[]TopologyResource `json:"resources,omitempty"` +} + +func (o *Topology) GetCreatedDateTimeAsTime() (*time.Time, error) { + if o.CreatedDateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedDateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Topology) SetCreatedDateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedDateTime = &formatted +} + +func (o *Topology) GetLastModifiedAsTime() (*time.Time, error) { + if o.LastModified == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModified, "2006-01-02T15:04:05Z07:00") +} + +func (o *Topology) SetLastModifiedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModified = &formatted +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_topologyassociation.go b/resource-manager/network/2024-07-01/networkwatchers/model_topologyassociation.go new file mode 100644 index 00000000000..9607c85650b --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_topologyassociation.go @@ -0,0 +1,10 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopologyAssociation struct { + AssociationType *AssociationType `json:"associationType,omitempty"` + Name *string `json:"name,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_topologyparameters.go b/resource-manager/network/2024-07-01/networkwatchers/model_topologyparameters.go new file mode 100644 index 00000000000..25bc77b5345 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_topologyparameters.go @@ -0,0 +1,10 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopologyParameters struct { + TargetResourceGroupName *string `json:"targetResourceGroupName,omitempty"` + TargetSubnet *SubResource `json:"targetSubnet,omitempty"` + TargetVirtualNetwork *SubResource `json:"targetVirtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_topologyresource.go b/resource-manager/network/2024-07-01/networkwatchers/model_topologyresource.go new file mode 100644 index 00000000000..e126c541c8e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_topologyresource.go @@ -0,0 +1,11 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopologyResource struct { + Associations *[]TopologyAssociation `json:"associations,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/networkwatchers/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..63df321f46e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/networkwatchers/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..415ca1a8f5e --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_troubleshootingdetails.go b/resource-manager/network/2024-07-01/networkwatchers/model_troubleshootingdetails.go new file mode 100644 index 00000000000..2bc7443b168 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_troubleshootingdetails.go @@ -0,0 +1,12 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TroubleshootingDetails struct { + Detail *string `json:"detail,omitempty"` + Id *string `json:"id,omitempty"` + ReasonType *string `json:"reasonType,omitempty"` + RecommendedActions *[]TroubleshootingRecommendedActions `json:"recommendedActions,omitempty"` + Summary *string `json:"summary,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_troubleshootingparameters.go b/resource-manager/network/2024-07-01/networkwatchers/model_troubleshootingparameters.go new file mode 100644 index 00000000000..5ee881c84a7 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_troubleshootingparameters.go @@ -0,0 +1,9 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TroubleshootingParameters struct { + Properties TroubleshootingProperties `json:"properties"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_troubleshootingproperties.go b/resource-manager/network/2024-07-01/networkwatchers/model_troubleshootingproperties.go new file mode 100644 index 00000000000..8d187050a32 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_troubleshootingproperties.go @@ -0,0 +1,9 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TroubleshootingProperties struct { + StorageId string `json:"storageId"` + StoragePath string `json:"storagePath"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_troubleshootingrecommendedactions.go b/resource-manager/network/2024-07-01/networkwatchers/model_troubleshootingrecommendedactions.go new file mode 100644 index 00000000000..c4e5781e659 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_troubleshootingrecommendedactions.go @@ -0,0 +1,11 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TroubleshootingRecommendedActions struct { + ActionId *string `json:"actionId,omitempty"` + ActionText *string `json:"actionText,omitempty"` + ActionUri *string `json:"actionUri,omitempty"` + ActionUriText *string `json:"actionUriText,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_troubleshootingresult.go b/resource-manager/network/2024-07-01/networkwatchers/model_troubleshootingresult.go new file mode 100644 index 00000000000..62df62353d2 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_troubleshootingresult.go @@ -0,0 +1,41 @@ +package networkwatchers + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TroubleshootingResult struct { + Code *string `json:"code,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Results *[]TroubleshootingDetails `json:"results,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *TroubleshootingResult) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *TroubleshootingResult) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *TroubleshootingResult) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *TroubleshootingResult) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_verificationipflowparameters.go b/resource-manager/network/2024-07-01/networkwatchers/model_verificationipflowparameters.go new file mode 100644 index 00000000000..05165f3ed26 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_verificationipflowparameters.go @@ -0,0 +1,15 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VerificationIPFlowParameters struct { + Direction Direction `json:"direction"` + LocalIPAddress string `json:"localIPAddress"` + LocalPort string `json:"localPort"` + Protocol IPFlowProtocol `json:"protocol"` + RemoteIPAddress string `json:"remoteIPAddress"` + RemotePort string `json:"remotePort"` + TargetNicResourceId *string `json:"targetNicResourceId,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/model_verificationipflowresult.go b/resource-manager/network/2024-07-01/networkwatchers/model_verificationipflowresult.go new file mode 100644 index 00000000000..97318928bd8 --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/model_verificationipflowresult.go @@ -0,0 +1,9 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VerificationIPFlowResult struct { + Access *Access `json:"access,omitempty"` + RuleName *string `json:"ruleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/networkwatchers/version.go b/resource-manager/network/2024-07-01/networkwatchers/version.go new file mode 100644 index 00000000000..e989b3ee6cd --- /dev/null +++ b/resource-manager/network/2024-07-01/networkwatchers/version.go @@ -0,0 +1,10 @@ +package networkwatchers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/networkwatchers/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/README.md b/resource-manager/network/2024-07-01/p2svpngateways/README.md new file mode 100644 index 00000000000..e3c6dcd93ff --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/README.md @@ -0,0 +1,113 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/p2svpngateways` Documentation + +The `p2svpngateways` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/p2svpngateways" +``` + + +### Client Initialization + +```go +client := p2svpngateways.NewP2sVpnGatewaysClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `P2sVpnGatewaysClient.DisconnectP2sVpnConnections` + +```go +ctx := context.TODO() +id := commonids.NewVirtualWANP2SVPNGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "p2sVpnGatewayName") + +payload := p2svpngateways.P2SVpnConnectionRequest{ + // ... +} + + +if err := client.DisconnectP2sVpnConnectionsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `P2sVpnGatewaysClient.GenerateVpnProfile` + +```go +ctx := context.TODO() +id := commonids.NewVirtualWANP2SVPNGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "p2sVpnGatewayName") + +payload := p2svpngateways.P2SVpnProfileParameters{ + // ... +} + + +if err := client.GenerateVpnProfileThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `P2sVpnGatewaysClient.GetP2sVpnConnectionHealth` + +```go +ctx := context.TODO() +id := commonids.NewVirtualWANP2SVPNGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "p2sVpnGatewayName") + +if err := client.GetP2sVpnConnectionHealthThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `P2sVpnGatewaysClient.GetP2sVpnConnectionHealthDetailed` + +```go +ctx := context.TODO() +id := commonids.NewVirtualWANP2SVPNGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "p2sVpnGatewayName") + +payload := p2svpngateways.P2SVpnConnectionHealthRequest{ + // ... +} + + +if err := client.GetP2sVpnConnectionHealthDetailedThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `P2sVpnGatewaysClient.Reset` + +```go +ctx := context.TODO() +id := commonids.NewVirtualWANP2SVPNGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "p2sVpnGatewayName") + +if err := client.ResetThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `P2sVpnGatewaysClient.UpdateTags` + +```go +ctx := context.TODO() +id := commonids.NewVirtualWANP2SVPNGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "p2sVpnGatewayName") + +payload := p2svpngateways.TagsObject{ + // ... +} + + +if err := client.UpdateTagsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/network/2024-07-01/p2svpngateways/client.go b/resource-manager/network/2024-07-01/p2svpngateways/client.go new file mode 100644 index 00000000000..b2a2ec08b88 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/client.go @@ -0,0 +1,26 @@ +package p2svpngateways + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2sVpnGatewaysClient struct { + Client *resourcemanager.Client +} + +func NewP2sVpnGatewaysClientWithBaseURI(sdkApi sdkEnv.Api) (*P2sVpnGatewaysClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "p2svpngateways", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating P2sVpnGatewaysClient: %+v", err) + } + + return &P2sVpnGatewaysClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/constants.go b/resource-manager/network/2024-07-01/p2svpngateways/constants.go new file mode 100644 index 00000000000..e0d727fd608 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/constants.go @@ -0,0 +1,183 @@ +package p2svpngateways + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthenticationMethod string + +const ( + AuthenticationMethodEAPMSCHAPvTwo AuthenticationMethod = "EAPMSCHAPv2" + AuthenticationMethodEAPTLS AuthenticationMethod = "EAPTLS" +) + +func PossibleValuesForAuthenticationMethod() []string { + return []string{ + string(AuthenticationMethodEAPMSCHAPvTwo), + string(AuthenticationMethodEAPTLS), + } +} + +func (s *AuthenticationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationMethod(input string) (*AuthenticationMethod, error) { + vals := map[string]AuthenticationMethod{ + "eapmschapv2": AuthenticationMethodEAPMSCHAPvTwo, + "eaptls": AuthenticationMethodEAPTLS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationMethod(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type VnetLocalRouteOverrideCriteria string + +const ( + VnetLocalRouteOverrideCriteriaContains VnetLocalRouteOverrideCriteria = "Contains" + VnetLocalRouteOverrideCriteriaEqual VnetLocalRouteOverrideCriteria = "Equal" +) + +func PossibleValuesForVnetLocalRouteOverrideCriteria() []string { + return []string{ + string(VnetLocalRouteOverrideCriteriaContains), + string(VnetLocalRouteOverrideCriteriaEqual), + } +} + +func (s *VnetLocalRouteOverrideCriteria) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVnetLocalRouteOverrideCriteria(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVnetLocalRouteOverrideCriteria(input string) (*VnetLocalRouteOverrideCriteria, error) { + vals := map[string]VnetLocalRouteOverrideCriteria{ + "contains": VnetLocalRouteOverrideCriteriaContains, + "equal": VnetLocalRouteOverrideCriteriaEqual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VnetLocalRouteOverrideCriteria(input) + return &out, nil +} + +type VpnPolicyMemberAttributeType string + +const ( + VpnPolicyMemberAttributeTypeAADGroupId VpnPolicyMemberAttributeType = "AADGroupId" + VpnPolicyMemberAttributeTypeCertificateGroupId VpnPolicyMemberAttributeType = "CertificateGroupId" + VpnPolicyMemberAttributeTypeRadiusAzureGroupId VpnPolicyMemberAttributeType = "RadiusAzureGroupId" +) + +func PossibleValuesForVpnPolicyMemberAttributeType() []string { + return []string{ + string(VpnPolicyMemberAttributeTypeAADGroupId), + string(VpnPolicyMemberAttributeTypeCertificateGroupId), + string(VpnPolicyMemberAttributeTypeRadiusAzureGroupId), + } +} + +func (s *VpnPolicyMemberAttributeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnPolicyMemberAttributeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnPolicyMemberAttributeType(input string) (*VpnPolicyMemberAttributeType, error) { + vals := map[string]VpnPolicyMemberAttributeType{ + "aadgroupid": VpnPolicyMemberAttributeTypeAADGroupId, + "certificategroupid": VpnPolicyMemberAttributeTypeCertificateGroupId, + "radiusazuregroupid": VpnPolicyMemberAttributeTypeRadiusAzureGroupId, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnPolicyMemberAttributeType(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/method_disconnectp2svpnconnections.go b/resource-manager/network/2024-07-01/p2svpngateways/method_disconnectp2svpnconnections.go new file mode 100644 index 00000000000..c7746ee57d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/method_disconnectp2svpnconnections.go @@ -0,0 +1,75 @@ +package p2svpngateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DisconnectP2sVpnConnectionsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DisconnectP2sVpnConnections ... +func (c P2sVpnGatewaysClient) DisconnectP2sVpnConnections(ctx context.Context, id commonids.VirtualWANP2SVPNGatewayId, input P2SVpnConnectionRequest) (result DisconnectP2sVpnConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disconnectP2sVpnConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DisconnectP2sVpnConnectionsThenPoll performs DisconnectP2sVpnConnections then polls until it's completed +func (c P2sVpnGatewaysClient) DisconnectP2sVpnConnectionsThenPoll(ctx context.Context, id commonids.VirtualWANP2SVPNGatewayId, input P2SVpnConnectionRequest) error { + result, err := c.DisconnectP2sVpnConnections(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DisconnectP2sVpnConnections: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DisconnectP2sVpnConnections: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/method_generatevpnprofile.go b/resource-manager/network/2024-07-01/p2svpngateways/method_generatevpnprofile.go new file mode 100644 index 00000000000..b3c5acf03dc --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/method_generatevpnprofile.go @@ -0,0 +1,76 @@ +package p2svpngateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GenerateVpnProfileOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VpnProfileResponse +} + +// GenerateVpnProfile ... +func (c P2sVpnGatewaysClient) GenerateVpnProfile(ctx context.Context, id commonids.VirtualWANP2SVPNGatewayId, input P2SVpnProfileParameters) (result GenerateVpnProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/generatevpnprofile", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GenerateVpnProfileThenPoll performs GenerateVpnProfile then polls until it's completed +func (c P2sVpnGatewaysClient) GenerateVpnProfileThenPoll(ctx context.Context, id commonids.VirtualWANP2SVPNGatewayId, input P2SVpnProfileParameters) error { + result, err := c.GenerateVpnProfile(ctx, id, input) + if err != nil { + return fmt.Errorf("performing GenerateVpnProfile: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GenerateVpnProfile: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/method_getp2svpnconnectionhealth.go b/resource-manager/network/2024-07-01/p2svpngateways/method_getp2svpnconnectionhealth.go new file mode 100644 index 00000000000..dab0de414a2 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/method_getp2svpnconnectionhealth.go @@ -0,0 +1,72 @@ +package p2svpngateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetP2sVpnConnectionHealthOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *P2SVpnGateway +} + +// GetP2sVpnConnectionHealth ... +func (c P2sVpnGatewaysClient) GetP2sVpnConnectionHealth(ctx context.Context, id commonids.VirtualWANP2SVPNGatewayId) (result GetP2sVpnConnectionHealthOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getP2sVpnConnectionHealth", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetP2sVpnConnectionHealthThenPoll performs GetP2sVpnConnectionHealth then polls until it's completed +func (c P2sVpnGatewaysClient) GetP2sVpnConnectionHealthThenPoll(ctx context.Context, id commonids.VirtualWANP2SVPNGatewayId) error { + result, err := c.GetP2sVpnConnectionHealth(ctx, id) + if err != nil { + return fmt.Errorf("performing GetP2sVpnConnectionHealth: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetP2sVpnConnectionHealth: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/method_getp2svpnconnectionhealthdetailed.go b/resource-manager/network/2024-07-01/p2svpngateways/method_getp2svpnconnectionhealthdetailed.go new file mode 100644 index 00000000000..d5c274634f2 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/method_getp2svpnconnectionhealthdetailed.go @@ -0,0 +1,76 @@ +package p2svpngateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetP2sVpnConnectionHealthDetailedOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *P2SVpnConnectionHealth +} + +// GetP2sVpnConnectionHealthDetailed ... +func (c P2sVpnGatewaysClient) GetP2sVpnConnectionHealthDetailed(ctx context.Context, id commonids.VirtualWANP2SVPNGatewayId, input P2SVpnConnectionHealthRequest) (result GetP2sVpnConnectionHealthDetailedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getP2sVpnConnectionHealthDetailed", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetP2sVpnConnectionHealthDetailedThenPoll performs GetP2sVpnConnectionHealthDetailed then polls until it's completed +func (c P2sVpnGatewaysClient) GetP2sVpnConnectionHealthDetailedThenPoll(ctx context.Context, id commonids.VirtualWANP2SVPNGatewayId, input P2SVpnConnectionHealthRequest) error { + result, err := c.GetP2sVpnConnectionHealthDetailed(ctx, id, input) + if err != nil { + return fmt.Errorf("performing GetP2sVpnConnectionHealthDetailed: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetP2sVpnConnectionHealthDetailed: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/method_reset.go b/resource-manager/network/2024-07-01/p2svpngateways/method_reset.go new file mode 100644 index 00000000000..d00e0082c46 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/method_reset.go @@ -0,0 +1,72 @@ +package p2svpngateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResetOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *P2SVpnGateway +} + +// Reset ... +func (c P2sVpnGatewaysClient) Reset(ctx context.Context, id commonids.VirtualWANP2SVPNGatewayId) (result ResetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reset", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResetThenPoll performs Reset then polls until it's completed +func (c P2sVpnGatewaysClient) ResetThenPoll(ctx context.Context, id commonids.VirtualWANP2SVPNGatewayId) error { + result, err := c.Reset(ctx, id) + if err != nil { + return fmt.Errorf("performing Reset: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Reset: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/method_updatetags.go b/resource-manager/network/2024-07-01/p2svpngateways/method_updatetags.go new file mode 100644 index 00000000000..e1cbbdbc914 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/method_updatetags.go @@ -0,0 +1,76 @@ +package p2svpngateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *P2SVpnGateway +} + +// UpdateTags ... +func (c P2sVpnGatewaysClient) UpdateTags(ctx context.Context, id commonids.VirtualWANP2SVPNGatewayId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateTagsThenPoll performs UpdateTags then polls until it's completed +func (c P2sVpnGatewaysClient) UpdateTagsThenPoll(ctx context.Context, id commonids.VirtualWANP2SVPNGatewayId, input TagsObject) error { + result, err := c.UpdateTags(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UpdateTags: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpdateTags: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_addressspace.go b/resource-manager/network/2024-07-01/p2svpngateways/model_addressspace.go new file mode 100644 index 00000000000..02026c1d632 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_addressspace.go @@ -0,0 +1,9 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressSpace struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/p2svpngateways/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..22b17dc6f6b --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/p2svpngateways/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..96b5eeb06ac --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_p2sconnectionconfiguration.go b/resource-manager/network/2024-07-01/p2svpngateways/model_p2sconnectionconfiguration.go new file mode 100644 index 00000000000..278f2d7145d --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_p2sconnectionconfiguration.go @@ -0,0 +1,11 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2SConnectionConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *P2SConnectionConfigurationProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_p2sconnectionconfigurationproperties.go b/resource-manager/network/2024-07-01/p2svpngateways/model_p2sconnectionconfigurationproperties.go new file mode 100644 index 00000000000..33a16482774 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_p2sconnectionconfigurationproperties.go @@ -0,0 +1,13 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2SConnectionConfigurationProperties struct { + ConfigurationPolicyGroupAssociations *[]SubResource `json:"configurationPolicyGroupAssociations,omitempty"` + EnableInternetSecurity *bool `json:"enableInternetSecurity,omitempty"` + PreviousConfigurationPolicyGroupAssociations *[]VpnServerConfigurationPolicyGroup `json:"previousConfigurationPolicyGroupAssociations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RoutingConfiguration *RoutingConfiguration `json:"routingConfiguration,omitempty"` + VpnClientAddressPool *AddressSpace `json:"vpnClientAddressPool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpnconnectionhealth.go b/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpnconnectionhealth.go new file mode 100644 index 00000000000..d7e951d0d0a --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpnconnectionhealth.go @@ -0,0 +1,8 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2SVpnConnectionHealth struct { + SasURL *string `json:"sasUrl,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpnconnectionhealthrequest.go b/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpnconnectionhealthrequest.go new file mode 100644 index 00000000000..cb5094a7b15 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpnconnectionhealthrequest.go @@ -0,0 +1,9 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2SVpnConnectionHealthRequest struct { + OutputBlobSasURL *string `json:"outputBlobSasUrl,omitempty"` + VpnUserNamesFilter *[]string `json:"vpnUserNamesFilter,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpnconnectionrequest.go b/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpnconnectionrequest.go new file mode 100644 index 00000000000..f7b746fc648 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpnconnectionrequest.go @@ -0,0 +1,8 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2SVpnConnectionRequest struct { + VpnConnectionIds *[]string `json:"vpnConnectionIds,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpngateway.go b/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpngateway.go new file mode 100644 index 00000000000..522c7458570 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpngateway.go @@ -0,0 +1,14 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2SVpnGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *P2SVpnGatewayProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpngatewayproperties.go b/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpngatewayproperties.go new file mode 100644 index 00000000000..6099821abd6 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpngatewayproperties.go @@ -0,0 +1,15 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2SVpnGatewayProperties struct { + CustomDnsServers *[]string `json:"customDnsServers,omitempty"` + IsRoutingPreferenceInternet *bool `json:"isRoutingPreferenceInternet,omitempty"` + P2SConnectionConfigurations *[]P2SConnectionConfiguration `json:"p2SConnectionConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualHub *SubResource `json:"virtualHub,omitempty"` + VpnClientConnectionHealth *VpnClientConnectionHealth `json:"vpnClientConnectionHealth,omitempty"` + VpnGatewayScaleUnit *int64 `json:"vpnGatewayScaleUnit,omitempty"` + VpnServerConfiguration *SubResource `json:"vpnServerConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpnprofileparameters.go b/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpnprofileparameters.go new file mode 100644 index 00000000000..7f798f2ae40 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_p2svpnprofileparameters.go @@ -0,0 +1,8 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2SVpnProfileParameters struct { + AuthenticationMethod *AuthenticationMethod `json:"authenticationMethod,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_propagatedroutetable.go b/resource-manager/network/2024-07-01/p2svpngateways/model_propagatedroutetable.go new file mode 100644 index 00000000000..f137f52cc84 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_propagatedroutetable.go @@ -0,0 +1,9 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PropagatedRouteTable struct { + Ids *[]SubResource `json:"ids,omitempty"` + Labels *[]string `json:"labels,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_routingconfiguration.go b/resource-manager/network/2024-07-01/p2svpngateways/model_routingconfiguration.go new file mode 100644 index 00000000000..abe87c9515c --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_routingconfiguration.go @@ -0,0 +1,12 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingConfiguration struct { + AssociatedRouteTable *SubResource `json:"associatedRouteTable,omitempty"` + InboundRouteMap *SubResource `json:"inboundRouteMap,omitempty"` + OutboundRouteMap *SubResource `json:"outboundRouteMap,omitempty"` + PropagatedRouteTables *PropagatedRouteTable `json:"propagatedRouteTables,omitempty"` + VnetRoutes *VnetRoute `json:"vnetRoutes,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_staticroute.go b/resource-manager/network/2024-07-01/p2svpngateways/model_staticroute.go new file mode 100644 index 00000000000..0a7ee0c9c99 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_staticroute.go @@ -0,0 +1,10 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticRoute struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + Name *string `json:"name,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_staticroutesconfig.go b/resource-manager/network/2024-07-01/p2svpngateways/model_staticroutesconfig.go new file mode 100644 index 00000000000..063926c25d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_staticroutesconfig.go @@ -0,0 +1,9 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticRoutesConfig struct { + PropagateStaticRoutes *bool `json:"propagateStaticRoutes,omitempty"` + VnetLocalRouteOverrideCriteria *VnetLocalRouteOverrideCriteria `json:"vnetLocalRouteOverrideCriteria,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_subresource.go b/resource-manager/network/2024-07-01/p2svpngateways/model_subresource.go new file mode 100644 index 00000000000..80d7b205b99 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_subresource.go @@ -0,0 +1,8 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_tagsobject.go b/resource-manager/network/2024-07-01/p2svpngateways/model_tagsobject.go new file mode 100644 index 00000000000..f314ca6d15c --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_tagsobject.go @@ -0,0 +1,8 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_vnetroute.go b/resource-manager/network/2024-07-01/p2svpngateways/model_vnetroute.go new file mode 100644 index 00000000000..445ec97bfa1 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_vnetroute.go @@ -0,0 +1,10 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRoute struct { + BgpConnections *[]SubResource `json:"bgpConnections,omitempty"` + StaticRoutes *[]StaticRoute `json:"staticRoutes,omitempty"` + StaticRoutesConfig *StaticRoutesConfig `json:"staticRoutesConfig,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_vpnclientconnectionhealth.go b/resource-manager/network/2024-07-01/p2svpngateways/model_vpnclientconnectionhealth.go new file mode 100644 index 00000000000..fb3596341d9 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_vpnclientconnectionhealth.go @@ -0,0 +1,11 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnClientConnectionHealth struct { + AllocatedIPAddresses *[]string `json:"allocatedIpAddresses,omitempty"` + TotalEgressBytesTransferred *int64 `json:"totalEgressBytesTransferred,omitempty"` + TotalIngressBytesTransferred *int64 `json:"totalIngressBytesTransferred,omitempty"` + VpnClientConnectionsCount *int64 `json:"vpnClientConnectionsCount,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_vpnprofileresponse.go b/resource-manager/network/2024-07-01/p2svpngateways/model_vpnprofileresponse.go new file mode 100644 index 00000000000..3d26db7265b --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_vpnprofileresponse.go @@ -0,0 +1,8 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnProfileResponse struct { + ProfileURL *string `json:"profileUrl,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_vpnserverconfigurationpolicygroup.go b/resource-manager/network/2024-07-01/p2svpngateways/model_vpnserverconfigurationpolicygroup.go new file mode 100644 index 00000000000..fe026c0a264 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_vpnserverconfigurationpolicygroup.go @@ -0,0 +1,12 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationPolicyGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnServerConfigurationPolicyGroupProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_vpnserverconfigurationpolicygroupmember.go b/resource-manager/network/2024-07-01/p2svpngateways/model_vpnserverconfigurationpolicygroupmember.go new file mode 100644 index 00000000000..cebb5053164 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_vpnserverconfigurationpolicygroupmember.go @@ -0,0 +1,10 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationPolicyGroupMember struct { + AttributeType *VpnPolicyMemberAttributeType `json:"attributeType,omitempty"` + AttributeValue *string `json:"attributeValue,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/model_vpnserverconfigurationpolicygroupproperties.go b/resource-manager/network/2024-07-01/p2svpngateways/model_vpnserverconfigurationpolicygroupproperties.go new file mode 100644 index 00000000000..f7a9edb1a56 --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/model_vpnserverconfigurationpolicygroupproperties.go @@ -0,0 +1,12 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationPolicyGroupProperties struct { + IsDefault *bool `json:"isDefault,omitempty"` + P2SConnectionConfigurations *[]SubResource `json:"p2SConnectionConfigurations,omitempty"` + PolicyMembers *[]VpnServerConfigurationPolicyGroupMember `json:"policyMembers,omitempty"` + Priority *int64 `json:"priority,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/p2svpngateways/version.go b/resource-manager/network/2024-07-01/p2svpngateways/version.go new file mode 100644 index 00000000000..f244937e24f --- /dev/null +++ b/resource-manager/network/2024-07-01/p2svpngateways/version.go @@ -0,0 +1,10 @@ +package p2svpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/p2svpngateways/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/README.md b/resource-manager/network/2024-07-01/packetcaptures/README.md new file mode 100644 index 00000000000..dd11843656e --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/README.md @@ -0,0 +1,105 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/packetcaptures` Documentation + +The `packetcaptures` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/packetcaptures" +``` + + +### Client Initialization + +```go +client := packetcaptures.NewPacketCapturesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PacketCapturesClient.Create` + +```go +ctx := context.TODO() +id := packetcaptures.NewPacketCaptureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "packetCaptureName") + +payload := packetcaptures.PacketCapture{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `PacketCapturesClient.Delete` + +```go +ctx := context.TODO() +id := packetcaptures.NewPacketCaptureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "packetCaptureName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PacketCapturesClient.Get` + +```go +ctx := context.TODO() +id := packetcaptures.NewPacketCaptureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "packetCaptureName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PacketCapturesClient.GetStatus` + +```go +ctx := context.TODO() +id := packetcaptures.NewPacketCaptureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "packetCaptureName") + +if err := client.GetStatusThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PacketCapturesClient.List` + +```go +ctx := context.TODO() +id := packetcaptures.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PacketCapturesClient.Stop` + +```go +ctx := context.TODO() +id := packetcaptures.NewPacketCaptureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "packetCaptureName") + +if err := client.StopThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/network/2024-07-01/packetcaptures/client.go b/resource-manager/network/2024-07-01/packetcaptures/client.go new file mode 100644 index 00000000000..9acbfd7c6f7 --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/client.go @@ -0,0 +1,26 @@ +package packetcaptures + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCapturesClient struct { + Client *resourcemanager.Client +} + +func NewPacketCapturesClientWithBaseURI(sdkApi sdkEnv.Api) (*PacketCapturesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "packetcaptures", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PacketCapturesClient: %+v", err) + } + + return &PacketCapturesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/constants.go b/resource-manager/network/2024-07-01/packetcaptures/constants.go new file mode 100644 index 00000000000..52471a03c9e --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/constants.go @@ -0,0 +1,242 @@ +package packetcaptures + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCaptureTargetType string + +const ( + PacketCaptureTargetTypeAzureVM PacketCaptureTargetType = "AzureVM" + PacketCaptureTargetTypeAzureVMSS PacketCaptureTargetType = "AzureVMSS" +) + +func PossibleValuesForPacketCaptureTargetType() []string { + return []string{ + string(PacketCaptureTargetTypeAzureVM), + string(PacketCaptureTargetTypeAzureVMSS), + } +} + +func (s *PacketCaptureTargetType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePacketCaptureTargetType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePacketCaptureTargetType(input string) (*PacketCaptureTargetType, error) { + vals := map[string]PacketCaptureTargetType{ + "azurevm": PacketCaptureTargetTypeAzureVM, + "azurevmss": PacketCaptureTargetTypeAzureVMSS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PacketCaptureTargetType(input) + return &out, nil +} + +type PcError string + +const ( + PcErrorAgentStopped PcError = "AgentStopped" + PcErrorCaptureFailed PcError = "CaptureFailed" + PcErrorInternalError PcError = "InternalError" + PcErrorLocalFileFailed PcError = "LocalFileFailed" + PcErrorStorageFailed PcError = "StorageFailed" +) + +func PossibleValuesForPcError() []string { + return []string{ + string(PcErrorAgentStopped), + string(PcErrorCaptureFailed), + string(PcErrorInternalError), + string(PcErrorLocalFileFailed), + string(PcErrorStorageFailed), + } +} + +func (s *PcError) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePcError(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePcError(input string) (*PcError, error) { + vals := map[string]PcError{ + "agentstopped": PcErrorAgentStopped, + "capturefailed": PcErrorCaptureFailed, + "internalerror": PcErrorInternalError, + "localfilefailed": PcErrorLocalFileFailed, + "storagefailed": PcErrorStorageFailed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PcError(input) + return &out, nil +} + +type PcProtocol string + +const ( + PcProtocolAny PcProtocol = "Any" + PcProtocolTCP PcProtocol = "TCP" + PcProtocolUDP PcProtocol = "UDP" +) + +func PossibleValuesForPcProtocol() []string { + return []string{ + string(PcProtocolAny), + string(PcProtocolTCP), + string(PcProtocolUDP), + } +} + +func (s *PcProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePcProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePcProtocol(input string) (*PcProtocol, error) { + vals := map[string]PcProtocol{ + "any": PcProtocolAny, + "tcp": PcProtocolTCP, + "udp": PcProtocolUDP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PcProtocol(input) + return &out, nil +} + +type PcStatus string + +const ( + PcStatusError PcStatus = "Error" + PcStatusNotStarted PcStatus = "NotStarted" + PcStatusRunning PcStatus = "Running" + PcStatusStopped PcStatus = "Stopped" + PcStatusUnknown PcStatus = "Unknown" +) + +func PossibleValuesForPcStatus() []string { + return []string{ + string(PcStatusError), + string(PcStatusNotStarted), + string(PcStatusRunning), + string(PcStatusStopped), + string(PcStatusUnknown), + } +} + +func (s *PcStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePcStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePcStatus(input string) (*PcStatus, error) { + vals := map[string]PcStatus{ + "error": PcStatusError, + "notstarted": PcStatusNotStarted, + "running": PcStatusRunning, + "stopped": PcStatusStopped, + "unknown": PcStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PcStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/id_networkwatcher.go b/resource-manager/network/2024-07-01/packetcaptures/id_networkwatcher.go new file mode 100644 index 00000000000..df59b51a316 --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/id_networkwatcher.go @@ -0,0 +1,130 @@ +package packetcaptures + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkWatcherId{}) +} + +var _ resourceids.ResourceId = &NetworkWatcherId{} + +// NetworkWatcherId is a struct representing the Resource ID for a Network Watcher +type NetworkWatcherId struct { + SubscriptionId string + ResourceGroupName string + NetworkWatcherName string +} + +// NewNetworkWatcherID returns a new NetworkWatcherId struct +func NewNetworkWatcherID(subscriptionId string, resourceGroupName string, networkWatcherName string) NetworkWatcherId { + return NetworkWatcherId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkWatcherName: networkWatcherName, + } +} + +// ParseNetworkWatcherID parses 'input' into a NetworkWatcherId +func ParseNetworkWatcherID(input string) (*NetworkWatcherId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkWatcherId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkWatcherId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkWatcherIDInsensitively parses 'input' case-insensitively into a NetworkWatcherId +// note: this method should only be used for API response data and not user input +func ParseNetworkWatcherIDInsensitively(input string) (*NetworkWatcherId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkWatcherId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkWatcherId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkWatcherId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkWatcherName, ok = input.Parsed["networkWatcherName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkWatcherName", input) + } + + return nil +} + +// ValidateNetworkWatcherID checks that 'input' can be parsed as a Network Watcher ID +func ValidateNetworkWatcherID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkWatcherID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Watcher ID +func (id NetworkWatcherId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkWatchers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkWatcherName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Watcher ID +func (id NetworkWatcherId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkWatchers", "networkWatchers", "networkWatchers"), + resourceids.UserSpecifiedSegment("networkWatcherName", "networkWatcherName"), + } +} + +// String returns a human-readable description of this Network Watcher ID +func (id NetworkWatcherId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Watcher Name: %q", id.NetworkWatcherName), + } + return fmt.Sprintf("Network Watcher (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/id_networkwatcher_test.go b/resource-manager/network/2024-07-01/packetcaptures/id_networkwatcher_test.go new file mode 100644 index 00000000000..26fc5a3df18 --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/id_networkwatcher_test.go @@ -0,0 +1,282 @@ +package packetcaptures + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkWatcherId{} + +func TestNewNetworkWatcherID(t *testing.T) { + id := NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkWatcherName != "networkWatcherName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkWatcherName'", id.NetworkWatcherName, "networkWatcherName") + } +} + +func TestFormatNetworkWatcherID(t *testing.T) { + actual := NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkWatcherID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkWatcherId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName", + Expected: &NetworkWatcherId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkWatcherName: "networkWatcherName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkWatcherID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkWatcherName != v.Expected.NetworkWatcherName { + t.Fatalf("Expected %q but got %q for NetworkWatcherName", v.Expected.NetworkWatcherName, actual.NetworkWatcherName) + } + + } +} + +func TestParseNetworkWatcherIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkWatcherId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName", + Expected: &NetworkWatcherId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkWatcherName: "networkWatcherName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE", + Expected: &NetworkWatcherId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkWatcherName: "nEtWoRkWaTcHeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkWatcherIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkWatcherName != v.Expected.NetworkWatcherName { + t.Fatalf("Expected %q but got %q for NetworkWatcherName", v.Expected.NetworkWatcherName, actual.NetworkWatcherName) + } + + } +} + +func TestSegmentsForNetworkWatcherId(t *testing.T) { + segments := NetworkWatcherId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkWatcherId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/id_packetcapture.go b/resource-manager/network/2024-07-01/packetcaptures/id_packetcapture.go new file mode 100644 index 00000000000..80f04f9f292 --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/id_packetcapture.go @@ -0,0 +1,139 @@ +package packetcaptures + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PacketCaptureId{}) +} + +var _ resourceids.ResourceId = &PacketCaptureId{} + +// PacketCaptureId is a struct representing the Resource ID for a Packet Capture +type PacketCaptureId struct { + SubscriptionId string + ResourceGroupName string + NetworkWatcherName string + PacketCaptureName string +} + +// NewPacketCaptureID returns a new PacketCaptureId struct +func NewPacketCaptureID(subscriptionId string, resourceGroupName string, networkWatcherName string, packetCaptureName string) PacketCaptureId { + return PacketCaptureId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkWatcherName: networkWatcherName, + PacketCaptureName: packetCaptureName, + } +} + +// ParsePacketCaptureID parses 'input' into a PacketCaptureId +func ParsePacketCaptureID(input string) (*PacketCaptureId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCaptureId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCaptureId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePacketCaptureIDInsensitively parses 'input' case-insensitively into a PacketCaptureId +// note: this method should only be used for API response data and not user input +func ParsePacketCaptureIDInsensitively(input string) (*PacketCaptureId, error) { + parser := resourceids.NewParserFromResourceIdType(&PacketCaptureId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PacketCaptureId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PacketCaptureId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkWatcherName, ok = input.Parsed["networkWatcherName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkWatcherName", input) + } + + if id.PacketCaptureName, ok = input.Parsed["packetCaptureName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "packetCaptureName", input) + } + + return nil +} + +// ValidatePacketCaptureID checks that 'input' can be parsed as a Packet Capture ID +func ValidatePacketCaptureID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePacketCaptureID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Packet Capture ID +func (id PacketCaptureId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkWatchers/%s/packetCaptures/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkWatcherName, id.PacketCaptureName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Packet Capture ID +func (id PacketCaptureId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkWatchers", "networkWatchers", "networkWatchers"), + resourceids.UserSpecifiedSegment("networkWatcherName", "networkWatcherName"), + resourceids.StaticSegment("staticPacketCaptures", "packetCaptures", "packetCaptures"), + resourceids.UserSpecifiedSegment("packetCaptureName", "packetCaptureName"), + } +} + +// String returns a human-readable description of this Packet Capture ID +func (id PacketCaptureId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Watcher Name: %q", id.NetworkWatcherName), + fmt.Sprintf("Packet Capture Name: %q", id.PacketCaptureName), + } + return fmt.Sprintf("Packet Capture (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/id_packetcapture_test.go b/resource-manager/network/2024-07-01/packetcaptures/id_packetcapture_test.go new file mode 100644 index 00000000000..7e1ec3c55bb --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/id_packetcapture_test.go @@ -0,0 +1,327 @@ +package packetcaptures + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PacketCaptureId{} + +func TestNewPacketCaptureID(t *testing.T) { + id := NewPacketCaptureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "packetCaptureName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkWatcherName != "networkWatcherName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkWatcherName'", id.NetworkWatcherName, "networkWatcherName") + } + + if id.PacketCaptureName != "packetCaptureName" { + t.Fatalf("Expected %q but got %q for Segment 'PacketCaptureName'", id.PacketCaptureName, "packetCaptureName") + } +} + +func TestFormatPacketCaptureID(t *testing.T) { + actual := NewPacketCaptureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName", "packetCaptureName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/packetCaptures/packetCaptureName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePacketCaptureID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCaptureId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/packetCaptures", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/packetCaptures/packetCaptureName", + Expected: &PacketCaptureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkWatcherName: "networkWatcherName", + PacketCaptureName: "packetCaptureName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/packetCaptures/packetCaptureName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCaptureID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkWatcherName != v.Expected.NetworkWatcherName { + t.Fatalf("Expected %q but got %q for NetworkWatcherName", v.Expected.NetworkWatcherName, actual.NetworkWatcherName) + } + + if actual.PacketCaptureName != v.Expected.PacketCaptureName { + t.Fatalf("Expected %q but got %q for PacketCaptureName", v.Expected.PacketCaptureName, actual.PacketCaptureName) + } + + } +} + +func TestParsePacketCaptureIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PacketCaptureId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/packetCaptures", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE/pAcKeTcApTuReS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/packetCaptures/packetCaptureName", + Expected: &PacketCaptureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkWatcherName: "networkWatcherName", + PacketCaptureName: "packetCaptureName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/packetCaptures/packetCaptureName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE/pAcKeTcApTuReS/pAcKeTcApTuReNaMe", + Expected: &PacketCaptureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkWatcherName: "nEtWoRkWaTcHeRnAmE", + PacketCaptureName: "pAcKeTcApTuReNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE/pAcKeTcApTuReS/pAcKeTcApTuReNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePacketCaptureIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkWatcherName != v.Expected.NetworkWatcherName { + t.Fatalf("Expected %q but got %q for NetworkWatcherName", v.Expected.NetworkWatcherName, actual.NetworkWatcherName) + } + + if actual.PacketCaptureName != v.Expected.PacketCaptureName { + t.Fatalf("Expected %q but got %q for PacketCaptureName", v.Expected.PacketCaptureName, actual.PacketCaptureName) + } + + } +} + +func TestSegmentsForPacketCaptureId(t *testing.T) { + segments := PacketCaptureId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PacketCaptureId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/method_create.go b/resource-manager/network/2024-07-01/packetcaptures/method_create.go new file mode 100644 index 00000000000..d01c4d4092c --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/method_create.go @@ -0,0 +1,74 @@ +package packetcaptures + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *PacketCaptureResult +} + +// Create ... +func (c PacketCapturesClient) Create(ctx context.Context, id PacketCaptureId, input PacketCapture) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c PacketCapturesClient) CreateThenPoll(ctx context.Context, id PacketCaptureId, input PacketCapture) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/method_delete.go b/resource-manager/network/2024-07-01/packetcaptures/method_delete.go new file mode 100644 index 00000000000..d35a3b48efa --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/method_delete.go @@ -0,0 +1,70 @@ +package packetcaptures + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c PacketCapturesClient) Delete(ctx context.Context, id PacketCaptureId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PacketCapturesClient) DeleteThenPoll(ctx context.Context, id PacketCaptureId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/method_get.go b/resource-manager/network/2024-07-01/packetcaptures/method_get.go new file mode 100644 index 00000000000..9f32b393d10 --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/method_get.go @@ -0,0 +1,53 @@ +package packetcaptures + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PacketCaptureResult +} + +// Get ... +func (c PacketCapturesClient) Get(ctx context.Context, id PacketCaptureId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PacketCaptureResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/method_getstatus.go b/resource-manager/network/2024-07-01/packetcaptures/method_getstatus.go new file mode 100644 index 00000000000..20a7fc75b3c --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/method_getstatus.go @@ -0,0 +1,71 @@ +package packetcaptures + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetStatusOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *PacketCaptureQueryStatusResult +} + +// GetStatus ... +func (c PacketCapturesClient) GetStatus(ctx context.Context, id PacketCaptureId) (result GetStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/queryStatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetStatusThenPoll performs GetStatus then polls until it's completed +func (c PacketCapturesClient) GetStatusThenPoll(ctx context.Context, id PacketCaptureId) error { + result, err := c.GetStatus(ctx, id) + if err != nil { + return fmt.Errorf("performing GetStatus: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetStatus: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/method_list.go b/resource-manager/network/2024-07-01/packetcaptures/method_list.go new file mode 100644 index 00000000000..08e6f424863 --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/method_list.go @@ -0,0 +1,54 @@ +package packetcaptures + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PacketCaptureListResult +} + +// List ... +func (c PacketCapturesClient) List(ctx context.Context, id NetworkWatcherId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/packetCaptures", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PacketCaptureListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/method_stop.go b/resource-manager/network/2024-07-01/packetcaptures/method_stop.go new file mode 100644 index 00000000000..31a3b050169 --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/method_stop.go @@ -0,0 +1,70 @@ +package packetcaptures + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Stop ... +func (c PacketCapturesClient) Stop(ctx context.Context, id PacketCaptureId) (result StopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StopThenPoll performs Stop then polls until it's completed +func (c PacketCapturesClient) StopThenPoll(ctx context.Context, id PacketCaptureId) error { + result, err := c.Stop(ctx, id) + if err != nil { + return fmt.Errorf("performing Stop: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Stop: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/model_packetcapture.go b/resource-manager/network/2024-07-01/packetcaptures/model_packetcapture.go new file mode 100644 index 00000000000..592cd89a6e7 --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/model_packetcapture.go @@ -0,0 +1,8 @@ +package packetcaptures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCapture struct { + Properties PacketCaptureParameters `json:"properties"` +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturefilter.go b/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturefilter.go new file mode 100644 index 00000000000..fb301880566 --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturefilter.go @@ -0,0 +1,12 @@ +package packetcaptures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCaptureFilter struct { + LocalIPAddress *string `json:"localIPAddress,omitempty"` + LocalPort *string `json:"localPort,omitempty"` + Protocol *PcProtocol `json:"protocol,omitempty"` + RemoteIPAddress *string `json:"remoteIPAddress,omitempty"` + RemotePort *string `json:"remotePort,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturelistresult.go b/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturelistresult.go new file mode 100644 index 00000000000..54c50c44871 --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturelistresult.go @@ -0,0 +1,8 @@ +package packetcaptures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCaptureListResult struct { + Value *[]PacketCaptureResult `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturemachinescope.go b/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturemachinescope.go new file mode 100644 index 00000000000..99b476671ba --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturemachinescope.go @@ -0,0 +1,9 @@ +package packetcaptures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCaptureMachineScope struct { + Exclude *[]string `json:"exclude,omitempty"` + Include *[]string `json:"include,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/model_packetcaptureparameters.go b/resource-manager/network/2024-07-01/packetcaptures/model_packetcaptureparameters.go new file mode 100644 index 00000000000..0ce5dbb1e97 --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/model_packetcaptureparameters.go @@ -0,0 +1,17 @@ +package packetcaptures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCaptureParameters struct { + BytesToCapturePerPacket *int64 `json:"bytesToCapturePerPacket,omitempty"` + CaptureSettings *PacketCaptureSettings `json:"captureSettings,omitempty"` + ContinuousCapture *bool `json:"continuousCapture,omitempty"` + Filters *[]PacketCaptureFilter `json:"filters,omitempty"` + Scope *PacketCaptureMachineScope `json:"scope,omitempty"` + StorageLocation PacketCaptureStorageLocation `json:"storageLocation"` + Target string `json:"target"` + TargetType *PacketCaptureTargetType `json:"targetType,omitempty"` + TimeLimitInSeconds *int64 `json:"timeLimitInSeconds,omitempty"` + TotalBytesPerSession *int64 `json:"totalBytesPerSession,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturequerystatusresult.go b/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturequerystatusresult.go new file mode 100644 index 00000000000..edea164feae --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturequerystatusresult.go @@ -0,0 +1,31 @@ +package packetcaptures + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCaptureQueryStatusResult struct { + CaptureStartTime *string `json:"captureStartTime,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + PacketCaptureError *[]PcError `json:"packetCaptureError,omitempty"` + PacketCaptureStatus *PcStatus `json:"packetCaptureStatus,omitempty"` + StopReason *string `json:"stopReason,omitempty"` +} + +func (o *PacketCaptureQueryStatusResult) GetCaptureStartTimeAsTime() (*time.Time, error) { + if o.CaptureStartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CaptureStartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PacketCaptureQueryStatusResult) SetCaptureStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CaptureStartTime = &formatted +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/model_packetcaptureresult.go b/resource-manager/network/2024-07-01/packetcaptures/model_packetcaptureresult.go new file mode 100644 index 00000000000..a2e7cd88e02 --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/model_packetcaptureresult.go @@ -0,0 +1,11 @@ +package packetcaptures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCaptureResult struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PacketCaptureResultProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/model_packetcaptureresultproperties.go b/resource-manager/network/2024-07-01/packetcaptures/model_packetcaptureresultproperties.go new file mode 100644 index 00000000000..2e3ffaf706e --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/model_packetcaptureresultproperties.go @@ -0,0 +1,18 @@ +package packetcaptures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCaptureResultProperties struct { + BytesToCapturePerPacket *int64 `json:"bytesToCapturePerPacket,omitempty"` + CaptureSettings *PacketCaptureSettings `json:"captureSettings,omitempty"` + ContinuousCapture *bool `json:"continuousCapture,omitempty"` + Filters *[]PacketCaptureFilter `json:"filters,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Scope *PacketCaptureMachineScope `json:"scope,omitempty"` + StorageLocation PacketCaptureStorageLocation `json:"storageLocation"` + Target string `json:"target"` + TargetType *PacketCaptureTargetType `json:"targetType,omitempty"` + TimeLimitInSeconds *int64 `json:"timeLimitInSeconds,omitempty"` + TotalBytesPerSession *int64 `json:"totalBytesPerSession,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturesettings.go b/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturesettings.go new file mode 100644 index 00000000000..008b5742c30 --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturesettings.go @@ -0,0 +1,10 @@ +package packetcaptures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCaptureSettings struct { + FileCount *int64 `json:"fileCount,omitempty"` + FileSizeInBytes *int64 `json:"fileSizeInBytes,omitempty"` + SessionTimeLimitInSeconds *int64 `json:"sessionTimeLimitInSeconds,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturestoragelocation.go b/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturestoragelocation.go new file mode 100644 index 00000000000..dc8803c6bdd --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/model_packetcapturestoragelocation.go @@ -0,0 +1,11 @@ +package packetcaptures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PacketCaptureStorageLocation struct { + FilePath *string `json:"filePath,omitempty"` + LocalPath *string `json:"localPath,omitempty"` + StorageId *string `json:"storageId,omitempty"` + StoragePath *string `json:"storagePath,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/packetcaptures/version.go b/resource-manager/network/2024-07-01/packetcaptures/version.go new file mode 100644 index 00000000000..0a8fc4aad50 --- /dev/null +++ b/resource-manager/network/2024-07-01/packetcaptures/version.go @@ -0,0 +1,10 @@ +package packetcaptures + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/packetcaptures/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/README.md b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/README.md new file mode 100644 index 00000000000..b02a4820ca7 --- /dev/null +++ b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/README.md @@ -0,0 +1,54 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections` Documentation + +The `peerexpressroutecircuitconnections` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections" +``` + + +### Client Initialization + +```go +client := peerexpressroutecircuitconnections.NewPeerExpressRouteCircuitConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PeerExpressRouteCircuitConnectionsClient.Get` + +```go +ctx := context.TODO() +id := peerexpressroutecircuitconnections.NewPeerConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName", "peerConnectionName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PeerExpressRouteCircuitConnectionsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewExpressRouteCircuitPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/client.go b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/client.go new file mode 100644 index 00000000000..6f26d87afd5 --- /dev/null +++ b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/client.go @@ -0,0 +1,26 @@ +package peerexpressroutecircuitconnections + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PeerExpressRouteCircuitConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewPeerExpressRouteCircuitConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*PeerExpressRouteCircuitConnectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "peerexpressroutecircuitconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PeerExpressRouteCircuitConnectionsClient: %+v", err) + } + + return &PeerExpressRouteCircuitConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/constants.go b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/constants.go new file mode 100644 index 00000000000..eda70745480 --- /dev/null +++ b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/constants.go @@ -0,0 +1,101 @@ +package peerexpressroutecircuitconnections + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CircuitConnectionStatus string + +const ( + CircuitConnectionStatusConnected CircuitConnectionStatus = "Connected" + CircuitConnectionStatusConnecting CircuitConnectionStatus = "Connecting" + CircuitConnectionStatusDisconnected CircuitConnectionStatus = "Disconnected" +) + +func PossibleValuesForCircuitConnectionStatus() []string { + return []string{ + string(CircuitConnectionStatusConnected), + string(CircuitConnectionStatusConnecting), + string(CircuitConnectionStatusDisconnected), + } +} + +func (s *CircuitConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCircuitConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCircuitConnectionStatus(input string) (*CircuitConnectionStatus, error) { + vals := map[string]CircuitConnectionStatus{ + "connected": CircuitConnectionStatusConnected, + "connecting": CircuitConnectionStatusConnecting, + "disconnected": CircuitConnectionStatusDisconnected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CircuitConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/id_peerconnection.go b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/id_peerconnection.go new file mode 100644 index 00000000000..4819211effd --- /dev/null +++ b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/id_peerconnection.go @@ -0,0 +1,148 @@ +package peerexpressroutecircuitconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PeerConnectionId{}) +} + +var _ resourceids.ResourceId = &PeerConnectionId{} + +// PeerConnectionId is a struct representing the Resource ID for a Peer Connection +type PeerConnectionId struct { + SubscriptionId string + ResourceGroupName string + ExpressRouteCircuitName string + PeeringName string + PeerConnectionName string +} + +// NewPeerConnectionID returns a new PeerConnectionId struct +func NewPeerConnectionID(subscriptionId string, resourceGroupName string, expressRouteCircuitName string, peeringName string, peerConnectionName string) PeerConnectionId { + return PeerConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ExpressRouteCircuitName: expressRouteCircuitName, + PeeringName: peeringName, + PeerConnectionName: peerConnectionName, + } +} + +// ParsePeerConnectionID parses 'input' into a PeerConnectionId +func ParsePeerConnectionID(input string) (*PeerConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PeerConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PeerConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePeerConnectionIDInsensitively parses 'input' case-insensitively into a PeerConnectionId +// note: this method should only be used for API response data and not user input +func ParsePeerConnectionIDInsensitively(input string) (*PeerConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PeerConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PeerConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PeerConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ExpressRouteCircuitName, ok = input.Parsed["expressRouteCircuitName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "expressRouteCircuitName", input) + } + + if id.PeeringName, ok = input.Parsed["peeringName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "peeringName", input) + } + + if id.PeerConnectionName, ok = input.Parsed["peerConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "peerConnectionName", input) + } + + return nil +} + +// ValidatePeerConnectionID checks that 'input' can be parsed as a Peer Connection ID +func ValidatePeerConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePeerConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Peer Connection ID +func (id PeerConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/expressRouteCircuits/%s/peerings/%s/peerConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ExpressRouteCircuitName, id.PeeringName, id.PeerConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Peer Connection ID +func (id PeerConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticExpressRouteCircuits", "expressRouteCircuits", "expressRouteCircuits"), + resourceids.UserSpecifiedSegment("expressRouteCircuitName", "expressRouteCircuitName"), + resourceids.StaticSegment("staticPeerings", "peerings", "peerings"), + resourceids.UserSpecifiedSegment("peeringName", "peeringName"), + resourceids.StaticSegment("staticPeerConnections", "peerConnections", "peerConnections"), + resourceids.UserSpecifiedSegment("peerConnectionName", "peerConnectionName"), + } +} + +// String returns a human-readable description of this Peer Connection ID +func (id PeerConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Express Route Circuit Name: %q", id.ExpressRouteCircuitName), + fmt.Sprintf("Peering Name: %q", id.PeeringName), + fmt.Sprintf("Peer Connection Name: %q", id.PeerConnectionName), + } + return fmt.Sprintf("Peer Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/id_peerconnection_test.go b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/id_peerconnection_test.go new file mode 100644 index 00000000000..578fee6fb85 --- /dev/null +++ b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/id_peerconnection_test.go @@ -0,0 +1,372 @@ +package peerexpressroutecircuitconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PeerConnectionId{} + +func TestNewPeerConnectionID(t *testing.T) { + id := NewPeerConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName", "peerConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ExpressRouteCircuitName != "expressRouteCircuitName" { + t.Fatalf("Expected %q but got %q for Segment 'ExpressRouteCircuitName'", id.ExpressRouteCircuitName, "expressRouteCircuitName") + } + + if id.PeeringName != "peeringName" { + t.Fatalf("Expected %q but got %q for Segment 'PeeringName'", id.PeeringName, "peeringName") + } + + if id.PeerConnectionName != "peerConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PeerConnectionName'", id.PeerConnectionName, "peerConnectionName") + } +} + +func TestFormatPeerConnectionID(t *testing.T) { + actual := NewPeerConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "expressRouteCircuitName", "peeringName", "peerConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/peerConnections/peerConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePeerConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PeerConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/peerConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/peerConnections/peerConnectionName", + Expected: &PeerConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + PeeringName: "peeringName", + PeerConnectionName: "peerConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/peerConnections/peerConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePeerConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + if actual.PeerConnectionName != v.Expected.PeerConnectionName { + t.Fatalf("Expected %q but got %q for PeerConnectionName", v.Expected.PeerConnectionName, actual.PeerConnectionName) + } + + } +} + +func TestParsePeerConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PeerConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/peerConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe/pEeRcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/peerConnections/peerConnectionName", + Expected: &PeerConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ExpressRouteCircuitName: "expressRouteCircuitName", + PeeringName: "peeringName", + PeerConnectionName: "peerConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName/peerings/peeringName/peerConnections/peerConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe/pEeRcOnNeCtIoNs/pEeRcOnNeCtIoNnAmE", + Expected: &PeerConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ExpressRouteCircuitName: "eXpReSsRoUtEcIrCuItNaMe", + PeeringName: "pEeRiNgNaMe", + PeerConnectionName: "pEeRcOnNeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/eXpReSsRoUtEcIrCuItS/eXpReSsRoUtEcIrCuItNaMe/pEeRiNgS/pEeRiNgNaMe/pEeRcOnNeCtIoNs/pEeRcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePeerConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ExpressRouteCircuitName != v.Expected.ExpressRouteCircuitName { + t.Fatalf("Expected %q but got %q for ExpressRouteCircuitName", v.Expected.ExpressRouteCircuitName, actual.ExpressRouteCircuitName) + } + + if actual.PeeringName != v.Expected.PeeringName { + t.Fatalf("Expected %q but got %q for PeeringName", v.Expected.PeeringName, actual.PeeringName) + } + + if actual.PeerConnectionName != v.Expected.PeerConnectionName { + t.Fatalf("Expected %q but got %q for PeerConnectionName", v.Expected.PeerConnectionName, actual.PeerConnectionName) + } + + } +} + +func TestSegmentsForPeerConnectionId(t *testing.T) { + segments := PeerConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PeerConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/method_get.go b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/method_get.go new file mode 100644 index 00000000000..554ac17ad6f --- /dev/null +++ b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/method_get.go @@ -0,0 +1,53 @@ +package peerexpressroutecircuitconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PeerExpressRouteCircuitConnection +} + +// Get ... +func (c PeerExpressRouteCircuitConnectionsClient) Get(ctx context.Context, id PeerConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PeerExpressRouteCircuitConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/method_list.go b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/method_list.go new file mode 100644 index 00000000000..34a9aaafbe4 --- /dev/null +++ b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/method_list.go @@ -0,0 +1,106 @@ +package peerexpressroutecircuitconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PeerExpressRouteCircuitConnection +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PeerExpressRouteCircuitConnection +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c PeerExpressRouteCircuitConnectionsClient) List(ctx context.Context, id commonids.ExpressRouteCircuitPeeringId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/peerConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PeerExpressRouteCircuitConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c PeerExpressRouteCircuitConnectionsClient) ListComplete(ctx context.Context, id commonids.ExpressRouteCircuitPeeringId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, PeerExpressRouteCircuitConnectionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PeerExpressRouteCircuitConnectionsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ExpressRouteCircuitPeeringId, predicate PeerExpressRouteCircuitConnectionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]PeerExpressRouteCircuitConnection, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/model_peerexpressroutecircuitconnection.go b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/model_peerexpressroutecircuitconnection.go new file mode 100644 index 00000000000..0ba2f68f213 --- /dev/null +++ b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/model_peerexpressroutecircuitconnection.go @@ -0,0 +1,12 @@ +package peerexpressroutecircuitconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PeerExpressRouteCircuitConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PeerExpressRouteCircuitConnectionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/model_peerexpressroutecircuitconnectionpropertiesformat.go b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/model_peerexpressroutecircuitconnectionpropertiesformat.go new file mode 100644 index 00000000000..c4a72c247d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/model_peerexpressroutecircuitconnectionpropertiesformat.go @@ -0,0 +1,14 @@ +package peerexpressroutecircuitconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PeerExpressRouteCircuitConnectionPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AuthResourceGuid *string `json:"authResourceGuid,omitempty"` + CircuitConnectionStatus *CircuitConnectionStatus `json:"circuitConnectionStatus,omitempty"` + ConnectionName *string `json:"connectionName,omitempty"` + ExpressRouteCircuitPeering *SubResource `json:"expressRouteCircuitPeering,omitempty"` + PeerExpressRouteCircuitPeering *SubResource `json:"peerExpressRouteCircuitPeering,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/model_subresource.go b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/model_subresource.go new file mode 100644 index 00000000000..da8f131efb2 --- /dev/null +++ b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/model_subresource.go @@ -0,0 +1,8 @@ +package peerexpressroutecircuitconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/predicates.go b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/predicates.go new file mode 100644 index 00000000000..c0766bb2d18 --- /dev/null +++ b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/predicates.go @@ -0,0 +1,32 @@ +package peerexpressroutecircuitconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PeerExpressRouteCircuitConnectionOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p PeerExpressRouteCircuitConnectionOperationPredicate) Matches(input PeerExpressRouteCircuitConnection) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/version.go b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/version.go new file mode 100644 index 00000000000..4d1cf4753b9 --- /dev/null +++ b/resource-manager/network/2024-07-01/peerexpressroutecircuitconnections/version.go @@ -0,0 +1,10 @@ +package peerexpressroutecircuitconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/peerexpressroutecircuitconnections/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/README.md b/resource-manager/network/2024-07-01/privatednszonegroups/README.md new file mode 100644 index 00000000000..34a9c416c2c --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/privatednszonegroups` Documentation + +The `privatednszonegroups` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/privatednszonegroups" +``` + + +### Client Initialization + +```go +client := privatednszonegroups.NewPrivateDnsZoneGroupsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateDnsZoneGroupsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := privatednszonegroups.NewPrivateDnsZoneGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateEndpointName", "privateDnsZoneGroupName") + +payload := privatednszonegroups.PrivateDnsZoneGroup{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateDnsZoneGroupsClient.Delete` + +```go +ctx := context.TODO() +id := privatednszonegroups.NewPrivateDnsZoneGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateEndpointName", "privateDnsZoneGroupName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateDnsZoneGroupsClient.Get` + +```go +ctx := context.TODO() +id := privatednszonegroups.NewPrivateDnsZoneGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateEndpointName", "privateDnsZoneGroupName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateDnsZoneGroupsClient.List` + +```go +ctx := context.TODO() +id := privatednszonegroups.NewPrivateEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateEndpointName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/client.go b/resource-manager/network/2024-07-01/privatednszonegroups/client.go new file mode 100644 index 00000000000..58e48fe8e2e --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/client.go @@ -0,0 +1,26 @@ +package privatednszonegroups + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateDnsZoneGroupsClient struct { + Client *resourcemanager.Client +} + +func NewPrivateDnsZoneGroupsClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateDnsZoneGroupsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "privatednszonegroups", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateDnsZoneGroupsClient: %+v", err) + } + + return &PrivateDnsZoneGroupsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/constants.go b/resource-manager/network/2024-07-01/privatednszonegroups/constants.go new file mode 100644 index 00000000000..a68ae3a4523 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/constants.go @@ -0,0 +1,57 @@ +package privatednszonegroups + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/id_privatednszonegroup.go b/resource-manager/network/2024-07-01/privatednszonegroups/id_privatednszonegroup.go new file mode 100644 index 00000000000..9d6d9b40c00 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/id_privatednszonegroup.go @@ -0,0 +1,139 @@ +package privatednszonegroups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateDnsZoneGroupId{}) +} + +var _ resourceids.ResourceId = &PrivateDnsZoneGroupId{} + +// PrivateDnsZoneGroupId is a struct representing the Resource ID for a Private Dns Zone Group +type PrivateDnsZoneGroupId struct { + SubscriptionId string + ResourceGroupName string + PrivateEndpointName string + PrivateDnsZoneGroupName string +} + +// NewPrivateDnsZoneGroupID returns a new PrivateDnsZoneGroupId struct +func NewPrivateDnsZoneGroupID(subscriptionId string, resourceGroupName string, privateEndpointName string, privateDnsZoneGroupName string) PrivateDnsZoneGroupId { + return PrivateDnsZoneGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PrivateEndpointName: privateEndpointName, + PrivateDnsZoneGroupName: privateDnsZoneGroupName, + } +} + +// ParsePrivateDnsZoneGroupID parses 'input' into a PrivateDnsZoneGroupId +func ParsePrivateDnsZoneGroupID(input string) (*PrivateDnsZoneGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateDnsZoneGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateDnsZoneGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateDnsZoneGroupIDInsensitively parses 'input' case-insensitively into a PrivateDnsZoneGroupId +// note: this method should only be used for API response data and not user input +func ParsePrivateDnsZoneGroupIDInsensitively(input string) (*PrivateDnsZoneGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateDnsZoneGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateDnsZoneGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateDnsZoneGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PrivateEndpointName, ok = input.Parsed["privateEndpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointName", input) + } + + if id.PrivateDnsZoneGroupName, ok = input.Parsed["privateDnsZoneGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateDnsZoneGroupName", input) + } + + return nil +} + +// ValidatePrivateDnsZoneGroupID checks that 'input' can be parsed as a Private Dns Zone Group ID +func ValidatePrivateDnsZoneGroupID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateDnsZoneGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Dns Zone Group ID +func (id PrivateDnsZoneGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/privateEndpoints/%s/privateDnsZoneGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PrivateEndpointName, id.PrivateDnsZoneGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Dns Zone Group ID +func (id PrivateDnsZoneGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticPrivateEndpoints", "privateEndpoints", "privateEndpoints"), + resourceids.UserSpecifiedSegment("privateEndpointName", "privateEndpointName"), + resourceids.StaticSegment("staticPrivateDnsZoneGroups", "privateDnsZoneGroups", "privateDnsZoneGroups"), + resourceids.UserSpecifiedSegment("privateDnsZoneGroupName", "privateDnsZoneGroupName"), + } +} + +// String returns a human-readable description of this Private Dns Zone Group ID +func (id PrivateDnsZoneGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Private Endpoint Name: %q", id.PrivateEndpointName), + fmt.Sprintf("Private Dns Zone Group Name: %q", id.PrivateDnsZoneGroupName), + } + return fmt.Sprintf("Private Dns Zone Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/id_privatednszonegroup_test.go b/resource-manager/network/2024-07-01/privatednszonegroups/id_privatednszonegroup_test.go new file mode 100644 index 00000000000..09f4046f057 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/id_privatednszonegroup_test.go @@ -0,0 +1,327 @@ +package privatednszonegroups + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateDnsZoneGroupId{} + +func TestNewPrivateDnsZoneGroupID(t *testing.T) { + id := NewPrivateDnsZoneGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateEndpointName", "privateDnsZoneGroupName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.PrivateEndpointName != "privateEndpointName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointName'", id.PrivateEndpointName, "privateEndpointName") + } + + if id.PrivateDnsZoneGroupName != "privateDnsZoneGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateDnsZoneGroupName'", id.PrivateDnsZoneGroupName, "privateDnsZoneGroupName") + } +} + +func TestFormatPrivateDnsZoneGroupID(t *testing.T) { + actual := NewPrivateDnsZoneGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateEndpointName", "privateDnsZoneGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName/privateDnsZoneGroups/privateDnsZoneGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateDnsZoneGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateDnsZoneGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName/privateDnsZoneGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName/privateDnsZoneGroups/privateDnsZoneGroupName", + Expected: &PrivateDnsZoneGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PrivateEndpointName: "privateEndpointName", + PrivateDnsZoneGroupName: "privateDnsZoneGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName/privateDnsZoneGroups/privateDnsZoneGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateDnsZoneGroupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.PrivateEndpointName != v.Expected.PrivateEndpointName { + t.Fatalf("Expected %q but got %q for PrivateEndpointName", v.Expected.PrivateEndpointName, actual.PrivateEndpointName) + } + + if actual.PrivateDnsZoneGroupName != v.Expected.PrivateDnsZoneGroupName { + t.Fatalf("Expected %q but got %q for PrivateDnsZoneGroupName", v.Expected.PrivateDnsZoneGroupName, actual.PrivateDnsZoneGroupName) + } + + } +} + +func TestParsePrivateDnsZoneGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateDnsZoneGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeEnDpOiNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeEnDpOiNtS/pRiVaTeEnDpOiNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName/privateDnsZoneGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeEnDpOiNtS/pRiVaTeEnDpOiNtNaMe/pRiVaTeDnSzOnEgRoUpS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName/privateDnsZoneGroups/privateDnsZoneGroupName", + Expected: &PrivateDnsZoneGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PrivateEndpointName: "privateEndpointName", + PrivateDnsZoneGroupName: "privateDnsZoneGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName/privateDnsZoneGroups/privateDnsZoneGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeEnDpOiNtS/pRiVaTeEnDpOiNtNaMe/pRiVaTeDnSzOnEgRoUpS/pRiVaTeDnSzOnEgRoUpNaMe", + Expected: &PrivateDnsZoneGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PrivateEndpointName: "pRiVaTeEnDpOiNtNaMe", + PrivateDnsZoneGroupName: "pRiVaTeDnSzOnEgRoUpNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeEnDpOiNtS/pRiVaTeEnDpOiNtNaMe/pRiVaTeDnSzOnEgRoUpS/pRiVaTeDnSzOnEgRoUpNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateDnsZoneGroupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.PrivateEndpointName != v.Expected.PrivateEndpointName { + t.Fatalf("Expected %q but got %q for PrivateEndpointName", v.Expected.PrivateEndpointName, actual.PrivateEndpointName) + } + + if actual.PrivateDnsZoneGroupName != v.Expected.PrivateDnsZoneGroupName { + t.Fatalf("Expected %q but got %q for PrivateDnsZoneGroupName", v.Expected.PrivateDnsZoneGroupName, actual.PrivateDnsZoneGroupName) + } + + } +} + +func TestSegmentsForPrivateDnsZoneGroupId(t *testing.T) { + segments := PrivateDnsZoneGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateDnsZoneGroupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/id_privateendpoint.go b/resource-manager/network/2024-07-01/privatednszonegroups/id_privateendpoint.go new file mode 100644 index 00000000000..858dc908589 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/id_privateendpoint.go @@ -0,0 +1,130 @@ +package privatednszonegroups + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointId{} + +// PrivateEndpointId is a struct representing the Resource ID for a Private Endpoint +type PrivateEndpointId struct { + SubscriptionId string + ResourceGroupName string + PrivateEndpointName string +} + +// NewPrivateEndpointID returns a new PrivateEndpointId struct +func NewPrivateEndpointID(subscriptionId string, resourceGroupName string, privateEndpointName string) PrivateEndpointId { + return PrivateEndpointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PrivateEndpointName: privateEndpointName, + } +} + +// ParsePrivateEndpointID parses 'input' into a PrivateEndpointId +func ParsePrivateEndpointID(input string) (*PrivateEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointIDInsensitively parses 'input' case-insensitively into a PrivateEndpointId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointIDInsensitively(input string) (*PrivateEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PrivateEndpointName, ok = input.Parsed["privateEndpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointName", input) + } + + return nil +} + +// ValidatePrivateEndpointID checks that 'input' can be parsed as a Private Endpoint ID +func ValidatePrivateEndpointID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateEndpointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint ID +func (id PrivateEndpointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/privateEndpoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PrivateEndpointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint ID +func (id PrivateEndpointId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticPrivateEndpoints", "privateEndpoints", "privateEndpoints"), + resourceids.UserSpecifiedSegment("privateEndpointName", "privateEndpointName"), + } +} + +// String returns a human-readable description of this Private Endpoint ID +func (id PrivateEndpointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Private Endpoint Name: %q", id.PrivateEndpointName), + } + return fmt.Sprintf("Private Endpoint (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/id_privateendpoint_test.go b/resource-manager/network/2024-07-01/privatednszonegroups/id_privateendpoint_test.go new file mode 100644 index 00000000000..7a798827c94 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/id_privateendpoint_test.go @@ -0,0 +1,282 @@ +package privatednszonegroups + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateEndpointId{} + +func TestNewPrivateEndpointID(t *testing.T) { + id := NewPrivateEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateEndpointName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.PrivateEndpointName != "privateEndpointName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointName'", id.PrivateEndpointName, "privateEndpointName") + } +} + +func TestFormatPrivateEndpointID(t *testing.T) { + actual := NewPrivateEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateEndpointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName", + Expected: &PrivateEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PrivateEndpointName: "privateEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.PrivateEndpointName != v.Expected.PrivateEndpointName { + t.Fatalf("Expected %q but got %q for PrivateEndpointName", v.Expected.PrivateEndpointName, actual.PrivateEndpointName) + } + + } +} + +func TestParsePrivateEndpointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeEnDpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName", + Expected: &PrivateEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PrivateEndpointName: "privateEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeEnDpOiNtS/pRiVaTeEnDpOiNtNaMe", + Expected: &PrivateEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PrivateEndpointName: "pRiVaTeEnDpOiNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeEnDpOiNtS/pRiVaTeEnDpOiNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.PrivateEndpointName != v.Expected.PrivateEndpointName { + t.Fatalf("Expected %q but got %q for PrivateEndpointName", v.Expected.PrivateEndpointName, actual.PrivateEndpointName) + } + + } +} + +func TestSegmentsForPrivateEndpointId(t *testing.T) { + segments := PrivateEndpointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/method_createorupdate.go b/resource-manager/network/2024-07-01/privatednszonegroups/method_createorupdate.go new file mode 100644 index 00000000000..88dadb3a0a5 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/method_createorupdate.go @@ -0,0 +1,75 @@ +package privatednszonegroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *PrivateDnsZoneGroup +} + +// CreateOrUpdate ... +func (c PrivateDnsZoneGroupsClient) CreateOrUpdate(ctx context.Context, id PrivateDnsZoneGroupId, input PrivateDnsZoneGroup) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c PrivateDnsZoneGroupsClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateDnsZoneGroupId, input PrivateDnsZoneGroup) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/method_delete.go b/resource-manager/network/2024-07-01/privatednszonegroups/method_delete.go new file mode 100644 index 00000000000..cdf382f2686 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/method_delete.go @@ -0,0 +1,71 @@ +package privatednszonegroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c PrivateDnsZoneGroupsClient) Delete(ctx context.Context, id PrivateDnsZoneGroupId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PrivateDnsZoneGroupsClient) DeleteThenPoll(ctx context.Context, id PrivateDnsZoneGroupId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/method_get.go b/resource-manager/network/2024-07-01/privatednszonegroups/method_get.go new file mode 100644 index 00000000000..b0a317bbf4d --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/method_get.go @@ -0,0 +1,53 @@ +package privatednszonegroups + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateDnsZoneGroup +} + +// Get ... +func (c PrivateDnsZoneGroupsClient) Get(ctx context.Context, id PrivateDnsZoneGroupId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateDnsZoneGroup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/method_list.go b/resource-manager/network/2024-07-01/privatednszonegroups/method_list.go new file mode 100644 index 00000000000..3abf08b87af --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/method_list.go @@ -0,0 +1,105 @@ +package privatednszonegroups + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateDnsZoneGroup +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateDnsZoneGroup +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c PrivateDnsZoneGroupsClient) List(ctx context.Context, id PrivateEndpointId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/privateDnsZoneGroups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateDnsZoneGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c PrivateDnsZoneGroupsClient) ListComplete(ctx context.Context, id PrivateEndpointId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, PrivateDnsZoneGroupOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateDnsZoneGroupsClient) ListCompleteMatchingPredicate(ctx context.Context, id PrivateEndpointId, predicate PrivateDnsZoneGroupOperationPredicate) (result ListCompleteResult, err error) { + items := make([]PrivateDnsZoneGroup, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/model_privatednszoneconfig.go b/resource-manager/network/2024-07-01/privatednszonegroups/model_privatednszoneconfig.go new file mode 100644 index 00000000000..e44ef143e5c --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/model_privatednszoneconfig.go @@ -0,0 +1,9 @@ +package privatednszonegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateDnsZoneConfig struct { + Name *string `json:"name,omitempty"` + Properties *PrivateDnsZonePropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/model_privatednszonegroup.go b/resource-manager/network/2024-07-01/privatednszonegroups/model_privatednszonegroup.go new file mode 100644 index 00000000000..75533fc47a5 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/model_privatednszonegroup.go @@ -0,0 +1,11 @@ +package privatednszonegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateDnsZoneGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateDnsZoneGroupPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/model_privatednszonegrouppropertiesformat.go b/resource-manager/network/2024-07-01/privatednszonegroups/model_privatednszonegrouppropertiesformat.go new file mode 100644 index 00000000000..f892f554965 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/model_privatednszonegrouppropertiesformat.go @@ -0,0 +1,9 @@ +package privatednszonegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateDnsZoneGroupPropertiesFormat struct { + PrivateDnsZoneConfigs *[]PrivateDnsZoneConfig `json:"privateDnsZoneConfigs,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/model_privatednszonepropertiesformat.go b/resource-manager/network/2024-07-01/privatednszonegroups/model_privatednszonepropertiesformat.go new file mode 100644 index 00000000000..33858bfe24e --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/model_privatednszonepropertiesformat.go @@ -0,0 +1,9 @@ +package privatednszonegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateDnsZonePropertiesFormat struct { + PrivateDnsZoneId *string `json:"privateDnsZoneId,omitempty"` + RecordSets *[]RecordSet `json:"recordSets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/model_recordset.go b/resource-manager/network/2024-07-01/privatednszonegroups/model_recordset.go new file mode 100644 index 00000000000..4a39969425d --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/model_recordset.go @@ -0,0 +1,13 @@ +package privatednszonegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecordSet struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RecordSetName *string `json:"recordSetName,omitempty"` + RecordType *string `json:"recordType,omitempty"` + Ttl *int64 `json:"ttl,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/predicates.go b/resource-manager/network/2024-07-01/privatednszonegroups/predicates.go new file mode 100644 index 00000000000..4d27803d6e2 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/predicates.go @@ -0,0 +1,27 @@ +package privatednszonegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateDnsZoneGroupOperationPredicate struct { + Etag *string + Id *string + Name *string +} + +func (p PrivateDnsZoneGroupOperationPredicate) Matches(input PrivateDnsZoneGroup) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/privatednszonegroups/version.go b/resource-manager/network/2024-07-01/privatednszonegroups/version.go new file mode 100644 index 00000000000..18f7072f51f --- /dev/null +++ b/resource-manager/network/2024-07-01/privatednszonegroups/version.go @@ -0,0 +1,10 @@ +package privatednszonegroups + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privatednszonegroups/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/README.md b/resource-manager/network/2024-07-01/privateendpoints/README.md new file mode 100644 index 00000000000..3e770f24414 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/README.md @@ -0,0 +1,134 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/privateendpoints` Documentation + +The `privateendpoints` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/privateendpoints" +``` + + +### Client Initialization + +```go +client := privateendpoints.NewPrivateEndpointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateEndpointsClient.AvailablePrivateEndpointTypesList` + +```go +ctx := context.TODO() +id := privateendpoints.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.AvailablePrivateEndpointTypesList(ctx, id)` can be used to do batched pagination +items, err := client.AvailablePrivateEndpointTypesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PrivateEndpointsClient.AvailablePrivateEndpointTypesListByResourceGroup` + +```go +ctx := context.TODO() +id := privateendpoints.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationName") + +// alternatively `client.AvailablePrivateEndpointTypesListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.AvailablePrivateEndpointTypesListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PrivateEndpointsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := privateendpoints.NewPrivateEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateEndpointName") + +payload := privateendpoints.PrivateEndpoint{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateEndpointsClient.Delete` + +```go +ctx := context.TODO() +id := privateendpoints.NewPrivateEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateEndpointName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateEndpointsClient.Get` + +```go +ctx := context.TODO() +id := privateendpoints.NewPrivateEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateEndpointName") + +read, err := client.Get(ctx, id, privateendpoints.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateEndpointsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PrivateEndpointsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/privateendpoints/client.go b/resource-manager/network/2024-07-01/privateendpoints/client.go new file mode 100644 index 00000000000..d03b3dc1800 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/client.go @@ -0,0 +1,26 @@ +package privateendpoints + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointsClient struct { + Client *resourcemanager.Client +} + +func NewPrivateEndpointsClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateEndpointsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "privateendpoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointsClient: %+v", err) + } + + return &PrivateEndpointsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/constants.go b/resource-manager/network/2024-07-01/privateendpoints/constants.go new file mode 100644 index 00000000000..c2699c8ad41 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/constants.go @@ -0,0 +1,1204 @@ +package privateendpoints + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/id_location.go b/resource-manager/network/2024-07-01/privateendpoints/id_location.go new file mode 100644 index 00000000000..77d85ed86a2 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/id_location.go @@ -0,0 +1,121 @@ +package privateendpoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Network/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/id_location_test.go b/resource-manager/network/2024-07-01/privateendpoints/id_location_test.go new file mode 100644 index 00000000000..aff4982b728 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/id_location_test.go @@ -0,0 +1,237 @@ +package privateendpoints + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/id_privateendpoint.go b/resource-manager/network/2024-07-01/privateendpoints/id_privateendpoint.go new file mode 100644 index 00000000000..09fd6278c20 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/id_privateendpoint.go @@ -0,0 +1,130 @@ +package privateendpoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointId{} + +// PrivateEndpointId is a struct representing the Resource ID for a Private Endpoint +type PrivateEndpointId struct { + SubscriptionId string + ResourceGroupName string + PrivateEndpointName string +} + +// NewPrivateEndpointID returns a new PrivateEndpointId struct +func NewPrivateEndpointID(subscriptionId string, resourceGroupName string, privateEndpointName string) PrivateEndpointId { + return PrivateEndpointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PrivateEndpointName: privateEndpointName, + } +} + +// ParsePrivateEndpointID parses 'input' into a PrivateEndpointId +func ParsePrivateEndpointID(input string) (*PrivateEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointIDInsensitively parses 'input' case-insensitively into a PrivateEndpointId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointIDInsensitively(input string) (*PrivateEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PrivateEndpointName, ok = input.Parsed["privateEndpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointName", input) + } + + return nil +} + +// ValidatePrivateEndpointID checks that 'input' can be parsed as a Private Endpoint ID +func ValidatePrivateEndpointID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateEndpointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint ID +func (id PrivateEndpointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/privateEndpoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PrivateEndpointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint ID +func (id PrivateEndpointId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticPrivateEndpoints", "privateEndpoints", "privateEndpoints"), + resourceids.UserSpecifiedSegment("privateEndpointName", "privateEndpointName"), + } +} + +// String returns a human-readable description of this Private Endpoint ID +func (id PrivateEndpointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Private Endpoint Name: %q", id.PrivateEndpointName), + } + return fmt.Sprintf("Private Endpoint (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/id_privateendpoint_test.go b/resource-manager/network/2024-07-01/privateendpoints/id_privateendpoint_test.go new file mode 100644 index 00000000000..837222fc5cf --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/id_privateendpoint_test.go @@ -0,0 +1,282 @@ +package privateendpoints + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateEndpointId{} + +func TestNewPrivateEndpointID(t *testing.T) { + id := NewPrivateEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateEndpointName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.PrivateEndpointName != "privateEndpointName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointName'", id.PrivateEndpointName, "privateEndpointName") + } +} + +func TestFormatPrivateEndpointID(t *testing.T) { + actual := NewPrivateEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateEndpointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName", + Expected: &PrivateEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PrivateEndpointName: "privateEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.PrivateEndpointName != v.Expected.PrivateEndpointName { + t.Fatalf("Expected %q but got %q for PrivateEndpointName", v.Expected.PrivateEndpointName, actual.PrivateEndpointName) + } + + } +} + +func TestParsePrivateEndpointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeEnDpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName", + Expected: &PrivateEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PrivateEndpointName: "privateEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateEndpoints/privateEndpointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeEnDpOiNtS/pRiVaTeEnDpOiNtNaMe", + Expected: &PrivateEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PrivateEndpointName: "pRiVaTeEnDpOiNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeEnDpOiNtS/pRiVaTeEnDpOiNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.PrivateEndpointName != v.Expected.PrivateEndpointName { + t.Fatalf("Expected %q but got %q for PrivateEndpointName", v.Expected.PrivateEndpointName, actual.PrivateEndpointName) + } + + } +} + +func TestSegmentsForPrivateEndpointId(t *testing.T) { + segments := PrivateEndpointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/id_providerlocation.go b/resource-manager/network/2024-07-01/privateendpoints/id_providerlocation.go new file mode 100644 index 00000000000..5bf08d4e861 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/id_providerlocation.go @@ -0,0 +1,130 @@ +package privateendpoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + ResourceGroupName string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, resourceGroupName string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/id_providerlocation_test.go b/resource-manager/network/2024-07-01/privateendpoints/id_providerlocation_test.go new file mode 100644 index 00000000000..ddd96efab6c --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/id_providerlocation_test.go @@ -0,0 +1,282 @@ +package privateendpoints + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/method_availableprivateendpointtypeslist.go b/resource-manager/network/2024-07-01/privateendpoints/method_availableprivateendpointtypeslist.go new file mode 100644 index 00000000000..f0c9af2990d --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/method_availableprivateendpointtypeslist.go @@ -0,0 +1,105 @@ +package privateendpoints + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailablePrivateEndpointTypesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AvailablePrivateEndpointType +} + +type AvailablePrivateEndpointTypesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AvailablePrivateEndpointType +} + +type AvailablePrivateEndpointTypesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *AvailablePrivateEndpointTypesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// AvailablePrivateEndpointTypesList ... +func (c PrivateEndpointsClient) AvailablePrivateEndpointTypesList(ctx context.Context, id LocationId) (result AvailablePrivateEndpointTypesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &AvailablePrivateEndpointTypesListCustomPager{}, + Path: fmt.Sprintf("%s/availablePrivateEndpointTypes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AvailablePrivateEndpointType `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// AvailablePrivateEndpointTypesListComplete retrieves all the results into a single object +func (c PrivateEndpointsClient) AvailablePrivateEndpointTypesListComplete(ctx context.Context, id LocationId) (AvailablePrivateEndpointTypesListCompleteResult, error) { + return c.AvailablePrivateEndpointTypesListCompleteMatchingPredicate(ctx, id, AvailablePrivateEndpointTypeOperationPredicate{}) +} + +// AvailablePrivateEndpointTypesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateEndpointsClient) AvailablePrivateEndpointTypesListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate AvailablePrivateEndpointTypeOperationPredicate) (result AvailablePrivateEndpointTypesListCompleteResult, err error) { + items := make([]AvailablePrivateEndpointType, 0) + + resp, err := c.AvailablePrivateEndpointTypesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = AvailablePrivateEndpointTypesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/method_availableprivateendpointtypeslistbyresourcegroup.go b/resource-manager/network/2024-07-01/privateendpoints/method_availableprivateendpointtypeslistbyresourcegroup.go new file mode 100644 index 00000000000..259ea902b1f --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/method_availableprivateendpointtypeslistbyresourcegroup.go @@ -0,0 +1,105 @@ +package privateendpoints + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailablePrivateEndpointTypesListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AvailablePrivateEndpointType +} + +type AvailablePrivateEndpointTypesListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AvailablePrivateEndpointType +} + +type AvailablePrivateEndpointTypesListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *AvailablePrivateEndpointTypesListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// AvailablePrivateEndpointTypesListByResourceGroup ... +func (c PrivateEndpointsClient) AvailablePrivateEndpointTypesListByResourceGroup(ctx context.Context, id ProviderLocationId) (result AvailablePrivateEndpointTypesListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &AvailablePrivateEndpointTypesListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/availablePrivateEndpointTypes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AvailablePrivateEndpointType `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// AvailablePrivateEndpointTypesListByResourceGroupComplete retrieves all the results into a single object +func (c PrivateEndpointsClient) AvailablePrivateEndpointTypesListByResourceGroupComplete(ctx context.Context, id ProviderLocationId) (AvailablePrivateEndpointTypesListByResourceGroupCompleteResult, error) { + return c.AvailablePrivateEndpointTypesListByResourceGroupCompleteMatchingPredicate(ctx, id, AvailablePrivateEndpointTypeOperationPredicate{}) +} + +// AvailablePrivateEndpointTypesListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateEndpointsClient) AvailablePrivateEndpointTypesListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id ProviderLocationId, predicate AvailablePrivateEndpointTypeOperationPredicate) (result AvailablePrivateEndpointTypesListByResourceGroupCompleteResult, err error) { + items := make([]AvailablePrivateEndpointType, 0) + + resp, err := c.AvailablePrivateEndpointTypesListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = AvailablePrivateEndpointTypesListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/method_createorupdate.go b/resource-manager/network/2024-07-01/privateendpoints/method_createorupdate.go new file mode 100644 index 00000000000..b5055a0cda4 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/method_createorupdate.go @@ -0,0 +1,75 @@ +package privateendpoints + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpoint +} + +// CreateOrUpdate ... +func (c PrivateEndpointsClient) CreateOrUpdate(ctx context.Context, id PrivateEndpointId, input PrivateEndpoint) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c PrivateEndpointsClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateEndpointId, input PrivateEndpoint) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/method_delete.go b/resource-manager/network/2024-07-01/privateendpoints/method_delete.go new file mode 100644 index 00000000000..70f382bf8e3 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/method_delete.go @@ -0,0 +1,71 @@ +package privateendpoints + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c PrivateEndpointsClient) Delete(ctx context.Context, id PrivateEndpointId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PrivateEndpointsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/method_get.go b/resource-manager/network/2024-07-01/privateendpoints/method_get.go new file mode 100644 index 00000000000..559e0f436c5 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/method_get.go @@ -0,0 +1,83 @@ +package privateendpoints + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpoint +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c PrivateEndpointsClient) Get(ctx context.Context, id PrivateEndpointId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateEndpoint + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/method_list.go b/resource-manager/network/2024-07-01/privateendpoints/method_list.go new file mode 100644 index 00000000000..f832db84c7a --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/method_list.go @@ -0,0 +1,106 @@ +package privateendpoints + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpoint +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateEndpoint +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c PrivateEndpointsClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/privateEndpoints", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateEndpoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c PrivateEndpointsClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, PrivateEndpointOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateEndpointsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate PrivateEndpointOperationPredicate) (result ListCompleteResult, err error) { + items := make([]PrivateEndpoint, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/method_listbysubscription.go b/resource-manager/network/2024-07-01/privateendpoints/method_listbysubscription.go new file mode 100644 index 00000000000..c517e23cdbf --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/method_listbysubscription.go @@ -0,0 +1,106 @@ +package privateendpoints + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpoint +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateEndpoint +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c PrivateEndpointsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/privateEndpoints", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateEndpoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c PrivateEndpointsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, PrivateEndpointOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateEndpointsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate PrivateEndpointOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]PrivateEndpoint, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/privateendpoints/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..b8767a924d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/privateendpoints/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..faea7af9635 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..bc45532ef99 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/privateendpoints/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..d7b619385a0 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..0975b3a3c18 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/privateendpoints/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..b514ce65a10 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..c505be8adad --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_availableprivateendpointtype.go b/resource-manager/network/2024-07-01/privateendpoints/model_availableprivateendpointtype.go new file mode 100644 index 00000000000..c6aa8839dc1 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_availableprivateendpointtype.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailablePrivateEndpointType struct { + DisplayName *string `json:"displayName,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_backendaddresspool.go b/resource-manager/network/2024-07-01/privateendpoints/model_backendaddresspool.go new file mode 100644 index 00000000000..afaee89cd0a --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..7079b861291 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..a078479b1cf --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_ddossettings.go b/resource-manager/network/2024-07-01/privateendpoints/model_ddossettings.go new file mode 100644 index 00000000000..6253ff1e5a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_ddossettings.go @@ -0,0 +1,9 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_delegation.go b/resource-manager/network/2024-07-01/privateendpoints/model_delegation.go new file mode 100644 index 00000000000..fd6104e1e68 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_delegation.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_flowlog.go b/resource-manager/network/2024-07-01/privateendpoints/model_flowlog.go new file mode 100644 index 00000000000..6e5b89e5f2c --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_flowlog.go @@ -0,0 +1,19 @@ +package privateendpoints + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/privateendpoints/model_flowlogformatparameters.go new file mode 100644 index 00000000000..a15c48049c6 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..3e3ef311eed --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/privateendpoints/model_frontendipconfiguration.go new file mode 100644 index 00000000000..3dcb8560fec --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package privateendpoints + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..8980fc3756f --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/privateendpoints/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..dde47c23fb2 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_inboundnatrule.go b/resource-manager/network/2024-07-01/privateendpoints/model_inboundnatrule.go new file mode 100644 index 00000000000..38c0ffd6728 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..b952302ddeb --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/privateendpoints/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..11c5136df60 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/privateendpoints/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..c7ea1c2e4cb --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_ipconfiguration.go b/resource-manager/network/2024-07-01/privateendpoints/model_ipconfiguration.go new file mode 100644 index 00000000000..cf18ee9415b --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/privateendpoints/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..d493529c992 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..dabdbd7c841 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..fdfdcd1d175 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_iptag.go b/resource-manager/network/2024-07-01/privateendpoints/model_iptag.go new file mode 100644 index 00000000000..83206500edc --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_iptag.go @@ -0,0 +1,9 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/privateendpoints/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..ee77fec93c3 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..9be73b64841 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_natgateway.go b/resource-manager/network/2024-07-01/privateendpoints/model_natgateway.go new file mode 100644 index 00000000000..e197bcd7ada --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_natgateway.go @@ -0,0 +1,20 @@ +package privateendpoints + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..f6b122bbf74 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_natgatewaysku.go b/resource-manager/network/2024-07-01/privateendpoints/model_natgatewaysku.go new file mode 100644 index 00000000000..c0b2d583e49 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_natruleportmapping.go b/resource-manager/network/2024-07-01/privateendpoints/model_natruleportmapping.go new file mode 100644 index 00000000000..07eeaf979f4 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_networkinterface.go b/resource-manager/network/2024-07-01/privateendpoints/model_networkinterface.go new file mode 100644 index 00000000000..9e9c7fcfa82 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_networkinterface.go @@ -0,0 +1,19 @@ +package privateendpoints + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..5182d846bf1 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..e41eb348a7b --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..ac6a234dd34 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..49402e36c83 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..a7c9822ea4e --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..ebe35c0a178 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..54e437f339f --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/privateendpoints/model_networksecuritygroup.go new file mode 100644 index 00000000000..cb420b60990 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..b03a951faff --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_privateendpoint.go b/resource-manager/network/2024-07-01/privateendpoints/model_privateendpoint.go new file mode 100644 index 00000000000..5e9da21fedb --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_privateendpoint.go @@ -0,0 +1,19 @@ +package privateendpoints + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/privateendpoints/model_privateendpointconnection.go new file mode 100644 index 00000000000..5bd8301f4f3 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/privateendpoints/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..8c0662fe4e2 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/privateendpoints/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..1fbe08553f6 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/privateendpoints/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..3772b023f53 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/privateendpoints/model_privateendpointproperties.go new file mode 100644 index 00000000000..ac88e7637f3 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkservice.go b/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkservice.go new file mode 100644 index 00000000000..e4c8723fc8b --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package privateendpoints + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..be10aca683d --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..da2a7ed3871 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..1d19bec0830 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..358ee0e7450 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..81634dd44b1 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..aa8c280a9ad --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_publicipaddress.go b/resource-manager/network/2024-07-01/privateendpoints/model_publicipaddress.go new file mode 100644 index 00000000000..eeca2133c31 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_publicipaddress.go @@ -0,0 +1,22 @@ +package privateendpoints + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/privateendpoints/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..bc8acd1515a --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..bed9d0ba8d7 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/privateendpoints/model_publicipaddresssku.go new file mode 100644 index 00000000000..2bbd107f243 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/privateendpoints/model_resourcenavigationlink.go new file mode 100644 index 00000000000..d8890442923 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..281da0ffc97 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_resourceset.go b/resource-manager/network/2024-07-01/privateendpoints/model_resourceset.go new file mode 100644 index 00000000000..999b1817a30 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_resourceset.go @@ -0,0 +1,8 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/privateendpoints/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..b3df6ba5fd1 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_route.go b/resource-manager/network/2024-07-01/privateendpoints/model_route.go new file mode 100644 index 00000000000..98c7a5ae476 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_route.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_routepropertiesformat.go new file mode 100644 index 00000000000..ca3956916f3 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_routetable.go b/resource-manager/network/2024-07-01/privateendpoints/model_routetable.go new file mode 100644 index 00000000000..e1f695300d8 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_routetable.go @@ -0,0 +1,14 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..4976a28f0ea --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_securityrule.go b/resource-manager/network/2024-07-01/privateendpoints/model_securityrule.go new file mode 100644 index 00000000000..ccfc50b4a7e --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_securityrule.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..2b19d6a628d --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/privateendpoints/model_serviceassociationlink.go new file mode 100644 index 00000000000..a88015b02e1 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..7a779312074 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..84e538e8350 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/privateendpoints/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..ea8ff121174 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/privateendpoints/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..cc2054776fa --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..8355dfbaae0 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..dbdcdea1442 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..c9bc7f38f99 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_subnet.go b/resource-manager/network/2024-07-01/privateendpoints/model_subnet.go new file mode 100644 index 00000000000..1eee73db2bd --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_subnet.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..d3e24496a81 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_subresource.go b/resource-manager/network/2024-07-01/privateendpoints/model_subresource.go new file mode 100644 index 00000000000..134c4f66102 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_subresource.go @@ -0,0 +1,8 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/privateendpoints/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..fc7cf55257e --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/privateendpoints/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..8a4f6042fa4 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/privateendpoints/model_virtualnetworktap.go new file mode 100644 index 00000000000..99fe7d7fe1d --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/privateendpoints/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..c7fa6565e0f --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/predicates.go b/resource-manager/network/2024-07-01/privateendpoints/predicates.go new file mode 100644 index 00000000000..c99098d0163 --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/predicates.go @@ -0,0 +1,70 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AvailablePrivateEndpointTypeOperationPredicate struct { + DisplayName *string + Id *string + Name *string + ResourceName *string + Type *string +} + +func (p AvailablePrivateEndpointTypeOperationPredicate) Matches(input AvailablePrivateEndpointType) bool { + + if p.DisplayName != nil && (input.DisplayName == nil || *p.DisplayName != *input.DisplayName) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.ResourceName != nil && (input.ResourceName == nil || *p.ResourceName != *input.ResourceName) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type PrivateEndpointOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p PrivateEndpointOperationPredicate) Matches(input PrivateEndpoint) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/privateendpoints/version.go b/resource-manager/network/2024-07-01/privateendpoints/version.go new file mode 100644 index 00000000000..bb30f97898f --- /dev/null +++ b/resource-manager/network/2024-07-01/privateendpoints/version.go @@ -0,0 +1,10 @@ +package privateendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privateendpoints/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/README.md b/resource-manager/network/2024-07-01/privatelinkservices/README.md new file mode 100644 index 00000000000..08e213e8621 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/README.md @@ -0,0 +1,234 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/privatelinkservices` Documentation + +The `privatelinkservices` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/privatelinkservices" +``` + + +### Client Initialization + +```go +client := privatelinkservices.NewPrivateLinkServicesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateLinkServicesClient.CheckPrivateLinkServiceVisibility` + +```go +ctx := context.TODO() +id := privatelinkservices.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := privatelinkservices.CheckPrivateLinkServiceVisibilityRequest{ + // ... +} + + +if err := client.CheckPrivateLinkServiceVisibilityThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateLinkServicesClient.CheckPrivateLinkServiceVisibilityByResourceGroup` + +```go +ctx := context.TODO() +id := privatelinkservices.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationName") + +payload := privatelinkservices.CheckPrivateLinkServiceVisibilityRequest{ + // ... +} + + +if err := client.CheckPrivateLinkServiceVisibilityByResourceGroupThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateLinkServicesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := privatelinkservices.NewPrivateLinkServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateLinkServiceName") + +payload := privatelinkservices.PrivateLinkService{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateLinkServicesClient.Delete` + +```go +ctx := context.TODO() +id := privatelinkservices.NewPrivateLinkServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateLinkServiceName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateLinkServicesClient.DeletePrivateEndpointConnection` + +```go +ctx := context.TODO() +id := privatelinkservices.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateLinkServiceName", "privateEndpointConnectionName") + +if err := client.DeletePrivateEndpointConnectionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateLinkServicesClient.Get` + +```go +ctx := context.TODO() +id := privatelinkservices.NewPrivateLinkServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateLinkServiceName") + +read, err := client.Get(ctx, id, privatelinkservices.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateLinkServicesClient.GetPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := privatelinkservices.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateLinkServiceName", "privateEndpointConnectionName") + +read, err := client.GetPrivateEndpointConnection(ctx, id, privatelinkservices.DefaultGetPrivateEndpointConnectionOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateLinkServicesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PrivateLinkServicesClient.ListAutoApprovedPrivateLinkServices` + +```go +ctx := context.TODO() +id := privatelinkservices.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.ListAutoApprovedPrivateLinkServices(ctx, id)` can be used to do batched pagination +items, err := client.ListAutoApprovedPrivateLinkServicesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PrivateLinkServicesClient.ListAutoApprovedPrivateLinkServicesByResourceGroup` + +```go +ctx := context.TODO() +id := privatelinkservices.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationName") + +// alternatively `client.ListAutoApprovedPrivateLinkServicesByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListAutoApprovedPrivateLinkServicesByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PrivateLinkServicesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PrivateLinkServicesClient.ListPrivateEndpointConnections` + +```go +ctx := context.TODO() +id := privatelinkservices.NewPrivateLinkServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateLinkServiceName") + +// alternatively `client.ListPrivateEndpointConnections(ctx, id)` can be used to do batched pagination +items, err := client.ListPrivateEndpointConnectionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PrivateLinkServicesClient.UpdatePrivateEndpointConnection` + +```go +ctx := context.TODO() +id := privatelinkservices.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateLinkServiceName", "privateEndpointConnectionName") + +payload := privatelinkservices.PrivateEndpointConnection{ + // ... +} + + +read, err := client.UpdatePrivateEndpointConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/privatelinkservices/client.go b/resource-manager/network/2024-07-01/privatelinkservices/client.go new file mode 100644 index 00000000000..e097e552e3f --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/client.go @@ -0,0 +1,26 @@ +package privatelinkservices + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServicesClient struct { + Client *resourcemanager.Client +} + +func NewPrivateLinkServicesClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateLinkServicesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "privatelinkservices", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateLinkServicesClient: %+v", err) + } + + return &PrivateLinkServicesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/constants.go b/resource-manager/network/2024-07-01/privatelinkservices/constants.go new file mode 100644 index 00000000000..aaf0a0b24dd --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/constants.go @@ -0,0 +1,1204 @@ +package privatelinkservices + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/id_location.go b/resource-manager/network/2024-07-01/privatelinkservices/id_location.go new file mode 100644 index 00000000000..ad61efbce7f --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/id_location.go @@ -0,0 +1,121 @@ +package privatelinkservices + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Network/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/id_location_test.go b/resource-manager/network/2024-07-01/privatelinkservices/id_location_test.go new file mode 100644 index 00000000000..56fdbbb4ab0 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/id_location_test.go @@ -0,0 +1,237 @@ +package privatelinkservices + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/id_privateendpointconnection.go b/resource-manager/network/2024-07-01/privatelinkservices/id_privateendpointconnection.go new file mode 100644 index 00000000000..3f1f439928b --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package privatelinkservices + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + PrivateLinkServiceName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, privateLinkServiceName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PrivateLinkServiceName: privateLinkServiceName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PrivateLinkServiceName, ok = input.Parsed["privateLinkServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateLinkServiceName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/privateLinkServices/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PrivateLinkServiceName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticPrivateLinkServices", "privateLinkServices", "privateLinkServices"), + resourceids.UserSpecifiedSegment("privateLinkServiceName", "privateLinkServiceName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Private Link Service Name: %q", id.PrivateLinkServiceName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/id_privateendpointconnection_test.go b/resource-manager/network/2024-07-01/privatelinkservices/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..b76fddc6e1b --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package privatelinkservices + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateLinkServiceName", "privateEndpointConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.PrivateLinkServiceName != "privateLinkServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateLinkServiceName'", id.PrivateLinkServiceName, "privateLinkServiceName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateLinkServiceName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices/privateLinkServiceName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices/privateLinkServiceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices/privateLinkServiceName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices/privateLinkServiceName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PrivateLinkServiceName: "privateLinkServiceName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices/privateLinkServiceName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.PrivateLinkServiceName != v.Expected.PrivateLinkServiceName { + t.Fatalf("Expected %q but got %q for PrivateLinkServiceName", v.Expected.PrivateLinkServiceName, actual.PrivateLinkServiceName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeLiNkSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices/privateLinkServiceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeLiNkSeRvIcEs/pRiVaTeLiNkSeRvIcEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices/privateLinkServiceName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeLiNkSeRvIcEs/pRiVaTeLiNkSeRvIcEnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices/privateLinkServiceName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PrivateLinkServiceName: "privateLinkServiceName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices/privateLinkServiceName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeLiNkSeRvIcEs/pRiVaTeLiNkSeRvIcEnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PrivateLinkServiceName: "pRiVaTeLiNkSeRvIcEnAmE", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeLiNkSeRvIcEs/pRiVaTeLiNkSeRvIcEnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.PrivateLinkServiceName != v.Expected.PrivateLinkServiceName { + t.Fatalf("Expected %q but got %q for PrivateLinkServiceName", v.Expected.PrivateLinkServiceName, actual.PrivateLinkServiceName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/id_privatelinkservice.go b/resource-manager/network/2024-07-01/privatelinkservices/id_privatelinkservice.go new file mode 100644 index 00000000000..d691d1eded6 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/id_privatelinkservice.go @@ -0,0 +1,130 @@ +package privatelinkservices + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateLinkServiceId{}) +} + +var _ resourceids.ResourceId = &PrivateLinkServiceId{} + +// PrivateLinkServiceId is a struct representing the Resource ID for a Private Link Service +type PrivateLinkServiceId struct { + SubscriptionId string + ResourceGroupName string + PrivateLinkServiceName string +} + +// NewPrivateLinkServiceID returns a new PrivateLinkServiceId struct +func NewPrivateLinkServiceID(subscriptionId string, resourceGroupName string, privateLinkServiceName string) PrivateLinkServiceId { + return PrivateLinkServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PrivateLinkServiceName: privateLinkServiceName, + } +} + +// ParsePrivateLinkServiceID parses 'input' into a PrivateLinkServiceId +func ParsePrivateLinkServiceID(input string) (*PrivateLinkServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateLinkServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateLinkServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateLinkServiceIDInsensitively parses 'input' case-insensitively into a PrivateLinkServiceId +// note: this method should only be used for API response data and not user input +func ParsePrivateLinkServiceIDInsensitively(input string) (*PrivateLinkServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateLinkServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateLinkServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateLinkServiceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PrivateLinkServiceName, ok = input.Parsed["privateLinkServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateLinkServiceName", input) + } + + return nil +} + +// ValidatePrivateLinkServiceID checks that 'input' can be parsed as a Private Link Service ID +func ValidatePrivateLinkServiceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateLinkServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Link Service ID +func (id PrivateLinkServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/privateLinkServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PrivateLinkServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Link Service ID +func (id PrivateLinkServiceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticPrivateLinkServices", "privateLinkServices", "privateLinkServices"), + resourceids.UserSpecifiedSegment("privateLinkServiceName", "privateLinkServiceName"), + } +} + +// String returns a human-readable description of this Private Link Service ID +func (id PrivateLinkServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Private Link Service Name: %q", id.PrivateLinkServiceName), + } + return fmt.Sprintf("Private Link Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/id_privatelinkservice_test.go b/resource-manager/network/2024-07-01/privatelinkservices/id_privatelinkservice_test.go new file mode 100644 index 00000000000..bccc5172aaf --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/id_privatelinkservice_test.go @@ -0,0 +1,282 @@ +package privatelinkservices + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateLinkServiceId{} + +func TestNewPrivateLinkServiceID(t *testing.T) { + id := NewPrivateLinkServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateLinkServiceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.PrivateLinkServiceName != "privateLinkServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateLinkServiceName'", id.PrivateLinkServiceName, "privateLinkServiceName") + } +} + +func TestFormatPrivateLinkServiceID(t *testing.T) { + actual := NewPrivateLinkServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateLinkServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices/privateLinkServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateLinkServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateLinkServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices/privateLinkServiceName", + Expected: &PrivateLinkServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PrivateLinkServiceName: "privateLinkServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices/privateLinkServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateLinkServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.PrivateLinkServiceName != v.Expected.PrivateLinkServiceName { + t.Fatalf("Expected %q but got %q for PrivateLinkServiceName", v.Expected.PrivateLinkServiceName, actual.PrivateLinkServiceName) + } + + } +} + +func TestParsePrivateLinkServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateLinkServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeLiNkSeRvIcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices/privateLinkServiceName", + Expected: &PrivateLinkServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PrivateLinkServiceName: "privateLinkServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/privateLinkServices/privateLinkServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeLiNkSeRvIcEs/pRiVaTeLiNkSeRvIcEnAmE", + Expected: &PrivateLinkServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PrivateLinkServiceName: "pRiVaTeLiNkSeRvIcEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pRiVaTeLiNkSeRvIcEs/pRiVaTeLiNkSeRvIcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateLinkServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.PrivateLinkServiceName != v.Expected.PrivateLinkServiceName { + t.Fatalf("Expected %q but got %q for PrivateLinkServiceName", v.Expected.PrivateLinkServiceName, actual.PrivateLinkServiceName) + } + + } +} + +func TestSegmentsForPrivateLinkServiceId(t *testing.T) { + segments := PrivateLinkServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateLinkServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/id_providerlocation.go b/resource-manager/network/2024-07-01/privatelinkservices/id_providerlocation.go new file mode 100644 index 00000000000..706ab2680a9 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/id_providerlocation.go @@ -0,0 +1,130 @@ +package privatelinkservices + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + ResourceGroupName string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, resourceGroupName string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/id_providerlocation_test.go b/resource-manager/network/2024-07-01/privatelinkservices/id_providerlocation_test.go new file mode 100644 index 00000000000..1565dd828b1 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/id_providerlocation_test.go @@ -0,0 +1,282 @@ +package privatelinkservices + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/method_checkprivatelinkservicevisibility.go b/resource-manager/network/2024-07-01/privatelinkservices/method_checkprivatelinkservicevisibility.go new file mode 100644 index 00000000000..1e8a53a5ec7 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/method_checkprivatelinkservicevisibility.go @@ -0,0 +1,75 @@ +package privatelinkservices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckPrivateLinkServiceVisibilityOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkServiceVisibility +} + +// CheckPrivateLinkServiceVisibility ... +func (c PrivateLinkServicesClient) CheckPrivateLinkServiceVisibility(ctx context.Context, id LocationId, input CheckPrivateLinkServiceVisibilityRequest) (result CheckPrivateLinkServiceVisibilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkPrivateLinkServiceVisibility", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CheckPrivateLinkServiceVisibilityThenPoll performs CheckPrivateLinkServiceVisibility then polls until it's completed +func (c PrivateLinkServicesClient) CheckPrivateLinkServiceVisibilityThenPoll(ctx context.Context, id LocationId, input CheckPrivateLinkServiceVisibilityRequest) error { + result, err := c.CheckPrivateLinkServiceVisibility(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CheckPrivateLinkServiceVisibility: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CheckPrivateLinkServiceVisibility: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/method_checkprivatelinkservicevisibilitybyresourcegroup.go b/resource-manager/network/2024-07-01/privatelinkservices/method_checkprivatelinkservicevisibilitybyresourcegroup.go new file mode 100644 index 00000000000..22023c980d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/method_checkprivatelinkservicevisibilitybyresourcegroup.go @@ -0,0 +1,75 @@ +package privatelinkservices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckPrivateLinkServiceVisibilityByResourceGroupOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkServiceVisibility +} + +// CheckPrivateLinkServiceVisibilityByResourceGroup ... +func (c PrivateLinkServicesClient) CheckPrivateLinkServiceVisibilityByResourceGroup(ctx context.Context, id ProviderLocationId, input CheckPrivateLinkServiceVisibilityRequest) (result CheckPrivateLinkServiceVisibilityByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checkPrivateLinkServiceVisibility", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CheckPrivateLinkServiceVisibilityByResourceGroupThenPoll performs CheckPrivateLinkServiceVisibilityByResourceGroup then polls until it's completed +func (c PrivateLinkServicesClient) CheckPrivateLinkServiceVisibilityByResourceGroupThenPoll(ctx context.Context, id ProviderLocationId, input CheckPrivateLinkServiceVisibilityRequest) error { + result, err := c.CheckPrivateLinkServiceVisibilityByResourceGroup(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CheckPrivateLinkServiceVisibilityByResourceGroup: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CheckPrivateLinkServiceVisibilityByResourceGroup: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/method_createorupdate.go b/resource-manager/network/2024-07-01/privatelinkservices/method_createorupdate.go new file mode 100644 index 00000000000..46962733498 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/method_createorupdate.go @@ -0,0 +1,75 @@ +package privatelinkservices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkService +} + +// CreateOrUpdate ... +func (c PrivateLinkServicesClient) CreateOrUpdate(ctx context.Context, id PrivateLinkServiceId, input PrivateLinkService) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c PrivateLinkServicesClient) CreateOrUpdateThenPoll(ctx context.Context, id PrivateLinkServiceId, input PrivateLinkService) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/method_delete.go b/resource-manager/network/2024-07-01/privatelinkservices/method_delete.go new file mode 100644 index 00000000000..d518ac5aede --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/method_delete.go @@ -0,0 +1,71 @@ +package privatelinkservices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c PrivateLinkServicesClient) Delete(ctx context.Context, id PrivateLinkServiceId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PrivateLinkServicesClient) DeleteThenPoll(ctx context.Context, id PrivateLinkServiceId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/method_deleteprivateendpointconnection.go b/resource-manager/network/2024-07-01/privatelinkservices/method_deleteprivateendpointconnection.go new file mode 100644 index 00000000000..92593766f11 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/method_deleteprivateendpointconnection.go @@ -0,0 +1,71 @@ +package privatelinkservices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletePrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePrivateEndpointConnection ... +func (c PrivateLinkServicesClient) DeletePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed +func (c PrivateLinkServicesClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnection(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/method_get.go b/resource-manager/network/2024-07-01/privatelinkservices/method_get.go new file mode 100644 index 00000000000..3be1df5bb53 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/method_get.go @@ -0,0 +1,83 @@ +package privatelinkservices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkService +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c PrivateLinkServicesClient) Get(ctx context.Context, id PrivateLinkServiceId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateLinkService + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/method_getprivateendpointconnection.go b/resource-manager/network/2024-07-01/privatelinkservices/method_getprivateendpointconnection.go new file mode 100644 index 00000000000..7690b7c62af --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/method_getprivateendpointconnection.go @@ -0,0 +1,83 @@ +package privatelinkservices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPrivateEndpointConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +type GetPrivateEndpointConnectionOperationOptions struct { + Expand *string +} + +func DefaultGetPrivateEndpointConnectionOperationOptions() GetPrivateEndpointConnectionOperationOptions { + return GetPrivateEndpointConnectionOperationOptions{} +} + +func (o GetPrivateEndpointConnectionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetPrivateEndpointConnectionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetPrivateEndpointConnectionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// GetPrivateEndpointConnection ... +func (c PrivateLinkServicesClient) GetPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId, options GetPrivateEndpointConnectionOperationOptions) (result GetPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateEndpointConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/method_list.go b/resource-manager/network/2024-07-01/privatelinkservices/method_list.go new file mode 100644 index 00000000000..70140c6dc93 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/method_list.go @@ -0,0 +1,106 @@ +package privatelinkservices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateLinkService +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateLinkService +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c PrivateLinkServicesClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/privateLinkServices", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateLinkService `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c PrivateLinkServicesClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, PrivateLinkServiceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateLinkServicesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate PrivateLinkServiceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]PrivateLinkService, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/method_listautoapprovedprivatelinkservices.go b/resource-manager/network/2024-07-01/privatelinkservices/method_listautoapprovedprivatelinkservices.go new file mode 100644 index 00000000000..f3156a5739c --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/method_listautoapprovedprivatelinkservices.go @@ -0,0 +1,105 @@ +package privatelinkservices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAutoApprovedPrivateLinkServicesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AutoApprovedPrivateLinkService +} + +type ListAutoApprovedPrivateLinkServicesCompleteResult struct { + LatestHttpResponse *http.Response + Items []AutoApprovedPrivateLinkService +} + +type ListAutoApprovedPrivateLinkServicesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAutoApprovedPrivateLinkServicesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAutoApprovedPrivateLinkServices ... +func (c PrivateLinkServicesClient) ListAutoApprovedPrivateLinkServices(ctx context.Context, id LocationId) (result ListAutoApprovedPrivateLinkServicesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAutoApprovedPrivateLinkServicesCustomPager{}, + Path: fmt.Sprintf("%s/autoApprovedPrivateLinkServices", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AutoApprovedPrivateLinkService `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAutoApprovedPrivateLinkServicesComplete retrieves all the results into a single object +func (c PrivateLinkServicesClient) ListAutoApprovedPrivateLinkServicesComplete(ctx context.Context, id LocationId) (ListAutoApprovedPrivateLinkServicesCompleteResult, error) { + return c.ListAutoApprovedPrivateLinkServicesCompleteMatchingPredicate(ctx, id, AutoApprovedPrivateLinkServiceOperationPredicate{}) +} + +// ListAutoApprovedPrivateLinkServicesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateLinkServicesClient) ListAutoApprovedPrivateLinkServicesCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate AutoApprovedPrivateLinkServiceOperationPredicate) (result ListAutoApprovedPrivateLinkServicesCompleteResult, err error) { + items := make([]AutoApprovedPrivateLinkService, 0) + + resp, err := c.ListAutoApprovedPrivateLinkServices(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAutoApprovedPrivateLinkServicesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/method_listautoapprovedprivatelinkservicesbyresourcegroup.go b/resource-manager/network/2024-07-01/privatelinkservices/method_listautoapprovedprivatelinkservicesbyresourcegroup.go new file mode 100644 index 00000000000..91eed65255f --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/method_listautoapprovedprivatelinkservicesbyresourcegroup.go @@ -0,0 +1,105 @@ +package privatelinkservices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAutoApprovedPrivateLinkServicesByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AutoApprovedPrivateLinkService +} + +type ListAutoApprovedPrivateLinkServicesByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AutoApprovedPrivateLinkService +} + +type ListAutoApprovedPrivateLinkServicesByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAutoApprovedPrivateLinkServicesByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAutoApprovedPrivateLinkServicesByResourceGroup ... +func (c PrivateLinkServicesClient) ListAutoApprovedPrivateLinkServicesByResourceGroup(ctx context.Context, id ProviderLocationId) (result ListAutoApprovedPrivateLinkServicesByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAutoApprovedPrivateLinkServicesByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/autoApprovedPrivateLinkServices", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AutoApprovedPrivateLinkService `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAutoApprovedPrivateLinkServicesByResourceGroupComplete retrieves all the results into a single object +func (c PrivateLinkServicesClient) ListAutoApprovedPrivateLinkServicesByResourceGroupComplete(ctx context.Context, id ProviderLocationId) (ListAutoApprovedPrivateLinkServicesByResourceGroupCompleteResult, error) { + return c.ListAutoApprovedPrivateLinkServicesByResourceGroupCompleteMatchingPredicate(ctx, id, AutoApprovedPrivateLinkServiceOperationPredicate{}) +} + +// ListAutoApprovedPrivateLinkServicesByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateLinkServicesClient) ListAutoApprovedPrivateLinkServicesByResourceGroupCompleteMatchingPredicate(ctx context.Context, id ProviderLocationId, predicate AutoApprovedPrivateLinkServiceOperationPredicate) (result ListAutoApprovedPrivateLinkServicesByResourceGroupCompleteResult, err error) { + items := make([]AutoApprovedPrivateLinkService, 0) + + resp, err := c.ListAutoApprovedPrivateLinkServicesByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAutoApprovedPrivateLinkServicesByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/method_listbysubscription.go b/resource-manager/network/2024-07-01/privatelinkservices/method_listbysubscription.go new file mode 100644 index 00000000000..63f9d6bf9c6 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/method_listbysubscription.go @@ -0,0 +1,106 @@ +package privatelinkservices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateLinkService +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateLinkService +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c PrivateLinkServicesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/privateLinkServices", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateLinkService `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c PrivateLinkServicesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, PrivateLinkServiceOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateLinkServicesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate PrivateLinkServiceOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]PrivateLinkService, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/method_listprivateendpointconnections.go b/resource-manager/network/2024-07-01/privatelinkservices/method_listprivateendpointconnections.go new file mode 100644 index 00000000000..c4742974fe5 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/method_listprivateendpointconnections.go @@ -0,0 +1,105 @@ +package privatelinkservices + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListPrivateEndpointConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PrivateEndpointConnection +} + +type ListPrivateEndpointConnectionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []PrivateEndpointConnection +} + +type ListPrivateEndpointConnectionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListPrivateEndpointConnectionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListPrivateEndpointConnections ... +func (c PrivateLinkServicesClient) ListPrivateEndpointConnections(ctx context.Context, id PrivateLinkServiceId) (result ListPrivateEndpointConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListPrivateEndpointConnectionsCustomPager{}, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PrivateEndpointConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPrivateEndpointConnectionsComplete retrieves all the results into a single object +func (c PrivateLinkServicesClient) ListPrivateEndpointConnectionsComplete(ctx context.Context, id PrivateLinkServiceId) (ListPrivateEndpointConnectionsCompleteResult, error) { + return c.ListPrivateEndpointConnectionsCompleteMatchingPredicate(ctx, id, PrivateEndpointConnectionOperationPredicate{}) +} + +// ListPrivateEndpointConnectionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PrivateLinkServicesClient) ListPrivateEndpointConnectionsCompleteMatchingPredicate(ctx context.Context, id PrivateLinkServiceId, predicate PrivateEndpointConnectionOperationPredicate) (result ListPrivateEndpointConnectionsCompleteResult, err error) { + items := make([]PrivateEndpointConnection, 0) + + resp, err := c.ListPrivateEndpointConnections(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListPrivateEndpointConnectionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/method_updateprivateendpointconnection.go b/resource-manager/network/2024-07-01/privatelinkservices/method_updateprivateendpointconnection.go new file mode 100644 index 00000000000..b108db06f2a --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/method_updateprivateendpointconnection.go @@ -0,0 +1,57 @@ +package privatelinkservices + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdatePrivateEndpointConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// UpdatePrivateEndpointConnection ... +func (c PrivateLinkServicesClient) UpdatePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result UpdatePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateEndpointConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/privatelinkservices/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..6e064132ab8 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/privatelinkservices/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..2b8b30f76cf --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..687ec802ef4 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/privatelinkservices/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..23747316443 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..bc231fd9d60 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/privatelinkservices/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..102038ead97 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..b9a224260e0 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_autoapprovedprivatelinkservice.go b/resource-manager/network/2024-07-01/privatelinkservices/model_autoapprovedprivatelinkservice.go new file mode 100644 index 00000000000..e8eb368b9fd --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_autoapprovedprivatelinkservice.go @@ -0,0 +1,8 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoApprovedPrivateLinkService struct { + PrivateLinkService *string `json:"privateLinkService,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_backendaddresspool.go b/resource-manager/network/2024-07-01/privatelinkservices/model_backendaddresspool.go new file mode 100644 index 00000000000..e621fc409e7 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..4fe2c6dad02 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_checkprivatelinkservicevisibilityrequest.go b/resource-manager/network/2024-07-01/privatelinkservices/model_checkprivatelinkservicevisibilityrequest.go new file mode 100644 index 00000000000..d338d570a52 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_checkprivatelinkservicevisibilityrequest.go @@ -0,0 +1,8 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckPrivateLinkServiceVisibilityRequest struct { + PrivateLinkServiceAlias *string `json:"privateLinkServiceAlias,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..5bb831424b8 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_ddossettings.go b/resource-manager/network/2024-07-01/privatelinkservices/model_ddossettings.go new file mode 100644 index 00000000000..a88f6af3346 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_ddossettings.go @@ -0,0 +1,9 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_delegation.go b/resource-manager/network/2024-07-01/privatelinkservices/model_delegation.go new file mode 100644 index 00000000000..861d7dccc33 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_delegation.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_flowlog.go b/resource-manager/network/2024-07-01/privatelinkservices/model_flowlog.go new file mode 100644 index 00000000000..a7a48567b58 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_flowlog.go @@ -0,0 +1,19 @@ +package privatelinkservices + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/privatelinkservices/model_flowlogformatparameters.go new file mode 100644 index 00000000000..e5d4b9b0d2f --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..f7d23503742 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/privatelinkservices/model_frontendipconfiguration.go new file mode 100644 index 00000000000..c4908a4dc2b --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package privatelinkservices + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..2a655d02dfc --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/privatelinkservices/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..57e817e63b2 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_inboundnatrule.go b/resource-manager/network/2024-07-01/privatelinkservices/model_inboundnatrule.go new file mode 100644 index 00000000000..acd7d0aa709 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..8bf73e3faf8 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/privatelinkservices/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..549438636a2 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/privatelinkservices/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..a53859a9e29 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_ipconfiguration.go b/resource-manager/network/2024-07-01/privatelinkservices/model_ipconfiguration.go new file mode 100644 index 00000000000..3ad6065a48e --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/privatelinkservices/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..0b4a7cbc860 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..f1bae207cc2 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..2852a27e2c3 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_iptag.go b/resource-manager/network/2024-07-01/privatelinkservices/model_iptag.go new file mode 100644 index 00000000000..a7e33392ad2 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_iptag.go @@ -0,0 +1,9 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/privatelinkservices/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..09bc3c7f06c --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..a567721ac6c --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_natgateway.go b/resource-manager/network/2024-07-01/privatelinkservices/model_natgateway.go new file mode 100644 index 00000000000..077d2bc5d5f --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_natgateway.go @@ -0,0 +1,20 @@ +package privatelinkservices + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..a0cf0fda217 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_natgatewaysku.go b/resource-manager/network/2024-07-01/privatelinkservices/model_natgatewaysku.go new file mode 100644 index 00000000000..ceae4c33372 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_natruleportmapping.go b/resource-manager/network/2024-07-01/privatelinkservices/model_natruleportmapping.go new file mode 100644 index 00000000000..e081a336375 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterface.go b/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterface.go new file mode 100644 index 00000000000..6ac282778d7 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterface.go @@ -0,0 +1,19 @@ +package privatelinkservices + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..b7993919c62 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..766f136f852 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..4e4cefa66b4 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..9574d828560 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..01c06a6cc15 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..66b7aeeab62 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..307c8944af0 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/privatelinkservices/model_networksecuritygroup.go new file mode 100644 index 00000000000..1a2792e0f88 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..7990d29a1bb --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpoint.go b/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpoint.go new file mode 100644 index 00000000000..d3a77eea754 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpoint.go @@ -0,0 +1,19 @@ +package privatelinkservices + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpointconnection.go new file mode 100644 index 00000000000..bb755a70536 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..5966a68df2a --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..6327ca28ff1 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..5e70530aabf --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpointproperties.go new file mode 100644 index 00000000000..4d6d18b46a5 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkservice.go b/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkservice.go new file mode 100644 index 00000000000..4a672116bc2 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package privatelinkservices + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..eb5e26941fd --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..a991f868fe8 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..f227e3d5e6c --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..de38cfbbde6 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..b1809f0d71c --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..1dbb659e872 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkservicevisibility.go b/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkservicevisibility.go new file mode 100644 index 00000000000..38f95ae51a1 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_privatelinkservicevisibility.go @@ -0,0 +1,8 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceVisibility struct { + Visible *bool `json:"visible,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_publicipaddress.go b/resource-manager/network/2024-07-01/privatelinkservices/model_publicipaddress.go new file mode 100644 index 00000000000..cdcddd86935 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_publicipaddress.go @@ -0,0 +1,22 @@ +package privatelinkservices + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/privatelinkservices/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..268300edf0b --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..2b9a811495b --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/privatelinkservices/model_publicipaddresssku.go new file mode 100644 index 00000000000..80c5ef44ece --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/privatelinkservices/model_resourcenavigationlink.go new file mode 100644 index 00000000000..68ad67e053e --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..57d6954d294 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_resourceset.go b/resource-manager/network/2024-07-01/privatelinkservices/model_resourceset.go new file mode 100644 index 00000000000..e923870d39f --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_resourceset.go @@ -0,0 +1,8 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/privatelinkservices/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..96f98884163 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_route.go b/resource-manager/network/2024-07-01/privatelinkservices/model_route.go new file mode 100644 index 00000000000..901d0eadcc6 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_route.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_routepropertiesformat.go new file mode 100644 index 00000000000..12088248968 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_routetable.go b/resource-manager/network/2024-07-01/privatelinkservices/model_routetable.go new file mode 100644 index 00000000000..8afe228ccfd --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_routetable.go @@ -0,0 +1,14 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..6377cd08fd9 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_securityrule.go b/resource-manager/network/2024-07-01/privatelinkservices/model_securityrule.go new file mode 100644 index 00000000000..df53714a81c --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_securityrule.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..52b151efed9 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/privatelinkservices/model_serviceassociationlink.go new file mode 100644 index 00000000000..5f9234cbb82 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..87f29c8ca65 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..2ad5375c2ca --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/privatelinkservices/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..c93c759f93a --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/privatelinkservices/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..d1116eb2a61 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..7f68e9513e3 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..5af6f94d80f --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..db38090185b --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_subnet.go b/resource-manager/network/2024-07-01/privatelinkservices/model_subnet.go new file mode 100644 index 00000000000..afb102ed10a --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_subnet.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..ff4a474c382 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_subresource.go b/resource-manager/network/2024-07-01/privatelinkservices/model_subresource.go new file mode 100644 index 00000000000..b9dcdcf56bf --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_subresource.go @@ -0,0 +1,8 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/privatelinkservices/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..c500218a37c --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/privatelinkservices/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..b98eb28874d --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/privatelinkservices/model_virtualnetworktap.go new file mode 100644 index 00000000000..8dbee65a21a --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/privatelinkservices/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..4fb395dbc76 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/predicates.go b/resource-manager/network/2024-07-01/privatelinkservices/predicates.go new file mode 100644 index 00000000000..f7e18f9feee --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/predicates.go @@ -0,0 +1,78 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoApprovedPrivateLinkServiceOperationPredicate struct { + PrivateLinkService *string +} + +func (p AutoApprovedPrivateLinkServiceOperationPredicate) Matches(input AutoApprovedPrivateLinkService) bool { + + if p.PrivateLinkService != nil && (input.PrivateLinkService == nil || *p.PrivateLinkService != *input.PrivateLinkService) { + return false + } + + return true +} + +type PrivateEndpointConnectionOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p PrivateEndpointConnectionOperationPredicate) Matches(input PrivateEndpointConnection) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type PrivateLinkServiceOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p PrivateLinkServiceOperationPredicate) Matches(input PrivateLinkService) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/privatelinkservices/version.go b/resource-manager/network/2024-07-01/privatelinkservices/version.go new file mode 100644 index 00000000000..4d5dbb8eee9 --- /dev/null +++ b/resource-manager/network/2024-07-01/privatelinkservices/version.go @@ -0,0 +1,10 @@ +package privatelinkservices + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privatelinkservices/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/README.md b/resource-manager/network/2024-07-01/publicipaddresses/README.md new file mode 100644 index 00000000000..43d3fb4ad90 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/README.md @@ -0,0 +1,133 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/publicipaddresses` Documentation + +The `publicipaddresses` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/publicipaddresses" +``` + + +### Client Initialization + +```go +client := publicipaddresses.NewPublicIPAddressesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PublicIPAddressesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewPublicIPAddressID("12345678-1234-9876-4563-123456789012", "example-resource-group", "publicIPAddressName") + +payload := publicipaddresses.PublicIPAddress{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `PublicIPAddressesClient.DdosProtectionStatus` + +```go +ctx := context.TODO() +id := commonids.NewPublicIPAddressID("12345678-1234-9876-4563-123456789012", "example-resource-group", "publicIPAddressName") + +if err := client.DdosProtectionStatusThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PublicIPAddressesClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewPublicIPAddressID("12345678-1234-9876-4563-123456789012", "example-resource-group", "publicIPAddressName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PublicIPAddressesClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewPublicIPAddressID("12345678-1234-9876-4563-123456789012", "example-resource-group", "publicIPAddressName") + +read, err := client.Get(ctx, id, publicipaddresses.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PublicIPAddressesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PublicIPAddressesClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PublicIPAddressesClient.UpdateTags` + +```go +ctx := context.TODO() +id := commonids.NewPublicIPAddressID("12345678-1234-9876-4563-123456789012", "example-resource-group", "publicIPAddressName") + +payload := publicipaddresses.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/publicipaddresses/client.go b/resource-manager/network/2024-07-01/publicipaddresses/client.go new file mode 100644 index 00000000000..54f2b0113c7 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/client.go @@ -0,0 +1,26 @@ +package publicipaddresses + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressesClient struct { + Client *resourcemanager.Client +} + +func NewPublicIPAddressesClientWithBaseURI(sdkApi sdkEnv.Api) (*PublicIPAddressesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "publicipaddresses", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PublicIPAddressesClient: %+v", err) + } + + return &PublicIPAddressesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/constants.go b/resource-manager/network/2024-07-01/publicipaddresses/constants.go new file mode 100644 index 00000000000..6a433627ea4 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/constants.go @@ -0,0 +1,1245 @@ +package publicipaddresses + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type IsWorkloadProtected string + +const ( + IsWorkloadProtectedFalse IsWorkloadProtected = "False" + IsWorkloadProtectedTrue IsWorkloadProtected = "True" +) + +func PossibleValuesForIsWorkloadProtected() []string { + return []string{ + string(IsWorkloadProtectedFalse), + string(IsWorkloadProtectedTrue), + } +} + +func (s *IsWorkloadProtected) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsWorkloadProtected(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIsWorkloadProtected(input string) (*IsWorkloadProtected, error) { + vals := map[string]IsWorkloadProtected{ + "false": IsWorkloadProtectedFalse, + "true": IsWorkloadProtectedTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IsWorkloadProtected(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/method_createorupdate.go b/resource-manager/network/2024-07-01/publicipaddresses/method_createorupdate.go new file mode 100644 index 00000000000..fca7faa2130 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/method_createorupdate.go @@ -0,0 +1,76 @@ +package publicipaddresses + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *PublicIPAddress +} + +// CreateOrUpdate ... +func (c PublicIPAddressesClient) CreateOrUpdate(ctx context.Context, id commonids.PublicIPAddressId, input PublicIPAddress) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c PublicIPAddressesClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.PublicIPAddressId, input PublicIPAddress) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/method_ddosprotectionstatus.go b/resource-manager/network/2024-07-01/publicipaddresses/method_ddosprotectionstatus.go new file mode 100644 index 00000000000..29e07596f6d --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/method_ddosprotectionstatus.go @@ -0,0 +1,72 @@ +package publicipaddresses + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosProtectionStatusOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *PublicIPDdosProtectionStatusResult +} + +// DdosProtectionStatus ... +func (c PublicIPAddressesClient) DdosProtectionStatus(ctx context.Context, id commonids.PublicIPAddressId) (result DdosProtectionStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/ddosProtectionStatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DdosProtectionStatusThenPoll performs DdosProtectionStatus then polls until it's completed +func (c PublicIPAddressesClient) DdosProtectionStatusThenPoll(ctx context.Context, id commonids.PublicIPAddressId) error { + result, err := c.DdosProtectionStatus(ctx, id) + if err != nil { + return fmt.Errorf("performing DdosProtectionStatus: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DdosProtectionStatus: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/method_delete.go b/resource-manager/network/2024-07-01/publicipaddresses/method_delete.go new file mode 100644 index 00000000000..20c57a22e75 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/method_delete.go @@ -0,0 +1,72 @@ +package publicipaddresses + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c PublicIPAddressesClient) Delete(ctx context.Context, id commonids.PublicIPAddressId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PublicIPAddressesClient) DeleteThenPoll(ctx context.Context, id commonids.PublicIPAddressId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/method_get.go b/resource-manager/network/2024-07-01/publicipaddresses/method_get.go new file mode 100644 index 00000000000..2548c9b4db6 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/method_get.go @@ -0,0 +1,84 @@ +package publicipaddresses + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicIPAddress +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c PublicIPAddressesClient) Get(ctx context.Context, id commonids.PublicIPAddressId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PublicIPAddress + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/method_list.go b/resource-manager/network/2024-07-01/publicipaddresses/method_list.go new file mode 100644 index 00000000000..013d0306760 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/method_list.go @@ -0,0 +1,106 @@ +package publicipaddresses + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PublicIPAddress +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PublicIPAddress +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c PublicIPAddressesClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/publicIPAddresses", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PublicIPAddress `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c PublicIPAddressesClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, PublicIPAddressOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PublicIPAddressesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate PublicIPAddressOperationPredicate) (result ListCompleteResult, err error) { + items := make([]PublicIPAddress, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/method_listall.go b/resource-manager/network/2024-07-01/publicipaddresses/method_listall.go new file mode 100644 index 00000000000..fc1c5ecc247 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/method_listall.go @@ -0,0 +1,106 @@ +package publicipaddresses + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PublicIPAddress +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []PublicIPAddress +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c PublicIPAddressesClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/publicIPAddresses", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PublicIPAddress `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c PublicIPAddressesClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, PublicIPAddressOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PublicIPAddressesClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate PublicIPAddressOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]PublicIPAddress, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/method_updatetags.go b/resource-manager/network/2024-07-01/publicipaddresses/method_updatetags.go new file mode 100644 index 00000000000..622a0a8c202 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/method_updatetags.go @@ -0,0 +1,58 @@ +package publicipaddresses + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicIPAddress +} + +// UpdateTags ... +func (c PublicIPAddressesClient) UpdateTags(ctx context.Context, id commonids.PublicIPAddressId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PublicIPAddress + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/publicipaddresses/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..d89d17bbae7 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/publicipaddresses/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..433f6b69df9 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..14750d210a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/publicipaddresses/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..33311f968a8 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..69ba272007f --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/publicipaddresses/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..7ab7c1cc362 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..3de744e7bae --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_backendaddresspool.go b/resource-manager/network/2024-07-01/publicipaddresses/model_backendaddresspool.go new file mode 100644 index 00000000000..c693d24a91b --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..b4b3a346a35 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..2bbec7ab523 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_ddossettings.go b/resource-manager/network/2024-07-01/publicipaddresses/model_ddossettings.go new file mode 100644 index 00000000000..360538854a2 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_ddossettings.go @@ -0,0 +1,9 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_delegation.go b/resource-manager/network/2024-07-01/publicipaddresses/model_delegation.go new file mode 100644 index 00000000000..1036beaaf72 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_delegation.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_flowlog.go b/resource-manager/network/2024-07-01/publicipaddresses/model_flowlog.go new file mode 100644 index 00000000000..d93575ba159 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_flowlog.go @@ -0,0 +1,19 @@ +package publicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/publicipaddresses/model_flowlogformatparameters.go new file mode 100644 index 00000000000..28da49ecc43 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..f1571aeca23 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/publicipaddresses/model_frontendipconfiguration.go new file mode 100644 index 00000000000..72aec2b5437 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package publicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..2d86f96cffb --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/publicipaddresses/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..9d2c813c821 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_inboundnatrule.go b/resource-manager/network/2024-07-01/publicipaddresses/model_inboundnatrule.go new file mode 100644 index 00000000000..bd6a9711828 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..320809245cf --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/publicipaddresses/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..7bc3794a461 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/publicipaddresses/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..b5e6987008b --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_ipconfiguration.go b/resource-manager/network/2024-07-01/publicipaddresses/model_ipconfiguration.go new file mode 100644 index 00000000000..398840974cd --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/publicipaddresses/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..1bf1de27441 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..1523f28e63d --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..bb4f647f729 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_iptag.go b/resource-manager/network/2024-07-01/publicipaddresses/model_iptag.go new file mode 100644 index 00000000000..7ea58148bb2 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_iptag.go @@ -0,0 +1,9 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/publicipaddresses/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..e427662f2a6 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..349c22b64f5 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_natgateway.go b/resource-manager/network/2024-07-01/publicipaddresses/model_natgateway.go new file mode 100644 index 00000000000..fc10c7874b7 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_natgateway.go @@ -0,0 +1,20 @@ +package publicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..bed45e7e6ee --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_natgatewaysku.go b/resource-manager/network/2024-07-01/publicipaddresses/model_natgatewaysku.go new file mode 100644 index 00000000000..764ce1ec4aa --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_natruleportmapping.go b/resource-manager/network/2024-07-01/publicipaddresses/model_natruleportmapping.go new file mode 100644 index 00000000000..8c9fe6cf53d --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterface.go b/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterface.go new file mode 100644 index 00000000000..5297e480153 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterface.go @@ -0,0 +1,19 @@ +package publicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..b5db798efaa --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..9840f48b636 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..7815eb1f03a --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..fefc0a7c7d9 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..a4eec8778aa --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..060a9d5285a --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..d229b2dfb8d --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/publicipaddresses/model_networksecuritygroup.go new file mode 100644 index 00000000000..485cb7f8e07 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..8fef2ca403a --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpoint.go b/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpoint.go new file mode 100644 index 00000000000..dd63348ae6f --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpoint.go @@ -0,0 +1,19 @@ +package publicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpointconnection.go new file mode 100644 index 00000000000..b449098f79d --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..8a20b5b22e7 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..e75d758ed00 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..42574e02e61 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpointproperties.go new file mode 100644 index 00000000000..a0108e9c621 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkservice.go b/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkservice.go new file mode 100644 index 00000000000..b4d87fc1513 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package publicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..2039fef8e1a --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..37f23eb3b44 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..ee170e64109 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..8dce57f93b6 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..17839c3231f --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..5ae889b7497 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_publicipaddress.go b/resource-manager/network/2024-07-01/publicipaddresses/model_publicipaddress.go new file mode 100644 index 00000000000..6be86648487 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_publicipaddress.go @@ -0,0 +1,22 @@ +package publicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/publicipaddresses/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..19bd5c73bdd --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..90c1d772012 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/publicipaddresses/model_publicipaddresssku.go new file mode 100644 index 00000000000..af0178060c9 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_publicipddosprotectionstatusresult.go b/resource-manager/network/2024-07-01/publicipaddresses/model_publicipddosprotectionstatusresult.go new file mode 100644 index 00000000000..dbf51354f05 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_publicipddosprotectionstatusresult.go @@ -0,0 +1,11 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPDdosProtectionStatusResult struct { + DdosProtectionPlanId *string `json:"ddosProtectionPlanId,omitempty"` + IsWorkloadProtected *IsWorkloadProtected `json:"isWorkloadProtected,omitempty"` + PublicIPAddress *string `json:"publicIpAddress,omitempty"` + PublicIPAddressId *string `json:"publicIpAddressId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/publicipaddresses/model_resourcenavigationlink.go new file mode 100644 index 00000000000..8df0e65c796 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..912dad5e9b9 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_resourceset.go b/resource-manager/network/2024-07-01/publicipaddresses/model_resourceset.go new file mode 100644 index 00000000000..eb4ec2e13c4 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_resourceset.go @@ -0,0 +1,8 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/publicipaddresses/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..57e746e6800 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_route.go b/resource-manager/network/2024-07-01/publicipaddresses/model_route.go new file mode 100644 index 00000000000..6aaf9130e49 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_route.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_routepropertiesformat.go new file mode 100644 index 00000000000..19e40f46ddb --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_routetable.go b/resource-manager/network/2024-07-01/publicipaddresses/model_routetable.go new file mode 100644 index 00000000000..eed83ddcb84 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_routetable.go @@ -0,0 +1,14 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..f408090b5c7 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_securityrule.go b/resource-manager/network/2024-07-01/publicipaddresses/model_securityrule.go new file mode 100644 index 00000000000..056a5506bcc --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_securityrule.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..e076569ccb4 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/publicipaddresses/model_serviceassociationlink.go new file mode 100644 index 00000000000..80405186b49 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..e0afefd43a1 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..dfdf08665d4 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/publicipaddresses/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..2937667f2df --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/publicipaddresses/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..a5c2fb10189 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..6eae5a09363 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..77840b5f2bd --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..b40e6fcd671 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_subnet.go b/resource-manager/network/2024-07-01/publicipaddresses/model_subnet.go new file mode 100644 index 00000000000..4dc6901bd98 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_subnet.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..21017979e73 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_subresource.go b/resource-manager/network/2024-07-01/publicipaddresses/model_subresource.go new file mode 100644 index 00000000000..f4a7d6a3248 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_subresource.go @@ -0,0 +1,8 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_tagsobject.go b/resource-manager/network/2024-07-01/publicipaddresses/model_tagsobject.go new file mode 100644 index 00000000000..717ed6f5d3d --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_tagsobject.go @@ -0,0 +1,8 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/publicipaddresses/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..f3cbae91cdc --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/publicipaddresses/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..4e34016e12e --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/publicipaddresses/model_virtualnetworktap.go new file mode 100644 index 00000000000..b4791998c22 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/publicipaddresses/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..4f32bce3226 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/predicates.go b/resource-manager/network/2024-07-01/publicipaddresses/predicates.go new file mode 100644 index 00000000000..07d29ffa733 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/predicates.go @@ -0,0 +1,37 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p PublicIPAddressOperationPredicate) Matches(input PublicIPAddress) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/publicipaddresses/version.go b/resource-manager/network/2024-07-01/publicipaddresses/version.go new file mode 100644 index 00000000000..7f66f66e862 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipaddresses/version.go @@ -0,0 +1,10 @@ +package publicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/publicipaddresses/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/README.md b/resource-manager/network/2024-07-01/publicipprefixes/README.md new file mode 100644 index 00000000000..952c918d5d5 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/publicipprefixes` Documentation + +The `publicipprefixes` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/publicipprefixes" +``` + + +### Client Initialization + +```go +client := publicipprefixes.NewPublicIPPrefixesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PublicIPPrefixesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := publicipprefixes.NewPublicIPPrefixID("12345678-1234-9876-4563-123456789012", "example-resource-group", "publicIPPrefixName") + +payload := publicipprefixes.PublicIPPrefix{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `PublicIPPrefixesClient.Delete` + +```go +ctx := context.TODO() +id := publicipprefixes.NewPublicIPPrefixID("12345678-1234-9876-4563-123456789012", "example-resource-group", "publicIPPrefixName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PublicIPPrefixesClient.Get` + +```go +ctx := context.TODO() +id := publicipprefixes.NewPublicIPPrefixID("12345678-1234-9876-4563-123456789012", "example-resource-group", "publicIPPrefixName") + +read, err := client.Get(ctx, id, publicipprefixes.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PublicIPPrefixesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PublicIPPrefixesClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PublicIPPrefixesClient.UpdateTags` + +```go +ctx := context.TODO() +id := publicipprefixes.NewPublicIPPrefixID("12345678-1234-9876-4563-123456789012", "example-resource-group", "publicIPPrefixName") + +payload := publicipprefixes.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/publicipprefixes/client.go b/resource-manager/network/2024-07-01/publicipprefixes/client.go new file mode 100644 index 00000000000..78db8973387 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/client.go @@ -0,0 +1,26 @@ +package publicipprefixes + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPPrefixesClient struct { + Client *resourcemanager.Client +} + +func NewPublicIPPrefixesClientWithBaseURI(sdkApi sdkEnv.Api) (*PublicIPPrefixesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "publicipprefixes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PublicIPPrefixesClient: %+v", err) + } + + return &PublicIPPrefixesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/constants.go b/resource-manager/network/2024-07-01/publicipprefixes/constants.go new file mode 100644 index 00000000000..152a24c6fbb --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/constants.go @@ -0,0 +1,221 @@ +package publicipprefixes + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPPrefixSkuName string + +const ( + PublicIPPrefixSkuNameStandard PublicIPPrefixSkuName = "Standard" + PublicIPPrefixSkuNameStandardVTwo PublicIPPrefixSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPPrefixSkuName() []string { + return []string{ + string(PublicIPPrefixSkuNameStandard), + string(PublicIPPrefixSkuNameStandardVTwo), + } +} + +func (s *PublicIPPrefixSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPPrefixSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPPrefixSkuName(input string) (*PublicIPPrefixSkuName, error) { + vals := map[string]PublicIPPrefixSkuName{ + "standard": PublicIPPrefixSkuNameStandard, + "standardv2": PublicIPPrefixSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPPrefixSkuName(input) + return &out, nil +} + +type PublicIPPrefixSkuTier string + +const ( + PublicIPPrefixSkuTierGlobal PublicIPPrefixSkuTier = "Global" + PublicIPPrefixSkuTierRegional PublicIPPrefixSkuTier = "Regional" +) + +func PossibleValuesForPublicIPPrefixSkuTier() []string { + return []string{ + string(PublicIPPrefixSkuTierGlobal), + string(PublicIPPrefixSkuTierRegional), + } +} + +func (s *PublicIPPrefixSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPPrefixSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPPrefixSkuTier(input string) (*PublicIPPrefixSkuTier, error) { + vals := map[string]PublicIPPrefixSkuTier{ + "global": PublicIPPrefixSkuTierGlobal, + "regional": PublicIPPrefixSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPPrefixSkuTier(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/id_publicipprefix.go b/resource-manager/network/2024-07-01/publicipprefixes/id_publicipprefix.go new file mode 100644 index 00000000000..35801814a57 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/id_publicipprefix.go @@ -0,0 +1,130 @@ +package publicipprefixes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PublicIPPrefixId{}) +} + +var _ resourceids.ResourceId = &PublicIPPrefixId{} + +// PublicIPPrefixId is a struct representing the Resource ID for a Public I P Prefix +type PublicIPPrefixId struct { + SubscriptionId string + ResourceGroupName string + PublicIPPrefixName string +} + +// NewPublicIPPrefixID returns a new PublicIPPrefixId struct +func NewPublicIPPrefixID(subscriptionId string, resourceGroupName string, publicIPPrefixName string) PublicIPPrefixId { + return PublicIPPrefixId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + PublicIPPrefixName: publicIPPrefixName, + } +} + +// ParsePublicIPPrefixID parses 'input' into a PublicIPPrefixId +func ParsePublicIPPrefixID(input string) (*PublicIPPrefixId, error) { + parser := resourceids.NewParserFromResourceIdType(&PublicIPPrefixId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PublicIPPrefixId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePublicIPPrefixIDInsensitively parses 'input' case-insensitively into a PublicIPPrefixId +// note: this method should only be used for API response data and not user input +func ParsePublicIPPrefixIDInsensitively(input string) (*PublicIPPrefixId, error) { + parser := resourceids.NewParserFromResourceIdType(&PublicIPPrefixId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PublicIPPrefixId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PublicIPPrefixId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.PublicIPPrefixName, ok = input.Parsed["publicIPPrefixName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "publicIPPrefixName", input) + } + + return nil +} + +// ValidatePublicIPPrefixID checks that 'input' can be parsed as a Public I P Prefix ID +func ValidatePublicIPPrefixID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePublicIPPrefixID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Public I P Prefix ID +func (id PublicIPPrefixId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/publicIPPrefixes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PublicIPPrefixName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Public I P Prefix ID +func (id PublicIPPrefixId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticPublicIPPrefixes", "publicIPPrefixes", "publicIPPrefixes"), + resourceids.UserSpecifiedSegment("publicIPPrefixName", "publicIPPrefixName"), + } +} + +// String returns a human-readable description of this Public I P Prefix ID +func (id PublicIPPrefixId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Public I P Prefix Name: %q", id.PublicIPPrefixName), + } + return fmt.Sprintf("Public I P Prefix (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/id_publicipprefix_test.go b/resource-manager/network/2024-07-01/publicipprefixes/id_publicipprefix_test.go new file mode 100644 index 00000000000..267591b6714 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/id_publicipprefix_test.go @@ -0,0 +1,282 @@ +package publicipprefixes + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PublicIPPrefixId{} + +func TestNewPublicIPPrefixID(t *testing.T) { + id := NewPublicIPPrefixID("12345678-1234-9876-4563-123456789012", "example-resource-group", "publicIPPrefixName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.PublicIPPrefixName != "publicIPPrefixName" { + t.Fatalf("Expected %q but got %q for Segment 'PublicIPPrefixName'", id.PublicIPPrefixName, "publicIPPrefixName") + } +} + +func TestFormatPublicIPPrefixID(t *testing.T) { + actual := NewPublicIPPrefixID("12345678-1234-9876-4563-123456789012", "example-resource-group", "publicIPPrefixName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/publicIPPrefixes/publicIPPrefixName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePublicIPPrefixID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PublicIPPrefixId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/publicIPPrefixes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/publicIPPrefixes/publicIPPrefixName", + Expected: &PublicIPPrefixId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PublicIPPrefixName: "publicIPPrefixName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/publicIPPrefixes/publicIPPrefixName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePublicIPPrefixID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.PublicIPPrefixName != v.Expected.PublicIPPrefixName { + t.Fatalf("Expected %q but got %q for PublicIPPrefixName", v.Expected.PublicIPPrefixName, actual.PublicIPPrefixName) + } + + } +} + +func TestParsePublicIPPrefixIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PublicIPPrefixId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/publicIPPrefixes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pUbLiCiPpReFiXeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/publicIPPrefixes/publicIPPrefixName", + Expected: &PublicIPPrefixId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + PublicIPPrefixName: "publicIPPrefixName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/publicIPPrefixes/publicIPPrefixName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pUbLiCiPpReFiXeS/pUbLiCiPpReFiXnAmE", + Expected: &PublicIPPrefixId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + PublicIPPrefixName: "pUbLiCiPpReFiXnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/pUbLiCiPpReFiXeS/pUbLiCiPpReFiXnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePublicIPPrefixIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.PublicIPPrefixName != v.Expected.PublicIPPrefixName { + t.Fatalf("Expected %q but got %q for PublicIPPrefixName", v.Expected.PublicIPPrefixName, actual.PublicIPPrefixName) + } + + } +} + +func TestSegmentsForPublicIPPrefixId(t *testing.T) { + segments := PublicIPPrefixId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PublicIPPrefixId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/method_createorupdate.go b/resource-manager/network/2024-07-01/publicipprefixes/method_createorupdate.go new file mode 100644 index 00000000000..eb586e03d6c --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/method_createorupdate.go @@ -0,0 +1,75 @@ +package publicipprefixes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *PublicIPPrefix +} + +// CreateOrUpdate ... +func (c PublicIPPrefixesClient) CreateOrUpdate(ctx context.Context, id PublicIPPrefixId, input PublicIPPrefix) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c PublicIPPrefixesClient) CreateOrUpdateThenPoll(ctx context.Context, id PublicIPPrefixId, input PublicIPPrefix) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/method_delete.go b/resource-manager/network/2024-07-01/publicipprefixes/method_delete.go new file mode 100644 index 00000000000..4ef74511d04 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/method_delete.go @@ -0,0 +1,71 @@ +package publicipprefixes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c PublicIPPrefixesClient) Delete(ctx context.Context, id PublicIPPrefixId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PublicIPPrefixesClient) DeleteThenPoll(ctx context.Context, id PublicIPPrefixId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/method_get.go b/resource-manager/network/2024-07-01/publicipprefixes/method_get.go new file mode 100644 index 00000000000..4d05c32931a --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/method_get.go @@ -0,0 +1,83 @@ +package publicipprefixes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicIPPrefix +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c PublicIPPrefixesClient) Get(ctx context.Context, id PublicIPPrefixId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PublicIPPrefix + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/method_list.go b/resource-manager/network/2024-07-01/publicipprefixes/method_list.go new file mode 100644 index 00000000000..122a9df6f37 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/method_list.go @@ -0,0 +1,106 @@ +package publicipprefixes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PublicIPPrefix +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PublicIPPrefix +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c PublicIPPrefixesClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/publicIPPrefixes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PublicIPPrefix `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c PublicIPPrefixesClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, PublicIPPrefixOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PublicIPPrefixesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate PublicIPPrefixOperationPredicate) (result ListCompleteResult, err error) { + items := make([]PublicIPPrefix, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/method_listall.go b/resource-manager/network/2024-07-01/publicipprefixes/method_listall.go new file mode 100644 index 00000000000..4c49b47b3fe --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/method_listall.go @@ -0,0 +1,106 @@ +package publicipprefixes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PublicIPPrefix +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []PublicIPPrefix +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c PublicIPPrefixesClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/publicIPPrefixes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PublicIPPrefix `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c PublicIPPrefixesClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, PublicIPPrefixOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PublicIPPrefixesClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate PublicIPPrefixOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]PublicIPPrefix, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/method_updatetags.go b/resource-manager/network/2024-07-01/publicipprefixes/method_updatetags.go new file mode 100644 index 00000000000..3111479b00a --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/method_updatetags.go @@ -0,0 +1,57 @@ +package publicipprefixes + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicIPPrefix +} + +// UpdateTags ... +func (c PublicIPPrefixesClient) UpdateTags(ctx context.Context, id PublicIPPrefixId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PublicIPPrefix + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/model_iptag.go b/resource-manager/network/2024-07-01/publicipprefixes/model_iptag.go new file mode 100644 index 00000000000..e1bbbc73a6e --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/model_iptag.go @@ -0,0 +1,9 @@ +package publicipprefixes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/model_natgateway.go b/resource-manager/network/2024-07-01/publicipprefixes/model_natgateway.go new file mode 100644 index 00000000000..170eeff6848 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/model_natgateway.go @@ -0,0 +1,20 @@ +package publicipprefixes + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/publicipprefixes/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..03c172c2538 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package publicipprefixes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/model_natgatewaysku.go b/resource-manager/network/2024-07-01/publicipprefixes/model_natgatewaysku.go new file mode 100644 index 00000000000..465e471e903 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package publicipprefixes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/model_publicipprefix.go b/resource-manager/network/2024-07-01/publicipprefixes/model_publicipprefix.go new file mode 100644 index 00000000000..6679bada47d --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/model_publicipprefix.go @@ -0,0 +1,22 @@ +package publicipprefixes + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPPrefix struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPPrefixPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPPrefixSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/model_publicipprefixpropertiesformat.go b/resource-manager/network/2024-07-01/publicipprefixes/model_publicipprefixpropertiesformat.go new file mode 100644 index 00000000000..32b58a818b3 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/model_publicipprefixpropertiesformat.go @@ -0,0 +1,17 @@ +package publicipprefixes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPPrefixPropertiesFormat struct { + CustomIPPrefix *SubResource `json:"customIPPrefix,omitempty"` + IPPrefix *string `json:"ipPrefix,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIpConfiguration,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + PrefixLength *int64 `json:"prefixLength,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAddresses *[]ReferencedPublicIPAddress `json:"publicIPAddresses,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/model_publicipprefixsku.go b/resource-manager/network/2024-07-01/publicipprefixes/model_publicipprefixsku.go new file mode 100644 index 00000000000..0737b92dee1 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/model_publicipprefixsku.go @@ -0,0 +1,9 @@ +package publicipprefixes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPPrefixSku struct { + Name *PublicIPPrefixSkuName `json:"name,omitempty"` + Tier *PublicIPPrefixSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/model_referencedpublicipaddress.go b/resource-manager/network/2024-07-01/publicipprefixes/model_referencedpublicipaddress.go new file mode 100644 index 00000000000..26027a800a2 --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/model_referencedpublicipaddress.go @@ -0,0 +1,8 @@ +package publicipprefixes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReferencedPublicIPAddress struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/model_subresource.go b/resource-manager/network/2024-07-01/publicipprefixes/model_subresource.go new file mode 100644 index 00000000000..53e3c780cbf --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/model_subresource.go @@ -0,0 +1,8 @@ +package publicipprefixes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/model_tagsobject.go b/resource-manager/network/2024-07-01/publicipprefixes/model_tagsobject.go new file mode 100644 index 00000000000..6a82f86f28f --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/model_tagsobject.go @@ -0,0 +1,8 @@ +package publicipprefixes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/predicates.go b/resource-manager/network/2024-07-01/publicipprefixes/predicates.go new file mode 100644 index 00000000000..7deb3ca2bbf --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/predicates.go @@ -0,0 +1,37 @@ +package publicipprefixes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPPrefixOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p PublicIPPrefixOperationPredicate) Matches(input PublicIPPrefix) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/publicipprefixes/version.go b/resource-manager/network/2024-07-01/publicipprefixes/version.go new file mode 100644 index 00000000000..b85072aa90f --- /dev/null +++ b/resource-manager/network/2024-07-01/publicipprefixes/version.go @@ -0,0 +1,10 @@ +package publicipprefixes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/publicipprefixes/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintent/client.go b/resource-manager/network/2024-07-01/reachabilityanalysisintent/client.go new file mode 100644 index 00000000000..8d80bbd5cd3 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintent/client.go @@ -0,0 +1,26 @@ +package reachabilityanalysisintent + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReachabilityAnalysisIntentClient struct { + Client *resourcemanager.Client +} + +func NewReachabilityAnalysisIntentClientWithBaseURI(sdkApi sdkEnv.Api) (*ReachabilityAnalysisIntentClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "reachabilityanalysisintent", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReachabilityAnalysisIntentClient: %+v", err) + } + + return &ReachabilityAnalysisIntentClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintent/id_reachabilityanalysisintent.go b/resource-manager/network/2024-07-01/reachabilityanalysisintent/id_reachabilityanalysisintent.go new file mode 100644 index 00000000000..213bd9e9c5d --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintent/id_reachabilityanalysisintent.go @@ -0,0 +1,148 @@ +package reachabilityanalysisintent + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReachabilityAnalysisIntentId{}) +} + +var _ resourceids.ResourceId = &ReachabilityAnalysisIntentId{} + +// ReachabilityAnalysisIntentId is a struct representing the Resource ID for a Reachability Analysis Intent +type ReachabilityAnalysisIntentId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + VerifierWorkspaceName string + ReachabilityAnalysisIntentName string +} + +// NewReachabilityAnalysisIntentID returns a new ReachabilityAnalysisIntentId struct +func NewReachabilityAnalysisIntentID(subscriptionId string, resourceGroupName string, networkManagerName string, verifierWorkspaceName string, reachabilityAnalysisIntentName string) ReachabilityAnalysisIntentId { + return ReachabilityAnalysisIntentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + VerifierWorkspaceName: verifierWorkspaceName, + ReachabilityAnalysisIntentName: reachabilityAnalysisIntentName, + } +} + +// ParseReachabilityAnalysisIntentID parses 'input' into a ReachabilityAnalysisIntentId +func ParseReachabilityAnalysisIntentID(input string) (*ReachabilityAnalysisIntentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReachabilityAnalysisIntentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReachabilityAnalysisIntentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReachabilityAnalysisIntentIDInsensitively parses 'input' case-insensitively into a ReachabilityAnalysisIntentId +// note: this method should only be used for API response data and not user input +func ParseReachabilityAnalysisIntentIDInsensitively(input string) (*ReachabilityAnalysisIntentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReachabilityAnalysisIntentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReachabilityAnalysisIntentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReachabilityAnalysisIntentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.VerifierWorkspaceName, ok = input.Parsed["verifierWorkspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "verifierWorkspaceName", input) + } + + if id.ReachabilityAnalysisIntentName, ok = input.Parsed["reachabilityAnalysisIntentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "reachabilityAnalysisIntentName", input) + } + + return nil +} + +// ValidateReachabilityAnalysisIntentID checks that 'input' can be parsed as a Reachability Analysis Intent ID +func ValidateReachabilityAnalysisIntentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReachabilityAnalysisIntentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Reachability Analysis Intent ID +func (id ReachabilityAnalysisIntentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/verifierWorkspaces/%s/reachabilityAnalysisIntents/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.VerifierWorkspaceName, id.ReachabilityAnalysisIntentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Reachability Analysis Intent ID +func (id ReachabilityAnalysisIntentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticVerifierWorkspaces", "verifierWorkspaces", "verifierWorkspaces"), + resourceids.UserSpecifiedSegment("verifierWorkspaceName", "verifierWorkspaceName"), + resourceids.StaticSegment("staticReachabilityAnalysisIntents", "reachabilityAnalysisIntents", "reachabilityAnalysisIntents"), + resourceids.UserSpecifiedSegment("reachabilityAnalysisIntentName", "reachabilityAnalysisIntentName"), + } +} + +// String returns a human-readable description of this Reachability Analysis Intent ID +func (id ReachabilityAnalysisIntentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Verifier Workspace Name: %q", id.VerifierWorkspaceName), + fmt.Sprintf("Reachability Analysis Intent Name: %q", id.ReachabilityAnalysisIntentName), + } + return fmt.Sprintf("Reachability Analysis Intent (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintent/id_reachabilityanalysisintent_test.go b/resource-manager/network/2024-07-01/reachabilityanalysisintent/id_reachabilityanalysisintent_test.go new file mode 100644 index 00000000000..993fd518e3a --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintent/id_reachabilityanalysisintent_test.go @@ -0,0 +1,372 @@ +package reachabilityanalysisintent + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReachabilityAnalysisIntentId{} + +func TestNewReachabilityAnalysisIntentID(t *testing.T) { + id := NewReachabilityAnalysisIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName", "reachabilityAnalysisIntentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.VerifierWorkspaceName != "verifierWorkspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'VerifierWorkspaceName'", id.VerifierWorkspaceName, "verifierWorkspaceName") + } + + if id.ReachabilityAnalysisIntentName != "reachabilityAnalysisIntentName" { + t.Fatalf("Expected %q but got %q for Segment 'ReachabilityAnalysisIntentName'", id.ReachabilityAnalysisIntentName, "reachabilityAnalysisIntentName") + } +} + +func TestFormatReachabilityAnalysisIntentID(t *testing.T) { + actual := NewReachabilityAnalysisIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName", "reachabilityAnalysisIntentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisIntents/reachabilityAnalysisIntentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReachabilityAnalysisIntentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReachabilityAnalysisIntentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisIntents", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisIntents/reachabilityAnalysisIntentName", + Expected: &ReachabilityAnalysisIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + VerifierWorkspaceName: "verifierWorkspaceName", + ReachabilityAnalysisIntentName: "reachabilityAnalysisIntentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisIntents/reachabilityAnalysisIntentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReachabilityAnalysisIntentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.VerifierWorkspaceName != v.Expected.VerifierWorkspaceName { + t.Fatalf("Expected %q but got %q for VerifierWorkspaceName", v.Expected.VerifierWorkspaceName, actual.VerifierWorkspaceName) + } + + if actual.ReachabilityAnalysisIntentName != v.Expected.ReachabilityAnalysisIntentName { + t.Fatalf("Expected %q but got %q for ReachabilityAnalysisIntentName", v.Expected.ReachabilityAnalysisIntentName, actual.ReachabilityAnalysisIntentName) + } + + } +} + +func TestParseReachabilityAnalysisIntentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReachabilityAnalysisIntentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisIntents", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe/rEaChAbIlItYaNaLySiSiNtEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisIntents/reachabilityAnalysisIntentName", + Expected: &ReachabilityAnalysisIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + VerifierWorkspaceName: "verifierWorkspaceName", + ReachabilityAnalysisIntentName: "reachabilityAnalysisIntentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisIntents/reachabilityAnalysisIntentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe/rEaChAbIlItYaNaLySiSiNtEnTs/rEaChAbIlItYaNaLySiSiNtEnTnAmE", + Expected: &ReachabilityAnalysisIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + VerifierWorkspaceName: "vErIfIeRwOrKsPaCeNaMe", + ReachabilityAnalysisIntentName: "rEaChAbIlItYaNaLySiSiNtEnTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe/rEaChAbIlItYaNaLySiSiNtEnTs/rEaChAbIlItYaNaLySiSiNtEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReachabilityAnalysisIntentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.VerifierWorkspaceName != v.Expected.VerifierWorkspaceName { + t.Fatalf("Expected %q but got %q for VerifierWorkspaceName", v.Expected.VerifierWorkspaceName, actual.VerifierWorkspaceName) + } + + if actual.ReachabilityAnalysisIntentName != v.Expected.ReachabilityAnalysisIntentName { + t.Fatalf("Expected %q but got %q for ReachabilityAnalysisIntentName", v.Expected.ReachabilityAnalysisIntentName, actual.ReachabilityAnalysisIntentName) + } + + } +} + +func TestSegmentsForReachabilityAnalysisIntentId(t *testing.T) { + segments := ReachabilityAnalysisIntentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReachabilityAnalysisIntentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintent/method_delete.go b/resource-manager/network/2024-07-01/reachabilityanalysisintent/method_delete.go new file mode 100644 index 00000000000..31924ee1ecb --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintent/method_delete.go @@ -0,0 +1,47 @@ +package reachabilityanalysisintent + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ReachabilityAnalysisIntentClient) Delete(ctx context.Context, id ReachabilityAnalysisIntentId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintent/version.go b/resource-manager/network/2024-07-01/reachabilityanalysisintent/version.go new file mode 100644 index 00000000000..a0d357cdb1f --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintent/version.go @@ -0,0 +1,10 @@ +package reachabilityanalysisintent + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/reachabilityanalysisintent/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintents/README.md b/resource-manager/network/2024-07-01/reachabilityanalysisintents/README.md new file mode 100644 index 00000000000..014b7ef50ab --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintents/README.md @@ -0,0 +1,74 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/reachabilityanalysisintents` Documentation + +The `reachabilityanalysisintents` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/reachabilityanalysisintents" +``` + + +### Client Initialization + +```go +client := reachabilityanalysisintents.NewReachabilityAnalysisIntentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReachabilityAnalysisIntentsClient.Create` + +```go +ctx := context.TODO() +id := reachabilityanalysisintents.NewReachabilityAnalysisIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName", "reachabilityAnalysisIntentName") + +payload := reachabilityanalysisintents.ReachabilityAnalysisIntent{ + // ... +} + + +read, err := client.Create(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ReachabilityAnalysisIntentsClient.Get` + +```go +ctx := context.TODO() +id := reachabilityanalysisintents.NewReachabilityAnalysisIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName", "reachabilityAnalysisIntentName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ReachabilityAnalysisIntentsClient.List` + +```go +ctx := context.TODO() +id := reachabilityanalysisintents.NewVerifierWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName") + +// alternatively `client.List(ctx, id, reachabilityanalysisintents.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, reachabilityanalysisintents.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintents/client.go b/resource-manager/network/2024-07-01/reachabilityanalysisintents/client.go new file mode 100644 index 00000000000..477d04a3ad1 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintents/client.go @@ -0,0 +1,26 @@ +package reachabilityanalysisintents + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReachabilityAnalysisIntentsClient struct { + Client *resourcemanager.Client +} + +func NewReachabilityAnalysisIntentsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReachabilityAnalysisIntentsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "reachabilityanalysisintents", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReachabilityAnalysisIntentsClient: %+v", err) + } + + return &ReachabilityAnalysisIntentsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintents/constants.go b/resource-manager/network/2024-07-01/reachabilityanalysisintents/constants.go new file mode 100644 index 00000000000..6cb8b8101ad --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintents/constants.go @@ -0,0 +1,110 @@ +package reachabilityanalysisintents + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkProtocol string + +const ( + NetworkProtocolAny NetworkProtocol = "Any" + NetworkProtocolICMP NetworkProtocol = "ICMP" + NetworkProtocolTCP NetworkProtocol = "TCP" + NetworkProtocolUDP NetworkProtocol = "UDP" +) + +func PossibleValuesForNetworkProtocol() []string { + return []string{ + string(NetworkProtocolAny), + string(NetworkProtocolICMP), + string(NetworkProtocolTCP), + string(NetworkProtocolUDP), + } +} + +func (s *NetworkProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkProtocol(input string) (*NetworkProtocol, error) { + vals := map[string]NetworkProtocol{ + "any": NetworkProtocolAny, + "icmp": NetworkProtocolICMP, + "tcp": NetworkProtocolTCP, + "udp": NetworkProtocolUDP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkProtocol(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintents/id_reachabilityanalysisintent.go b/resource-manager/network/2024-07-01/reachabilityanalysisintents/id_reachabilityanalysisintent.go new file mode 100644 index 00000000000..35d489e168e --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintents/id_reachabilityanalysisintent.go @@ -0,0 +1,148 @@ +package reachabilityanalysisintents + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReachabilityAnalysisIntentId{}) +} + +var _ resourceids.ResourceId = &ReachabilityAnalysisIntentId{} + +// ReachabilityAnalysisIntentId is a struct representing the Resource ID for a Reachability Analysis Intent +type ReachabilityAnalysisIntentId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + VerifierWorkspaceName string + ReachabilityAnalysisIntentName string +} + +// NewReachabilityAnalysisIntentID returns a new ReachabilityAnalysisIntentId struct +func NewReachabilityAnalysisIntentID(subscriptionId string, resourceGroupName string, networkManagerName string, verifierWorkspaceName string, reachabilityAnalysisIntentName string) ReachabilityAnalysisIntentId { + return ReachabilityAnalysisIntentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + VerifierWorkspaceName: verifierWorkspaceName, + ReachabilityAnalysisIntentName: reachabilityAnalysisIntentName, + } +} + +// ParseReachabilityAnalysisIntentID parses 'input' into a ReachabilityAnalysisIntentId +func ParseReachabilityAnalysisIntentID(input string) (*ReachabilityAnalysisIntentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReachabilityAnalysisIntentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReachabilityAnalysisIntentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReachabilityAnalysisIntentIDInsensitively parses 'input' case-insensitively into a ReachabilityAnalysisIntentId +// note: this method should only be used for API response data and not user input +func ParseReachabilityAnalysisIntentIDInsensitively(input string) (*ReachabilityAnalysisIntentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReachabilityAnalysisIntentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReachabilityAnalysisIntentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReachabilityAnalysisIntentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.VerifierWorkspaceName, ok = input.Parsed["verifierWorkspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "verifierWorkspaceName", input) + } + + if id.ReachabilityAnalysisIntentName, ok = input.Parsed["reachabilityAnalysisIntentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "reachabilityAnalysisIntentName", input) + } + + return nil +} + +// ValidateReachabilityAnalysisIntentID checks that 'input' can be parsed as a Reachability Analysis Intent ID +func ValidateReachabilityAnalysisIntentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReachabilityAnalysisIntentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Reachability Analysis Intent ID +func (id ReachabilityAnalysisIntentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/verifierWorkspaces/%s/reachabilityAnalysisIntents/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.VerifierWorkspaceName, id.ReachabilityAnalysisIntentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Reachability Analysis Intent ID +func (id ReachabilityAnalysisIntentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticVerifierWorkspaces", "verifierWorkspaces", "verifierWorkspaces"), + resourceids.UserSpecifiedSegment("verifierWorkspaceName", "verifierWorkspaceName"), + resourceids.StaticSegment("staticReachabilityAnalysisIntents", "reachabilityAnalysisIntents", "reachabilityAnalysisIntents"), + resourceids.UserSpecifiedSegment("reachabilityAnalysisIntentName", "reachabilityAnalysisIntentName"), + } +} + +// String returns a human-readable description of this Reachability Analysis Intent ID +func (id ReachabilityAnalysisIntentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Verifier Workspace Name: %q", id.VerifierWorkspaceName), + fmt.Sprintf("Reachability Analysis Intent Name: %q", id.ReachabilityAnalysisIntentName), + } + return fmt.Sprintf("Reachability Analysis Intent (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintents/id_reachabilityanalysisintent_test.go b/resource-manager/network/2024-07-01/reachabilityanalysisintents/id_reachabilityanalysisintent_test.go new file mode 100644 index 00000000000..9e61c3f257d --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintents/id_reachabilityanalysisintent_test.go @@ -0,0 +1,372 @@ +package reachabilityanalysisintents + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReachabilityAnalysisIntentId{} + +func TestNewReachabilityAnalysisIntentID(t *testing.T) { + id := NewReachabilityAnalysisIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName", "reachabilityAnalysisIntentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.VerifierWorkspaceName != "verifierWorkspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'VerifierWorkspaceName'", id.VerifierWorkspaceName, "verifierWorkspaceName") + } + + if id.ReachabilityAnalysisIntentName != "reachabilityAnalysisIntentName" { + t.Fatalf("Expected %q but got %q for Segment 'ReachabilityAnalysisIntentName'", id.ReachabilityAnalysisIntentName, "reachabilityAnalysisIntentName") + } +} + +func TestFormatReachabilityAnalysisIntentID(t *testing.T) { + actual := NewReachabilityAnalysisIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName", "reachabilityAnalysisIntentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisIntents/reachabilityAnalysisIntentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReachabilityAnalysisIntentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReachabilityAnalysisIntentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisIntents", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisIntents/reachabilityAnalysisIntentName", + Expected: &ReachabilityAnalysisIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + VerifierWorkspaceName: "verifierWorkspaceName", + ReachabilityAnalysisIntentName: "reachabilityAnalysisIntentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisIntents/reachabilityAnalysisIntentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReachabilityAnalysisIntentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.VerifierWorkspaceName != v.Expected.VerifierWorkspaceName { + t.Fatalf("Expected %q but got %q for VerifierWorkspaceName", v.Expected.VerifierWorkspaceName, actual.VerifierWorkspaceName) + } + + if actual.ReachabilityAnalysisIntentName != v.Expected.ReachabilityAnalysisIntentName { + t.Fatalf("Expected %q but got %q for ReachabilityAnalysisIntentName", v.Expected.ReachabilityAnalysisIntentName, actual.ReachabilityAnalysisIntentName) + } + + } +} + +func TestParseReachabilityAnalysisIntentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReachabilityAnalysisIntentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisIntents", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe/rEaChAbIlItYaNaLySiSiNtEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisIntents/reachabilityAnalysisIntentName", + Expected: &ReachabilityAnalysisIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + VerifierWorkspaceName: "verifierWorkspaceName", + ReachabilityAnalysisIntentName: "reachabilityAnalysisIntentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisIntents/reachabilityAnalysisIntentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe/rEaChAbIlItYaNaLySiSiNtEnTs/rEaChAbIlItYaNaLySiSiNtEnTnAmE", + Expected: &ReachabilityAnalysisIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + VerifierWorkspaceName: "vErIfIeRwOrKsPaCeNaMe", + ReachabilityAnalysisIntentName: "rEaChAbIlItYaNaLySiSiNtEnTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe/rEaChAbIlItYaNaLySiSiNtEnTs/rEaChAbIlItYaNaLySiSiNtEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReachabilityAnalysisIntentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.VerifierWorkspaceName != v.Expected.VerifierWorkspaceName { + t.Fatalf("Expected %q but got %q for VerifierWorkspaceName", v.Expected.VerifierWorkspaceName, actual.VerifierWorkspaceName) + } + + if actual.ReachabilityAnalysisIntentName != v.Expected.ReachabilityAnalysisIntentName { + t.Fatalf("Expected %q but got %q for ReachabilityAnalysisIntentName", v.Expected.ReachabilityAnalysisIntentName, actual.ReachabilityAnalysisIntentName) + } + + } +} + +func TestSegmentsForReachabilityAnalysisIntentId(t *testing.T) { + segments := ReachabilityAnalysisIntentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReachabilityAnalysisIntentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintents/id_verifierworkspace.go b/resource-manager/network/2024-07-01/reachabilityanalysisintents/id_verifierworkspace.go new file mode 100644 index 00000000000..838b602e9b6 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintents/id_verifierworkspace.go @@ -0,0 +1,139 @@ +package reachabilityanalysisintents + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VerifierWorkspaceId{}) +} + +var _ resourceids.ResourceId = &VerifierWorkspaceId{} + +// VerifierWorkspaceId is a struct representing the Resource ID for a Verifier Workspace +type VerifierWorkspaceId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + VerifierWorkspaceName string +} + +// NewVerifierWorkspaceID returns a new VerifierWorkspaceId struct +func NewVerifierWorkspaceID(subscriptionId string, resourceGroupName string, networkManagerName string, verifierWorkspaceName string) VerifierWorkspaceId { + return VerifierWorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + VerifierWorkspaceName: verifierWorkspaceName, + } +} + +// ParseVerifierWorkspaceID parses 'input' into a VerifierWorkspaceId +func ParseVerifierWorkspaceID(input string) (*VerifierWorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&VerifierWorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VerifierWorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVerifierWorkspaceIDInsensitively parses 'input' case-insensitively into a VerifierWorkspaceId +// note: this method should only be used for API response data and not user input +func ParseVerifierWorkspaceIDInsensitively(input string) (*VerifierWorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&VerifierWorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VerifierWorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VerifierWorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.VerifierWorkspaceName, ok = input.Parsed["verifierWorkspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "verifierWorkspaceName", input) + } + + return nil +} + +// ValidateVerifierWorkspaceID checks that 'input' can be parsed as a Verifier Workspace ID +func ValidateVerifierWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVerifierWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Verifier Workspace ID +func (id VerifierWorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/verifierWorkspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.VerifierWorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Verifier Workspace ID +func (id VerifierWorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticVerifierWorkspaces", "verifierWorkspaces", "verifierWorkspaces"), + resourceids.UserSpecifiedSegment("verifierWorkspaceName", "verifierWorkspaceName"), + } +} + +// String returns a human-readable description of this Verifier Workspace ID +func (id VerifierWorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Verifier Workspace Name: %q", id.VerifierWorkspaceName), + } + return fmt.Sprintf("Verifier Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintents/id_verifierworkspace_test.go b/resource-manager/network/2024-07-01/reachabilityanalysisintents/id_verifierworkspace_test.go new file mode 100644 index 00000000000..37b3d08e82b --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintents/id_verifierworkspace_test.go @@ -0,0 +1,327 @@ +package reachabilityanalysisintents + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VerifierWorkspaceId{} + +func TestNewVerifierWorkspaceID(t *testing.T) { + id := NewVerifierWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.VerifierWorkspaceName != "verifierWorkspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'VerifierWorkspaceName'", id.VerifierWorkspaceName, "verifierWorkspaceName") + } +} + +func TestFormatVerifierWorkspaceID(t *testing.T) { + actual := NewVerifierWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVerifierWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VerifierWorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName", + Expected: &VerifierWorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + VerifierWorkspaceName: "verifierWorkspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVerifierWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.VerifierWorkspaceName != v.Expected.VerifierWorkspaceName { + t.Fatalf("Expected %q but got %q for VerifierWorkspaceName", v.Expected.VerifierWorkspaceName, actual.VerifierWorkspaceName) + } + + } +} + +func TestParseVerifierWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VerifierWorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName", + Expected: &VerifierWorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + VerifierWorkspaceName: "verifierWorkspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe", + Expected: &VerifierWorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + VerifierWorkspaceName: "vErIfIeRwOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVerifierWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.VerifierWorkspaceName != v.Expected.VerifierWorkspaceName { + t.Fatalf("Expected %q but got %q for VerifierWorkspaceName", v.Expected.VerifierWorkspaceName, actual.VerifierWorkspaceName) + } + + } +} + +func TestSegmentsForVerifierWorkspaceId(t *testing.T) { + segments := VerifierWorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VerifierWorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintents/method_create.go b/resource-manager/network/2024-07-01/reachabilityanalysisintents/method_create.go new file mode 100644 index 00000000000..88254ae9602 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintents/method_create.go @@ -0,0 +1,58 @@ +package reachabilityanalysisintents + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ReachabilityAnalysisIntent +} + +// Create ... +func (c ReachabilityAnalysisIntentsClient) Create(ctx context.Context, id ReachabilityAnalysisIntentId, input ReachabilityAnalysisIntent) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ReachabilityAnalysisIntent + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintents/method_get.go b/resource-manager/network/2024-07-01/reachabilityanalysisintents/method_get.go new file mode 100644 index 00000000000..8eadfc891b9 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintents/method_get.go @@ -0,0 +1,53 @@ +package reachabilityanalysisintents + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ReachabilityAnalysisIntent +} + +// Get ... +func (c ReachabilityAnalysisIntentsClient) Get(ctx context.Context, id ReachabilityAnalysisIntentId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ReachabilityAnalysisIntent + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintents/method_list.go b/resource-manager/network/2024-07-01/reachabilityanalysisintents/method_list.go new file mode 100644 index 00000000000..f9bffc5041c --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintents/method_list.go @@ -0,0 +1,150 @@ +package reachabilityanalysisintents + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReachabilityAnalysisIntent +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReachabilityAnalysisIntent +} + +type ListOperationOptions struct { + Skip *int64 + SkipToken *string + SortKey *string + SortValue *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skip != nil { + out.Append("skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + if o.SortKey != nil { + out.Append("sortKey", fmt.Sprintf("%v", *o.SortKey)) + } + if o.SortValue != nil { + out.Append("sortValue", fmt.Sprintf("%v", *o.SortValue)) + } + if o.Top != nil { + out.Append("top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReachabilityAnalysisIntentsClient) List(ctx context.Context, id VerifierWorkspaceId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/reachabilityAnalysisIntents", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReachabilityAnalysisIntent `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReachabilityAnalysisIntentsClient) ListComplete(ctx context.Context, id VerifierWorkspaceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ReachabilityAnalysisIntentOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReachabilityAnalysisIntentsClient) ListCompleteMatchingPredicate(ctx context.Context, id VerifierWorkspaceId, options ListOperationOptions, predicate ReachabilityAnalysisIntentOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ReachabilityAnalysisIntent, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintents/model_iptraffic.go b/resource-manager/network/2024-07-01/reachabilityanalysisintents/model_iptraffic.go new file mode 100644 index 00000000000..9e20b97671e --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintents/model_iptraffic.go @@ -0,0 +1,12 @@ +package reachabilityanalysisintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTraffic struct { + DestinationIPs []string `json:"destinationIps"` + DestinationPorts []string `json:"destinationPorts"` + Protocols []NetworkProtocol `json:"protocols"` + SourceIPs []string `json:"sourceIps"` + SourcePorts []string `json:"sourcePorts"` +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintents/model_reachabilityanalysisintent.go b/resource-manager/network/2024-07-01/reachabilityanalysisintents/model_reachabilityanalysisintent.go new file mode 100644 index 00000000000..d84ce18b72a --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintents/model_reachabilityanalysisintent.go @@ -0,0 +1,16 @@ +package reachabilityanalysisintents + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReachabilityAnalysisIntent struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ReachabilityAnalysisIntentProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintents/model_reachabilityanalysisintentproperties.go b/resource-manager/network/2024-07-01/reachabilityanalysisintents/model_reachabilityanalysisintentproperties.go new file mode 100644 index 00000000000..2c34fff4eaf --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintents/model_reachabilityanalysisintentproperties.go @@ -0,0 +1,12 @@ +package reachabilityanalysisintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReachabilityAnalysisIntentProperties struct { + Description *string `json:"description,omitempty"` + DestinationResourceId string `json:"destinationResourceId"` + IPTraffic IPTraffic `json:"ipTraffic"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceResourceId string `json:"sourceResourceId"` +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintents/predicates.go b/resource-manager/network/2024-07-01/reachabilityanalysisintents/predicates.go new file mode 100644 index 00000000000..b8a08136ed4 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintents/predicates.go @@ -0,0 +1,27 @@ +package reachabilityanalysisintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReachabilityAnalysisIntentOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ReachabilityAnalysisIntentOperationPredicate) Matches(input ReachabilityAnalysisIntent) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisintents/version.go b/resource-manager/network/2024-07-01/reachabilityanalysisintents/version.go new file mode 100644 index 00000000000..cfb378d5780 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisintents/version.go @@ -0,0 +1,10 @@ +package reachabilityanalysisintents + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/reachabilityanalysisintents/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisruns/README.md b/resource-manager/network/2024-07-01/reachabilityanalysisruns/README.md new file mode 100644 index 00000000000..1185bb238e2 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisruns/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/reachabilityanalysisruns` Documentation + +The `reachabilityanalysisruns` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/reachabilityanalysisruns" +``` + + +### Client Initialization + +```go +client := reachabilityanalysisruns.NewReachabilityAnalysisRunsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ReachabilityAnalysisRunsClient.Create` + +```go +ctx := context.TODO() +id := reachabilityanalysisruns.NewReachabilityAnalysisRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName", "reachabilityAnalysisRunName") + +payload := reachabilityanalysisruns.ReachabilityAnalysisRun{ + // ... +} + + +read, err := client.Create(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ReachabilityAnalysisRunsClient.Delete` + +```go +ctx := context.TODO() +id := reachabilityanalysisruns.NewReachabilityAnalysisRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName", "reachabilityAnalysisRunName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ReachabilityAnalysisRunsClient.Get` + +```go +ctx := context.TODO() +id := reachabilityanalysisruns.NewReachabilityAnalysisRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName", "reachabilityAnalysisRunName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ReachabilityAnalysisRunsClient.List` + +```go +ctx := context.TODO() +id := reachabilityanalysisruns.NewVerifierWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName") + +// alternatively `client.List(ctx, id, reachabilityanalysisruns.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, reachabilityanalysisruns.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisruns/client.go b/resource-manager/network/2024-07-01/reachabilityanalysisruns/client.go new file mode 100644 index 00000000000..59658cf90da --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisruns/client.go @@ -0,0 +1,26 @@ +package reachabilityanalysisruns + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReachabilityAnalysisRunsClient struct { + Client *resourcemanager.Client +} + +func NewReachabilityAnalysisRunsClientWithBaseURI(sdkApi sdkEnv.Api) (*ReachabilityAnalysisRunsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "reachabilityanalysisruns", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ReachabilityAnalysisRunsClient: %+v", err) + } + + return &ReachabilityAnalysisRunsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisruns/constants.go b/resource-manager/network/2024-07-01/reachabilityanalysisruns/constants.go new file mode 100644 index 00000000000..b49091ec995 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisruns/constants.go @@ -0,0 +1,110 @@ +package reachabilityanalysisruns + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkProtocol string + +const ( + NetworkProtocolAny NetworkProtocol = "Any" + NetworkProtocolICMP NetworkProtocol = "ICMP" + NetworkProtocolTCP NetworkProtocol = "TCP" + NetworkProtocolUDP NetworkProtocol = "UDP" +) + +func PossibleValuesForNetworkProtocol() []string { + return []string{ + string(NetworkProtocolAny), + string(NetworkProtocolICMP), + string(NetworkProtocolTCP), + string(NetworkProtocolUDP), + } +} + +func (s *NetworkProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkProtocol(input string) (*NetworkProtocol, error) { + vals := map[string]NetworkProtocol{ + "any": NetworkProtocolAny, + "icmp": NetworkProtocolICMP, + "tcp": NetworkProtocolTCP, + "udp": NetworkProtocolUDP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkProtocol(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisruns/id_reachabilityanalysisrun.go b/resource-manager/network/2024-07-01/reachabilityanalysisruns/id_reachabilityanalysisrun.go new file mode 100644 index 00000000000..1d98dccc029 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisruns/id_reachabilityanalysisrun.go @@ -0,0 +1,148 @@ +package reachabilityanalysisruns + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ReachabilityAnalysisRunId{}) +} + +var _ resourceids.ResourceId = &ReachabilityAnalysisRunId{} + +// ReachabilityAnalysisRunId is a struct representing the Resource ID for a Reachability Analysis Run +type ReachabilityAnalysisRunId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + VerifierWorkspaceName string + ReachabilityAnalysisRunName string +} + +// NewReachabilityAnalysisRunID returns a new ReachabilityAnalysisRunId struct +func NewReachabilityAnalysisRunID(subscriptionId string, resourceGroupName string, networkManagerName string, verifierWorkspaceName string, reachabilityAnalysisRunName string) ReachabilityAnalysisRunId { + return ReachabilityAnalysisRunId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + VerifierWorkspaceName: verifierWorkspaceName, + ReachabilityAnalysisRunName: reachabilityAnalysisRunName, + } +} + +// ParseReachabilityAnalysisRunID parses 'input' into a ReachabilityAnalysisRunId +func ParseReachabilityAnalysisRunID(input string) (*ReachabilityAnalysisRunId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReachabilityAnalysisRunId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReachabilityAnalysisRunId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseReachabilityAnalysisRunIDInsensitively parses 'input' case-insensitively into a ReachabilityAnalysisRunId +// note: this method should only be used for API response data and not user input +func ParseReachabilityAnalysisRunIDInsensitively(input string) (*ReachabilityAnalysisRunId, error) { + parser := resourceids.NewParserFromResourceIdType(&ReachabilityAnalysisRunId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ReachabilityAnalysisRunId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ReachabilityAnalysisRunId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.VerifierWorkspaceName, ok = input.Parsed["verifierWorkspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "verifierWorkspaceName", input) + } + + if id.ReachabilityAnalysisRunName, ok = input.Parsed["reachabilityAnalysisRunName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "reachabilityAnalysisRunName", input) + } + + return nil +} + +// ValidateReachabilityAnalysisRunID checks that 'input' can be parsed as a Reachability Analysis Run ID +func ValidateReachabilityAnalysisRunID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseReachabilityAnalysisRunID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Reachability Analysis Run ID +func (id ReachabilityAnalysisRunId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/verifierWorkspaces/%s/reachabilityAnalysisRuns/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.VerifierWorkspaceName, id.ReachabilityAnalysisRunName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Reachability Analysis Run ID +func (id ReachabilityAnalysisRunId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticVerifierWorkspaces", "verifierWorkspaces", "verifierWorkspaces"), + resourceids.UserSpecifiedSegment("verifierWorkspaceName", "verifierWorkspaceName"), + resourceids.StaticSegment("staticReachabilityAnalysisRuns", "reachabilityAnalysisRuns", "reachabilityAnalysisRuns"), + resourceids.UserSpecifiedSegment("reachabilityAnalysisRunName", "reachabilityAnalysisRunName"), + } +} + +// String returns a human-readable description of this Reachability Analysis Run ID +func (id ReachabilityAnalysisRunId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Verifier Workspace Name: %q", id.VerifierWorkspaceName), + fmt.Sprintf("Reachability Analysis Run Name: %q", id.ReachabilityAnalysisRunName), + } + return fmt.Sprintf("Reachability Analysis Run (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisruns/id_reachabilityanalysisrun_test.go b/resource-manager/network/2024-07-01/reachabilityanalysisruns/id_reachabilityanalysisrun_test.go new file mode 100644 index 00000000000..b1e57878f5c --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisruns/id_reachabilityanalysisrun_test.go @@ -0,0 +1,372 @@ +package reachabilityanalysisruns + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ReachabilityAnalysisRunId{} + +func TestNewReachabilityAnalysisRunID(t *testing.T) { + id := NewReachabilityAnalysisRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName", "reachabilityAnalysisRunName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.VerifierWorkspaceName != "verifierWorkspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'VerifierWorkspaceName'", id.VerifierWorkspaceName, "verifierWorkspaceName") + } + + if id.ReachabilityAnalysisRunName != "reachabilityAnalysisRunName" { + t.Fatalf("Expected %q but got %q for Segment 'ReachabilityAnalysisRunName'", id.ReachabilityAnalysisRunName, "reachabilityAnalysisRunName") + } +} + +func TestFormatReachabilityAnalysisRunID(t *testing.T) { + actual := NewReachabilityAnalysisRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName", "reachabilityAnalysisRunName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisRuns/reachabilityAnalysisRunName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseReachabilityAnalysisRunID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReachabilityAnalysisRunId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisRuns", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisRuns/reachabilityAnalysisRunName", + Expected: &ReachabilityAnalysisRunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + VerifierWorkspaceName: "verifierWorkspaceName", + ReachabilityAnalysisRunName: "reachabilityAnalysisRunName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisRuns/reachabilityAnalysisRunName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReachabilityAnalysisRunID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.VerifierWorkspaceName != v.Expected.VerifierWorkspaceName { + t.Fatalf("Expected %q but got %q for VerifierWorkspaceName", v.Expected.VerifierWorkspaceName, actual.VerifierWorkspaceName) + } + + if actual.ReachabilityAnalysisRunName != v.Expected.ReachabilityAnalysisRunName { + t.Fatalf("Expected %q but got %q for ReachabilityAnalysisRunName", v.Expected.ReachabilityAnalysisRunName, actual.ReachabilityAnalysisRunName) + } + + } +} + +func TestParseReachabilityAnalysisRunIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ReachabilityAnalysisRunId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisRuns", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe/rEaChAbIlItYaNaLySiSrUnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisRuns/reachabilityAnalysisRunName", + Expected: &ReachabilityAnalysisRunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + VerifierWorkspaceName: "verifierWorkspaceName", + ReachabilityAnalysisRunName: "reachabilityAnalysisRunName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/reachabilityAnalysisRuns/reachabilityAnalysisRunName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe/rEaChAbIlItYaNaLySiSrUnS/rEaChAbIlItYaNaLySiSrUnNaMe", + Expected: &ReachabilityAnalysisRunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + VerifierWorkspaceName: "vErIfIeRwOrKsPaCeNaMe", + ReachabilityAnalysisRunName: "rEaChAbIlItYaNaLySiSrUnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe/rEaChAbIlItYaNaLySiSrUnS/rEaChAbIlItYaNaLySiSrUnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseReachabilityAnalysisRunIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.VerifierWorkspaceName != v.Expected.VerifierWorkspaceName { + t.Fatalf("Expected %q but got %q for VerifierWorkspaceName", v.Expected.VerifierWorkspaceName, actual.VerifierWorkspaceName) + } + + if actual.ReachabilityAnalysisRunName != v.Expected.ReachabilityAnalysisRunName { + t.Fatalf("Expected %q but got %q for ReachabilityAnalysisRunName", v.Expected.ReachabilityAnalysisRunName, actual.ReachabilityAnalysisRunName) + } + + } +} + +func TestSegmentsForReachabilityAnalysisRunId(t *testing.T) { + segments := ReachabilityAnalysisRunId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ReachabilityAnalysisRunId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisruns/id_verifierworkspace.go b/resource-manager/network/2024-07-01/reachabilityanalysisruns/id_verifierworkspace.go new file mode 100644 index 00000000000..3032969101a --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisruns/id_verifierworkspace.go @@ -0,0 +1,139 @@ +package reachabilityanalysisruns + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VerifierWorkspaceId{}) +} + +var _ resourceids.ResourceId = &VerifierWorkspaceId{} + +// VerifierWorkspaceId is a struct representing the Resource ID for a Verifier Workspace +type VerifierWorkspaceId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + VerifierWorkspaceName string +} + +// NewVerifierWorkspaceID returns a new VerifierWorkspaceId struct +func NewVerifierWorkspaceID(subscriptionId string, resourceGroupName string, networkManagerName string, verifierWorkspaceName string) VerifierWorkspaceId { + return VerifierWorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + VerifierWorkspaceName: verifierWorkspaceName, + } +} + +// ParseVerifierWorkspaceID parses 'input' into a VerifierWorkspaceId +func ParseVerifierWorkspaceID(input string) (*VerifierWorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&VerifierWorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VerifierWorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVerifierWorkspaceIDInsensitively parses 'input' case-insensitively into a VerifierWorkspaceId +// note: this method should only be used for API response data and not user input +func ParseVerifierWorkspaceIDInsensitively(input string) (*VerifierWorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&VerifierWorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VerifierWorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VerifierWorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.VerifierWorkspaceName, ok = input.Parsed["verifierWorkspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "verifierWorkspaceName", input) + } + + return nil +} + +// ValidateVerifierWorkspaceID checks that 'input' can be parsed as a Verifier Workspace ID +func ValidateVerifierWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVerifierWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Verifier Workspace ID +func (id VerifierWorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/verifierWorkspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.VerifierWorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Verifier Workspace ID +func (id VerifierWorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticVerifierWorkspaces", "verifierWorkspaces", "verifierWorkspaces"), + resourceids.UserSpecifiedSegment("verifierWorkspaceName", "verifierWorkspaceName"), + } +} + +// String returns a human-readable description of this Verifier Workspace ID +func (id VerifierWorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Verifier Workspace Name: %q", id.VerifierWorkspaceName), + } + return fmt.Sprintf("Verifier Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisruns/id_verifierworkspace_test.go b/resource-manager/network/2024-07-01/reachabilityanalysisruns/id_verifierworkspace_test.go new file mode 100644 index 00000000000..a53ef083d22 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisruns/id_verifierworkspace_test.go @@ -0,0 +1,327 @@ +package reachabilityanalysisruns + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VerifierWorkspaceId{} + +func TestNewVerifierWorkspaceID(t *testing.T) { + id := NewVerifierWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.VerifierWorkspaceName != "verifierWorkspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'VerifierWorkspaceName'", id.VerifierWorkspaceName, "verifierWorkspaceName") + } +} + +func TestFormatVerifierWorkspaceID(t *testing.T) { + actual := NewVerifierWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVerifierWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VerifierWorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName", + Expected: &VerifierWorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + VerifierWorkspaceName: "verifierWorkspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVerifierWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.VerifierWorkspaceName != v.Expected.VerifierWorkspaceName { + t.Fatalf("Expected %q but got %q for VerifierWorkspaceName", v.Expected.VerifierWorkspaceName, actual.VerifierWorkspaceName) + } + + } +} + +func TestParseVerifierWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VerifierWorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName", + Expected: &VerifierWorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + VerifierWorkspaceName: "verifierWorkspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe", + Expected: &VerifierWorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + VerifierWorkspaceName: "vErIfIeRwOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVerifierWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.VerifierWorkspaceName != v.Expected.VerifierWorkspaceName { + t.Fatalf("Expected %q but got %q for VerifierWorkspaceName", v.Expected.VerifierWorkspaceName, actual.VerifierWorkspaceName) + } + + } +} + +func TestSegmentsForVerifierWorkspaceId(t *testing.T) { + segments := VerifierWorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VerifierWorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisruns/method_create.go b/resource-manager/network/2024-07-01/reachabilityanalysisruns/method_create.go new file mode 100644 index 00000000000..0e187215e46 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisruns/method_create.go @@ -0,0 +1,58 @@ +package reachabilityanalysisruns + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ReachabilityAnalysisRun +} + +// Create ... +func (c ReachabilityAnalysisRunsClient) Create(ctx context.Context, id ReachabilityAnalysisRunId, input ReachabilityAnalysisRun) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ReachabilityAnalysisRun + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisruns/method_delete.go b/resource-manager/network/2024-07-01/reachabilityanalysisruns/method_delete.go new file mode 100644 index 00000000000..2394a3e9a77 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisruns/method_delete.go @@ -0,0 +1,70 @@ +package reachabilityanalysisruns + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ReachabilityAnalysisRunsClient) Delete(ctx context.Context, id ReachabilityAnalysisRunId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ReachabilityAnalysisRunsClient) DeleteThenPoll(ctx context.Context, id ReachabilityAnalysisRunId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisruns/method_get.go b/resource-manager/network/2024-07-01/reachabilityanalysisruns/method_get.go new file mode 100644 index 00000000000..42240eb5d8c --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisruns/method_get.go @@ -0,0 +1,53 @@ +package reachabilityanalysisruns + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ReachabilityAnalysisRun +} + +// Get ... +func (c ReachabilityAnalysisRunsClient) Get(ctx context.Context, id ReachabilityAnalysisRunId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ReachabilityAnalysisRun + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisruns/method_list.go b/resource-manager/network/2024-07-01/reachabilityanalysisruns/method_list.go new file mode 100644 index 00000000000..3edb0e689f7 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisruns/method_list.go @@ -0,0 +1,150 @@ +package reachabilityanalysisruns + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ReachabilityAnalysisRun +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ReachabilityAnalysisRun +} + +type ListOperationOptions struct { + Skip *int64 + SkipToken *string + SortKey *string + SortValue *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skip != nil { + out.Append("skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + if o.SortKey != nil { + out.Append("sortKey", fmt.Sprintf("%v", *o.SortKey)) + } + if o.SortValue != nil { + out.Append("sortValue", fmt.Sprintf("%v", *o.SortValue)) + } + if o.Top != nil { + out.Append("top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ReachabilityAnalysisRunsClient) List(ctx context.Context, id VerifierWorkspaceId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/reachabilityAnalysisRuns", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ReachabilityAnalysisRun `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ReachabilityAnalysisRunsClient) ListComplete(ctx context.Context, id VerifierWorkspaceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ReachabilityAnalysisRunOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ReachabilityAnalysisRunsClient) ListCompleteMatchingPredicate(ctx context.Context, id VerifierWorkspaceId, options ListOperationOptions, predicate ReachabilityAnalysisRunOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ReachabilityAnalysisRun, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisruns/model_intentcontent.go b/resource-manager/network/2024-07-01/reachabilityanalysisruns/model_intentcontent.go new file mode 100644 index 00000000000..2c0db2c47c6 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisruns/model_intentcontent.go @@ -0,0 +1,11 @@ +package reachabilityanalysisruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IntentContent struct { + Description *string `json:"description,omitempty"` + DestinationResourceId string `json:"destinationResourceId"` + IPTraffic IPTraffic `json:"ipTraffic"` + SourceResourceId string `json:"sourceResourceId"` +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisruns/model_iptraffic.go b/resource-manager/network/2024-07-01/reachabilityanalysisruns/model_iptraffic.go new file mode 100644 index 00000000000..aec11d7d1bf --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisruns/model_iptraffic.go @@ -0,0 +1,12 @@ +package reachabilityanalysisruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTraffic struct { + DestinationIPs []string `json:"destinationIps"` + DestinationPorts []string `json:"destinationPorts"` + Protocols []NetworkProtocol `json:"protocols"` + SourceIPs []string `json:"sourceIps"` + SourcePorts []string `json:"sourcePorts"` +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisruns/model_reachabilityanalysisrun.go b/resource-manager/network/2024-07-01/reachabilityanalysisruns/model_reachabilityanalysisrun.go new file mode 100644 index 00000000000..1ce13570f72 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisruns/model_reachabilityanalysisrun.go @@ -0,0 +1,16 @@ +package reachabilityanalysisruns + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReachabilityAnalysisRun struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ReachabilityAnalysisRunProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisruns/model_reachabilityanalysisrunproperties.go b/resource-manager/network/2024-07-01/reachabilityanalysisruns/model_reachabilityanalysisrunproperties.go new file mode 100644 index 00000000000..d1d8b2184d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisruns/model_reachabilityanalysisrunproperties.go @@ -0,0 +1,13 @@ +package reachabilityanalysisruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReachabilityAnalysisRunProperties struct { + AnalysisResult *string `json:"analysisResult,omitempty"` + Description *string `json:"description,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + IntentContent *IntentContent `json:"intentContent,omitempty"` + IntentId string `json:"intentId"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisruns/predicates.go b/resource-manager/network/2024-07-01/reachabilityanalysisruns/predicates.go new file mode 100644 index 00000000000..4408caca61c --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisruns/predicates.go @@ -0,0 +1,27 @@ +package reachabilityanalysisruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReachabilityAnalysisRunOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ReachabilityAnalysisRunOperationPredicate) Matches(input ReachabilityAnalysisRun) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/reachabilityanalysisruns/version.go b/resource-manager/network/2024-07-01/reachabilityanalysisruns/version.go new file mode 100644 index 00000000000..a189926c5d8 --- /dev/null +++ b/resource-manager/network/2024-07-01/reachabilityanalysisruns/version.go @@ -0,0 +1,10 @@ +package reachabilityanalysisruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/reachabilityanalysisruns/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/routefilterrules/README.md b/resource-manager/network/2024-07-01/routefilterrules/README.md new file mode 100644 index 00000000000..0a8b176456d --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilterrules/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routefilterrules` Documentation + +The `routefilterrules` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routefilterrules" +``` + + +### Client Initialization + +```go +client := routefilterrules.NewRouteFilterRulesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RouteFilterRulesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := routefilterrules.NewRouteFilterRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeFilterName", "routeFilterRuleName") + +payload := routefilterrules.RouteFilterRule{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `RouteFilterRulesClient.Delete` + +```go +ctx := context.TODO() +id := routefilterrules.NewRouteFilterRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeFilterName", "routeFilterRuleName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `RouteFilterRulesClient.Get` + +```go +ctx := context.TODO() +id := routefilterrules.NewRouteFilterRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeFilterName", "routeFilterRuleName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RouteFilterRulesClient.ListByRouteFilter` + +```go +ctx := context.TODO() +id := routefilterrules.NewRouteFilterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeFilterName") + +// alternatively `client.ListByRouteFilter(ctx, id)` can be used to do batched pagination +items, err := client.ListByRouteFilterComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/routefilterrules/client.go b/resource-manager/network/2024-07-01/routefilterrules/client.go new file mode 100644 index 00000000000..87a6916e467 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilterrules/client.go @@ -0,0 +1,26 @@ +package routefilterrules + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteFilterRulesClient struct { + Client *resourcemanager.Client +} + +func NewRouteFilterRulesClientWithBaseURI(sdkApi sdkEnv.Api) (*RouteFilterRulesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "routefilterrules", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RouteFilterRulesClient: %+v", err) + } + + return &RouteFilterRulesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/routefilterrules/constants.go b/resource-manager/network/2024-07-01/routefilterrules/constants.go new file mode 100644 index 00000000000..cf65052c645 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilterrules/constants.go @@ -0,0 +1,136 @@ +package routefilterrules + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Access string + +const ( + AccessAllow Access = "Allow" + AccessDeny Access = "Deny" +) + +func PossibleValuesForAccess() []string { + return []string{ + string(AccessAllow), + string(AccessDeny), + } +} + +func (s *Access) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAccess(input string) (*Access, error) { + vals := map[string]Access{ + "allow": AccessAllow, + "deny": AccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Access(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type RouteFilterRuleType string + +const ( + RouteFilterRuleTypeCommunity RouteFilterRuleType = "Community" +) + +func PossibleValuesForRouteFilterRuleType() []string { + return []string{ + string(RouteFilterRuleTypeCommunity), + } +} + +func (s *RouteFilterRuleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteFilterRuleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteFilterRuleType(input string) (*RouteFilterRuleType, error) { + vals := map[string]RouteFilterRuleType{ + "community": RouteFilterRuleTypeCommunity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteFilterRuleType(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/routefilterrules/id_routefilter.go b/resource-manager/network/2024-07-01/routefilterrules/id_routefilter.go new file mode 100644 index 00000000000..9cb0ba95fc8 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilterrules/id_routefilter.go @@ -0,0 +1,130 @@ +package routefilterrules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RouteFilterId{}) +} + +var _ resourceids.ResourceId = &RouteFilterId{} + +// RouteFilterId is a struct representing the Resource ID for a Route Filter +type RouteFilterId struct { + SubscriptionId string + ResourceGroupName string + RouteFilterName string +} + +// NewRouteFilterID returns a new RouteFilterId struct +func NewRouteFilterID(subscriptionId string, resourceGroupName string, routeFilterName string) RouteFilterId { + return RouteFilterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RouteFilterName: routeFilterName, + } +} + +// ParseRouteFilterID parses 'input' into a RouteFilterId +func ParseRouteFilterID(input string) (*RouteFilterId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteFilterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteFilterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRouteFilterIDInsensitively parses 'input' case-insensitively into a RouteFilterId +// note: this method should only be used for API response data and not user input +func ParseRouteFilterIDInsensitively(input string) (*RouteFilterId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteFilterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteFilterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RouteFilterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RouteFilterName, ok = input.Parsed["routeFilterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeFilterName", input) + } + + return nil +} + +// ValidateRouteFilterID checks that 'input' can be parsed as a Route Filter ID +func ValidateRouteFilterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRouteFilterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Route Filter ID +func (id RouteFilterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/routeFilters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RouteFilterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Route Filter ID +func (id RouteFilterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticRouteFilters", "routeFilters", "routeFilters"), + resourceids.UserSpecifiedSegment("routeFilterName", "routeFilterName"), + } +} + +// String returns a human-readable description of this Route Filter ID +func (id RouteFilterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Route Filter Name: %q", id.RouteFilterName), + } + return fmt.Sprintf("Route Filter (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/routefilterrules/id_routefilter_test.go b/resource-manager/network/2024-07-01/routefilterrules/id_routefilter_test.go new file mode 100644 index 00000000000..32c600c8d29 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilterrules/id_routefilter_test.go @@ -0,0 +1,282 @@ +package routefilterrules + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RouteFilterId{} + +func TestNewRouteFilterID(t *testing.T) { + id := NewRouteFilterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeFilterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RouteFilterName != "routeFilterName" { + t.Fatalf("Expected %q but got %q for Segment 'RouteFilterName'", id.RouteFilterName, "routeFilterName") + } +} + +func TestFormatRouteFilterID(t *testing.T) { + actual := NewRouteFilterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeFilterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRouteFilterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteFilterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName", + Expected: &RouteFilterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RouteFilterName: "routeFilterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteFilterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RouteFilterName != v.Expected.RouteFilterName { + t.Fatalf("Expected %q but got %q for RouteFilterName", v.Expected.RouteFilterName, actual.RouteFilterName) + } + + } +} + +func TestParseRouteFilterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteFilterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeFiLtErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName", + Expected: &RouteFilterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RouteFilterName: "routeFilterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeFiLtErS/rOuTeFiLtErNaMe", + Expected: &RouteFilterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RouteFilterName: "rOuTeFiLtErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeFiLtErS/rOuTeFiLtErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteFilterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RouteFilterName != v.Expected.RouteFilterName { + t.Fatalf("Expected %q but got %q for RouteFilterName", v.Expected.RouteFilterName, actual.RouteFilterName) + } + + } +} + +func TestSegmentsForRouteFilterId(t *testing.T) { + segments := RouteFilterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RouteFilterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/routefilterrules/id_routefilterrule.go b/resource-manager/network/2024-07-01/routefilterrules/id_routefilterrule.go new file mode 100644 index 00000000000..d06e7791dfc --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilterrules/id_routefilterrule.go @@ -0,0 +1,139 @@ +package routefilterrules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RouteFilterRuleId{}) +} + +var _ resourceids.ResourceId = &RouteFilterRuleId{} + +// RouteFilterRuleId is a struct representing the Resource ID for a Route Filter Rule +type RouteFilterRuleId struct { + SubscriptionId string + ResourceGroupName string + RouteFilterName string + RouteFilterRuleName string +} + +// NewRouteFilterRuleID returns a new RouteFilterRuleId struct +func NewRouteFilterRuleID(subscriptionId string, resourceGroupName string, routeFilterName string, routeFilterRuleName string) RouteFilterRuleId { + return RouteFilterRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RouteFilterName: routeFilterName, + RouteFilterRuleName: routeFilterRuleName, + } +} + +// ParseRouteFilterRuleID parses 'input' into a RouteFilterRuleId +func ParseRouteFilterRuleID(input string) (*RouteFilterRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteFilterRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteFilterRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRouteFilterRuleIDInsensitively parses 'input' case-insensitively into a RouteFilterRuleId +// note: this method should only be used for API response data and not user input +func ParseRouteFilterRuleIDInsensitively(input string) (*RouteFilterRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteFilterRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteFilterRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RouteFilterRuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RouteFilterName, ok = input.Parsed["routeFilterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeFilterName", input) + } + + if id.RouteFilterRuleName, ok = input.Parsed["routeFilterRuleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeFilterRuleName", input) + } + + return nil +} + +// ValidateRouteFilterRuleID checks that 'input' can be parsed as a Route Filter Rule ID +func ValidateRouteFilterRuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRouteFilterRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Route Filter Rule ID +func (id RouteFilterRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/routeFilters/%s/routeFilterRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RouteFilterName, id.RouteFilterRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Route Filter Rule ID +func (id RouteFilterRuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticRouteFilters", "routeFilters", "routeFilters"), + resourceids.UserSpecifiedSegment("routeFilterName", "routeFilterName"), + resourceids.StaticSegment("staticRouteFilterRules", "routeFilterRules", "routeFilterRules"), + resourceids.UserSpecifiedSegment("routeFilterRuleName", "routeFilterRuleName"), + } +} + +// String returns a human-readable description of this Route Filter Rule ID +func (id RouteFilterRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Route Filter Name: %q", id.RouteFilterName), + fmt.Sprintf("Route Filter Rule Name: %q", id.RouteFilterRuleName), + } + return fmt.Sprintf("Route Filter Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/routefilterrules/id_routefilterrule_test.go b/resource-manager/network/2024-07-01/routefilterrules/id_routefilterrule_test.go new file mode 100644 index 00000000000..4a52969db44 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilterrules/id_routefilterrule_test.go @@ -0,0 +1,327 @@ +package routefilterrules + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RouteFilterRuleId{} + +func TestNewRouteFilterRuleID(t *testing.T) { + id := NewRouteFilterRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeFilterName", "routeFilterRuleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RouteFilterName != "routeFilterName" { + t.Fatalf("Expected %q but got %q for Segment 'RouteFilterName'", id.RouteFilterName, "routeFilterName") + } + + if id.RouteFilterRuleName != "routeFilterRuleName" { + t.Fatalf("Expected %q but got %q for Segment 'RouteFilterRuleName'", id.RouteFilterRuleName, "routeFilterRuleName") + } +} + +func TestFormatRouteFilterRuleID(t *testing.T) { + actual := NewRouteFilterRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeFilterName", "routeFilterRuleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName/routeFilterRules/routeFilterRuleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRouteFilterRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteFilterRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName/routeFilterRules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName/routeFilterRules/routeFilterRuleName", + Expected: &RouteFilterRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RouteFilterName: "routeFilterName", + RouteFilterRuleName: "routeFilterRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName/routeFilterRules/routeFilterRuleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteFilterRuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RouteFilterName != v.Expected.RouteFilterName { + t.Fatalf("Expected %q but got %q for RouteFilterName", v.Expected.RouteFilterName, actual.RouteFilterName) + } + + if actual.RouteFilterRuleName != v.Expected.RouteFilterRuleName { + t.Fatalf("Expected %q but got %q for RouteFilterRuleName", v.Expected.RouteFilterRuleName, actual.RouteFilterRuleName) + } + + } +} + +func TestParseRouteFilterRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteFilterRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeFiLtErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeFiLtErS/rOuTeFiLtErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName/routeFilterRules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeFiLtErS/rOuTeFiLtErNaMe/rOuTeFiLtErRuLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName/routeFilterRules/routeFilterRuleName", + Expected: &RouteFilterRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RouteFilterName: "routeFilterName", + RouteFilterRuleName: "routeFilterRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName/routeFilterRules/routeFilterRuleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeFiLtErS/rOuTeFiLtErNaMe/rOuTeFiLtErRuLeS/rOuTeFiLtErRuLeNaMe", + Expected: &RouteFilterRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RouteFilterName: "rOuTeFiLtErNaMe", + RouteFilterRuleName: "rOuTeFiLtErRuLeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeFiLtErS/rOuTeFiLtErNaMe/rOuTeFiLtErRuLeS/rOuTeFiLtErRuLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteFilterRuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RouteFilterName != v.Expected.RouteFilterName { + t.Fatalf("Expected %q but got %q for RouteFilterName", v.Expected.RouteFilterName, actual.RouteFilterName) + } + + if actual.RouteFilterRuleName != v.Expected.RouteFilterRuleName { + t.Fatalf("Expected %q but got %q for RouteFilterRuleName", v.Expected.RouteFilterRuleName, actual.RouteFilterRuleName) + } + + } +} + +func TestSegmentsForRouteFilterRuleId(t *testing.T) { + segments := RouteFilterRuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RouteFilterRuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/routefilterrules/method_createorupdate.go b/resource-manager/network/2024-07-01/routefilterrules/method_createorupdate.go new file mode 100644 index 00000000000..6e1717e3fce --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilterrules/method_createorupdate.go @@ -0,0 +1,75 @@ +package routefilterrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RouteFilterRule +} + +// CreateOrUpdate ... +func (c RouteFilterRulesClient) CreateOrUpdate(ctx context.Context, id RouteFilterRuleId, input RouteFilterRule) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c RouteFilterRulesClient) CreateOrUpdateThenPoll(ctx context.Context, id RouteFilterRuleId, input RouteFilterRule) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/routefilterrules/method_delete.go b/resource-manager/network/2024-07-01/routefilterrules/method_delete.go new file mode 100644 index 00000000000..bbac130984b --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilterrules/method_delete.go @@ -0,0 +1,71 @@ +package routefilterrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c RouteFilterRulesClient) Delete(ctx context.Context, id RouteFilterRuleId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c RouteFilterRulesClient) DeleteThenPoll(ctx context.Context, id RouteFilterRuleId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/routefilterrules/method_get.go b/resource-manager/network/2024-07-01/routefilterrules/method_get.go new file mode 100644 index 00000000000..66ebdba141b --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilterrules/method_get.go @@ -0,0 +1,53 @@ +package routefilterrules + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RouteFilterRule +} + +// Get ... +func (c RouteFilterRulesClient) Get(ctx context.Context, id RouteFilterRuleId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RouteFilterRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/routefilterrules/method_listbyroutefilter.go b/resource-manager/network/2024-07-01/routefilterrules/method_listbyroutefilter.go new file mode 100644 index 00000000000..5c0268dc0a5 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilterrules/method_listbyroutefilter.go @@ -0,0 +1,105 @@ +package routefilterrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByRouteFilterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RouteFilterRule +} + +type ListByRouteFilterCompleteResult struct { + LatestHttpResponse *http.Response + Items []RouteFilterRule +} + +type ListByRouteFilterCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByRouteFilterCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByRouteFilter ... +func (c RouteFilterRulesClient) ListByRouteFilter(ctx context.Context, id RouteFilterId) (result ListByRouteFilterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByRouteFilterCustomPager{}, + Path: fmt.Sprintf("%s/routeFilterRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RouteFilterRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByRouteFilterComplete retrieves all the results into a single object +func (c RouteFilterRulesClient) ListByRouteFilterComplete(ctx context.Context, id RouteFilterId) (ListByRouteFilterCompleteResult, error) { + return c.ListByRouteFilterCompleteMatchingPredicate(ctx, id, RouteFilterRuleOperationPredicate{}) +} + +// ListByRouteFilterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RouteFilterRulesClient) ListByRouteFilterCompleteMatchingPredicate(ctx context.Context, id RouteFilterId, predicate RouteFilterRuleOperationPredicate) (result ListByRouteFilterCompleteResult, err error) { + items := make([]RouteFilterRule, 0) + + resp, err := c.ListByRouteFilter(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByRouteFilterCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/routefilterrules/model_routefilterrule.go b/resource-manager/network/2024-07-01/routefilterrules/model_routefilterrule.go new file mode 100644 index 00000000000..d3ad4488a83 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilterrules/model_routefilterrule.go @@ -0,0 +1,12 @@ +package routefilterrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteFilterRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteFilterRulePropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilterrules/model_routefilterrulepropertiesformat.go b/resource-manager/network/2024-07-01/routefilterrules/model_routefilterrulepropertiesformat.go new file mode 100644 index 00000000000..e59fbff04f1 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilterrules/model_routefilterrulepropertiesformat.go @@ -0,0 +1,11 @@ +package routefilterrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteFilterRulePropertiesFormat struct { + Access Access `json:"access"` + Communities []string `json:"communities"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RouteFilterRuleType RouteFilterRuleType `json:"routeFilterRuleType"` +} diff --git a/resource-manager/network/2024-07-01/routefilterrules/predicates.go b/resource-manager/network/2024-07-01/routefilterrules/predicates.go new file mode 100644 index 00000000000..3067b052089 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilterrules/predicates.go @@ -0,0 +1,32 @@ +package routefilterrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteFilterRuleOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string +} + +func (p RouteFilterRuleOperationPredicate) Matches(input RouteFilterRule) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/routefilterrules/version.go b/resource-manager/network/2024-07-01/routefilterrules/version.go new file mode 100644 index 00000000000..b6e05f47f98 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilterrules/version.go @@ -0,0 +1,10 @@ +package routefilterrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/routefilterrules/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/routefilters/README.md b/resource-manager/network/2024-07-01/routefilters/README.md new file mode 100644 index 00000000000..79f2ac508ed --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routefilters` Documentation + +The `routefilters` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routefilters" +``` + + +### Client Initialization + +```go +client := routefilters.NewRouteFiltersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RouteFiltersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := routefilters.NewRouteFilterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeFilterName") + +payload := routefilters.RouteFilter{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `RouteFiltersClient.Delete` + +```go +ctx := context.TODO() +id := routefilters.NewRouteFilterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeFilterName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `RouteFiltersClient.Get` + +```go +ctx := context.TODO() +id := routefilters.NewRouteFilterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeFilterName") + +read, err := client.Get(ctx, id, routefilters.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RouteFiltersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RouteFiltersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RouteFiltersClient.UpdateTags` + +```go +ctx := context.TODO() +id := routefilters.NewRouteFilterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeFilterName") + +payload := routefilters.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/routefilters/client.go b/resource-manager/network/2024-07-01/routefilters/client.go new file mode 100644 index 00000000000..5bf2183b43d --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/client.go @@ -0,0 +1,26 @@ +package routefilters + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteFiltersClient struct { + Client *resourcemanager.Client +} + +func NewRouteFiltersClientWithBaseURI(sdkApi sdkEnv.Api) (*RouteFiltersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "routefilters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RouteFiltersClient: %+v", err) + } + + return &RouteFiltersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/routefilters/constants.go b/resource-manager/network/2024-07-01/routefilters/constants.go new file mode 100644 index 00000000000..4c45f9e9207 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/constants.go @@ -0,0 +1,418 @@ +package routefilters + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Access string + +const ( + AccessAllow Access = "Allow" + AccessDeny Access = "Deny" +) + +func PossibleValuesForAccess() []string { + return []string{ + string(AccessAllow), + string(AccessDeny), + } +} + +func (s *Access) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAccess(input string) (*Access, error) { + vals := map[string]Access{ + "allow": AccessAllow, + "deny": AccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Access(input) + return &out, nil +} + +type AdvertisedPublicPrefixPropertiesValidationState string + +const ( + AdvertisedPublicPrefixPropertiesValidationStateAsnValidationFailed AdvertisedPublicPrefixPropertiesValidationState = "AsnValidationFailed" + AdvertisedPublicPrefixPropertiesValidationStateCertificateMissingInRoutingRegistry AdvertisedPublicPrefixPropertiesValidationState = "CertificateMissingInRoutingRegistry" + AdvertisedPublicPrefixPropertiesValidationStateConfigured AdvertisedPublicPrefixPropertiesValidationState = "Configured" + AdvertisedPublicPrefixPropertiesValidationStateConfiguring AdvertisedPublicPrefixPropertiesValidationState = "Configuring" + AdvertisedPublicPrefixPropertiesValidationStateInvalidSignatureEncoding AdvertisedPublicPrefixPropertiesValidationState = "InvalidSignatureEncoding" + AdvertisedPublicPrefixPropertiesValidationStateManualValidationNeeded AdvertisedPublicPrefixPropertiesValidationState = "ManualValidationNeeded" + AdvertisedPublicPrefixPropertiesValidationStateNotConfigured AdvertisedPublicPrefixPropertiesValidationState = "NotConfigured" + AdvertisedPublicPrefixPropertiesValidationStateSignatureVerificationFailed AdvertisedPublicPrefixPropertiesValidationState = "SignatureVerificationFailed" + AdvertisedPublicPrefixPropertiesValidationStateValidationFailed AdvertisedPublicPrefixPropertiesValidationState = "ValidationFailed" + AdvertisedPublicPrefixPropertiesValidationStateValidationNeeded AdvertisedPublicPrefixPropertiesValidationState = "ValidationNeeded" +) + +func PossibleValuesForAdvertisedPublicPrefixPropertiesValidationState() []string { + return []string{ + string(AdvertisedPublicPrefixPropertiesValidationStateAsnValidationFailed), + string(AdvertisedPublicPrefixPropertiesValidationStateCertificateMissingInRoutingRegistry), + string(AdvertisedPublicPrefixPropertiesValidationStateConfigured), + string(AdvertisedPublicPrefixPropertiesValidationStateConfiguring), + string(AdvertisedPublicPrefixPropertiesValidationStateInvalidSignatureEncoding), + string(AdvertisedPublicPrefixPropertiesValidationStateManualValidationNeeded), + string(AdvertisedPublicPrefixPropertiesValidationStateNotConfigured), + string(AdvertisedPublicPrefixPropertiesValidationStateSignatureVerificationFailed), + string(AdvertisedPublicPrefixPropertiesValidationStateValidationFailed), + string(AdvertisedPublicPrefixPropertiesValidationStateValidationNeeded), + } +} + +func (s *AdvertisedPublicPrefixPropertiesValidationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAdvertisedPublicPrefixPropertiesValidationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAdvertisedPublicPrefixPropertiesValidationState(input string) (*AdvertisedPublicPrefixPropertiesValidationState, error) { + vals := map[string]AdvertisedPublicPrefixPropertiesValidationState{ + "asnvalidationfailed": AdvertisedPublicPrefixPropertiesValidationStateAsnValidationFailed, + "certificatemissinginroutingregistry": AdvertisedPublicPrefixPropertiesValidationStateCertificateMissingInRoutingRegistry, + "configured": AdvertisedPublicPrefixPropertiesValidationStateConfigured, + "configuring": AdvertisedPublicPrefixPropertiesValidationStateConfiguring, + "invalidsignatureencoding": AdvertisedPublicPrefixPropertiesValidationStateInvalidSignatureEncoding, + "manualvalidationneeded": AdvertisedPublicPrefixPropertiesValidationStateManualValidationNeeded, + "notconfigured": AdvertisedPublicPrefixPropertiesValidationStateNotConfigured, + "signatureverificationfailed": AdvertisedPublicPrefixPropertiesValidationStateSignatureVerificationFailed, + "validationfailed": AdvertisedPublicPrefixPropertiesValidationStateValidationFailed, + "validationneeded": AdvertisedPublicPrefixPropertiesValidationStateValidationNeeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AdvertisedPublicPrefixPropertiesValidationState(input) + return &out, nil +} + +type CircuitConnectionStatus string + +const ( + CircuitConnectionStatusConnected CircuitConnectionStatus = "Connected" + CircuitConnectionStatusConnecting CircuitConnectionStatus = "Connecting" + CircuitConnectionStatusDisconnected CircuitConnectionStatus = "Disconnected" +) + +func PossibleValuesForCircuitConnectionStatus() []string { + return []string{ + string(CircuitConnectionStatusConnected), + string(CircuitConnectionStatusConnecting), + string(CircuitConnectionStatusDisconnected), + } +} + +func (s *CircuitConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCircuitConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCircuitConnectionStatus(input string) (*CircuitConnectionStatus, error) { + vals := map[string]CircuitConnectionStatus{ + "connected": CircuitConnectionStatusConnected, + "connecting": CircuitConnectionStatusConnecting, + "disconnected": CircuitConnectionStatusDisconnected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CircuitConnectionStatus(input) + return &out, nil +} + +type ExpressRouteCircuitPeeringAdvertisedPublicPrefixState string + +const ( + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfigured ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "Configured" + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfiguring ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "Configuring" + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateNotConfigured ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "NotConfigured" + ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateValidationNeeded ExpressRouteCircuitPeeringAdvertisedPublicPrefixState = "ValidationNeeded" +) + +func PossibleValuesForExpressRouteCircuitPeeringAdvertisedPublicPrefixState() []string { + return []string{ + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfigured), + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfiguring), + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateNotConfigured), + string(ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateValidationNeeded), + } +} + +func (s *ExpressRouteCircuitPeeringAdvertisedPublicPrefixState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteCircuitPeeringAdvertisedPublicPrefixState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteCircuitPeeringAdvertisedPublicPrefixState(input string) (*ExpressRouteCircuitPeeringAdvertisedPublicPrefixState, error) { + vals := map[string]ExpressRouteCircuitPeeringAdvertisedPublicPrefixState{ + "configured": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfigured, + "configuring": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateConfiguring, + "notconfigured": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateNotConfigured, + "validationneeded": ExpressRouteCircuitPeeringAdvertisedPublicPrefixStateValidationNeeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteCircuitPeeringAdvertisedPublicPrefixState(input) + return &out, nil +} + +type ExpressRouteCircuitPeeringState string + +const ( + ExpressRouteCircuitPeeringStateDisabled ExpressRouteCircuitPeeringState = "Disabled" + ExpressRouteCircuitPeeringStateEnabled ExpressRouteCircuitPeeringState = "Enabled" +) + +func PossibleValuesForExpressRouteCircuitPeeringState() []string { + return []string{ + string(ExpressRouteCircuitPeeringStateDisabled), + string(ExpressRouteCircuitPeeringStateEnabled), + } +} + +func (s *ExpressRouteCircuitPeeringState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRouteCircuitPeeringState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRouteCircuitPeeringState(input string) (*ExpressRouteCircuitPeeringState, error) { + vals := map[string]ExpressRouteCircuitPeeringState{ + "disabled": ExpressRouteCircuitPeeringStateDisabled, + "enabled": ExpressRouteCircuitPeeringStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRouteCircuitPeeringState(input) + return &out, nil +} + +type ExpressRoutePeeringState string + +const ( + ExpressRoutePeeringStateDisabled ExpressRoutePeeringState = "Disabled" + ExpressRoutePeeringStateEnabled ExpressRoutePeeringState = "Enabled" +) + +func PossibleValuesForExpressRoutePeeringState() []string { + return []string{ + string(ExpressRoutePeeringStateDisabled), + string(ExpressRoutePeeringStateEnabled), + } +} + +func (s *ExpressRoutePeeringState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRoutePeeringState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRoutePeeringState(input string) (*ExpressRoutePeeringState, error) { + vals := map[string]ExpressRoutePeeringState{ + "disabled": ExpressRoutePeeringStateDisabled, + "enabled": ExpressRoutePeeringStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRoutePeeringState(input) + return &out, nil +} + +type ExpressRoutePeeringType string + +const ( + ExpressRoutePeeringTypeAzurePrivatePeering ExpressRoutePeeringType = "AzurePrivatePeering" + ExpressRoutePeeringTypeAzurePublicPeering ExpressRoutePeeringType = "AzurePublicPeering" + ExpressRoutePeeringTypeMicrosoftPeering ExpressRoutePeeringType = "MicrosoftPeering" +) + +func PossibleValuesForExpressRoutePeeringType() []string { + return []string{ + string(ExpressRoutePeeringTypeAzurePrivatePeering), + string(ExpressRoutePeeringTypeAzurePublicPeering), + string(ExpressRoutePeeringTypeMicrosoftPeering), + } +} + +func (s *ExpressRoutePeeringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpressRoutePeeringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpressRoutePeeringType(input string) (*ExpressRoutePeeringType, error) { + vals := map[string]ExpressRoutePeeringType{ + "azureprivatepeering": ExpressRoutePeeringTypeAzurePrivatePeering, + "azurepublicpeering": ExpressRoutePeeringTypeAzurePublicPeering, + "microsoftpeering": ExpressRoutePeeringTypeMicrosoftPeering, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExpressRoutePeeringType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type RouteFilterRuleType string + +const ( + RouteFilterRuleTypeCommunity RouteFilterRuleType = "Community" +) + +func PossibleValuesForRouteFilterRuleType() []string { + return []string{ + string(RouteFilterRuleTypeCommunity), + } +} + +func (s *RouteFilterRuleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteFilterRuleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteFilterRuleType(input string) (*RouteFilterRuleType, error) { + vals := map[string]RouteFilterRuleType{ + "community": RouteFilterRuleTypeCommunity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteFilterRuleType(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/routefilters/id_routefilter.go b/resource-manager/network/2024-07-01/routefilters/id_routefilter.go new file mode 100644 index 00000000000..0e497c52d8b --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/id_routefilter.go @@ -0,0 +1,130 @@ +package routefilters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RouteFilterId{}) +} + +var _ resourceids.ResourceId = &RouteFilterId{} + +// RouteFilterId is a struct representing the Resource ID for a Route Filter +type RouteFilterId struct { + SubscriptionId string + ResourceGroupName string + RouteFilterName string +} + +// NewRouteFilterID returns a new RouteFilterId struct +func NewRouteFilterID(subscriptionId string, resourceGroupName string, routeFilterName string) RouteFilterId { + return RouteFilterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RouteFilterName: routeFilterName, + } +} + +// ParseRouteFilterID parses 'input' into a RouteFilterId +func ParseRouteFilterID(input string) (*RouteFilterId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteFilterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteFilterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRouteFilterIDInsensitively parses 'input' case-insensitively into a RouteFilterId +// note: this method should only be used for API response data and not user input +func ParseRouteFilterIDInsensitively(input string) (*RouteFilterId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteFilterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteFilterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RouteFilterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RouteFilterName, ok = input.Parsed["routeFilterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeFilterName", input) + } + + return nil +} + +// ValidateRouteFilterID checks that 'input' can be parsed as a Route Filter ID +func ValidateRouteFilterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRouteFilterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Route Filter ID +func (id RouteFilterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/routeFilters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RouteFilterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Route Filter ID +func (id RouteFilterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticRouteFilters", "routeFilters", "routeFilters"), + resourceids.UserSpecifiedSegment("routeFilterName", "routeFilterName"), + } +} + +// String returns a human-readable description of this Route Filter ID +func (id RouteFilterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Route Filter Name: %q", id.RouteFilterName), + } + return fmt.Sprintf("Route Filter (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/routefilters/id_routefilter_test.go b/resource-manager/network/2024-07-01/routefilters/id_routefilter_test.go new file mode 100644 index 00000000000..6eda9e98a41 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/id_routefilter_test.go @@ -0,0 +1,282 @@ +package routefilters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RouteFilterId{} + +func TestNewRouteFilterID(t *testing.T) { + id := NewRouteFilterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeFilterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RouteFilterName != "routeFilterName" { + t.Fatalf("Expected %q but got %q for Segment 'RouteFilterName'", id.RouteFilterName, "routeFilterName") + } +} + +func TestFormatRouteFilterID(t *testing.T) { + actual := NewRouteFilterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeFilterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRouteFilterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteFilterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName", + Expected: &RouteFilterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RouteFilterName: "routeFilterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteFilterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RouteFilterName != v.Expected.RouteFilterName { + t.Fatalf("Expected %q but got %q for RouteFilterName", v.Expected.RouteFilterName, actual.RouteFilterName) + } + + } +} + +func TestParseRouteFilterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteFilterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeFiLtErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName", + Expected: &RouteFilterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RouteFilterName: "routeFilterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeFilters/routeFilterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeFiLtErS/rOuTeFiLtErNaMe", + Expected: &RouteFilterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RouteFilterName: "rOuTeFiLtErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeFiLtErS/rOuTeFiLtErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteFilterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RouteFilterName != v.Expected.RouteFilterName { + t.Fatalf("Expected %q but got %q for RouteFilterName", v.Expected.RouteFilterName, actual.RouteFilterName) + } + + } +} + +func TestSegmentsForRouteFilterId(t *testing.T) { + segments := RouteFilterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RouteFilterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/routefilters/method_createorupdate.go b/resource-manager/network/2024-07-01/routefilters/method_createorupdate.go new file mode 100644 index 00000000000..4881008706e --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/method_createorupdate.go @@ -0,0 +1,75 @@ +package routefilters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RouteFilter +} + +// CreateOrUpdate ... +func (c RouteFiltersClient) CreateOrUpdate(ctx context.Context, id RouteFilterId, input RouteFilter) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c RouteFiltersClient) CreateOrUpdateThenPoll(ctx context.Context, id RouteFilterId, input RouteFilter) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/routefilters/method_delete.go b/resource-manager/network/2024-07-01/routefilters/method_delete.go new file mode 100644 index 00000000000..1a389b5108c --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/method_delete.go @@ -0,0 +1,71 @@ +package routefilters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c RouteFiltersClient) Delete(ctx context.Context, id RouteFilterId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c RouteFiltersClient) DeleteThenPoll(ctx context.Context, id RouteFilterId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/routefilters/method_get.go b/resource-manager/network/2024-07-01/routefilters/method_get.go new file mode 100644 index 00000000000..f57a061fb52 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/method_get.go @@ -0,0 +1,83 @@ +package routefilters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RouteFilter +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c RouteFiltersClient) Get(ctx context.Context, id RouteFilterId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RouteFilter + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/routefilters/method_list.go b/resource-manager/network/2024-07-01/routefilters/method_list.go new file mode 100644 index 00000000000..927387fb2da --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/method_list.go @@ -0,0 +1,106 @@ +package routefilters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RouteFilter +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RouteFilter +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c RouteFiltersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/routeFilters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RouteFilter `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c RouteFiltersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, RouteFilterOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RouteFiltersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate RouteFilterOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RouteFilter, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/routefilters/method_listbyresourcegroup.go b/resource-manager/network/2024-07-01/routefilters/method_listbyresourcegroup.go new file mode 100644 index 00000000000..256467e7de9 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package routefilters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RouteFilter +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []RouteFilter +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c RouteFiltersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/routeFilters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RouteFilter `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c RouteFiltersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, RouteFilterOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RouteFiltersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate RouteFilterOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]RouteFilter, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/routefilters/method_updatetags.go b/resource-manager/network/2024-07-01/routefilters/method_updatetags.go new file mode 100644 index 00000000000..5fe88949683 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/method_updatetags.go @@ -0,0 +1,57 @@ +package routefilters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RouteFilter +} + +// UpdateTags ... +func (c RouteFiltersClient) UpdateTags(ctx context.Context, id RouteFilterId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RouteFilter + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_advertisedpublicprefixproperties.go b/resource-manager/network/2024-07-01/routefilters/model_advertisedpublicprefixproperties.go new file mode 100644 index 00000000000..00cc052c75f --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_advertisedpublicprefixproperties.go @@ -0,0 +1,11 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdvertisedPublicPrefixProperties struct { + Prefix *string `json:"prefix,omitempty"` + Signature *string `json:"signature,omitempty"` + ValidationId *string `json:"validationId,omitempty"` + ValidationState *AdvertisedPublicPrefixPropertiesValidationState `json:"validationState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitconnection.go b/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitconnection.go new file mode 100644 index 00000000000..b4ee9836dca --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitconnection.go @@ -0,0 +1,12 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRouteCircuitConnectionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitconnectionpropertiesformat.go b/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitconnectionpropertiesformat.go new file mode 100644 index 00000000000..2e9948e07f4 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitconnectionpropertiesformat.go @@ -0,0 +1,14 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitConnectionPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AuthorizationKey *string `json:"authorizationKey,omitempty"` + CircuitConnectionStatus *CircuitConnectionStatus `json:"circuitConnectionStatus,omitempty"` + ExpressRouteCircuitPeering *SubResource `json:"expressRouteCircuitPeering,omitempty"` + IPv6CircuitConnectionConfig *IPv6CircuitConnectionConfig `json:"ipv6CircuitConnectionConfig,omitempty"` + PeerExpressRouteCircuitPeering *SubResource `json:"peerExpressRouteCircuitPeering,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitpeering.go b/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitpeering.go new file mode 100644 index 00000000000..79ef27f6ed8 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitpeering.go @@ -0,0 +1,12 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitPeering struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ExpressRouteCircuitPeeringPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitpeeringconfig.go b/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitpeeringconfig.go new file mode 100644 index 00000000000..089aa4b0ac8 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitpeeringconfig.go @@ -0,0 +1,14 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitPeeringConfig struct { + AdvertisedCommunities *[]string `json:"advertisedCommunities,omitempty"` + AdvertisedPublicPrefixInfo *[]AdvertisedPublicPrefixProperties `json:"advertisedPublicPrefixInfo,omitempty"` + AdvertisedPublicPrefixes *[]string `json:"advertisedPublicPrefixes,omitempty"` + AdvertisedPublicPrefixesState *ExpressRouteCircuitPeeringAdvertisedPublicPrefixState `json:"advertisedPublicPrefixesState,omitempty"` + CustomerASN *int64 `json:"customerASN,omitempty"` + LegacyMode *int64 `json:"legacyMode,omitempty"` + RoutingRegistryName *string `json:"routingRegistryName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitpeeringpropertiesformat.go b/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitpeeringpropertiesformat.go new file mode 100644 index 00000000000..1f5f8e7a726 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitpeeringpropertiesformat.go @@ -0,0 +1,27 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitPeeringPropertiesFormat struct { + AzureASN *int64 `json:"azureASN,omitempty"` + Connections *[]ExpressRouteCircuitConnection `json:"connections,omitempty"` + ExpressRouteConnection *ExpressRouteConnectionId `json:"expressRouteConnection,omitempty"` + GatewayManagerEtag *string `json:"gatewayManagerEtag,omitempty"` + IPv6PeeringConfig *IPv6ExpressRouteCircuitPeeringConfig `json:"ipv6PeeringConfig,omitempty"` + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + MicrosoftPeeringConfig *ExpressRouteCircuitPeeringConfig `json:"microsoftPeeringConfig,omitempty"` + PeerASN *int64 `json:"peerASN,omitempty"` + PeeredConnections *[]PeerExpressRouteCircuitConnection `json:"peeredConnections,omitempty"` + PeeringType *ExpressRoutePeeringType `json:"peeringType,omitempty"` + PrimaryAzurePort *string `json:"primaryAzurePort,omitempty"` + PrimaryPeerAddressPrefix *string `json:"primaryPeerAddressPrefix,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RouteFilter *SubResource `json:"routeFilter,omitempty"` + SecondaryAzurePort *string `json:"secondaryAzurePort,omitempty"` + SecondaryPeerAddressPrefix *string `json:"secondaryPeerAddressPrefix,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` + State *ExpressRoutePeeringState `json:"state,omitempty"` + Stats *ExpressRouteCircuitStats `json:"stats,omitempty"` + VlanId *int64 `json:"vlanId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitstats.go b/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitstats.go new file mode 100644 index 00000000000..b57109bba40 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_expressroutecircuitstats.go @@ -0,0 +1,11 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteCircuitStats struct { + PrimarybytesIn *int64 `json:"primarybytesIn,omitempty"` + PrimarybytesOut *int64 `json:"primarybytesOut,omitempty"` + SecondarybytesIn *int64 `json:"secondarybytesIn,omitempty"` + SecondarybytesOut *int64 `json:"secondarybytesOut,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_expressrouteconnectionid.go b/resource-manager/network/2024-07-01/routefilters/model_expressrouteconnectionid.go new file mode 100644 index 00000000000..8d033b8e0e1 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_expressrouteconnectionid.go @@ -0,0 +1,8 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteConnectionId struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_ipv6circuitconnectionconfig.go b/resource-manager/network/2024-07-01/routefilters/model_ipv6circuitconnectionconfig.go new file mode 100644 index 00000000000..036a19fa8aa --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_ipv6circuitconnectionconfig.go @@ -0,0 +1,9 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPv6CircuitConnectionConfig struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + CircuitConnectionStatus *CircuitConnectionStatus `json:"circuitConnectionStatus,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_ipv6expressroutecircuitpeeringconfig.go b/resource-manager/network/2024-07-01/routefilters/model_ipv6expressroutecircuitpeeringconfig.go new file mode 100644 index 00000000000..66f1810d2ef --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_ipv6expressroutecircuitpeeringconfig.go @@ -0,0 +1,12 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPv6ExpressRouteCircuitPeeringConfig struct { + MicrosoftPeeringConfig *ExpressRouteCircuitPeeringConfig `json:"microsoftPeeringConfig,omitempty"` + PrimaryPeerAddressPrefix *string `json:"primaryPeerAddressPrefix,omitempty"` + RouteFilter *SubResource `json:"routeFilter,omitempty"` + SecondaryPeerAddressPrefix *string `json:"secondaryPeerAddressPrefix,omitempty"` + State *ExpressRouteCircuitPeeringState `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_peerexpressroutecircuitconnection.go b/resource-manager/network/2024-07-01/routefilters/model_peerexpressroutecircuitconnection.go new file mode 100644 index 00000000000..1cceefb8321 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_peerexpressroutecircuitconnection.go @@ -0,0 +1,12 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PeerExpressRouteCircuitConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PeerExpressRouteCircuitConnectionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_peerexpressroutecircuitconnectionpropertiesformat.go b/resource-manager/network/2024-07-01/routefilters/model_peerexpressroutecircuitconnectionpropertiesformat.go new file mode 100644 index 00000000000..ae3652f5c1b --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_peerexpressroutecircuitconnectionpropertiesformat.go @@ -0,0 +1,14 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PeerExpressRouteCircuitConnectionPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AuthResourceGuid *string `json:"authResourceGuid,omitempty"` + CircuitConnectionStatus *CircuitConnectionStatus `json:"circuitConnectionStatus,omitempty"` + ConnectionName *string `json:"connectionName,omitempty"` + ExpressRouteCircuitPeering *SubResource `json:"expressRouteCircuitPeering,omitempty"` + PeerExpressRouteCircuitPeering *SubResource `json:"peerExpressRouteCircuitPeering,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_routefilter.go b/resource-manager/network/2024-07-01/routefilters/model_routefilter.go new file mode 100644 index 00000000000..932567d03cc --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_routefilter.go @@ -0,0 +1,14 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteFilter struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteFilterPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_routefilterpropertiesformat.go b/resource-manager/network/2024-07-01/routefilters/model_routefilterpropertiesformat.go new file mode 100644 index 00000000000..3442c803e11 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_routefilterpropertiesformat.go @@ -0,0 +1,11 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteFilterPropertiesFormat struct { + IPv6Peerings *[]ExpressRouteCircuitPeering `json:"ipv6Peerings,omitempty"` + Peerings *[]ExpressRouteCircuitPeering `json:"peerings,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Rules *[]RouteFilterRule `json:"rules,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_routefilterrule.go b/resource-manager/network/2024-07-01/routefilters/model_routefilterrule.go new file mode 100644 index 00000000000..7bce6e5cdbc --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_routefilterrule.go @@ -0,0 +1,12 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteFilterRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteFilterRulePropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_routefilterrulepropertiesformat.go b/resource-manager/network/2024-07-01/routefilters/model_routefilterrulepropertiesformat.go new file mode 100644 index 00000000000..70f71e0d28d --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_routefilterrulepropertiesformat.go @@ -0,0 +1,11 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteFilterRulePropertiesFormat struct { + Access Access `json:"access"` + Communities []string `json:"communities"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RouteFilterRuleType RouteFilterRuleType `json:"routeFilterRuleType"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_subresource.go b/resource-manager/network/2024-07-01/routefilters/model_subresource.go new file mode 100644 index 00000000000..18344aa65b5 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_subresource.go @@ -0,0 +1,8 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/model_tagsobject.go b/resource-manager/network/2024-07-01/routefilters/model_tagsobject.go new file mode 100644 index 00000000000..7657d1402ea --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/model_tagsobject.go @@ -0,0 +1,8 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routefilters/predicates.go b/resource-manager/network/2024-07-01/routefilters/predicates.go new file mode 100644 index 00000000000..333d40af18b --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/predicates.go @@ -0,0 +1,37 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteFilterOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p RouteFilterOperationPredicate) Matches(input RouteFilter) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/routefilters/version.go b/resource-manager/network/2024-07-01/routefilters/version.go new file mode 100644 index 00000000000..be735267008 --- /dev/null +++ b/resource-manager/network/2024-07-01/routefilters/version.go @@ -0,0 +1,10 @@ +package routefilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/routefilters/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/routes/README.md b/resource-manager/network/2024-07-01/routes/README.md new file mode 100644 index 00000000000..aab41b81892 --- /dev/null +++ b/resource-manager/network/2024-07-01/routes/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routes` Documentation + +The `routes` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routes" +``` + + +### Client Initialization + +```go +client := routes.NewRoutesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RoutesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := routes.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeTableName", "routeName") + +payload := routes.Route{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `RoutesClient.Delete` + +```go +ctx := context.TODO() +id := routes.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeTableName", "routeName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `RoutesClient.Get` + +```go +ctx := context.TODO() +id := routes.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeTableName", "routeName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RoutesClient.List` + +```go +ctx := context.TODO() +id := routes.NewRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeTableName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/routes/client.go b/resource-manager/network/2024-07-01/routes/client.go new file mode 100644 index 00000000000..88e9f135cd1 --- /dev/null +++ b/resource-manager/network/2024-07-01/routes/client.go @@ -0,0 +1,26 @@ +package routes + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutesClient struct { + Client *resourcemanager.Client +} + +func NewRoutesClientWithBaseURI(sdkApi sdkEnv.Api) (*RoutesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "routes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RoutesClient: %+v", err) + } + + return &RoutesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/routes/constants.go b/resource-manager/network/2024-07-01/routes/constants.go new file mode 100644 index 00000000000..e26bed906c5 --- /dev/null +++ b/resource-manager/network/2024-07-01/routes/constants.go @@ -0,0 +1,107 @@ +package routes + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/routes/id_route.go b/resource-manager/network/2024-07-01/routes/id_route.go new file mode 100644 index 00000000000..55f4d71097a --- /dev/null +++ b/resource-manager/network/2024-07-01/routes/id_route.go @@ -0,0 +1,139 @@ +package routes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RouteId{}) +} + +var _ resourceids.ResourceId = &RouteId{} + +// RouteId is a struct representing the Resource ID for a Route +type RouteId struct { + SubscriptionId string + ResourceGroupName string + RouteTableName string + RouteName string +} + +// NewRouteID returns a new RouteId struct +func NewRouteID(subscriptionId string, resourceGroupName string, routeTableName string, routeName string) RouteId { + return RouteId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RouteTableName: routeTableName, + RouteName: routeName, + } +} + +// ParseRouteID parses 'input' into a RouteId +func ParseRouteID(input string) (*RouteId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRouteIDInsensitively parses 'input' case-insensitively into a RouteId +// note: this method should only be used for API response data and not user input +func ParseRouteIDInsensitively(input string) (*RouteId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RouteId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RouteTableName, ok = input.Parsed["routeTableName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeTableName", input) + } + + if id.RouteName, ok = input.Parsed["routeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeName", input) + } + + return nil +} + +// ValidateRouteID checks that 'input' can be parsed as a Route ID +func ValidateRouteID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRouteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Route ID +func (id RouteId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/routeTables/%s/routes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RouteTableName, id.RouteName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Route ID +func (id RouteId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticRouteTables", "routeTables", "routeTables"), + resourceids.UserSpecifiedSegment("routeTableName", "routeTableName"), + resourceids.StaticSegment("staticRoutes", "routes", "routes"), + resourceids.UserSpecifiedSegment("routeName", "routeName"), + } +} + +// String returns a human-readable description of this Route ID +func (id RouteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Route Table Name: %q", id.RouteTableName), + fmt.Sprintf("Route Name: %q", id.RouteName), + } + return fmt.Sprintf("Route (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/routes/id_route_test.go b/resource-manager/network/2024-07-01/routes/id_route_test.go new file mode 100644 index 00000000000..dd78f504e34 --- /dev/null +++ b/resource-manager/network/2024-07-01/routes/id_route_test.go @@ -0,0 +1,327 @@ +package routes + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RouteId{} + +func TestNewRouteID(t *testing.T) { + id := NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeTableName", "routeName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RouteTableName != "routeTableName" { + t.Fatalf("Expected %q but got %q for Segment 'RouteTableName'", id.RouteTableName, "routeTableName") + } + + if id.RouteName != "routeName" { + t.Fatalf("Expected %q but got %q for Segment 'RouteName'", id.RouteName, "routeName") + } +} + +func TestFormatRouteID(t *testing.T) { + actual := NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeTableName", "routeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName/routes/routeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRouteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName/routes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName/routes/routeName", + Expected: &RouteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RouteTableName: "routeTableName", + RouteName: "routeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName/routes/routeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RouteTableName != v.Expected.RouteTableName { + t.Fatalf("Expected %q but got %q for RouteTableName", v.Expected.RouteTableName, actual.RouteTableName) + } + + if actual.RouteName != v.Expected.RouteName { + t.Fatalf("Expected %q but got %q for RouteName", v.Expected.RouteName, actual.RouteName) + } + + } +} + +func TestParseRouteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeTaBlEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeTaBlEs/rOuTeTaBlEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName/routes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeTaBlEs/rOuTeTaBlEnAmE/rOuTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName/routes/routeName", + Expected: &RouteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RouteTableName: "routeTableName", + RouteName: "routeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName/routes/routeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeTaBlEs/rOuTeTaBlEnAmE/rOuTeS/rOuTeNaMe", + Expected: &RouteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RouteTableName: "rOuTeTaBlEnAmE", + RouteName: "rOuTeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeTaBlEs/rOuTeTaBlEnAmE/rOuTeS/rOuTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RouteTableName != v.Expected.RouteTableName { + t.Fatalf("Expected %q but got %q for RouteTableName", v.Expected.RouteTableName, actual.RouteTableName) + } + + if actual.RouteName != v.Expected.RouteName { + t.Fatalf("Expected %q but got %q for RouteName", v.Expected.RouteName, actual.RouteName) + } + + } +} + +func TestSegmentsForRouteId(t *testing.T) { + segments := RouteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RouteId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/routes/id_routetable.go b/resource-manager/network/2024-07-01/routes/id_routetable.go new file mode 100644 index 00000000000..3fc7a015224 --- /dev/null +++ b/resource-manager/network/2024-07-01/routes/id_routetable.go @@ -0,0 +1,130 @@ +package routes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RouteTableId{}) +} + +var _ resourceids.ResourceId = &RouteTableId{} + +// RouteTableId is a struct representing the Resource ID for a Route Table +type RouteTableId struct { + SubscriptionId string + ResourceGroupName string + RouteTableName string +} + +// NewRouteTableID returns a new RouteTableId struct +func NewRouteTableID(subscriptionId string, resourceGroupName string, routeTableName string) RouteTableId { + return RouteTableId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RouteTableName: routeTableName, + } +} + +// ParseRouteTableID parses 'input' into a RouteTableId +func ParseRouteTableID(input string) (*RouteTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteTableId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRouteTableIDInsensitively parses 'input' case-insensitively into a RouteTableId +// note: this method should only be used for API response data and not user input +func ParseRouteTableIDInsensitively(input string) (*RouteTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteTableId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RouteTableId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RouteTableName, ok = input.Parsed["routeTableName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeTableName", input) + } + + return nil +} + +// ValidateRouteTableID checks that 'input' can be parsed as a Route Table ID +func ValidateRouteTableID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRouteTableID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Route Table ID +func (id RouteTableId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/routeTables/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RouteTableName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Route Table ID +func (id RouteTableId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticRouteTables", "routeTables", "routeTables"), + resourceids.UserSpecifiedSegment("routeTableName", "routeTableName"), + } +} + +// String returns a human-readable description of this Route Table ID +func (id RouteTableId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Route Table Name: %q", id.RouteTableName), + } + return fmt.Sprintf("Route Table (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/routes/id_routetable_test.go b/resource-manager/network/2024-07-01/routes/id_routetable_test.go new file mode 100644 index 00000000000..3a87898b842 --- /dev/null +++ b/resource-manager/network/2024-07-01/routes/id_routetable_test.go @@ -0,0 +1,282 @@ +package routes + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RouteTableId{} + +func TestNewRouteTableID(t *testing.T) { + id := NewRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeTableName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RouteTableName != "routeTableName" { + t.Fatalf("Expected %q but got %q for Segment 'RouteTableName'", id.RouteTableName, "routeTableName") + } +} + +func TestFormatRouteTableID(t *testing.T) { + actual := NewRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeTableName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRouteTableID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName", + Expected: &RouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RouteTableName: "routeTableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteTableID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RouteTableName != v.Expected.RouteTableName { + t.Fatalf("Expected %q but got %q for RouteTableName", v.Expected.RouteTableName, actual.RouteTableName) + } + + } +} + +func TestParseRouteTableIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeTaBlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName", + Expected: &RouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RouteTableName: "routeTableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeTaBlEs/rOuTeTaBlEnAmE", + Expected: &RouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RouteTableName: "rOuTeTaBlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeTaBlEs/rOuTeTaBlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteTableIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RouteTableName != v.Expected.RouteTableName { + t.Fatalf("Expected %q but got %q for RouteTableName", v.Expected.RouteTableName, actual.RouteTableName) + } + + } +} + +func TestSegmentsForRouteTableId(t *testing.T) { + segments := RouteTableId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RouteTableId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/routes/method_createorupdate.go b/resource-manager/network/2024-07-01/routes/method_createorupdate.go new file mode 100644 index 00000000000..29b466f45ef --- /dev/null +++ b/resource-manager/network/2024-07-01/routes/method_createorupdate.go @@ -0,0 +1,75 @@ +package routes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Route +} + +// CreateOrUpdate ... +func (c RoutesClient) CreateOrUpdate(ctx context.Context, id RouteId, input Route) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c RoutesClient) CreateOrUpdateThenPoll(ctx context.Context, id RouteId, input Route) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/routes/method_delete.go b/resource-manager/network/2024-07-01/routes/method_delete.go new file mode 100644 index 00000000000..f6cee23c133 --- /dev/null +++ b/resource-manager/network/2024-07-01/routes/method_delete.go @@ -0,0 +1,71 @@ +package routes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c RoutesClient) Delete(ctx context.Context, id RouteId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c RoutesClient) DeleteThenPoll(ctx context.Context, id RouteId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/routes/method_get.go b/resource-manager/network/2024-07-01/routes/method_get.go new file mode 100644 index 00000000000..306c6528c39 --- /dev/null +++ b/resource-manager/network/2024-07-01/routes/method_get.go @@ -0,0 +1,53 @@ +package routes + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Route +} + +// Get ... +func (c RoutesClient) Get(ctx context.Context, id RouteId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Route + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/routes/method_list.go b/resource-manager/network/2024-07-01/routes/method_list.go new file mode 100644 index 00000000000..dddfb46f64c --- /dev/null +++ b/resource-manager/network/2024-07-01/routes/method_list.go @@ -0,0 +1,105 @@ +package routes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Route +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Route +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c RoutesClient) List(ctx context.Context, id RouteTableId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/routes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Route `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c RoutesClient) ListComplete(ctx context.Context, id RouteTableId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, RouteOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RoutesClient) ListCompleteMatchingPredicate(ctx context.Context, id RouteTableId, predicate RouteOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Route, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/routes/model_route.go b/resource-manager/network/2024-07-01/routes/model_route.go new file mode 100644 index 00000000000..364b3bb3322 --- /dev/null +++ b/resource-manager/network/2024-07-01/routes/model_route.go @@ -0,0 +1,12 @@ +package routes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routes/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/routes/model_routepropertiesformat.go new file mode 100644 index 00000000000..82a30d0f4e0 --- /dev/null +++ b/resource-manager/network/2024-07-01/routes/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package routes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routes/predicates.go b/resource-manager/network/2024-07-01/routes/predicates.go new file mode 100644 index 00000000000..b0ff24a6573 --- /dev/null +++ b/resource-manager/network/2024-07-01/routes/predicates.go @@ -0,0 +1,32 @@ +package routes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p RouteOperationPredicate) Matches(input Route) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/routes/version.go b/resource-manager/network/2024-07-01/routes/version.go new file mode 100644 index 00000000000..6c93d801739 --- /dev/null +++ b/resource-manager/network/2024-07-01/routes/version.go @@ -0,0 +1,10 @@ +package routes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/routes/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/routetables/README.md b/resource-manager/network/2024-07-01/routetables/README.md new file mode 100644 index 00000000000..702e80d1598 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routetables` Documentation + +The `routetables` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routetables" +``` + + +### Client Initialization + +```go +client := routetables.NewRouteTablesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RouteTablesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := routetables.NewRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeTableName") + +payload := routetables.RouteTable{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `RouteTablesClient.Delete` + +```go +ctx := context.TODO() +id := routetables.NewRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeTableName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `RouteTablesClient.Get` + +```go +ctx := context.TODO() +id := routetables.NewRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeTableName") + +read, err := client.Get(ctx, id, routetables.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RouteTablesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RouteTablesClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RouteTablesClient.UpdateTags` + +```go +ctx := context.TODO() +id := routetables.NewRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeTableName") + +payload := routetables.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/routetables/client.go b/resource-manager/network/2024-07-01/routetables/client.go new file mode 100644 index 00000000000..b52049cd5f7 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/client.go @@ -0,0 +1,26 @@ +package routetables + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablesClient struct { + Client *resourcemanager.Client +} + +func NewRouteTablesClientWithBaseURI(sdkApi sdkEnv.Api) (*RouteTablesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "routetables", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RouteTablesClient: %+v", err) + } + + return &RouteTablesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/routetables/constants.go b/resource-manager/network/2024-07-01/routetables/constants.go new file mode 100644 index 00000000000..348c239ac5b --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/constants.go @@ -0,0 +1,1204 @@ +package routetables + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/routetables/id_routetable.go b/resource-manager/network/2024-07-01/routetables/id_routetable.go new file mode 100644 index 00000000000..a18bf05ff67 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/id_routetable.go @@ -0,0 +1,130 @@ +package routetables + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RouteTableId{}) +} + +var _ resourceids.ResourceId = &RouteTableId{} + +// RouteTableId is a struct representing the Resource ID for a Route Table +type RouteTableId struct { + SubscriptionId string + ResourceGroupName string + RouteTableName string +} + +// NewRouteTableID returns a new RouteTableId struct +func NewRouteTableID(subscriptionId string, resourceGroupName string, routeTableName string) RouteTableId { + return RouteTableId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RouteTableName: routeTableName, + } +} + +// ParseRouteTableID parses 'input' into a RouteTableId +func ParseRouteTableID(input string) (*RouteTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteTableId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRouteTableIDInsensitively parses 'input' case-insensitively into a RouteTableId +// note: this method should only be used for API response data and not user input +func ParseRouteTableIDInsensitively(input string) (*RouteTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteTableId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RouteTableId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RouteTableName, ok = input.Parsed["routeTableName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeTableName", input) + } + + return nil +} + +// ValidateRouteTableID checks that 'input' can be parsed as a Route Table ID +func ValidateRouteTableID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRouteTableID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Route Table ID +func (id RouteTableId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/routeTables/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RouteTableName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Route Table ID +func (id RouteTableId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticRouteTables", "routeTables", "routeTables"), + resourceids.UserSpecifiedSegment("routeTableName", "routeTableName"), + } +} + +// String returns a human-readable description of this Route Table ID +func (id RouteTableId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Route Table Name: %q", id.RouteTableName), + } + return fmt.Sprintf("Route Table (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/routetables/id_routetable_test.go b/resource-manager/network/2024-07-01/routetables/id_routetable_test.go new file mode 100644 index 00000000000..6d1b3ad4c25 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/id_routetable_test.go @@ -0,0 +1,282 @@ +package routetables + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RouteTableId{} + +func TestNewRouteTableID(t *testing.T) { + id := NewRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeTableName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RouteTableName != "routeTableName" { + t.Fatalf("Expected %q but got %q for Segment 'RouteTableName'", id.RouteTableName, "routeTableName") + } +} + +func TestFormatRouteTableID(t *testing.T) { + actual := NewRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "routeTableName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRouteTableID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName", + Expected: &RouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RouteTableName: "routeTableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteTableID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RouteTableName != v.Expected.RouteTableName { + t.Fatalf("Expected %q but got %q for RouteTableName", v.Expected.RouteTableName, actual.RouteTableName) + } + + } +} + +func TestParseRouteTableIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeTaBlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName", + Expected: &RouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RouteTableName: "routeTableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/routeTables/routeTableName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeTaBlEs/rOuTeTaBlEnAmE", + Expected: &RouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RouteTableName: "rOuTeTaBlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/rOuTeTaBlEs/rOuTeTaBlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteTableIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RouteTableName != v.Expected.RouteTableName { + t.Fatalf("Expected %q but got %q for RouteTableName", v.Expected.RouteTableName, actual.RouteTableName) + } + + } +} + +func TestSegmentsForRouteTableId(t *testing.T) { + segments := RouteTableId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RouteTableId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/routetables/method_createorupdate.go b/resource-manager/network/2024-07-01/routetables/method_createorupdate.go new file mode 100644 index 00000000000..04fdd62101d --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/method_createorupdate.go @@ -0,0 +1,75 @@ +package routetables + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RouteTable +} + +// CreateOrUpdate ... +func (c RouteTablesClient) CreateOrUpdate(ctx context.Context, id RouteTableId, input RouteTable) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c RouteTablesClient) CreateOrUpdateThenPoll(ctx context.Context, id RouteTableId, input RouteTable) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/routetables/method_delete.go b/resource-manager/network/2024-07-01/routetables/method_delete.go new file mode 100644 index 00000000000..6ef6e0e531d --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/method_delete.go @@ -0,0 +1,71 @@ +package routetables + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c RouteTablesClient) Delete(ctx context.Context, id RouteTableId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c RouteTablesClient) DeleteThenPoll(ctx context.Context, id RouteTableId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/routetables/method_get.go b/resource-manager/network/2024-07-01/routetables/method_get.go new file mode 100644 index 00000000000..6a2409acbfb --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/method_get.go @@ -0,0 +1,83 @@ +package routetables + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RouteTable +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c RouteTablesClient) Get(ctx context.Context, id RouteTableId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RouteTable + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/routetables/method_list.go b/resource-manager/network/2024-07-01/routetables/method_list.go new file mode 100644 index 00000000000..c219fd770ef --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/method_list.go @@ -0,0 +1,106 @@ +package routetables + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RouteTable +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RouteTable +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c RouteTablesClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/routeTables", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RouteTable `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c RouteTablesClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, RouteTableOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RouteTablesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate RouteTableOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RouteTable, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/routetables/method_listall.go b/resource-manager/network/2024-07-01/routetables/method_listall.go new file mode 100644 index 00000000000..c3c8de7e20d --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/method_listall.go @@ -0,0 +1,106 @@ +package routetables + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RouteTable +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []RouteTable +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c RouteTablesClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/routeTables", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RouteTable `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c RouteTablesClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, RouteTableOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RouteTablesClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate RouteTableOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]RouteTable, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/routetables/method_updatetags.go b/resource-manager/network/2024-07-01/routetables/method_updatetags.go new file mode 100644 index 00000000000..258335fc600 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/method_updatetags.go @@ -0,0 +1,57 @@ +package routetables + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RouteTable +} + +// UpdateTags ... +func (c RouteTablesClient) UpdateTags(ctx context.Context, id RouteTableId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RouteTable + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/routetables/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/routetables/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..3f1666af192 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/routetables/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..aa535e08a6a --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..26b2afe4fb6 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/routetables/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..2474ea7f89e --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..b0ea966f8a5 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/routetables/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..da94563b915 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..d270ac905b2 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_backendaddresspool.go b/resource-manager/network/2024-07-01/routetables/model_backendaddresspool.go new file mode 100644 index 00000000000..90a55576b63 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..34067eb4dc7 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..d85f90834ef --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_ddossettings.go b/resource-manager/network/2024-07-01/routetables/model_ddossettings.go new file mode 100644 index 00000000000..ffd9663e361 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_ddossettings.go @@ -0,0 +1,9 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_delegation.go b/resource-manager/network/2024-07-01/routetables/model_delegation.go new file mode 100644 index 00000000000..2098ca8ace8 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_delegation.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_flowlog.go b/resource-manager/network/2024-07-01/routetables/model_flowlog.go new file mode 100644 index 00000000000..34743bfa20f --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_flowlog.go @@ -0,0 +1,19 @@ +package routetables + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/routetables/model_flowlogformatparameters.go new file mode 100644 index 00000000000..46d83a48283 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..8a24bb94c55 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/routetables/model_frontendipconfiguration.go new file mode 100644 index 00000000000..15308372f3a --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package routetables + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..c3ba5e8cb16 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/routetables/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..f99a910776d --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_inboundnatrule.go b/resource-manager/network/2024-07-01/routetables/model_inboundnatrule.go new file mode 100644 index 00000000000..b540b7a4ff5 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..5fa1c54256c --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/routetables/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..1adc5179025 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/routetables/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..b1e395f98bb --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_ipconfiguration.go b/resource-manager/network/2024-07-01/routetables/model_ipconfiguration.go new file mode 100644 index 00000000000..7f86bd442fd --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/routetables/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..10063b56d94 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..8be23ea8407 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..33538e3da04 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_iptag.go b/resource-manager/network/2024-07-01/routetables/model_iptag.go new file mode 100644 index 00000000000..0591a6fbb81 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_iptag.go @@ -0,0 +1,9 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/routetables/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..6eb63262bd2 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..b4070586d52 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_natgateway.go b/resource-manager/network/2024-07-01/routetables/model_natgateway.go new file mode 100644 index 00000000000..cdcecbfa098 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_natgateway.go @@ -0,0 +1,20 @@ +package routetables + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..4c4b841b1e9 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_natgatewaysku.go b/resource-manager/network/2024-07-01/routetables/model_natgatewaysku.go new file mode 100644 index 00000000000..8e15e8b1250 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_natruleportmapping.go b/resource-manager/network/2024-07-01/routetables/model_natruleportmapping.go new file mode 100644 index 00000000000..665d5f253ce --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_networkinterface.go b/resource-manager/network/2024-07-01/routetables/model_networkinterface.go new file mode 100644 index 00000000000..fac5f0869e6 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_networkinterface.go @@ -0,0 +1,19 @@ +package routetables + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/routetables/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..9d476ca2642 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/routetables/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..7db216219a1 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/routetables/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..60fdba4dd13 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..e81aa38f5f9 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..d8ad8727b87 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/routetables/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..6f876f8ce53 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..fbd84b3af86 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/routetables/model_networksecuritygroup.go new file mode 100644 index 00000000000..84c0fadac17 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..633f7012e04 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_privateendpoint.go b/resource-manager/network/2024-07-01/routetables/model_privateendpoint.go new file mode 100644 index 00000000000..80308b3a2a6 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_privateendpoint.go @@ -0,0 +1,19 @@ +package routetables + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/routetables/model_privateendpointconnection.go new file mode 100644 index 00000000000..0e503458e9c --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/routetables/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..f8d3eeab02b --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/routetables/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..de4e0254405 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/routetables/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..1ba73d98f4a --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/routetables/model_privateendpointproperties.go new file mode 100644 index 00000000000..3d92a4a92e1 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_privatelinkservice.go b/resource-manager/network/2024-07-01/routetables/model_privatelinkservice.go new file mode 100644 index 00000000000..29bf0cf5834 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package routetables + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..4adf690c566 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..063a4faec37 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..3b1634cb059 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..e3ad61faa8f --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..430eebd19ae --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..7be9cd6ea0f --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_publicipaddress.go b/resource-manager/network/2024-07-01/routetables/model_publicipaddress.go new file mode 100644 index 00000000000..8248c499a22 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_publicipaddress.go @@ -0,0 +1,22 @@ +package routetables + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/routetables/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..84b1e72e903 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..ba0c692ec23 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/routetables/model_publicipaddresssku.go new file mode 100644 index 00000000000..956c758896f --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/routetables/model_resourcenavigationlink.go new file mode 100644 index 00000000000..c5d74e0472b --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/routetables/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..eca6b593c69 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_resourceset.go b/resource-manager/network/2024-07-01/routetables/model_resourceset.go new file mode 100644 index 00000000000..8a57a8fb40d --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_resourceset.go @@ -0,0 +1,8 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/routetables/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..37bad49cdcb --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_route.go b/resource-manager/network/2024-07-01/routetables/model_route.go new file mode 100644 index 00000000000..10c17005b28 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_route.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_routepropertiesformat.go new file mode 100644 index 00000000000..028abe93e73 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_routetable.go b/resource-manager/network/2024-07-01/routetables/model_routetable.go new file mode 100644 index 00000000000..1b2bb754997 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_routetable.go @@ -0,0 +1,14 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..64470e39699 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_securityrule.go b/resource-manager/network/2024-07-01/routetables/model_securityrule.go new file mode 100644 index 00000000000..ab6f4a35210 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_securityrule.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..636af5195f0 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/routetables/model_serviceassociationlink.go new file mode 100644 index 00000000000..682b3659989 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..7ed4a93de00 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..fba1a21dc46 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/routetables/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..c941578ec3f --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/routetables/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..6a6135ec206 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..a9fcdcec846 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..25a22cda3fd --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..3f11f7d1bad --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_subnet.go b/resource-manager/network/2024-07-01/routetables/model_subnet.go new file mode 100644 index 00000000000..949e07613d6 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_subnet.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..dc85cf44555 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_subresource.go b/resource-manager/network/2024-07-01/routetables/model_subresource.go new file mode 100644 index 00000000000..eab315946e0 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_subresource.go @@ -0,0 +1,8 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_tagsobject.go b/resource-manager/network/2024-07-01/routetables/model_tagsobject.go new file mode 100644 index 00000000000..61b33687ad4 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_tagsobject.go @@ -0,0 +1,8 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/routetables/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..e02ff0c097e --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/routetables/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..d88b7ea067e --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/routetables/model_virtualnetworktap.go new file mode 100644 index 00000000000..7551bed07c8 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/routetables/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..2094070851f --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routetables/predicates.go b/resource-manager/network/2024-07-01/routetables/predicates.go new file mode 100644 index 00000000000..e1d89b9fbd4 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/predicates.go @@ -0,0 +1,37 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTableOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p RouteTableOperationPredicate) Matches(input RouteTable) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/routetables/version.go b/resource-manager/network/2024-07-01/routetables/version.go new file mode 100644 index 00000000000..36d5052fa98 --- /dev/null +++ b/resource-manager/network/2024-07-01/routetables/version.go @@ -0,0 +1,10 @@ +package routetables + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/routetables/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/routingrulecollections/README.md b/resource-manager/network/2024-07-01/routingrulecollections/README.md new file mode 100644 index 00000000000..671cf72ce9b --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrulecollections/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routingrulecollections` Documentation + +The `routingrulecollections` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routingrulecollections" +``` + + +### Client Initialization + +```go +client := routingrulecollections.NewRoutingRuleCollectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RoutingRuleCollectionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := routingrulecollections.NewRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName", "ruleCollectionName") + +payload := routingrulecollections.RoutingRuleCollection{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RoutingRuleCollectionsClient.Delete` + +```go +ctx := context.TODO() +id := routingrulecollections.NewRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName", "ruleCollectionName") + +if err := client.DeleteThenPoll(ctx, id, routingrulecollections.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `RoutingRuleCollectionsClient.Get` + +```go +ctx := context.TODO() +id := routingrulecollections.NewRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName", "ruleCollectionName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RoutingRuleCollectionsClient.List` + +```go +ctx := context.TODO() +id := routingrulecollections.NewRoutingConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName") + +// alternatively `client.List(ctx, id, routingrulecollections.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, routingrulecollections.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/routingrulecollections/client.go b/resource-manager/network/2024-07-01/routingrulecollections/client.go new file mode 100644 index 00000000000..23d57a92201 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrulecollections/client.go @@ -0,0 +1,26 @@ +package routingrulecollections + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingRuleCollectionsClient struct { + Client *resourcemanager.Client +} + +func NewRoutingRuleCollectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*RoutingRuleCollectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "routingrulecollections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RoutingRuleCollectionsClient: %+v", err) + } + + return &RoutingRuleCollectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/routingrulecollections/constants.go b/resource-manager/network/2024-07-01/routingrulecollections/constants.go new file mode 100644 index 00000000000..3f69337d898 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrulecollections/constants.go @@ -0,0 +1,98 @@ +package routingrulecollections + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DisableBgpRoutePropagation string + +const ( + DisableBgpRoutePropagationFalse DisableBgpRoutePropagation = "False" + DisableBgpRoutePropagationTrue DisableBgpRoutePropagation = "True" +) + +func PossibleValuesForDisableBgpRoutePropagation() []string { + return []string{ + string(DisableBgpRoutePropagationFalse), + string(DisableBgpRoutePropagationTrue), + } +} + +func (s *DisableBgpRoutePropagation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDisableBgpRoutePropagation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDisableBgpRoutePropagation(input string) (*DisableBgpRoutePropagation, error) { + vals := map[string]DisableBgpRoutePropagation{ + "false": DisableBgpRoutePropagationFalse, + "true": DisableBgpRoutePropagationTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DisableBgpRoutePropagation(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/routingrulecollections/id_routingconfiguration.go b/resource-manager/network/2024-07-01/routingrulecollections/id_routingconfiguration.go new file mode 100644 index 00000000000..1f12375338a --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrulecollections/id_routingconfiguration.go @@ -0,0 +1,139 @@ +package routingrulecollections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RoutingConfigurationId{}) +} + +var _ resourceids.ResourceId = &RoutingConfigurationId{} + +// RoutingConfigurationId is a struct representing the Resource ID for a Routing Configuration +type RoutingConfigurationId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + RoutingConfigurationName string +} + +// NewRoutingConfigurationID returns a new RoutingConfigurationId struct +func NewRoutingConfigurationID(subscriptionId string, resourceGroupName string, networkManagerName string, routingConfigurationName string) RoutingConfigurationId { + return RoutingConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + RoutingConfigurationName: routingConfigurationName, + } +} + +// ParseRoutingConfigurationID parses 'input' into a RoutingConfigurationId +func ParseRoutingConfigurationID(input string) (*RoutingConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&RoutingConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RoutingConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRoutingConfigurationIDInsensitively parses 'input' case-insensitively into a RoutingConfigurationId +// note: this method should only be used for API response data and not user input +func ParseRoutingConfigurationIDInsensitively(input string) (*RoutingConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&RoutingConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RoutingConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RoutingConfigurationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.RoutingConfigurationName, ok = input.Parsed["routingConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routingConfigurationName", input) + } + + return nil +} + +// ValidateRoutingConfigurationID checks that 'input' can be parsed as a Routing Configuration ID +func ValidateRoutingConfigurationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRoutingConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Routing Configuration ID +func (id RoutingConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/routingConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.RoutingConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Routing Configuration ID +func (id RoutingConfigurationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticRoutingConfigurations", "routingConfigurations", "routingConfigurations"), + resourceids.UserSpecifiedSegment("routingConfigurationName", "routingConfigurationName"), + } +} + +// String returns a human-readable description of this Routing Configuration ID +func (id RoutingConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Routing Configuration Name: %q", id.RoutingConfigurationName), + } + return fmt.Sprintf("Routing Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/routingrulecollections/id_routingconfiguration_test.go b/resource-manager/network/2024-07-01/routingrulecollections/id_routingconfiguration_test.go new file mode 100644 index 00000000000..1181a338915 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrulecollections/id_routingconfiguration_test.go @@ -0,0 +1,327 @@ +package routingrulecollections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RoutingConfigurationId{} + +func TestNewRoutingConfigurationID(t *testing.T) { + id := NewRoutingConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.RoutingConfigurationName != "routingConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'RoutingConfigurationName'", id.RoutingConfigurationName, "routingConfigurationName") + } +} + +func TestFormatRoutingConfigurationID(t *testing.T) { + actual := NewRoutingConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRoutingConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RoutingConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName", + Expected: &RoutingConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + RoutingConfigurationName: "routingConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRoutingConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.RoutingConfigurationName != v.Expected.RoutingConfigurationName { + t.Fatalf("Expected %q but got %q for RoutingConfigurationName", v.Expected.RoutingConfigurationName, actual.RoutingConfigurationName) + } + + } +} + +func TestParseRoutingConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RoutingConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName", + Expected: &RoutingConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + RoutingConfigurationName: "routingConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE", + Expected: &RoutingConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + RoutingConfigurationName: "rOuTiNgCoNfIgUrAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRoutingConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.RoutingConfigurationName != v.Expected.RoutingConfigurationName { + t.Fatalf("Expected %q but got %q for RoutingConfigurationName", v.Expected.RoutingConfigurationName, actual.RoutingConfigurationName) + } + + } +} + +func TestSegmentsForRoutingConfigurationId(t *testing.T) { + segments := RoutingConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RoutingConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/routingrulecollections/id_rulecollection.go b/resource-manager/network/2024-07-01/routingrulecollections/id_rulecollection.go new file mode 100644 index 00000000000..a6828c64486 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrulecollections/id_rulecollection.go @@ -0,0 +1,148 @@ +package routingrulecollections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RuleCollectionId{}) +} + +var _ resourceids.ResourceId = &RuleCollectionId{} + +// RuleCollectionId is a struct representing the Resource ID for a Rule Collection +type RuleCollectionId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + RoutingConfigurationName string + RuleCollectionName string +} + +// NewRuleCollectionID returns a new RuleCollectionId struct +func NewRuleCollectionID(subscriptionId string, resourceGroupName string, networkManagerName string, routingConfigurationName string, ruleCollectionName string) RuleCollectionId { + return RuleCollectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + RoutingConfigurationName: routingConfigurationName, + RuleCollectionName: ruleCollectionName, + } +} + +// ParseRuleCollectionID parses 'input' into a RuleCollectionId +func ParseRuleCollectionID(input string) (*RuleCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleCollectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRuleCollectionIDInsensitively parses 'input' case-insensitively into a RuleCollectionId +// note: this method should only be used for API response data and not user input +func ParseRuleCollectionIDInsensitively(input string) (*RuleCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleCollectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RuleCollectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.RoutingConfigurationName, ok = input.Parsed["routingConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routingConfigurationName", input) + } + + if id.RuleCollectionName, ok = input.Parsed["ruleCollectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleCollectionName", input) + } + + return nil +} + +// ValidateRuleCollectionID checks that 'input' can be parsed as a Rule Collection ID +func ValidateRuleCollectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRuleCollectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rule Collection ID +func (id RuleCollectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/routingConfigurations/%s/ruleCollections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.RoutingConfigurationName, id.RuleCollectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rule Collection ID +func (id RuleCollectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticRoutingConfigurations", "routingConfigurations", "routingConfigurations"), + resourceids.UserSpecifiedSegment("routingConfigurationName", "routingConfigurationName"), + resourceids.StaticSegment("staticRuleCollections", "ruleCollections", "ruleCollections"), + resourceids.UserSpecifiedSegment("ruleCollectionName", "ruleCollectionName"), + } +} + +// String returns a human-readable description of this Rule Collection ID +func (id RuleCollectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Routing Configuration Name: %q", id.RoutingConfigurationName), + fmt.Sprintf("Rule Collection Name: %q", id.RuleCollectionName), + } + return fmt.Sprintf("Rule Collection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/routingrulecollections/id_rulecollection_test.go b/resource-manager/network/2024-07-01/routingrulecollections/id_rulecollection_test.go new file mode 100644 index 00000000000..a24f9f8fd34 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrulecollections/id_rulecollection_test.go @@ -0,0 +1,372 @@ +package routingrulecollections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RuleCollectionId{} + +func TestNewRuleCollectionID(t *testing.T) { + id := NewRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName", "ruleCollectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.RoutingConfigurationName != "routingConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'RoutingConfigurationName'", id.RoutingConfigurationName, "routingConfigurationName") + } + + if id.RuleCollectionName != "ruleCollectionName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleCollectionName'", id.RuleCollectionName, "ruleCollectionName") + } +} + +func TestFormatRuleCollectionID(t *testing.T) { + actual := NewRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName", "ruleCollectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRuleCollectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName", + Expected: &RuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + RoutingConfigurationName: "routingConfigurationName", + RuleCollectionName: "ruleCollectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleCollectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.RoutingConfigurationName != v.Expected.RoutingConfigurationName { + t.Fatalf("Expected %q but got %q for RoutingConfigurationName", v.Expected.RoutingConfigurationName, actual.RoutingConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + } +} + +func TestParseRuleCollectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName", + Expected: &RuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + RoutingConfigurationName: "routingConfigurationName", + RuleCollectionName: "ruleCollectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE", + Expected: &RuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + RoutingConfigurationName: "rOuTiNgCoNfIgUrAtIoNnAmE", + RuleCollectionName: "rUlEcOlLeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleCollectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.RoutingConfigurationName != v.Expected.RoutingConfigurationName { + t.Fatalf("Expected %q but got %q for RoutingConfigurationName", v.Expected.RoutingConfigurationName, actual.RoutingConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + } +} + +func TestSegmentsForRuleCollectionId(t *testing.T) { + segments := RuleCollectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RuleCollectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/routingrulecollections/method_createorupdate.go b/resource-manager/network/2024-07-01/routingrulecollections/method_createorupdate.go new file mode 100644 index 00000000000..4fc90824f8f --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrulecollections/method_createorupdate.go @@ -0,0 +1,58 @@ +package routingrulecollections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RoutingRuleCollection +} + +// CreateOrUpdate ... +func (c RoutingRuleCollectionsClient) CreateOrUpdate(ctx context.Context, id RuleCollectionId, input RoutingRuleCollection) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RoutingRuleCollection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/routingrulecollections/method_delete.go b/resource-manager/network/2024-07-01/routingrulecollections/method_delete.go new file mode 100644 index 00000000000..dbc7657c4ca --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrulecollections/method_delete.go @@ -0,0 +1,100 @@ +package routingrulecollections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c RoutingRuleCollectionsClient) Delete(ctx context.Context, id RuleCollectionId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c RoutingRuleCollectionsClient) DeleteThenPoll(ctx context.Context, id RuleCollectionId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/routingrulecollections/method_get.go b/resource-manager/network/2024-07-01/routingrulecollections/method_get.go new file mode 100644 index 00000000000..02ef76119f5 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrulecollections/method_get.go @@ -0,0 +1,53 @@ +package routingrulecollections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RoutingRuleCollection +} + +// Get ... +func (c RoutingRuleCollectionsClient) Get(ctx context.Context, id RuleCollectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RoutingRuleCollection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/routingrulecollections/method_list.go b/resource-manager/network/2024-07-01/routingrulecollections/method_list.go new file mode 100644 index 00000000000..9911a1912bd --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrulecollections/method_list.go @@ -0,0 +1,134 @@ +package routingrulecollections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RoutingRuleCollection +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RoutingRuleCollection +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c RoutingRuleCollectionsClient) List(ctx context.Context, id RoutingConfigurationId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/ruleCollections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RoutingRuleCollection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c RoutingRuleCollectionsClient) ListComplete(ctx context.Context, id RoutingConfigurationId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, RoutingRuleCollectionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RoutingRuleCollectionsClient) ListCompleteMatchingPredicate(ctx context.Context, id RoutingConfigurationId, options ListOperationOptions, predicate RoutingRuleCollectionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RoutingRuleCollection, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/routingrulecollections/model_networkmanagerroutinggroupitem.go b/resource-manager/network/2024-07-01/routingrulecollections/model_networkmanagerroutinggroupitem.go new file mode 100644 index 00000000000..1f6c81f7f4a --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrulecollections/model_networkmanagerroutinggroupitem.go @@ -0,0 +1,8 @@ +package routingrulecollections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkManagerRoutingGroupItem struct { + NetworkGroupId string `json:"networkGroupId"` +} diff --git a/resource-manager/network/2024-07-01/routingrulecollections/model_routingrulecollection.go b/resource-manager/network/2024-07-01/routingrulecollections/model_routingrulecollection.go new file mode 100644 index 00000000000..46b420d6707 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrulecollections/model_routingrulecollection.go @@ -0,0 +1,17 @@ +package routingrulecollections + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingRuleCollection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutingRuleCollectionPropertiesFormat `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routingrulecollections/model_routingrulecollectionpropertiesformat.go b/resource-manager/network/2024-07-01/routingrulecollections/model_routingrulecollectionpropertiesformat.go new file mode 100644 index 00000000000..089e4d560ae --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrulecollections/model_routingrulecollectionpropertiesformat.go @@ -0,0 +1,12 @@ +package routingrulecollections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingRuleCollectionPropertiesFormat struct { + AppliesTo []NetworkManagerRoutingGroupItem `json:"appliesTo"` + Description *string `json:"description,omitempty"` + DisableBgpRoutePropagation *DisableBgpRoutePropagation `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routingrulecollections/predicates.go b/resource-manager/network/2024-07-01/routingrulecollections/predicates.go new file mode 100644 index 00000000000..3a5830616cd --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrulecollections/predicates.go @@ -0,0 +1,32 @@ +package routingrulecollections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingRuleCollectionOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p RoutingRuleCollectionOperationPredicate) Matches(input RoutingRuleCollection) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/routingrulecollections/version.go b/resource-manager/network/2024-07-01/routingrulecollections/version.go new file mode 100644 index 00000000000..8aeb6055b89 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrulecollections/version.go @@ -0,0 +1,10 @@ +package routingrulecollections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/routingrulecollections/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/routingrules/README.md b/resource-manager/network/2024-07-01/routingrules/README.md new file mode 100644 index 00000000000..9b8d13907b1 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrules/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routingrules` Documentation + +The `routingrules` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/routingrules" +``` + + +### Client Initialization + +```go +client := routingrules.NewRoutingRulesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RoutingRulesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := routingrules.NewRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName", "ruleCollectionName", "ruleName") + +payload := routingrules.RoutingRule{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RoutingRulesClient.Delete` + +```go +ctx := context.TODO() +id := routingrules.NewRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName", "ruleCollectionName", "ruleName") + +if err := client.DeleteThenPoll(ctx, id, routingrules.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `RoutingRulesClient.Get` + +```go +ctx := context.TODO() +id := routingrules.NewRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName", "ruleCollectionName", "ruleName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RoutingRulesClient.List` + +```go +ctx := context.TODO() +id := routingrules.NewRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName", "ruleCollectionName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/routingrules/client.go b/resource-manager/network/2024-07-01/routingrules/client.go new file mode 100644 index 00000000000..8fb9187c0c3 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrules/client.go @@ -0,0 +1,26 @@ +package routingrules + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingRulesClient struct { + Client *resourcemanager.Client +} + +func NewRoutingRulesClientWithBaseURI(sdkApi sdkEnv.Api) (*RoutingRulesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "routingrules", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RoutingRulesClient: %+v", err) + } + + return &RoutingRulesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/routingrules/constants.go b/resource-manager/network/2024-07-01/routingrules/constants.go new file mode 100644 index 00000000000..ca5824bf606 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrules/constants.go @@ -0,0 +1,148 @@ +package routingrules + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type RoutingRuleDestinationType string + +const ( + RoutingRuleDestinationTypeAddressPrefix RoutingRuleDestinationType = "AddressPrefix" + RoutingRuleDestinationTypeServiceTag RoutingRuleDestinationType = "ServiceTag" +) + +func PossibleValuesForRoutingRuleDestinationType() []string { + return []string{ + string(RoutingRuleDestinationTypeAddressPrefix), + string(RoutingRuleDestinationTypeServiceTag), + } +} + +func (s *RoutingRuleDestinationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRoutingRuleDestinationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRoutingRuleDestinationType(input string) (*RoutingRuleDestinationType, error) { + vals := map[string]RoutingRuleDestinationType{ + "addressprefix": RoutingRuleDestinationTypeAddressPrefix, + "servicetag": RoutingRuleDestinationTypeServiceTag, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RoutingRuleDestinationType(input) + return &out, nil +} + +type RoutingRuleNextHopType string + +const ( + RoutingRuleNextHopTypeInternet RoutingRuleNextHopType = "Internet" + RoutingRuleNextHopTypeNoNextHop RoutingRuleNextHopType = "NoNextHop" + RoutingRuleNextHopTypeVirtualAppliance RoutingRuleNextHopType = "VirtualAppliance" + RoutingRuleNextHopTypeVirtualNetworkGateway RoutingRuleNextHopType = "VirtualNetworkGateway" + RoutingRuleNextHopTypeVnetLocal RoutingRuleNextHopType = "VnetLocal" +) + +func PossibleValuesForRoutingRuleNextHopType() []string { + return []string{ + string(RoutingRuleNextHopTypeInternet), + string(RoutingRuleNextHopTypeNoNextHop), + string(RoutingRuleNextHopTypeVirtualAppliance), + string(RoutingRuleNextHopTypeVirtualNetworkGateway), + string(RoutingRuleNextHopTypeVnetLocal), + } +} + +func (s *RoutingRuleNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRoutingRuleNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRoutingRuleNextHopType(input string) (*RoutingRuleNextHopType, error) { + vals := map[string]RoutingRuleNextHopType{ + "internet": RoutingRuleNextHopTypeInternet, + "nonexthop": RoutingRuleNextHopTypeNoNextHop, + "virtualappliance": RoutingRuleNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RoutingRuleNextHopTypeVirtualNetworkGateway, + "vnetlocal": RoutingRuleNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RoutingRuleNextHopType(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/routingrules/id_rule.go b/resource-manager/network/2024-07-01/routingrules/id_rule.go new file mode 100644 index 00000000000..6418e71b786 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrules/id_rule.go @@ -0,0 +1,157 @@ +package routingrules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RuleId{}) +} + +var _ resourceids.ResourceId = &RuleId{} + +// RuleId is a struct representing the Resource ID for a Rule +type RuleId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + RoutingConfigurationName string + RuleCollectionName string + RuleName string +} + +// NewRuleID returns a new RuleId struct +func NewRuleID(subscriptionId string, resourceGroupName string, networkManagerName string, routingConfigurationName string, ruleCollectionName string, ruleName string) RuleId { + return RuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + RoutingConfigurationName: routingConfigurationName, + RuleCollectionName: ruleCollectionName, + RuleName: ruleName, + } +} + +// ParseRuleID parses 'input' into a RuleId +func ParseRuleID(input string) (*RuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRuleIDInsensitively parses 'input' case-insensitively into a RuleId +// note: this method should only be used for API response data and not user input +func ParseRuleIDInsensitively(input string) (*RuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.RoutingConfigurationName, ok = input.Parsed["routingConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routingConfigurationName", input) + } + + if id.RuleCollectionName, ok = input.Parsed["ruleCollectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleCollectionName", input) + } + + if id.RuleName, ok = input.Parsed["ruleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleName", input) + } + + return nil +} + +// ValidateRuleID checks that 'input' can be parsed as a Rule ID +func ValidateRuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rule ID +func (id RuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/routingConfigurations/%s/ruleCollections/%s/rules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.RoutingConfigurationName, id.RuleCollectionName, id.RuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rule ID +func (id RuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticRoutingConfigurations", "routingConfigurations", "routingConfigurations"), + resourceids.UserSpecifiedSegment("routingConfigurationName", "routingConfigurationName"), + resourceids.StaticSegment("staticRuleCollections", "ruleCollections", "ruleCollections"), + resourceids.UserSpecifiedSegment("ruleCollectionName", "ruleCollectionName"), + resourceids.StaticSegment("staticRules", "rules", "rules"), + resourceids.UserSpecifiedSegment("ruleName", "ruleName"), + } +} + +// String returns a human-readable description of this Rule ID +func (id RuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Routing Configuration Name: %q", id.RoutingConfigurationName), + fmt.Sprintf("Rule Collection Name: %q", id.RuleCollectionName), + fmt.Sprintf("Rule Name: %q", id.RuleName), + } + return fmt.Sprintf("Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/routingrules/id_rule_test.go b/resource-manager/network/2024-07-01/routingrules/id_rule_test.go new file mode 100644 index 00000000000..79c5f1ebcf1 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrules/id_rule_test.go @@ -0,0 +1,417 @@ +package routingrules + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RuleId{} + +func TestNewRuleID(t *testing.T) { + id := NewRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName", "ruleCollectionName", "ruleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.RoutingConfigurationName != "routingConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'RoutingConfigurationName'", id.RoutingConfigurationName, "routingConfigurationName") + } + + if id.RuleCollectionName != "ruleCollectionName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleCollectionName'", id.RuleCollectionName, "ruleCollectionName") + } + + if id.RuleName != "ruleName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleName'", id.RuleName, "ruleName") + } +} + +func TestFormatRuleID(t *testing.T) { + actual := NewRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName", "ruleCollectionName", "ruleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName/rules/ruleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName/rules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName/rules/ruleName", + Expected: &RuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + RoutingConfigurationName: "routingConfigurationName", + RuleCollectionName: "ruleCollectionName", + RuleName: "ruleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName/rules/ruleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.RoutingConfigurationName != v.Expected.RoutingConfigurationName { + t.Fatalf("Expected %q but got %q for RoutingConfigurationName", v.Expected.RoutingConfigurationName, actual.RoutingConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + if actual.RuleName != v.Expected.RuleName { + t.Fatalf("Expected %q but got %q for RuleName", v.Expected.RuleName, actual.RuleName) + } + + } +} + +func TestParseRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName/rules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE/rUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName/rules/ruleName", + Expected: &RuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + RoutingConfigurationName: "routingConfigurationName", + RuleCollectionName: "ruleCollectionName", + RuleName: "ruleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName/rules/ruleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE/rUlEs/rUlEnAmE", + Expected: &RuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + RoutingConfigurationName: "rOuTiNgCoNfIgUrAtIoNnAmE", + RuleCollectionName: "rUlEcOlLeCtIoNnAmE", + RuleName: "rUlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE/rUlEs/rUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.RoutingConfigurationName != v.Expected.RoutingConfigurationName { + t.Fatalf("Expected %q but got %q for RoutingConfigurationName", v.Expected.RoutingConfigurationName, actual.RoutingConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + if actual.RuleName != v.Expected.RuleName { + t.Fatalf("Expected %q but got %q for RuleName", v.Expected.RuleName, actual.RuleName) + } + + } +} + +func TestSegmentsForRuleId(t *testing.T) { + segments := RuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/routingrules/id_rulecollection.go b/resource-manager/network/2024-07-01/routingrules/id_rulecollection.go new file mode 100644 index 00000000000..44d316acd6f --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrules/id_rulecollection.go @@ -0,0 +1,148 @@ +package routingrules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RuleCollectionId{}) +} + +var _ resourceids.ResourceId = &RuleCollectionId{} + +// RuleCollectionId is a struct representing the Resource ID for a Rule Collection +type RuleCollectionId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + RoutingConfigurationName string + RuleCollectionName string +} + +// NewRuleCollectionID returns a new RuleCollectionId struct +func NewRuleCollectionID(subscriptionId string, resourceGroupName string, networkManagerName string, routingConfigurationName string, ruleCollectionName string) RuleCollectionId { + return RuleCollectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + RoutingConfigurationName: routingConfigurationName, + RuleCollectionName: ruleCollectionName, + } +} + +// ParseRuleCollectionID parses 'input' into a RuleCollectionId +func ParseRuleCollectionID(input string) (*RuleCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleCollectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRuleCollectionIDInsensitively parses 'input' case-insensitively into a RuleCollectionId +// note: this method should only be used for API response data and not user input +func ParseRuleCollectionIDInsensitively(input string) (*RuleCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleCollectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RuleCollectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.RoutingConfigurationName, ok = input.Parsed["routingConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routingConfigurationName", input) + } + + if id.RuleCollectionName, ok = input.Parsed["ruleCollectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleCollectionName", input) + } + + return nil +} + +// ValidateRuleCollectionID checks that 'input' can be parsed as a Rule Collection ID +func ValidateRuleCollectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRuleCollectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rule Collection ID +func (id RuleCollectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/routingConfigurations/%s/ruleCollections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.RoutingConfigurationName, id.RuleCollectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rule Collection ID +func (id RuleCollectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticRoutingConfigurations", "routingConfigurations", "routingConfigurations"), + resourceids.UserSpecifiedSegment("routingConfigurationName", "routingConfigurationName"), + resourceids.StaticSegment("staticRuleCollections", "ruleCollections", "ruleCollections"), + resourceids.UserSpecifiedSegment("ruleCollectionName", "ruleCollectionName"), + } +} + +// String returns a human-readable description of this Rule Collection ID +func (id RuleCollectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Routing Configuration Name: %q", id.RoutingConfigurationName), + fmt.Sprintf("Rule Collection Name: %q", id.RuleCollectionName), + } + return fmt.Sprintf("Rule Collection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/routingrules/id_rulecollection_test.go b/resource-manager/network/2024-07-01/routingrules/id_rulecollection_test.go new file mode 100644 index 00000000000..79c7cf9ce28 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrules/id_rulecollection_test.go @@ -0,0 +1,372 @@ +package routingrules + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RuleCollectionId{} + +func TestNewRuleCollectionID(t *testing.T) { + id := NewRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName", "ruleCollectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.RoutingConfigurationName != "routingConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'RoutingConfigurationName'", id.RoutingConfigurationName, "routingConfigurationName") + } + + if id.RuleCollectionName != "ruleCollectionName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleCollectionName'", id.RuleCollectionName, "ruleCollectionName") + } +} + +func TestFormatRuleCollectionID(t *testing.T) { + actual := NewRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "routingConfigurationName", "ruleCollectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRuleCollectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName", + Expected: &RuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + RoutingConfigurationName: "routingConfigurationName", + RuleCollectionName: "ruleCollectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleCollectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.RoutingConfigurationName != v.Expected.RoutingConfigurationName { + t.Fatalf("Expected %q but got %q for RoutingConfigurationName", v.Expected.RoutingConfigurationName, actual.RoutingConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + } +} + +func TestParseRuleCollectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName", + Expected: &RuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + RoutingConfigurationName: "routingConfigurationName", + RuleCollectionName: "ruleCollectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/routingConfigurations/routingConfigurationName/ruleCollections/ruleCollectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE", + Expected: &RuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + RoutingConfigurationName: "rOuTiNgCoNfIgUrAtIoNnAmE", + RuleCollectionName: "rUlEcOlLeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/rOuTiNgCoNfIgUrAtIoNs/rOuTiNgCoNfIgUrAtIoNnAmE/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleCollectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.RoutingConfigurationName != v.Expected.RoutingConfigurationName { + t.Fatalf("Expected %q but got %q for RoutingConfigurationName", v.Expected.RoutingConfigurationName, actual.RoutingConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + } +} + +func TestSegmentsForRuleCollectionId(t *testing.T) { + segments := RuleCollectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RuleCollectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/routingrules/method_createorupdate.go b/resource-manager/network/2024-07-01/routingrules/method_createorupdate.go new file mode 100644 index 00000000000..35bab801563 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrules/method_createorupdate.go @@ -0,0 +1,58 @@ +package routingrules + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RoutingRule +} + +// CreateOrUpdate ... +func (c RoutingRulesClient) CreateOrUpdate(ctx context.Context, id RuleId, input RoutingRule) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RoutingRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/routingrules/method_delete.go b/resource-manager/network/2024-07-01/routingrules/method_delete.go new file mode 100644 index 00000000000..3e5ea4998c8 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrules/method_delete.go @@ -0,0 +1,100 @@ +package routingrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c RoutingRulesClient) Delete(ctx context.Context, id RuleId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c RoutingRulesClient) DeleteThenPoll(ctx context.Context, id RuleId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/routingrules/method_get.go b/resource-manager/network/2024-07-01/routingrules/method_get.go new file mode 100644 index 00000000000..746ff6cedf3 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrules/method_get.go @@ -0,0 +1,53 @@ +package routingrules + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RoutingRule +} + +// Get ... +func (c RoutingRulesClient) Get(ctx context.Context, id RuleId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RoutingRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/routingrules/method_list.go b/resource-manager/network/2024-07-01/routingrules/method_list.go new file mode 100644 index 00000000000..76a1bfb9a06 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrules/method_list.go @@ -0,0 +1,105 @@ +package routingrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RoutingRule +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RoutingRule +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c RoutingRulesClient) List(ctx context.Context, id RuleCollectionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/rules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RoutingRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c RoutingRulesClient) ListComplete(ctx context.Context, id RuleCollectionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, RoutingRuleOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RoutingRulesClient) ListCompleteMatchingPredicate(ctx context.Context, id RuleCollectionId, predicate RoutingRuleOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RoutingRule, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/routingrules/model_routingrule.go b/resource-manager/network/2024-07-01/routingrules/model_routingrule.go new file mode 100644 index 00000000000..7f78cd2655a --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrules/model_routingrule.go @@ -0,0 +1,17 @@ +package routingrules + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutingRulePropertiesFormat `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routingrules/model_routingrulenexthop.go b/resource-manager/network/2024-07-01/routingrules/model_routingrulenexthop.go new file mode 100644 index 00000000000..4cc1a52a6fe --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrules/model_routingrulenexthop.go @@ -0,0 +1,9 @@ +package routingrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingRuleNextHop struct { + NextHopAddress *string `json:"nextHopAddress,omitempty"` + NextHopType RoutingRuleNextHopType `json:"nextHopType"` +} diff --git a/resource-manager/network/2024-07-01/routingrules/model_routingrulepropertiesformat.go b/resource-manager/network/2024-07-01/routingrules/model_routingrulepropertiesformat.go new file mode 100644 index 00000000000..a45d96ed053 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrules/model_routingrulepropertiesformat.go @@ -0,0 +1,12 @@ +package routingrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingRulePropertiesFormat struct { + Description *string `json:"description,omitempty"` + Destination RoutingRuleRouteDestination `json:"destination"` + NextHop RoutingRuleNextHop `json:"nextHop"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/routingrules/model_routingruleroutedestination.go b/resource-manager/network/2024-07-01/routingrules/model_routingruleroutedestination.go new file mode 100644 index 00000000000..e05f812849c --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrules/model_routingruleroutedestination.go @@ -0,0 +1,9 @@ +package routingrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingRuleRouteDestination struct { + DestinationAddress string `json:"destinationAddress"` + Type RoutingRuleDestinationType `json:"type"` +} diff --git a/resource-manager/network/2024-07-01/routingrules/predicates.go b/resource-manager/network/2024-07-01/routingrules/predicates.go new file mode 100644 index 00000000000..b668fb3729b --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrules/predicates.go @@ -0,0 +1,32 @@ +package routingrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingRuleOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p RoutingRuleOperationPredicate) Matches(input RoutingRule) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/routingrules/version.go b/resource-manager/network/2024-07-01/routingrules/version.go new file mode 100644 index 00000000000..d78ad81a314 --- /dev/null +++ b/resource-manager/network/2024-07-01/routingrules/version.go @@ -0,0 +1,10 @@ +package routingrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/routingrules/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/scopeconnections/README.md b/resource-manager/network/2024-07-01/scopeconnections/README.md new file mode 100644 index 00000000000..fe0294dbe97 --- /dev/null +++ b/resource-manager/network/2024-07-01/scopeconnections/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/scopeconnections` Documentation + +The `scopeconnections` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/scopeconnections" +``` + + +### Client Initialization + +```go +client := scopeconnections.NewScopeConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ScopeConnectionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := scopeconnections.NewScopeConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "scopeConnectionName") + +payload := scopeconnections.ScopeConnection{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScopeConnectionsClient.Delete` + +```go +ctx := context.TODO() +id := scopeconnections.NewScopeConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "scopeConnectionName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScopeConnectionsClient.Get` + +```go +ctx := context.TODO() +id := scopeconnections.NewScopeConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "scopeConnectionName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ScopeConnectionsClient.List` + +```go +ctx := context.TODO() +id := scopeconnections.NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + +// alternatively `client.List(ctx, id, scopeconnections.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, scopeconnections.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/scopeconnections/client.go b/resource-manager/network/2024-07-01/scopeconnections/client.go new file mode 100644 index 00000000000..81942e9b5e9 --- /dev/null +++ b/resource-manager/network/2024-07-01/scopeconnections/client.go @@ -0,0 +1,26 @@ +package scopeconnections + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScopeConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewScopeConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*ScopeConnectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "scopeconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ScopeConnectionsClient: %+v", err) + } + + return &ScopeConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/scopeconnections/constants.go b/resource-manager/network/2024-07-01/scopeconnections/constants.go new file mode 100644 index 00000000000..24a9bb99e3a --- /dev/null +++ b/resource-manager/network/2024-07-01/scopeconnections/constants.go @@ -0,0 +1,60 @@ +package scopeconnections + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScopeConnectionState string + +const ( + ScopeConnectionStateConflict ScopeConnectionState = "Conflict" + ScopeConnectionStateConnected ScopeConnectionState = "Connected" + ScopeConnectionStatePending ScopeConnectionState = "Pending" + ScopeConnectionStateRejected ScopeConnectionState = "Rejected" + ScopeConnectionStateRevoked ScopeConnectionState = "Revoked" +) + +func PossibleValuesForScopeConnectionState() []string { + return []string{ + string(ScopeConnectionStateConflict), + string(ScopeConnectionStateConnected), + string(ScopeConnectionStatePending), + string(ScopeConnectionStateRejected), + string(ScopeConnectionStateRevoked), + } +} + +func (s *ScopeConnectionState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScopeConnectionState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScopeConnectionState(input string) (*ScopeConnectionState, error) { + vals := map[string]ScopeConnectionState{ + "conflict": ScopeConnectionStateConflict, + "connected": ScopeConnectionStateConnected, + "pending": ScopeConnectionStatePending, + "rejected": ScopeConnectionStateRejected, + "revoked": ScopeConnectionStateRevoked, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScopeConnectionState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/scopeconnections/id_networkmanager.go b/resource-manager/network/2024-07-01/scopeconnections/id_networkmanager.go new file mode 100644 index 00000000000..9deea7f3943 --- /dev/null +++ b/resource-manager/network/2024-07-01/scopeconnections/id_networkmanager.go @@ -0,0 +1,130 @@ +package scopeconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkManagerId{}) +} + +var _ resourceids.ResourceId = &NetworkManagerId{} + +// NetworkManagerId is a struct representing the Resource ID for a Network Manager +type NetworkManagerId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string +} + +// NewNetworkManagerID returns a new NetworkManagerId struct +func NewNetworkManagerID(subscriptionId string, resourceGroupName string, networkManagerName string) NetworkManagerId { + return NetworkManagerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + } +} + +// ParseNetworkManagerID parses 'input' into a NetworkManagerId +func ParseNetworkManagerID(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkManagerIDInsensitively parses 'input' case-insensitively into a NetworkManagerId +// note: this method should only be used for API response data and not user input +func ParseNetworkManagerIDInsensitively(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkManagerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + return nil +} + +// ValidateNetworkManagerID checks that 'input' can be parsed as a Network Manager ID +func ValidateNetworkManagerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkManagerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Manager ID +func (id NetworkManagerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Manager ID +func (id NetworkManagerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + } +} + +// String returns a human-readable description of this Network Manager ID +func (id NetworkManagerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + } + return fmt.Sprintf("Network Manager (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/scopeconnections/id_networkmanager_test.go b/resource-manager/network/2024-07-01/scopeconnections/id_networkmanager_test.go new file mode 100644 index 00000000000..a5bfdb991b1 --- /dev/null +++ b/resource-manager/network/2024-07-01/scopeconnections/id_networkmanager_test.go @@ -0,0 +1,282 @@ +package scopeconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkManagerId{} + +func TestNewNetworkManagerID(t *testing.T) { + id := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } +} + +func TestFormatNetworkManagerID(t *testing.T) { + actual := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkManagerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestParseNetworkManagerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestSegmentsForNetworkManagerId(t *testing.T) { + segments := NetworkManagerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkManagerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/scopeconnections/id_scopeconnection.go b/resource-manager/network/2024-07-01/scopeconnections/id_scopeconnection.go new file mode 100644 index 00000000000..9af347c43b6 --- /dev/null +++ b/resource-manager/network/2024-07-01/scopeconnections/id_scopeconnection.go @@ -0,0 +1,139 @@ +package scopeconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ScopeConnectionId{}) +} + +var _ resourceids.ResourceId = &ScopeConnectionId{} + +// ScopeConnectionId is a struct representing the Resource ID for a Scope Connection +type ScopeConnectionId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + ScopeConnectionName string +} + +// NewScopeConnectionID returns a new ScopeConnectionId struct +func NewScopeConnectionID(subscriptionId string, resourceGroupName string, networkManagerName string, scopeConnectionName string) ScopeConnectionId { + return ScopeConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + ScopeConnectionName: scopeConnectionName, + } +} + +// ParseScopeConnectionID parses 'input' into a ScopeConnectionId +func ParseScopeConnectionID(input string) (*ScopeConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopeConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopeConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseScopeConnectionIDInsensitively parses 'input' case-insensitively into a ScopeConnectionId +// note: this method should only be used for API response data and not user input +func ParseScopeConnectionIDInsensitively(input string) (*ScopeConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopeConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopeConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ScopeConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.ScopeConnectionName, ok = input.Parsed["scopeConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "scopeConnectionName", input) + } + + return nil +} + +// ValidateScopeConnectionID checks that 'input' can be parsed as a Scope Connection ID +func ValidateScopeConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseScopeConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Scope Connection ID +func (id ScopeConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/scopeConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.ScopeConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Scope Connection ID +func (id ScopeConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticScopeConnections", "scopeConnections", "scopeConnections"), + resourceids.UserSpecifiedSegment("scopeConnectionName", "scopeConnectionName"), + } +} + +// String returns a human-readable description of this Scope Connection ID +func (id ScopeConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Scope Connection Name: %q", id.ScopeConnectionName), + } + return fmt.Sprintf("Scope Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/scopeconnections/id_scopeconnection_test.go b/resource-manager/network/2024-07-01/scopeconnections/id_scopeconnection_test.go new file mode 100644 index 00000000000..6bc00e7b627 --- /dev/null +++ b/resource-manager/network/2024-07-01/scopeconnections/id_scopeconnection_test.go @@ -0,0 +1,327 @@ +package scopeconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ScopeConnectionId{} + +func TestNewScopeConnectionID(t *testing.T) { + id := NewScopeConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "scopeConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.ScopeConnectionName != "scopeConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'ScopeConnectionName'", id.ScopeConnectionName, "scopeConnectionName") + } +} + +func TestFormatScopeConnectionID(t *testing.T) { + actual := NewScopeConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "scopeConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/scopeConnections/scopeConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseScopeConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopeConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/scopeConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/scopeConnections/scopeConnectionName", + Expected: &ScopeConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + ScopeConnectionName: "scopeConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/scopeConnections/scopeConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopeConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.ScopeConnectionName != v.Expected.ScopeConnectionName { + t.Fatalf("Expected %q but got %q for ScopeConnectionName", v.Expected.ScopeConnectionName, actual.ScopeConnectionName) + } + + } +} + +func TestParseScopeConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopeConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/scopeConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sCoPeCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/scopeConnections/scopeConnectionName", + Expected: &ScopeConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + ScopeConnectionName: "scopeConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/scopeConnections/scopeConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sCoPeCoNnEcTiOnS/sCoPeCoNnEcTiOnNaMe", + Expected: &ScopeConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + ScopeConnectionName: "sCoPeCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sCoPeCoNnEcTiOnS/sCoPeCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopeConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.ScopeConnectionName != v.Expected.ScopeConnectionName { + t.Fatalf("Expected %q but got %q for ScopeConnectionName", v.Expected.ScopeConnectionName, actual.ScopeConnectionName) + } + + } +} + +func TestSegmentsForScopeConnectionId(t *testing.T) { + segments := ScopeConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ScopeConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/scopeconnections/method_createorupdate.go b/resource-manager/network/2024-07-01/scopeconnections/method_createorupdate.go new file mode 100644 index 00000000000..08383ec6587 --- /dev/null +++ b/resource-manager/network/2024-07-01/scopeconnections/method_createorupdate.go @@ -0,0 +1,58 @@ +package scopeconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ScopeConnection +} + +// CreateOrUpdate ... +func (c ScopeConnectionsClient) CreateOrUpdate(ctx context.Context, id ScopeConnectionId, input ScopeConnection) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ScopeConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/scopeconnections/method_delete.go b/resource-manager/network/2024-07-01/scopeconnections/method_delete.go new file mode 100644 index 00000000000..0ef9f60e8f6 --- /dev/null +++ b/resource-manager/network/2024-07-01/scopeconnections/method_delete.go @@ -0,0 +1,47 @@ +package scopeconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ScopeConnectionsClient) Delete(ctx context.Context, id ScopeConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/scopeconnections/method_get.go b/resource-manager/network/2024-07-01/scopeconnections/method_get.go new file mode 100644 index 00000000000..67789a31c53 --- /dev/null +++ b/resource-manager/network/2024-07-01/scopeconnections/method_get.go @@ -0,0 +1,53 @@ +package scopeconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ScopeConnection +} + +// Get ... +func (c ScopeConnectionsClient) Get(ctx context.Context, id ScopeConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ScopeConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/scopeconnections/method_list.go b/resource-manager/network/2024-07-01/scopeconnections/method_list.go new file mode 100644 index 00000000000..c9f73b61411 --- /dev/null +++ b/resource-manager/network/2024-07-01/scopeconnections/method_list.go @@ -0,0 +1,134 @@ +package scopeconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ScopeConnection +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ScopeConnection +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ScopeConnectionsClient) List(ctx context.Context, id NetworkManagerId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/scopeConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ScopeConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ScopeConnectionsClient) ListComplete(ctx context.Context, id NetworkManagerId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ScopeConnectionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ScopeConnectionsClient) ListCompleteMatchingPredicate(ctx context.Context, id NetworkManagerId, options ListOperationOptions, predicate ScopeConnectionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ScopeConnection, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/scopeconnections/model_scopeconnection.go b/resource-manager/network/2024-07-01/scopeconnections/model_scopeconnection.go new file mode 100644 index 00000000000..ddb7dcfd3ff --- /dev/null +++ b/resource-manager/network/2024-07-01/scopeconnections/model_scopeconnection.go @@ -0,0 +1,17 @@ +package scopeconnections + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScopeConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ScopeConnectionProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/scopeconnections/model_scopeconnectionproperties.go b/resource-manager/network/2024-07-01/scopeconnections/model_scopeconnectionproperties.go new file mode 100644 index 00000000000..0997147a2a9 --- /dev/null +++ b/resource-manager/network/2024-07-01/scopeconnections/model_scopeconnectionproperties.go @@ -0,0 +1,11 @@ +package scopeconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScopeConnectionProperties struct { + ConnectionState *ScopeConnectionState `json:"connectionState,omitempty"` + Description *string `json:"description,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/scopeconnections/predicates.go b/resource-manager/network/2024-07-01/scopeconnections/predicates.go new file mode 100644 index 00000000000..eda309664f4 --- /dev/null +++ b/resource-manager/network/2024-07-01/scopeconnections/predicates.go @@ -0,0 +1,32 @@ +package scopeconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScopeConnectionOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p ScopeConnectionOperationPredicate) Matches(input ScopeConnection) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/scopeconnections/version.go b/resource-manager/network/2024-07-01/scopeconnections/version.go new file mode 100644 index 00000000000..adeac734f63 --- /dev/null +++ b/resource-manager/network/2024-07-01/scopeconnections/version.go @@ -0,0 +1,10 @@ +package scopeconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/scopeconnections/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/securityadminconfigurations/README.md b/resource-manager/network/2024-07-01/securityadminconfigurations/README.md new file mode 100644 index 00000000000..df34f29b750 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityadminconfigurations/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securityadminconfigurations` Documentation + +The `securityadminconfigurations` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securityadminconfigurations" +``` + + +### Client Initialization + +```go +client := securityadminconfigurations.NewSecurityAdminConfigurationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SecurityAdminConfigurationsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := securityadminconfigurations.NewSecurityAdminConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName") + +payload := securityadminconfigurations.SecurityAdminConfiguration{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SecurityAdminConfigurationsClient.Delete` + +```go +ctx := context.TODO() +id := securityadminconfigurations.NewSecurityAdminConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName") + +if err := client.DeleteThenPoll(ctx, id, securityadminconfigurations.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `SecurityAdminConfigurationsClient.Get` + +```go +ctx := context.TODO() +id := securityadminconfigurations.NewSecurityAdminConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SecurityAdminConfigurationsClient.List` + +```go +ctx := context.TODO() +id := securityadminconfigurations.NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + +// alternatively `client.List(ctx, id, securityadminconfigurations.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, securityadminconfigurations.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/securityadminconfigurations/client.go b/resource-manager/network/2024-07-01/securityadminconfigurations/client.go new file mode 100644 index 00000000000..c4acda9a655 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityadminconfigurations/client.go @@ -0,0 +1,26 @@ +package securityadminconfigurations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityAdminConfigurationsClient struct { + Client *resourcemanager.Client +} + +func NewSecurityAdminConfigurationsClientWithBaseURI(sdkApi sdkEnv.Api) (*SecurityAdminConfigurationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "securityadminconfigurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SecurityAdminConfigurationsClient: %+v", err) + } + + return &SecurityAdminConfigurationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/securityadminconfigurations/constants.go b/resource-manager/network/2024-07-01/securityadminconfigurations/constants.go new file mode 100644 index 00000000000..cde6a1742d5 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityadminconfigurations/constants.go @@ -0,0 +1,148 @@ +package securityadminconfigurations + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressSpaceAggregationOption string + +const ( + AddressSpaceAggregationOptionManual AddressSpaceAggregationOption = "Manual" + AddressSpaceAggregationOptionNone AddressSpaceAggregationOption = "None" +) + +func PossibleValuesForAddressSpaceAggregationOption() []string { + return []string{ + string(AddressSpaceAggregationOptionManual), + string(AddressSpaceAggregationOptionNone), + } +} + +func (s *AddressSpaceAggregationOption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAddressSpaceAggregationOption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAddressSpaceAggregationOption(input string) (*AddressSpaceAggregationOption, error) { + vals := map[string]AddressSpaceAggregationOption{ + "manual": AddressSpaceAggregationOptionManual, + "none": AddressSpaceAggregationOptionNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AddressSpaceAggregationOption(input) + return &out, nil +} + +type NetworkIntentPolicyBasedService string + +const ( + NetworkIntentPolicyBasedServiceAll NetworkIntentPolicyBasedService = "All" + NetworkIntentPolicyBasedServiceAllowRulesOnly NetworkIntentPolicyBasedService = "AllowRulesOnly" + NetworkIntentPolicyBasedServiceNone NetworkIntentPolicyBasedService = "None" +) + +func PossibleValuesForNetworkIntentPolicyBasedService() []string { + return []string{ + string(NetworkIntentPolicyBasedServiceAll), + string(NetworkIntentPolicyBasedServiceAllowRulesOnly), + string(NetworkIntentPolicyBasedServiceNone), + } +} + +func (s *NetworkIntentPolicyBasedService) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkIntentPolicyBasedService(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkIntentPolicyBasedService(input string) (*NetworkIntentPolicyBasedService, error) { + vals := map[string]NetworkIntentPolicyBasedService{ + "all": NetworkIntentPolicyBasedServiceAll, + "allowrulesonly": NetworkIntentPolicyBasedServiceAllowRulesOnly, + "none": NetworkIntentPolicyBasedServiceNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkIntentPolicyBasedService(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/securityadminconfigurations/id_networkmanager.go b/resource-manager/network/2024-07-01/securityadminconfigurations/id_networkmanager.go new file mode 100644 index 00000000000..5829592a2f1 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityadminconfigurations/id_networkmanager.go @@ -0,0 +1,130 @@ +package securityadminconfigurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkManagerId{}) +} + +var _ resourceids.ResourceId = &NetworkManagerId{} + +// NetworkManagerId is a struct representing the Resource ID for a Network Manager +type NetworkManagerId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string +} + +// NewNetworkManagerID returns a new NetworkManagerId struct +func NewNetworkManagerID(subscriptionId string, resourceGroupName string, networkManagerName string) NetworkManagerId { + return NetworkManagerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + } +} + +// ParseNetworkManagerID parses 'input' into a NetworkManagerId +func ParseNetworkManagerID(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkManagerIDInsensitively parses 'input' case-insensitively into a NetworkManagerId +// note: this method should only be used for API response data and not user input +func ParseNetworkManagerIDInsensitively(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkManagerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + return nil +} + +// ValidateNetworkManagerID checks that 'input' can be parsed as a Network Manager ID +func ValidateNetworkManagerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkManagerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Manager ID +func (id NetworkManagerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Manager ID +func (id NetworkManagerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + } +} + +// String returns a human-readable description of this Network Manager ID +func (id NetworkManagerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + } + return fmt.Sprintf("Network Manager (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/securityadminconfigurations/id_networkmanager_test.go b/resource-manager/network/2024-07-01/securityadminconfigurations/id_networkmanager_test.go new file mode 100644 index 00000000000..c948b83fb0d --- /dev/null +++ b/resource-manager/network/2024-07-01/securityadminconfigurations/id_networkmanager_test.go @@ -0,0 +1,282 @@ +package securityadminconfigurations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkManagerId{} + +func TestNewNetworkManagerID(t *testing.T) { + id := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } +} + +func TestFormatNetworkManagerID(t *testing.T) { + actual := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkManagerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestParseNetworkManagerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestSegmentsForNetworkManagerId(t *testing.T) { + segments := NetworkManagerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkManagerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/securityadminconfigurations/id_securityadminconfiguration.go b/resource-manager/network/2024-07-01/securityadminconfigurations/id_securityadminconfiguration.go new file mode 100644 index 00000000000..070ef0fa83e --- /dev/null +++ b/resource-manager/network/2024-07-01/securityadminconfigurations/id_securityadminconfiguration.go @@ -0,0 +1,139 @@ +package securityadminconfigurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SecurityAdminConfigurationId{}) +} + +var _ resourceids.ResourceId = &SecurityAdminConfigurationId{} + +// SecurityAdminConfigurationId is a struct representing the Resource ID for a Security Admin Configuration +type SecurityAdminConfigurationId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + SecurityAdminConfigurationName string +} + +// NewSecurityAdminConfigurationID returns a new SecurityAdminConfigurationId struct +func NewSecurityAdminConfigurationID(subscriptionId string, resourceGroupName string, networkManagerName string, securityAdminConfigurationName string) SecurityAdminConfigurationId { + return SecurityAdminConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + SecurityAdminConfigurationName: securityAdminConfigurationName, + } +} + +// ParseSecurityAdminConfigurationID parses 'input' into a SecurityAdminConfigurationId +func ParseSecurityAdminConfigurationID(input string) (*SecurityAdminConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityAdminConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityAdminConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSecurityAdminConfigurationIDInsensitively parses 'input' case-insensitively into a SecurityAdminConfigurationId +// note: this method should only be used for API response data and not user input +func ParseSecurityAdminConfigurationIDInsensitively(input string) (*SecurityAdminConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityAdminConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityAdminConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SecurityAdminConfigurationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.SecurityAdminConfigurationName, ok = input.Parsed["securityAdminConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "securityAdminConfigurationName", input) + } + + return nil +} + +// ValidateSecurityAdminConfigurationID checks that 'input' can be parsed as a Security Admin Configuration ID +func ValidateSecurityAdminConfigurationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSecurityAdminConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Security Admin Configuration ID +func (id SecurityAdminConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/securityAdminConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.SecurityAdminConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Security Admin Configuration ID +func (id SecurityAdminConfigurationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticSecurityAdminConfigurations", "securityAdminConfigurations", "securityAdminConfigurations"), + resourceids.UserSpecifiedSegment("securityAdminConfigurationName", "securityAdminConfigurationName"), + } +} + +// String returns a human-readable description of this Security Admin Configuration ID +func (id SecurityAdminConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Security Admin Configuration Name: %q", id.SecurityAdminConfigurationName), + } + return fmt.Sprintf("Security Admin Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/securityadminconfigurations/id_securityadminconfiguration_test.go b/resource-manager/network/2024-07-01/securityadminconfigurations/id_securityadminconfiguration_test.go new file mode 100644 index 00000000000..66fc3677b11 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityadminconfigurations/id_securityadminconfiguration_test.go @@ -0,0 +1,327 @@ +package securityadminconfigurations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SecurityAdminConfigurationId{} + +func TestNewSecurityAdminConfigurationID(t *testing.T) { + id := NewSecurityAdminConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.SecurityAdminConfigurationName != "securityAdminConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'SecurityAdminConfigurationName'", id.SecurityAdminConfigurationName, "securityAdminConfigurationName") + } +} + +func TestFormatSecurityAdminConfigurationID(t *testing.T) { + actual := NewSecurityAdminConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityAdminConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSecurityAdminConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityAdminConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName", + Expected: &SecurityAdminConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityAdminConfigurationName: "securityAdminConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityAdminConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityAdminConfigurationName != v.Expected.SecurityAdminConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityAdminConfigurationName", v.Expected.SecurityAdminConfigurationName, actual.SecurityAdminConfigurationName) + } + + } +} + +func TestParseSecurityAdminConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityAdminConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName", + Expected: &SecurityAdminConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityAdminConfigurationName: "securityAdminConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityAdminConfigurations/securityAdminConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE", + Expected: &SecurityAdminConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + SecurityAdminConfigurationName: "sEcUrItYaDmInCoNfIgUrAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYaDmInCoNfIgUrAtIoNs/sEcUrItYaDmInCoNfIgUrAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityAdminConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityAdminConfigurationName != v.Expected.SecurityAdminConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityAdminConfigurationName", v.Expected.SecurityAdminConfigurationName, actual.SecurityAdminConfigurationName) + } + + } +} + +func TestSegmentsForSecurityAdminConfigurationId(t *testing.T) { + segments := SecurityAdminConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SecurityAdminConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/securityadminconfigurations/method_createorupdate.go b/resource-manager/network/2024-07-01/securityadminconfigurations/method_createorupdate.go new file mode 100644 index 00000000000..2406a218954 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityadminconfigurations/method_createorupdate.go @@ -0,0 +1,58 @@ +package securityadminconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecurityAdminConfiguration +} + +// CreateOrUpdate ... +func (c SecurityAdminConfigurationsClient) CreateOrUpdate(ctx context.Context, id SecurityAdminConfigurationId, input SecurityAdminConfiguration) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SecurityAdminConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/securityadminconfigurations/method_delete.go b/resource-manager/network/2024-07-01/securityadminconfigurations/method_delete.go new file mode 100644 index 00000000000..98f2658625f --- /dev/null +++ b/resource-manager/network/2024-07-01/securityadminconfigurations/method_delete.go @@ -0,0 +1,100 @@ +package securityadminconfigurations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c SecurityAdminConfigurationsClient) Delete(ctx context.Context, id SecurityAdminConfigurationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c SecurityAdminConfigurationsClient) DeleteThenPoll(ctx context.Context, id SecurityAdminConfigurationId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/securityadminconfigurations/method_get.go b/resource-manager/network/2024-07-01/securityadminconfigurations/method_get.go new file mode 100644 index 00000000000..65a62286882 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityadminconfigurations/method_get.go @@ -0,0 +1,53 @@ +package securityadminconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecurityAdminConfiguration +} + +// Get ... +func (c SecurityAdminConfigurationsClient) Get(ctx context.Context, id SecurityAdminConfigurationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SecurityAdminConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/securityadminconfigurations/method_list.go b/resource-manager/network/2024-07-01/securityadminconfigurations/method_list.go new file mode 100644 index 00000000000..a4abe4c74d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityadminconfigurations/method_list.go @@ -0,0 +1,134 @@ +package securityadminconfigurations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SecurityAdminConfiguration +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SecurityAdminConfiguration +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c SecurityAdminConfigurationsClient) List(ctx context.Context, id NetworkManagerId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/securityAdminConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SecurityAdminConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c SecurityAdminConfigurationsClient) ListComplete(ctx context.Context, id NetworkManagerId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, SecurityAdminConfigurationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SecurityAdminConfigurationsClient) ListCompleteMatchingPredicate(ctx context.Context, id NetworkManagerId, options ListOperationOptions, predicate SecurityAdminConfigurationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SecurityAdminConfiguration, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/securityadminconfigurations/model_securityadminconfiguration.go b/resource-manager/network/2024-07-01/securityadminconfigurations/model_securityadminconfiguration.go new file mode 100644 index 00000000000..004c4d46b07 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityadminconfigurations/model_securityadminconfiguration.go @@ -0,0 +1,17 @@ +package securityadminconfigurations + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityAdminConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityAdminConfigurationPropertiesFormat `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/securityadminconfigurations/model_securityadminconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/securityadminconfigurations/model_securityadminconfigurationpropertiesformat.go new file mode 100644 index 00000000000..c8ed663ad8d --- /dev/null +++ b/resource-manager/network/2024-07-01/securityadminconfigurations/model_securityadminconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package securityadminconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityAdminConfigurationPropertiesFormat struct { + ApplyOnNetworkIntentPolicyBasedServices *[]NetworkIntentPolicyBasedService `json:"applyOnNetworkIntentPolicyBasedServices,omitempty"` + Description *string `json:"description,omitempty"` + NetworkGroupAddressSpaceAggregationOption *AddressSpaceAggregationOption `json:"networkGroupAddressSpaceAggregationOption,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/securityadminconfigurations/predicates.go b/resource-manager/network/2024-07-01/securityadminconfigurations/predicates.go new file mode 100644 index 00000000000..bcc5de9a6a8 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityadminconfigurations/predicates.go @@ -0,0 +1,32 @@ +package securityadminconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityAdminConfigurationOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p SecurityAdminConfigurationOperationPredicate) Matches(input SecurityAdminConfiguration) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/securityadminconfigurations/version.go b/resource-manager/network/2024-07-01/securityadminconfigurations/version.go new file mode 100644 index 00000000000..807e134f99f --- /dev/null +++ b/resource-manager/network/2024-07-01/securityadminconfigurations/version.go @@ -0,0 +1,10 @@ +package securityadminconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/securityadminconfigurations/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/securitypartnerproviders/README.md b/resource-manager/network/2024-07-01/securitypartnerproviders/README.md new file mode 100644 index 00000000000..af1c1a66b52 --- /dev/null +++ b/resource-manager/network/2024-07-01/securitypartnerproviders/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securitypartnerproviders` Documentation + +The `securitypartnerproviders` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securitypartnerproviders" +``` + + +### Client Initialization + +```go +client := securitypartnerproviders.NewSecurityPartnerProvidersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SecurityPartnerProvidersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := securitypartnerproviders.NewSecurityPartnerProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "securityPartnerProviderName") + +payload := securitypartnerproviders.SecurityPartnerProvider{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SecurityPartnerProvidersClient.Delete` + +```go +ctx := context.TODO() +id := securitypartnerproviders.NewSecurityPartnerProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "securityPartnerProviderName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SecurityPartnerProvidersClient.Get` + +```go +ctx := context.TODO() +id := securitypartnerproviders.NewSecurityPartnerProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "securityPartnerProviderName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SecurityPartnerProvidersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SecurityPartnerProvidersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SecurityPartnerProvidersClient.UpdateTags` + +```go +ctx := context.TODO() +id := securitypartnerproviders.NewSecurityPartnerProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "securityPartnerProviderName") + +payload := securitypartnerproviders.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/securitypartnerproviders/client.go b/resource-manager/network/2024-07-01/securitypartnerproviders/client.go new file mode 100644 index 00000000000..7752e07fcf3 --- /dev/null +++ b/resource-manager/network/2024-07-01/securitypartnerproviders/client.go @@ -0,0 +1,26 @@ +package securitypartnerproviders + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityPartnerProvidersClient struct { + Client *resourcemanager.Client +} + +func NewSecurityPartnerProvidersClientWithBaseURI(sdkApi sdkEnv.Api) (*SecurityPartnerProvidersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "securitypartnerproviders", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SecurityPartnerProvidersClient: %+v", err) + } + + return &SecurityPartnerProvidersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/securitypartnerproviders/constants.go b/resource-manager/network/2024-07-01/securitypartnerproviders/constants.go new file mode 100644 index 00000000000..2390c77210a --- /dev/null +++ b/resource-manager/network/2024-07-01/securitypartnerproviders/constants.go @@ -0,0 +1,148 @@ +package securitypartnerproviders + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SecurityPartnerProviderConnectionStatus string + +const ( + SecurityPartnerProviderConnectionStatusConnected SecurityPartnerProviderConnectionStatus = "Connected" + SecurityPartnerProviderConnectionStatusNotConnected SecurityPartnerProviderConnectionStatus = "NotConnected" + SecurityPartnerProviderConnectionStatusPartiallyConnected SecurityPartnerProviderConnectionStatus = "PartiallyConnected" + SecurityPartnerProviderConnectionStatusUnknown SecurityPartnerProviderConnectionStatus = "Unknown" +) + +func PossibleValuesForSecurityPartnerProviderConnectionStatus() []string { + return []string{ + string(SecurityPartnerProviderConnectionStatusConnected), + string(SecurityPartnerProviderConnectionStatusNotConnected), + string(SecurityPartnerProviderConnectionStatusPartiallyConnected), + string(SecurityPartnerProviderConnectionStatusUnknown), + } +} + +func (s *SecurityPartnerProviderConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityPartnerProviderConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityPartnerProviderConnectionStatus(input string) (*SecurityPartnerProviderConnectionStatus, error) { + vals := map[string]SecurityPartnerProviderConnectionStatus{ + "connected": SecurityPartnerProviderConnectionStatusConnected, + "notconnected": SecurityPartnerProviderConnectionStatusNotConnected, + "partiallyconnected": SecurityPartnerProviderConnectionStatusPartiallyConnected, + "unknown": SecurityPartnerProviderConnectionStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityPartnerProviderConnectionStatus(input) + return &out, nil +} + +type SecurityProviderName string + +const ( + SecurityProviderNameCheckpoint SecurityProviderName = "Checkpoint" + SecurityProviderNameIBoss SecurityProviderName = "IBoss" + SecurityProviderNameZScaler SecurityProviderName = "ZScaler" +) + +func PossibleValuesForSecurityProviderName() []string { + return []string{ + string(SecurityProviderNameCheckpoint), + string(SecurityProviderNameIBoss), + string(SecurityProviderNameZScaler), + } +} + +func (s *SecurityProviderName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityProviderName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityProviderName(input string) (*SecurityProviderName, error) { + vals := map[string]SecurityProviderName{ + "checkpoint": SecurityProviderNameCheckpoint, + "iboss": SecurityProviderNameIBoss, + "zscaler": SecurityProviderNameZScaler, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityProviderName(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/securitypartnerproviders/id_securitypartnerprovider.go b/resource-manager/network/2024-07-01/securitypartnerproviders/id_securitypartnerprovider.go new file mode 100644 index 00000000000..6cdcf1022ee --- /dev/null +++ b/resource-manager/network/2024-07-01/securitypartnerproviders/id_securitypartnerprovider.go @@ -0,0 +1,130 @@ +package securitypartnerproviders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SecurityPartnerProviderId{}) +} + +var _ resourceids.ResourceId = &SecurityPartnerProviderId{} + +// SecurityPartnerProviderId is a struct representing the Resource ID for a Security Partner Provider +type SecurityPartnerProviderId struct { + SubscriptionId string + ResourceGroupName string + SecurityPartnerProviderName string +} + +// NewSecurityPartnerProviderID returns a new SecurityPartnerProviderId struct +func NewSecurityPartnerProviderID(subscriptionId string, resourceGroupName string, securityPartnerProviderName string) SecurityPartnerProviderId { + return SecurityPartnerProviderId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SecurityPartnerProviderName: securityPartnerProviderName, + } +} + +// ParseSecurityPartnerProviderID parses 'input' into a SecurityPartnerProviderId +func ParseSecurityPartnerProviderID(input string) (*SecurityPartnerProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityPartnerProviderId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityPartnerProviderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSecurityPartnerProviderIDInsensitively parses 'input' case-insensitively into a SecurityPartnerProviderId +// note: this method should only be used for API response data and not user input +func ParseSecurityPartnerProviderIDInsensitively(input string) (*SecurityPartnerProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityPartnerProviderId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityPartnerProviderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SecurityPartnerProviderId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SecurityPartnerProviderName, ok = input.Parsed["securityPartnerProviderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "securityPartnerProviderName", input) + } + + return nil +} + +// ValidateSecurityPartnerProviderID checks that 'input' can be parsed as a Security Partner Provider ID +func ValidateSecurityPartnerProviderID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSecurityPartnerProviderID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Security Partner Provider ID +func (id SecurityPartnerProviderId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/securityPartnerProviders/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SecurityPartnerProviderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Security Partner Provider ID +func (id SecurityPartnerProviderId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticSecurityPartnerProviders", "securityPartnerProviders", "securityPartnerProviders"), + resourceids.UserSpecifiedSegment("securityPartnerProviderName", "securityPartnerProviderName"), + } +} + +// String returns a human-readable description of this Security Partner Provider ID +func (id SecurityPartnerProviderId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Security Partner Provider Name: %q", id.SecurityPartnerProviderName), + } + return fmt.Sprintf("Security Partner Provider (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/securitypartnerproviders/id_securitypartnerprovider_test.go b/resource-manager/network/2024-07-01/securitypartnerproviders/id_securitypartnerprovider_test.go new file mode 100644 index 00000000000..915d4b3facc --- /dev/null +++ b/resource-manager/network/2024-07-01/securitypartnerproviders/id_securitypartnerprovider_test.go @@ -0,0 +1,282 @@ +package securitypartnerproviders + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SecurityPartnerProviderId{} + +func TestNewSecurityPartnerProviderID(t *testing.T) { + id := NewSecurityPartnerProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "securityPartnerProviderName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SecurityPartnerProviderName != "securityPartnerProviderName" { + t.Fatalf("Expected %q but got %q for Segment 'SecurityPartnerProviderName'", id.SecurityPartnerProviderName, "securityPartnerProviderName") + } +} + +func TestFormatSecurityPartnerProviderID(t *testing.T) { + actual := NewSecurityPartnerProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "securityPartnerProviderName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/securityPartnerProviders/securityPartnerProviderName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSecurityPartnerProviderID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityPartnerProviderId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/securityPartnerProviders", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/securityPartnerProviders/securityPartnerProviderName", + Expected: &SecurityPartnerProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SecurityPartnerProviderName: "securityPartnerProviderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/securityPartnerProviders/securityPartnerProviderName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityPartnerProviderID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SecurityPartnerProviderName != v.Expected.SecurityPartnerProviderName { + t.Fatalf("Expected %q but got %q for SecurityPartnerProviderName", v.Expected.SecurityPartnerProviderName, actual.SecurityPartnerProviderName) + } + + } +} + +func TestParseSecurityPartnerProviderIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityPartnerProviderId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/securityPartnerProviders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/sEcUrItYpArTnErPrOvIdErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/securityPartnerProviders/securityPartnerProviderName", + Expected: &SecurityPartnerProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SecurityPartnerProviderName: "securityPartnerProviderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/securityPartnerProviders/securityPartnerProviderName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/sEcUrItYpArTnErPrOvIdErS/sEcUrItYpArTnErPrOvIdErNaMe", + Expected: &SecurityPartnerProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SecurityPartnerProviderName: "sEcUrItYpArTnErPrOvIdErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/sEcUrItYpArTnErPrOvIdErS/sEcUrItYpArTnErPrOvIdErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityPartnerProviderIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SecurityPartnerProviderName != v.Expected.SecurityPartnerProviderName { + t.Fatalf("Expected %q but got %q for SecurityPartnerProviderName", v.Expected.SecurityPartnerProviderName, actual.SecurityPartnerProviderName) + } + + } +} + +func TestSegmentsForSecurityPartnerProviderId(t *testing.T) { + segments := SecurityPartnerProviderId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SecurityPartnerProviderId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/securitypartnerproviders/method_createorupdate.go b/resource-manager/network/2024-07-01/securitypartnerproviders/method_createorupdate.go new file mode 100644 index 00000000000..3fb82d42ab3 --- /dev/null +++ b/resource-manager/network/2024-07-01/securitypartnerproviders/method_createorupdate.go @@ -0,0 +1,75 @@ +package securitypartnerproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SecurityPartnerProvider +} + +// CreateOrUpdate ... +func (c SecurityPartnerProvidersClient) CreateOrUpdate(ctx context.Context, id SecurityPartnerProviderId, input SecurityPartnerProvider) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c SecurityPartnerProvidersClient) CreateOrUpdateThenPoll(ctx context.Context, id SecurityPartnerProviderId, input SecurityPartnerProvider) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/securitypartnerproviders/method_delete.go b/resource-manager/network/2024-07-01/securitypartnerproviders/method_delete.go new file mode 100644 index 00000000000..9494188070d --- /dev/null +++ b/resource-manager/network/2024-07-01/securitypartnerproviders/method_delete.go @@ -0,0 +1,71 @@ +package securitypartnerproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c SecurityPartnerProvidersClient) Delete(ctx context.Context, id SecurityPartnerProviderId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c SecurityPartnerProvidersClient) DeleteThenPoll(ctx context.Context, id SecurityPartnerProviderId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/securitypartnerproviders/method_get.go b/resource-manager/network/2024-07-01/securitypartnerproviders/method_get.go new file mode 100644 index 00000000000..5b244206a3f --- /dev/null +++ b/resource-manager/network/2024-07-01/securitypartnerproviders/method_get.go @@ -0,0 +1,53 @@ +package securitypartnerproviders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecurityPartnerProvider +} + +// Get ... +func (c SecurityPartnerProvidersClient) Get(ctx context.Context, id SecurityPartnerProviderId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SecurityPartnerProvider + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/securitypartnerproviders/method_list.go b/resource-manager/network/2024-07-01/securitypartnerproviders/method_list.go new file mode 100644 index 00000000000..9a4f5451680 --- /dev/null +++ b/resource-manager/network/2024-07-01/securitypartnerproviders/method_list.go @@ -0,0 +1,106 @@ +package securitypartnerproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SecurityPartnerProvider +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SecurityPartnerProvider +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c SecurityPartnerProvidersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/securityPartnerProviders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SecurityPartnerProvider `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c SecurityPartnerProvidersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SecurityPartnerProviderOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SecurityPartnerProvidersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SecurityPartnerProviderOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SecurityPartnerProvider, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/securitypartnerproviders/method_listbyresourcegroup.go b/resource-manager/network/2024-07-01/securitypartnerproviders/method_listbyresourcegroup.go new file mode 100644 index 00000000000..0616c919e32 --- /dev/null +++ b/resource-manager/network/2024-07-01/securitypartnerproviders/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package securitypartnerproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SecurityPartnerProvider +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []SecurityPartnerProvider +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c SecurityPartnerProvidersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/securityPartnerProviders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SecurityPartnerProvider `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c SecurityPartnerProvidersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, SecurityPartnerProviderOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SecurityPartnerProvidersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate SecurityPartnerProviderOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]SecurityPartnerProvider, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/securitypartnerproviders/method_updatetags.go b/resource-manager/network/2024-07-01/securitypartnerproviders/method_updatetags.go new file mode 100644 index 00000000000..dfd04e92e88 --- /dev/null +++ b/resource-manager/network/2024-07-01/securitypartnerproviders/method_updatetags.go @@ -0,0 +1,57 @@ +package securitypartnerproviders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecurityPartnerProvider +} + +// UpdateTags ... +func (c SecurityPartnerProvidersClient) UpdateTags(ctx context.Context, id SecurityPartnerProviderId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SecurityPartnerProvider + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/securitypartnerproviders/model_securitypartnerprovider.go b/resource-manager/network/2024-07-01/securitypartnerproviders/model_securitypartnerprovider.go new file mode 100644 index 00000000000..059710a7ff6 --- /dev/null +++ b/resource-manager/network/2024-07-01/securitypartnerproviders/model_securitypartnerprovider.go @@ -0,0 +1,14 @@ +package securitypartnerproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityPartnerProvider struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityPartnerProviderPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/securitypartnerproviders/model_securitypartnerproviderpropertiesformat.go b/resource-manager/network/2024-07-01/securitypartnerproviders/model_securitypartnerproviderpropertiesformat.go new file mode 100644 index 00000000000..100f4648a9e --- /dev/null +++ b/resource-manager/network/2024-07-01/securitypartnerproviders/model_securitypartnerproviderpropertiesformat.go @@ -0,0 +1,11 @@ +package securitypartnerproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityPartnerProviderPropertiesFormat struct { + ConnectionStatus *SecurityPartnerProviderConnectionStatus `json:"connectionStatus,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SecurityProviderName *SecurityProviderName `json:"securityProviderName,omitempty"` + VirtualHub *SubResource `json:"virtualHub,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/securitypartnerproviders/model_subresource.go b/resource-manager/network/2024-07-01/securitypartnerproviders/model_subresource.go new file mode 100644 index 00000000000..0d259c7609a --- /dev/null +++ b/resource-manager/network/2024-07-01/securitypartnerproviders/model_subresource.go @@ -0,0 +1,8 @@ +package securitypartnerproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/securitypartnerproviders/model_tagsobject.go b/resource-manager/network/2024-07-01/securitypartnerproviders/model_tagsobject.go new file mode 100644 index 00000000000..64020cc08ef --- /dev/null +++ b/resource-manager/network/2024-07-01/securitypartnerproviders/model_tagsobject.go @@ -0,0 +1,8 @@ +package securitypartnerproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/securitypartnerproviders/predicates.go b/resource-manager/network/2024-07-01/securitypartnerproviders/predicates.go new file mode 100644 index 00000000000..ef826d6c55f --- /dev/null +++ b/resource-manager/network/2024-07-01/securitypartnerproviders/predicates.go @@ -0,0 +1,37 @@ +package securitypartnerproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityPartnerProviderOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p SecurityPartnerProviderOperationPredicate) Matches(input SecurityPartnerProvider) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/securitypartnerproviders/version.go b/resource-manager/network/2024-07-01/securitypartnerproviders/version.go new file mode 100644 index 00000000000..e2600746d19 --- /dev/null +++ b/resource-manager/network/2024-07-01/securitypartnerproviders/version.go @@ -0,0 +1,10 @@ +package securitypartnerproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/securitypartnerproviders/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/securityrules/README.md b/resource-manager/network/2024-07-01/securityrules/README.md new file mode 100644 index 00000000000..c22fdaa4485 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/README.md @@ -0,0 +1,115 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securityrules` Documentation + +The `securityrules` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securityrules" +``` + + +### Client Initialization + +```go +client := securityrules.NewSecurityRulesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SecurityRulesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := securityrules.NewSecurityRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName", "securityRuleName") + +payload := securityrules.SecurityRule{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SecurityRulesClient.DefaultSecurityRulesGet` + +```go +ctx := context.TODO() +id := securityrules.NewDefaultSecurityRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName", "defaultSecurityRuleName") + +read, err := client.DefaultSecurityRulesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SecurityRulesClient.DefaultSecurityRulesList` + +```go +ctx := context.TODO() +id := securityrules.NewNetworkSecurityGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName") + +// alternatively `client.DefaultSecurityRulesList(ctx, id)` can be used to do batched pagination +items, err := client.DefaultSecurityRulesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SecurityRulesClient.Delete` + +```go +ctx := context.TODO() +id := securityrules.NewSecurityRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName", "securityRuleName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SecurityRulesClient.Get` + +```go +ctx := context.TODO() +id := securityrules.NewSecurityRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName", "securityRuleName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SecurityRulesClient.List` + +```go +ctx := context.TODO() +id := securityrules.NewNetworkSecurityGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/securityrules/client.go b/resource-manager/network/2024-07-01/securityrules/client.go new file mode 100644 index 00000000000..fe76b456975 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/client.go @@ -0,0 +1,26 @@ +package securityrules + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulesClient struct { + Client *resourcemanager.Client +} + +func NewSecurityRulesClientWithBaseURI(sdkApi sdkEnv.Api) (*SecurityRulesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "securityrules", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SecurityRulesClient: %+v", err) + } + + return &SecurityRulesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/securityrules/constants.go b/resource-manager/network/2024-07-01/securityrules/constants.go new file mode 100644 index 00000000000..41396358614 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/constants.go @@ -0,0 +1,192 @@ +package securityrules + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/securityrules/id_defaultsecurityrule.go b/resource-manager/network/2024-07-01/securityrules/id_defaultsecurityrule.go new file mode 100644 index 00000000000..0a8b4713607 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/id_defaultsecurityrule.go @@ -0,0 +1,139 @@ +package securityrules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DefaultSecurityRuleId{}) +} + +var _ resourceids.ResourceId = &DefaultSecurityRuleId{} + +// DefaultSecurityRuleId is a struct representing the Resource ID for a Default Security Rule +type DefaultSecurityRuleId struct { + SubscriptionId string + ResourceGroupName string + NetworkSecurityGroupName string + DefaultSecurityRuleName string +} + +// NewDefaultSecurityRuleID returns a new DefaultSecurityRuleId struct +func NewDefaultSecurityRuleID(subscriptionId string, resourceGroupName string, networkSecurityGroupName string, defaultSecurityRuleName string) DefaultSecurityRuleId { + return DefaultSecurityRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkSecurityGroupName: networkSecurityGroupName, + DefaultSecurityRuleName: defaultSecurityRuleName, + } +} + +// ParseDefaultSecurityRuleID parses 'input' into a DefaultSecurityRuleId +func ParseDefaultSecurityRuleID(input string) (*DefaultSecurityRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&DefaultSecurityRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DefaultSecurityRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDefaultSecurityRuleIDInsensitively parses 'input' case-insensitively into a DefaultSecurityRuleId +// note: this method should only be used for API response data and not user input +func ParseDefaultSecurityRuleIDInsensitively(input string) (*DefaultSecurityRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&DefaultSecurityRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DefaultSecurityRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DefaultSecurityRuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkSecurityGroupName, ok = input.Parsed["networkSecurityGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityGroupName", input) + } + + if id.DefaultSecurityRuleName, ok = input.Parsed["defaultSecurityRuleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "defaultSecurityRuleName", input) + } + + return nil +} + +// ValidateDefaultSecurityRuleID checks that 'input' can be parsed as a Default Security Rule ID +func ValidateDefaultSecurityRuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDefaultSecurityRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Default Security Rule ID +func (id DefaultSecurityRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s/defaultSecurityRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkSecurityGroupName, id.DefaultSecurityRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Default Security Rule ID +func (id DefaultSecurityRuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkSecurityGroups", "networkSecurityGroups", "networkSecurityGroups"), + resourceids.UserSpecifiedSegment("networkSecurityGroupName", "networkSecurityGroupName"), + resourceids.StaticSegment("staticDefaultSecurityRules", "defaultSecurityRules", "defaultSecurityRules"), + resourceids.UserSpecifiedSegment("defaultSecurityRuleName", "defaultSecurityRuleName"), + } +} + +// String returns a human-readable description of this Default Security Rule ID +func (id DefaultSecurityRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Security Group Name: %q", id.NetworkSecurityGroupName), + fmt.Sprintf("Default Security Rule Name: %q", id.DefaultSecurityRuleName), + } + return fmt.Sprintf("Default Security Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/securityrules/id_defaultsecurityrule_test.go b/resource-manager/network/2024-07-01/securityrules/id_defaultsecurityrule_test.go new file mode 100644 index 00000000000..2ee34648af5 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/id_defaultsecurityrule_test.go @@ -0,0 +1,327 @@ +package securityrules + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DefaultSecurityRuleId{} + +func TestNewDefaultSecurityRuleID(t *testing.T) { + id := NewDefaultSecurityRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName", "defaultSecurityRuleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkSecurityGroupName != "networkSecurityGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityGroupName'", id.NetworkSecurityGroupName, "networkSecurityGroupName") + } + + if id.DefaultSecurityRuleName != "defaultSecurityRuleName" { + t.Fatalf("Expected %q but got %q for Segment 'DefaultSecurityRuleName'", id.DefaultSecurityRuleName, "defaultSecurityRuleName") + } +} + +func TestFormatDefaultSecurityRuleID(t *testing.T) { + actual := NewDefaultSecurityRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName", "defaultSecurityRuleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/defaultSecurityRules/defaultSecurityRuleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDefaultSecurityRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DefaultSecurityRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/defaultSecurityRules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/defaultSecurityRules/defaultSecurityRuleName", + Expected: &DefaultSecurityRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityGroupName: "networkSecurityGroupName", + DefaultSecurityRuleName: "defaultSecurityRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/defaultSecurityRules/defaultSecurityRuleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDefaultSecurityRuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityGroupName != v.Expected.NetworkSecurityGroupName { + t.Fatalf("Expected %q but got %q for NetworkSecurityGroupName", v.Expected.NetworkSecurityGroupName, actual.NetworkSecurityGroupName) + } + + if actual.DefaultSecurityRuleName != v.Expected.DefaultSecurityRuleName { + t.Fatalf("Expected %q but got %q for DefaultSecurityRuleName", v.Expected.DefaultSecurityRuleName, actual.DefaultSecurityRuleName) + } + + } +} + +func TestParseDefaultSecurityRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DefaultSecurityRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyGrOuPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyGrOuPs/nEtWoRkSeCuRiTyGrOuPnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/defaultSecurityRules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyGrOuPs/nEtWoRkSeCuRiTyGrOuPnAmE/dEfAuLtSeCuRiTyRuLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/defaultSecurityRules/defaultSecurityRuleName", + Expected: &DefaultSecurityRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityGroupName: "networkSecurityGroupName", + DefaultSecurityRuleName: "defaultSecurityRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/defaultSecurityRules/defaultSecurityRuleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyGrOuPs/nEtWoRkSeCuRiTyGrOuPnAmE/dEfAuLtSeCuRiTyRuLeS/dEfAuLtSeCuRiTyRuLeNaMe", + Expected: &DefaultSecurityRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkSecurityGroupName: "nEtWoRkSeCuRiTyGrOuPnAmE", + DefaultSecurityRuleName: "dEfAuLtSeCuRiTyRuLeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyGrOuPs/nEtWoRkSeCuRiTyGrOuPnAmE/dEfAuLtSeCuRiTyRuLeS/dEfAuLtSeCuRiTyRuLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDefaultSecurityRuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityGroupName != v.Expected.NetworkSecurityGroupName { + t.Fatalf("Expected %q but got %q for NetworkSecurityGroupName", v.Expected.NetworkSecurityGroupName, actual.NetworkSecurityGroupName) + } + + if actual.DefaultSecurityRuleName != v.Expected.DefaultSecurityRuleName { + t.Fatalf("Expected %q but got %q for DefaultSecurityRuleName", v.Expected.DefaultSecurityRuleName, actual.DefaultSecurityRuleName) + } + + } +} + +func TestSegmentsForDefaultSecurityRuleId(t *testing.T) { + segments := DefaultSecurityRuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DefaultSecurityRuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/securityrules/id_networksecuritygroup.go b/resource-manager/network/2024-07-01/securityrules/id_networksecuritygroup.go new file mode 100644 index 00000000000..c684ad86696 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/id_networksecuritygroup.go @@ -0,0 +1,130 @@ +package securityrules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkSecurityGroupId{}) +} + +var _ resourceids.ResourceId = &NetworkSecurityGroupId{} + +// NetworkSecurityGroupId is a struct representing the Resource ID for a Network Security Group +type NetworkSecurityGroupId struct { + SubscriptionId string + ResourceGroupName string + NetworkSecurityGroupName string +} + +// NewNetworkSecurityGroupID returns a new NetworkSecurityGroupId struct +func NewNetworkSecurityGroupID(subscriptionId string, resourceGroupName string, networkSecurityGroupName string) NetworkSecurityGroupId { + return NetworkSecurityGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkSecurityGroupName: networkSecurityGroupName, + } +} + +// ParseNetworkSecurityGroupID parses 'input' into a NetworkSecurityGroupId +func ParseNetworkSecurityGroupID(input string) (*NetworkSecurityGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkSecurityGroupIDInsensitively parses 'input' case-insensitively into a NetworkSecurityGroupId +// note: this method should only be used for API response data and not user input +func ParseNetworkSecurityGroupIDInsensitively(input string) (*NetworkSecurityGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkSecurityGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkSecurityGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkSecurityGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkSecurityGroupName, ok = input.Parsed["networkSecurityGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityGroupName", input) + } + + return nil +} + +// ValidateNetworkSecurityGroupID checks that 'input' can be parsed as a Network Security Group ID +func ValidateNetworkSecurityGroupID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkSecurityGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Security Group ID +func (id NetworkSecurityGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkSecurityGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Security Group ID +func (id NetworkSecurityGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkSecurityGroups", "networkSecurityGroups", "networkSecurityGroups"), + resourceids.UserSpecifiedSegment("networkSecurityGroupName", "networkSecurityGroupName"), + } +} + +// String returns a human-readable description of this Network Security Group ID +func (id NetworkSecurityGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Security Group Name: %q", id.NetworkSecurityGroupName), + } + return fmt.Sprintf("Network Security Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/securityrules/id_networksecuritygroup_test.go b/resource-manager/network/2024-07-01/securityrules/id_networksecuritygroup_test.go new file mode 100644 index 00000000000..a43e2ec48a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/id_networksecuritygroup_test.go @@ -0,0 +1,282 @@ +package securityrules + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkSecurityGroupId{} + +func TestNewNetworkSecurityGroupID(t *testing.T) { + id := NewNetworkSecurityGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkSecurityGroupName != "networkSecurityGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityGroupName'", id.NetworkSecurityGroupName, "networkSecurityGroupName") + } +} + +func TestFormatNetworkSecurityGroupID(t *testing.T) { + actual := NewNetworkSecurityGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkSecurityGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName", + Expected: &NetworkSecurityGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityGroupName: "networkSecurityGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityGroupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityGroupName != v.Expected.NetworkSecurityGroupName { + t.Fatalf("Expected %q but got %q for NetworkSecurityGroupName", v.Expected.NetworkSecurityGroupName, actual.NetworkSecurityGroupName) + } + + } +} + +func TestParseNetworkSecurityGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkSecurityGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyGrOuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName", + Expected: &NetworkSecurityGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityGroupName: "networkSecurityGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyGrOuPs/nEtWoRkSeCuRiTyGrOuPnAmE", + Expected: &NetworkSecurityGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkSecurityGroupName: "nEtWoRkSeCuRiTyGrOuPnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyGrOuPs/nEtWoRkSeCuRiTyGrOuPnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkSecurityGroupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityGroupName != v.Expected.NetworkSecurityGroupName { + t.Fatalf("Expected %q but got %q for NetworkSecurityGroupName", v.Expected.NetworkSecurityGroupName, actual.NetworkSecurityGroupName) + } + + } +} + +func TestSegmentsForNetworkSecurityGroupId(t *testing.T) { + segments := NetworkSecurityGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkSecurityGroupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/securityrules/id_securityrule.go b/resource-manager/network/2024-07-01/securityrules/id_securityrule.go new file mode 100644 index 00000000000..105879c1133 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/id_securityrule.go @@ -0,0 +1,139 @@ +package securityrules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SecurityRuleId{}) +} + +var _ resourceids.ResourceId = &SecurityRuleId{} + +// SecurityRuleId is a struct representing the Resource ID for a Security Rule +type SecurityRuleId struct { + SubscriptionId string + ResourceGroupName string + NetworkSecurityGroupName string + SecurityRuleName string +} + +// NewSecurityRuleID returns a new SecurityRuleId struct +func NewSecurityRuleID(subscriptionId string, resourceGroupName string, networkSecurityGroupName string, securityRuleName string) SecurityRuleId { + return SecurityRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkSecurityGroupName: networkSecurityGroupName, + SecurityRuleName: securityRuleName, + } +} + +// ParseSecurityRuleID parses 'input' into a SecurityRuleId +func ParseSecurityRuleID(input string) (*SecurityRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSecurityRuleIDInsensitively parses 'input' case-insensitively into a SecurityRuleId +// note: this method should only be used for API response data and not user input +func ParseSecurityRuleIDInsensitively(input string) (*SecurityRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SecurityRuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkSecurityGroupName, ok = input.Parsed["networkSecurityGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkSecurityGroupName", input) + } + + if id.SecurityRuleName, ok = input.Parsed["securityRuleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "securityRuleName", input) + } + + return nil +} + +// ValidateSecurityRuleID checks that 'input' can be parsed as a Security Rule ID +func ValidateSecurityRuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSecurityRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Security Rule ID +func (id SecurityRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkSecurityGroups/%s/securityRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkSecurityGroupName, id.SecurityRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Security Rule ID +func (id SecurityRuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkSecurityGroups", "networkSecurityGroups", "networkSecurityGroups"), + resourceids.UserSpecifiedSegment("networkSecurityGroupName", "networkSecurityGroupName"), + resourceids.StaticSegment("staticSecurityRules", "securityRules", "securityRules"), + resourceids.UserSpecifiedSegment("securityRuleName", "securityRuleName"), + } +} + +// String returns a human-readable description of this Security Rule ID +func (id SecurityRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Security Group Name: %q", id.NetworkSecurityGroupName), + fmt.Sprintf("Security Rule Name: %q", id.SecurityRuleName), + } + return fmt.Sprintf("Security Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/securityrules/id_securityrule_test.go b/resource-manager/network/2024-07-01/securityrules/id_securityrule_test.go new file mode 100644 index 00000000000..5dae175a65c --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/id_securityrule_test.go @@ -0,0 +1,327 @@ +package securityrules + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SecurityRuleId{} + +func TestNewSecurityRuleID(t *testing.T) { + id := NewSecurityRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName", "securityRuleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkSecurityGroupName != "networkSecurityGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkSecurityGroupName'", id.NetworkSecurityGroupName, "networkSecurityGroupName") + } + + if id.SecurityRuleName != "securityRuleName" { + t.Fatalf("Expected %q but got %q for Segment 'SecurityRuleName'", id.SecurityRuleName, "securityRuleName") + } +} + +func TestFormatSecurityRuleID(t *testing.T) { + actual := NewSecurityRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkSecurityGroupName", "securityRuleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/securityRules/securityRuleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSecurityRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/securityRules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/securityRules/securityRuleName", + Expected: &SecurityRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityGroupName: "networkSecurityGroupName", + SecurityRuleName: "securityRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/securityRules/securityRuleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityRuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityGroupName != v.Expected.NetworkSecurityGroupName { + t.Fatalf("Expected %q but got %q for NetworkSecurityGroupName", v.Expected.NetworkSecurityGroupName, actual.NetworkSecurityGroupName) + } + + if actual.SecurityRuleName != v.Expected.SecurityRuleName { + t.Fatalf("Expected %q but got %q for SecurityRuleName", v.Expected.SecurityRuleName, actual.SecurityRuleName) + } + + } +} + +func TestParseSecurityRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyGrOuPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyGrOuPs/nEtWoRkSeCuRiTyGrOuPnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/securityRules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyGrOuPs/nEtWoRkSeCuRiTyGrOuPnAmE/sEcUrItYrUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/securityRules/securityRuleName", + Expected: &SecurityRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkSecurityGroupName: "networkSecurityGroupName", + SecurityRuleName: "securityRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkSecurityGroups/networkSecurityGroupName/securityRules/securityRuleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyGrOuPs/nEtWoRkSeCuRiTyGrOuPnAmE/sEcUrItYrUlEs/sEcUrItYrUlEnAmE", + Expected: &SecurityRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkSecurityGroupName: "nEtWoRkSeCuRiTyGrOuPnAmE", + SecurityRuleName: "sEcUrItYrUlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkSeCuRiTyGrOuPs/nEtWoRkSeCuRiTyGrOuPnAmE/sEcUrItYrUlEs/sEcUrItYrUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityRuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkSecurityGroupName != v.Expected.NetworkSecurityGroupName { + t.Fatalf("Expected %q but got %q for NetworkSecurityGroupName", v.Expected.NetworkSecurityGroupName, actual.NetworkSecurityGroupName) + } + + if actual.SecurityRuleName != v.Expected.SecurityRuleName { + t.Fatalf("Expected %q but got %q for SecurityRuleName", v.Expected.SecurityRuleName, actual.SecurityRuleName) + } + + } +} + +func TestSegmentsForSecurityRuleId(t *testing.T) { + segments := SecurityRuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SecurityRuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/securityrules/method_createorupdate.go b/resource-manager/network/2024-07-01/securityrules/method_createorupdate.go new file mode 100644 index 00000000000..ca2001b1716 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/method_createorupdate.go @@ -0,0 +1,75 @@ +package securityrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SecurityRule +} + +// CreateOrUpdate ... +func (c SecurityRulesClient) CreateOrUpdate(ctx context.Context, id SecurityRuleId, input SecurityRule) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c SecurityRulesClient) CreateOrUpdateThenPoll(ctx context.Context, id SecurityRuleId, input SecurityRule) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/securityrules/method_defaultsecurityrulesget.go b/resource-manager/network/2024-07-01/securityrules/method_defaultsecurityrulesget.go new file mode 100644 index 00000000000..0d436a23706 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/method_defaultsecurityrulesget.go @@ -0,0 +1,53 @@ +package securityrules + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DefaultSecurityRulesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecurityRule +} + +// DefaultSecurityRulesGet ... +func (c SecurityRulesClient) DefaultSecurityRulesGet(ctx context.Context, id DefaultSecurityRuleId) (result DefaultSecurityRulesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SecurityRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/securityrules/method_defaultsecurityruleslist.go b/resource-manager/network/2024-07-01/securityrules/method_defaultsecurityruleslist.go new file mode 100644 index 00000000000..fbf92af5b89 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/method_defaultsecurityruleslist.go @@ -0,0 +1,105 @@ +package securityrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DefaultSecurityRulesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SecurityRule +} + +type DefaultSecurityRulesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SecurityRule +} + +type DefaultSecurityRulesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *DefaultSecurityRulesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// DefaultSecurityRulesList ... +func (c SecurityRulesClient) DefaultSecurityRulesList(ctx context.Context, id NetworkSecurityGroupId) (result DefaultSecurityRulesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &DefaultSecurityRulesListCustomPager{}, + Path: fmt.Sprintf("%s/defaultSecurityRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SecurityRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// DefaultSecurityRulesListComplete retrieves all the results into a single object +func (c SecurityRulesClient) DefaultSecurityRulesListComplete(ctx context.Context, id NetworkSecurityGroupId) (DefaultSecurityRulesListCompleteResult, error) { + return c.DefaultSecurityRulesListCompleteMatchingPredicate(ctx, id, SecurityRuleOperationPredicate{}) +} + +// DefaultSecurityRulesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SecurityRulesClient) DefaultSecurityRulesListCompleteMatchingPredicate(ctx context.Context, id NetworkSecurityGroupId, predicate SecurityRuleOperationPredicate) (result DefaultSecurityRulesListCompleteResult, err error) { + items := make([]SecurityRule, 0) + + resp, err := c.DefaultSecurityRulesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = DefaultSecurityRulesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/securityrules/method_delete.go b/resource-manager/network/2024-07-01/securityrules/method_delete.go new file mode 100644 index 00000000000..769b4866b0d --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/method_delete.go @@ -0,0 +1,71 @@ +package securityrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c SecurityRulesClient) Delete(ctx context.Context, id SecurityRuleId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c SecurityRulesClient) DeleteThenPoll(ctx context.Context, id SecurityRuleId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/securityrules/method_get.go b/resource-manager/network/2024-07-01/securityrules/method_get.go new file mode 100644 index 00000000000..85ddb4310ff --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/method_get.go @@ -0,0 +1,53 @@ +package securityrules + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecurityRule +} + +// Get ... +func (c SecurityRulesClient) Get(ctx context.Context, id SecurityRuleId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SecurityRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/securityrules/method_list.go b/resource-manager/network/2024-07-01/securityrules/method_list.go new file mode 100644 index 00000000000..73b4f2f1a16 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/method_list.go @@ -0,0 +1,105 @@ +package securityrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SecurityRule +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SecurityRule +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c SecurityRulesClient) List(ctx context.Context, id NetworkSecurityGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/securityRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SecurityRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c SecurityRulesClient) ListComplete(ctx context.Context, id NetworkSecurityGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SecurityRuleOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SecurityRulesClient) ListCompleteMatchingPredicate(ctx context.Context, id NetworkSecurityGroupId, predicate SecurityRuleOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SecurityRule, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/securityrules/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/securityrules/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..7a6b77fa92a --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package securityrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/securityrules/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/securityrules/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..b73ae024539 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package securityrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/securityrules/model_securityrule.go b/resource-manager/network/2024-07-01/securityrules/model_securityrule.go new file mode 100644 index 00000000000..e96cb57aa16 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/model_securityrule.go @@ -0,0 +1,12 @@ +package securityrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/securityrules/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/securityrules/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..a7e44555d95 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package securityrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/securityrules/predicates.go b/resource-manager/network/2024-07-01/securityrules/predicates.go new file mode 100644 index 00000000000..adf918c9ac4 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/predicates.go @@ -0,0 +1,32 @@ +package securityrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRuleOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p SecurityRuleOperationPredicate) Matches(input SecurityRule) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/securityrules/version.go b/resource-manager/network/2024-07-01/securityrules/version.go new file mode 100644 index 00000000000..83dd78a4094 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityrules/version.go @@ -0,0 +1,10 @@ +package securityrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/securityrules/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/securityuserconfigurations/README.md b/resource-manager/network/2024-07-01/securityuserconfigurations/README.md new file mode 100644 index 00000000000..54aa1614d86 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserconfigurations/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securityuserconfigurations` Documentation + +The `securityuserconfigurations` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securityuserconfigurations" +``` + + +### Client Initialization + +```go +client := securityuserconfigurations.NewSecurityUserConfigurationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SecurityUserConfigurationsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := securityuserconfigurations.NewSecurityUserConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName") + +payload := securityuserconfigurations.SecurityUserConfiguration{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SecurityUserConfigurationsClient.Delete` + +```go +ctx := context.TODO() +id := securityuserconfigurations.NewSecurityUserConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName") + +if err := client.DeleteThenPoll(ctx, id, securityuserconfigurations.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `SecurityUserConfigurationsClient.Get` + +```go +ctx := context.TODO() +id := securityuserconfigurations.NewSecurityUserConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SecurityUserConfigurationsClient.List` + +```go +ctx := context.TODO() +id := securityuserconfigurations.NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + +// alternatively `client.List(ctx, id, securityuserconfigurations.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, securityuserconfigurations.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/securityuserconfigurations/client.go b/resource-manager/network/2024-07-01/securityuserconfigurations/client.go new file mode 100644 index 00000000000..81e35e1bfd0 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserconfigurations/client.go @@ -0,0 +1,26 @@ +package securityuserconfigurations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityUserConfigurationsClient struct { + Client *resourcemanager.Client +} + +func NewSecurityUserConfigurationsClientWithBaseURI(sdkApi sdkEnv.Api) (*SecurityUserConfigurationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "securityuserconfigurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SecurityUserConfigurationsClient: %+v", err) + } + + return &SecurityUserConfigurationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/securityuserconfigurations/constants.go b/resource-manager/network/2024-07-01/securityuserconfigurations/constants.go new file mode 100644 index 00000000000..28a18df6697 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserconfigurations/constants.go @@ -0,0 +1,57 @@ +package securityuserconfigurations + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/securityuserconfigurations/id_networkmanager.go b/resource-manager/network/2024-07-01/securityuserconfigurations/id_networkmanager.go new file mode 100644 index 00000000000..a1c611edbe6 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserconfigurations/id_networkmanager.go @@ -0,0 +1,130 @@ +package securityuserconfigurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkManagerId{}) +} + +var _ resourceids.ResourceId = &NetworkManagerId{} + +// NetworkManagerId is a struct representing the Resource ID for a Network Manager +type NetworkManagerId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string +} + +// NewNetworkManagerID returns a new NetworkManagerId struct +func NewNetworkManagerID(subscriptionId string, resourceGroupName string, networkManagerName string) NetworkManagerId { + return NetworkManagerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + } +} + +// ParseNetworkManagerID parses 'input' into a NetworkManagerId +func ParseNetworkManagerID(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkManagerIDInsensitively parses 'input' case-insensitively into a NetworkManagerId +// note: this method should only be used for API response data and not user input +func ParseNetworkManagerIDInsensitively(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkManagerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + return nil +} + +// ValidateNetworkManagerID checks that 'input' can be parsed as a Network Manager ID +func ValidateNetworkManagerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkManagerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Manager ID +func (id NetworkManagerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Manager ID +func (id NetworkManagerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + } +} + +// String returns a human-readable description of this Network Manager ID +func (id NetworkManagerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + } + return fmt.Sprintf("Network Manager (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/securityuserconfigurations/id_networkmanager_test.go b/resource-manager/network/2024-07-01/securityuserconfigurations/id_networkmanager_test.go new file mode 100644 index 00000000000..fbd2c4a29e8 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserconfigurations/id_networkmanager_test.go @@ -0,0 +1,282 @@ +package securityuserconfigurations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkManagerId{} + +func TestNewNetworkManagerID(t *testing.T) { + id := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } +} + +func TestFormatNetworkManagerID(t *testing.T) { + actual := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkManagerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestParseNetworkManagerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestSegmentsForNetworkManagerId(t *testing.T) { + segments := NetworkManagerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkManagerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/securityuserconfigurations/id_securityuserconfiguration.go b/resource-manager/network/2024-07-01/securityuserconfigurations/id_securityuserconfiguration.go new file mode 100644 index 00000000000..6df5321bd18 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserconfigurations/id_securityuserconfiguration.go @@ -0,0 +1,139 @@ +package securityuserconfigurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SecurityUserConfigurationId{}) +} + +var _ resourceids.ResourceId = &SecurityUserConfigurationId{} + +// SecurityUserConfigurationId is a struct representing the Resource ID for a Security User Configuration +type SecurityUserConfigurationId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + SecurityUserConfigurationName string +} + +// NewSecurityUserConfigurationID returns a new SecurityUserConfigurationId struct +func NewSecurityUserConfigurationID(subscriptionId string, resourceGroupName string, networkManagerName string, securityUserConfigurationName string) SecurityUserConfigurationId { + return SecurityUserConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + SecurityUserConfigurationName: securityUserConfigurationName, + } +} + +// ParseSecurityUserConfigurationID parses 'input' into a SecurityUserConfigurationId +func ParseSecurityUserConfigurationID(input string) (*SecurityUserConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityUserConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityUserConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSecurityUserConfigurationIDInsensitively parses 'input' case-insensitively into a SecurityUserConfigurationId +// note: this method should only be used for API response data and not user input +func ParseSecurityUserConfigurationIDInsensitively(input string) (*SecurityUserConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityUserConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityUserConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SecurityUserConfigurationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.SecurityUserConfigurationName, ok = input.Parsed["securityUserConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "securityUserConfigurationName", input) + } + + return nil +} + +// ValidateSecurityUserConfigurationID checks that 'input' can be parsed as a Security User Configuration ID +func ValidateSecurityUserConfigurationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSecurityUserConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Security User Configuration ID +func (id SecurityUserConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/securityUserConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.SecurityUserConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Security User Configuration ID +func (id SecurityUserConfigurationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticSecurityUserConfigurations", "securityUserConfigurations", "securityUserConfigurations"), + resourceids.UserSpecifiedSegment("securityUserConfigurationName", "securityUserConfigurationName"), + } +} + +// String returns a human-readable description of this Security User Configuration ID +func (id SecurityUserConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Security User Configuration Name: %q", id.SecurityUserConfigurationName), + } + return fmt.Sprintf("Security User Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/securityuserconfigurations/id_securityuserconfiguration_test.go b/resource-manager/network/2024-07-01/securityuserconfigurations/id_securityuserconfiguration_test.go new file mode 100644 index 00000000000..f9324fcf41d --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserconfigurations/id_securityuserconfiguration_test.go @@ -0,0 +1,327 @@ +package securityuserconfigurations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SecurityUserConfigurationId{} + +func TestNewSecurityUserConfigurationID(t *testing.T) { + id := NewSecurityUserConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.SecurityUserConfigurationName != "securityUserConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'SecurityUserConfigurationName'", id.SecurityUserConfigurationName, "securityUserConfigurationName") + } +} + +func TestFormatSecurityUserConfigurationID(t *testing.T) { + actual := NewSecurityUserConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSecurityUserConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityUserConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName", + Expected: &SecurityUserConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityUserConfigurationName: "securityUserConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityUserConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityUserConfigurationName != v.Expected.SecurityUserConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityUserConfigurationName", v.Expected.SecurityUserConfigurationName, actual.SecurityUserConfigurationName) + } + + } +} + +func TestParseSecurityUserConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityUserConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName", + Expected: &SecurityUserConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityUserConfigurationName: "securityUserConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe", + Expected: &SecurityUserConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + SecurityUserConfigurationName: "sEcUrItYuSeRcOnFiGuRaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityUserConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityUserConfigurationName != v.Expected.SecurityUserConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityUserConfigurationName", v.Expected.SecurityUserConfigurationName, actual.SecurityUserConfigurationName) + } + + } +} + +func TestSegmentsForSecurityUserConfigurationId(t *testing.T) { + segments := SecurityUserConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SecurityUserConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/securityuserconfigurations/method_createorupdate.go b/resource-manager/network/2024-07-01/securityuserconfigurations/method_createorupdate.go new file mode 100644 index 00000000000..dd523a47376 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserconfigurations/method_createorupdate.go @@ -0,0 +1,58 @@ +package securityuserconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecurityUserConfiguration +} + +// CreateOrUpdate ... +func (c SecurityUserConfigurationsClient) CreateOrUpdate(ctx context.Context, id SecurityUserConfigurationId, input SecurityUserConfiguration) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SecurityUserConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/securityuserconfigurations/method_delete.go b/resource-manager/network/2024-07-01/securityuserconfigurations/method_delete.go new file mode 100644 index 00000000000..afdd0d941f6 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserconfigurations/method_delete.go @@ -0,0 +1,100 @@ +package securityuserconfigurations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c SecurityUserConfigurationsClient) Delete(ctx context.Context, id SecurityUserConfigurationId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c SecurityUserConfigurationsClient) DeleteThenPoll(ctx context.Context, id SecurityUserConfigurationId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/securityuserconfigurations/method_get.go b/resource-manager/network/2024-07-01/securityuserconfigurations/method_get.go new file mode 100644 index 00000000000..bf0940d6925 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserconfigurations/method_get.go @@ -0,0 +1,53 @@ +package securityuserconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecurityUserConfiguration +} + +// Get ... +func (c SecurityUserConfigurationsClient) Get(ctx context.Context, id SecurityUserConfigurationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SecurityUserConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/securityuserconfigurations/method_list.go b/resource-manager/network/2024-07-01/securityuserconfigurations/method_list.go new file mode 100644 index 00000000000..43f0254db99 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserconfigurations/method_list.go @@ -0,0 +1,134 @@ +package securityuserconfigurations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SecurityUserConfiguration +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SecurityUserConfiguration +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c SecurityUserConfigurationsClient) List(ctx context.Context, id NetworkManagerId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/securityUserConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SecurityUserConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c SecurityUserConfigurationsClient) ListComplete(ctx context.Context, id NetworkManagerId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, SecurityUserConfigurationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SecurityUserConfigurationsClient) ListCompleteMatchingPredicate(ctx context.Context, id NetworkManagerId, options ListOperationOptions, predicate SecurityUserConfigurationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SecurityUserConfiguration, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/securityuserconfigurations/model_securityuserconfiguration.go b/resource-manager/network/2024-07-01/securityuserconfigurations/model_securityuserconfiguration.go new file mode 100644 index 00000000000..9ac10a92364 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserconfigurations/model_securityuserconfiguration.go @@ -0,0 +1,17 @@ +package securityuserconfigurations + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityUserConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityUserConfigurationPropertiesFormat `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/securityuserconfigurations/model_securityuserconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/securityuserconfigurations/model_securityuserconfigurationpropertiesformat.go new file mode 100644 index 00000000000..18af4f046ec --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserconfigurations/model_securityuserconfigurationpropertiesformat.go @@ -0,0 +1,10 @@ +package securityuserconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityUserConfigurationPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/securityuserconfigurations/predicates.go b/resource-manager/network/2024-07-01/securityuserconfigurations/predicates.go new file mode 100644 index 00000000000..835b3ccdcdb --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserconfigurations/predicates.go @@ -0,0 +1,32 @@ +package securityuserconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityUserConfigurationOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p SecurityUserConfigurationOperationPredicate) Matches(input SecurityUserConfiguration) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/securityuserconfigurations/version.go b/resource-manager/network/2024-07-01/securityuserconfigurations/version.go new file mode 100644 index 00000000000..8dcfe545ccf --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserconfigurations/version.go @@ -0,0 +1,10 @@ +package securityuserconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/securityuserconfigurations/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/securityuserrulecollections/README.md b/resource-manager/network/2024-07-01/securityuserrulecollections/README.md new file mode 100644 index 00000000000..5bdba6e0f4b --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrulecollections/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securityuserrulecollections` Documentation + +The `securityuserrulecollections` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securityuserrulecollections" +``` + + +### Client Initialization + +```go +client := securityuserrulecollections.NewSecurityUserRuleCollectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SecurityUserRuleCollectionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := securityuserrulecollections.NewSecurityUserConfigurationRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName", "ruleCollectionName") + +payload := securityuserrulecollections.SecurityUserRuleCollection{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SecurityUserRuleCollectionsClient.Delete` + +```go +ctx := context.TODO() +id := securityuserrulecollections.NewSecurityUserConfigurationRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName", "ruleCollectionName") + +if err := client.DeleteThenPoll(ctx, id, securityuserrulecollections.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `SecurityUserRuleCollectionsClient.Get` + +```go +ctx := context.TODO() +id := securityuserrulecollections.NewSecurityUserConfigurationRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName", "ruleCollectionName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SecurityUserRuleCollectionsClient.List` + +```go +ctx := context.TODO() +id := securityuserrulecollections.NewSecurityUserConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName") + +// alternatively `client.List(ctx, id, securityuserrulecollections.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, securityuserrulecollections.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/securityuserrulecollections/client.go b/resource-manager/network/2024-07-01/securityuserrulecollections/client.go new file mode 100644 index 00000000000..2e65998d969 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrulecollections/client.go @@ -0,0 +1,26 @@ +package securityuserrulecollections + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityUserRuleCollectionsClient struct { + Client *resourcemanager.Client +} + +func NewSecurityUserRuleCollectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*SecurityUserRuleCollectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "securityuserrulecollections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SecurityUserRuleCollectionsClient: %+v", err) + } + + return &SecurityUserRuleCollectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/securityuserrulecollections/constants.go b/resource-manager/network/2024-07-01/securityuserrulecollections/constants.go new file mode 100644 index 00000000000..d49d97eed47 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrulecollections/constants.go @@ -0,0 +1,57 @@ +package securityuserrulecollections + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/securityuserrulecollections/id_securityuserconfiguration.go b/resource-manager/network/2024-07-01/securityuserrulecollections/id_securityuserconfiguration.go new file mode 100644 index 00000000000..ab8dfdd078d --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrulecollections/id_securityuserconfiguration.go @@ -0,0 +1,139 @@ +package securityuserrulecollections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SecurityUserConfigurationId{}) +} + +var _ resourceids.ResourceId = &SecurityUserConfigurationId{} + +// SecurityUserConfigurationId is a struct representing the Resource ID for a Security User Configuration +type SecurityUserConfigurationId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + SecurityUserConfigurationName string +} + +// NewSecurityUserConfigurationID returns a new SecurityUserConfigurationId struct +func NewSecurityUserConfigurationID(subscriptionId string, resourceGroupName string, networkManagerName string, securityUserConfigurationName string) SecurityUserConfigurationId { + return SecurityUserConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + SecurityUserConfigurationName: securityUserConfigurationName, + } +} + +// ParseSecurityUserConfigurationID parses 'input' into a SecurityUserConfigurationId +func ParseSecurityUserConfigurationID(input string) (*SecurityUserConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityUserConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityUserConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSecurityUserConfigurationIDInsensitively parses 'input' case-insensitively into a SecurityUserConfigurationId +// note: this method should only be used for API response data and not user input +func ParseSecurityUserConfigurationIDInsensitively(input string) (*SecurityUserConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityUserConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityUserConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SecurityUserConfigurationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.SecurityUserConfigurationName, ok = input.Parsed["securityUserConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "securityUserConfigurationName", input) + } + + return nil +} + +// ValidateSecurityUserConfigurationID checks that 'input' can be parsed as a Security User Configuration ID +func ValidateSecurityUserConfigurationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSecurityUserConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Security User Configuration ID +func (id SecurityUserConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/securityUserConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.SecurityUserConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Security User Configuration ID +func (id SecurityUserConfigurationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticSecurityUserConfigurations", "securityUserConfigurations", "securityUserConfigurations"), + resourceids.UserSpecifiedSegment("securityUserConfigurationName", "securityUserConfigurationName"), + } +} + +// String returns a human-readable description of this Security User Configuration ID +func (id SecurityUserConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Security User Configuration Name: %q", id.SecurityUserConfigurationName), + } + return fmt.Sprintf("Security User Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/securityuserrulecollections/id_securityuserconfiguration_test.go b/resource-manager/network/2024-07-01/securityuserrulecollections/id_securityuserconfiguration_test.go new file mode 100644 index 00000000000..9164ec66054 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrulecollections/id_securityuserconfiguration_test.go @@ -0,0 +1,327 @@ +package securityuserrulecollections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SecurityUserConfigurationId{} + +func TestNewSecurityUserConfigurationID(t *testing.T) { + id := NewSecurityUserConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.SecurityUserConfigurationName != "securityUserConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'SecurityUserConfigurationName'", id.SecurityUserConfigurationName, "securityUserConfigurationName") + } +} + +func TestFormatSecurityUserConfigurationID(t *testing.T) { + actual := NewSecurityUserConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSecurityUserConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityUserConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName", + Expected: &SecurityUserConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityUserConfigurationName: "securityUserConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityUserConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityUserConfigurationName != v.Expected.SecurityUserConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityUserConfigurationName", v.Expected.SecurityUserConfigurationName, actual.SecurityUserConfigurationName) + } + + } +} + +func TestParseSecurityUserConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityUserConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName", + Expected: &SecurityUserConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityUserConfigurationName: "securityUserConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe", + Expected: &SecurityUserConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + SecurityUserConfigurationName: "sEcUrItYuSeRcOnFiGuRaTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityUserConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityUserConfigurationName != v.Expected.SecurityUserConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityUserConfigurationName", v.Expected.SecurityUserConfigurationName, actual.SecurityUserConfigurationName) + } + + } +} + +func TestSegmentsForSecurityUserConfigurationId(t *testing.T) { + segments := SecurityUserConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SecurityUserConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/securityuserrulecollections/id_securityuserconfigurationrulecollection.go b/resource-manager/network/2024-07-01/securityuserrulecollections/id_securityuserconfigurationrulecollection.go new file mode 100644 index 00000000000..2b4f8fd6ed5 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrulecollections/id_securityuserconfigurationrulecollection.go @@ -0,0 +1,148 @@ +package securityuserrulecollections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SecurityUserConfigurationRuleCollectionId{}) +} + +var _ resourceids.ResourceId = &SecurityUserConfigurationRuleCollectionId{} + +// SecurityUserConfigurationRuleCollectionId is a struct representing the Resource ID for a Security User Configuration Rule Collection +type SecurityUserConfigurationRuleCollectionId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + SecurityUserConfigurationName string + RuleCollectionName string +} + +// NewSecurityUserConfigurationRuleCollectionID returns a new SecurityUserConfigurationRuleCollectionId struct +func NewSecurityUserConfigurationRuleCollectionID(subscriptionId string, resourceGroupName string, networkManagerName string, securityUserConfigurationName string, ruleCollectionName string) SecurityUserConfigurationRuleCollectionId { + return SecurityUserConfigurationRuleCollectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + SecurityUserConfigurationName: securityUserConfigurationName, + RuleCollectionName: ruleCollectionName, + } +} + +// ParseSecurityUserConfigurationRuleCollectionID parses 'input' into a SecurityUserConfigurationRuleCollectionId +func ParseSecurityUserConfigurationRuleCollectionID(input string) (*SecurityUserConfigurationRuleCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityUserConfigurationRuleCollectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityUserConfigurationRuleCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSecurityUserConfigurationRuleCollectionIDInsensitively parses 'input' case-insensitively into a SecurityUserConfigurationRuleCollectionId +// note: this method should only be used for API response data and not user input +func ParseSecurityUserConfigurationRuleCollectionIDInsensitively(input string) (*SecurityUserConfigurationRuleCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityUserConfigurationRuleCollectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityUserConfigurationRuleCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SecurityUserConfigurationRuleCollectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.SecurityUserConfigurationName, ok = input.Parsed["securityUserConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "securityUserConfigurationName", input) + } + + if id.RuleCollectionName, ok = input.Parsed["ruleCollectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleCollectionName", input) + } + + return nil +} + +// ValidateSecurityUserConfigurationRuleCollectionID checks that 'input' can be parsed as a Security User Configuration Rule Collection ID +func ValidateSecurityUserConfigurationRuleCollectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSecurityUserConfigurationRuleCollectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Security User Configuration Rule Collection ID +func (id SecurityUserConfigurationRuleCollectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/securityUserConfigurations/%s/ruleCollections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.SecurityUserConfigurationName, id.RuleCollectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Security User Configuration Rule Collection ID +func (id SecurityUserConfigurationRuleCollectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticSecurityUserConfigurations", "securityUserConfigurations", "securityUserConfigurations"), + resourceids.UserSpecifiedSegment("securityUserConfigurationName", "securityUserConfigurationName"), + resourceids.StaticSegment("staticRuleCollections", "ruleCollections", "ruleCollections"), + resourceids.UserSpecifiedSegment("ruleCollectionName", "ruleCollectionName"), + } +} + +// String returns a human-readable description of this Security User Configuration Rule Collection ID +func (id SecurityUserConfigurationRuleCollectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Security User Configuration Name: %q", id.SecurityUserConfigurationName), + fmt.Sprintf("Rule Collection Name: %q", id.RuleCollectionName), + } + return fmt.Sprintf("Security User Configuration Rule Collection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/securityuserrulecollections/id_securityuserconfigurationrulecollection_test.go b/resource-manager/network/2024-07-01/securityuserrulecollections/id_securityuserconfigurationrulecollection_test.go new file mode 100644 index 00000000000..5c6cdfca615 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrulecollections/id_securityuserconfigurationrulecollection_test.go @@ -0,0 +1,372 @@ +package securityuserrulecollections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SecurityUserConfigurationRuleCollectionId{} + +func TestNewSecurityUserConfigurationRuleCollectionID(t *testing.T) { + id := NewSecurityUserConfigurationRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName", "ruleCollectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.SecurityUserConfigurationName != "securityUserConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'SecurityUserConfigurationName'", id.SecurityUserConfigurationName, "securityUserConfigurationName") + } + + if id.RuleCollectionName != "ruleCollectionName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleCollectionName'", id.RuleCollectionName, "ruleCollectionName") + } +} + +func TestFormatSecurityUserConfigurationRuleCollectionID(t *testing.T) { + actual := NewSecurityUserConfigurationRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName", "ruleCollectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSecurityUserConfigurationRuleCollectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityUserConfigurationRuleCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName", + Expected: &SecurityUserConfigurationRuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityUserConfigurationName: "securityUserConfigurationName", + RuleCollectionName: "ruleCollectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityUserConfigurationRuleCollectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityUserConfigurationName != v.Expected.SecurityUserConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityUserConfigurationName", v.Expected.SecurityUserConfigurationName, actual.SecurityUserConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + } +} + +func TestParseSecurityUserConfigurationRuleCollectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityUserConfigurationRuleCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe/rUlEcOlLeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName", + Expected: &SecurityUserConfigurationRuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityUserConfigurationName: "securityUserConfigurationName", + RuleCollectionName: "ruleCollectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE", + Expected: &SecurityUserConfigurationRuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + SecurityUserConfigurationName: "sEcUrItYuSeRcOnFiGuRaTiOnNaMe", + RuleCollectionName: "rUlEcOlLeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityUserConfigurationRuleCollectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityUserConfigurationName != v.Expected.SecurityUserConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityUserConfigurationName", v.Expected.SecurityUserConfigurationName, actual.SecurityUserConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + } +} + +func TestSegmentsForSecurityUserConfigurationRuleCollectionId(t *testing.T) { + segments := SecurityUserConfigurationRuleCollectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SecurityUserConfigurationRuleCollectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/securityuserrulecollections/method_createorupdate.go b/resource-manager/network/2024-07-01/securityuserrulecollections/method_createorupdate.go new file mode 100644 index 00000000000..a6360eab05c --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrulecollections/method_createorupdate.go @@ -0,0 +1,58 @@ +package securityuserrulecollections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecurityUserRuleCollection +} + +// CreateOrUpdate ... +func (c SecurityUserRuleCollectionsClient) CreateOrUpdate(ctx context.Context, id SecurityUserConfigurationRuleCollectionId, input SecurityUserRuleCollection) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SecurityUserRuleCollection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/securityuserrulecollections/method_delete.go b/resource-manager/network/2024-07-01/securityuserrulecollections/method_delete.go new file mode 100644 index 00000000000..45d73ed7010 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrulecollections/method_delete.go @@ -0,0 +1,100 @@ +package securityuserrulecollections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c SecurityUserRuleCollectionsClient) Delete(ctx context.Context, id SecurityUserConfigurationRuleCollectionId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c SecurityUserRuleCollectionsClient) DeleteThenPoll(ctx context.Context, id SecurityUserConfigurationRuleCollectionId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/securityuserrulecollections/method_get.go b/resource-manager/network/2024-07-01/securityuserrulecollections/method_get.go new file mode 100644 index 00000000000..6e3eacdacac --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrulecollections/method_get.go @@ -0,0 +1,53 @@ +package securityuserrulecollections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecurityUserRuleCollection +} + +// Get ... +func (c SecurityUserRuleCollectionsClient) Get(ctx context.Context, id SecurityUserConfigurationRuleCollectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SecurityUserRuleCollection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/securityuserrulecollections/method_list.go b/resource-manager/network/2024-07-01/securityuserrulecollections/method_list.go new file mode 100644 index 00000000000..72290b92b79 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrulecollections/method_list.go @@ -0,0 +1,134 @@ +package securityuserrulecollections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SecurityUserRuleCollection +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SecurityUserRuleCollection +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c SecurityUserRuleCollectionsClient) List(ctx context.Context, id SecurityUserConfigurationId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/ruleCollections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SecurityUserRuleCollection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c SecurityUserRuleCollectionsClient) ListComplete(ctx context.Context, id SecurityUserConfigurationId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, SecurityUserRuleCollectionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SecurityUserRuleCollectionsClient) ListCompleteMatchingPredicate(ctx context.Context, id SecurityUserConfigurationId, options ListOperationOptions, predicate SecurityUserRuleCollectionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SecurityUserRuleCollection, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/securityuserrulecollections/model_securityusergroupitem.go b/resource-manager/network/2024-07-01/securityuserrulecollections/model_securityusergroupitem.go new file mode 100644 index 00000000000..a067fbcbfe0 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrulecollections/model_securityusergroupitem.go @@ -0,0 +1,8 @@ +package securityuserrulecollections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityUserGroupItem struct { + NetworkGroupId string `json:"networkGroupId"` +} diff --git a/resource-manager/network/2024-07-01/securityuserrulecollections/model_securityuserrulecollection.go b/resource-manager/network/2024-07-01/securityuserrulecollections/model_securityuserrulecollection.go new file mode 100644 index 00000000000..dc9c51b4598 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrulecollections/model_securityuserrulecollection.go @@ -0,0 +1,17 @@ +package securityuserrulecollections + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityUserRuleCollection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityUserRuleCollectionPropertiesFormat `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/securityuserrulecollections/model_securityuserrulecollectionpropertiesformat.go b/resource-manager/network/2024-07-01/securityuserrulecollections/model_securityuserrulecollectionpropertiesformat.go new file mode 100644 index 00000000000..752e873a957 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrulecollections/model_securityuserrulecollectionpropertiesformat.go @@ -0,0 +1,11 @@ +package securityuserrulecollections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityUserRuleCollectionPropertiesFormat struct { + AppliesToGroups []SecurityUserGroupItem `json:"appliesToGroups"` + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/securityuserrulecollections/predicates.go b/resource-manager/network/2024-07-01/securityuserrulecollections/predicates.go new file mode 100644 index 00000000000..10ac4063ad9 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrulecollections/predicates.go @@ -0,0 +1,32 @@ +package securityuserrulecollections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityUserRuleCollectionOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p SecurityUserRuleCollectionOperationPredicate) Matches(input SecurityUserRuleCollection) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/securityuserrulecollections/version.go b/resource-manager/network/2024-07-01/securityuserrulecollections/version.go new file mode 100644 index 00000000000..1c32ef135bb --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrulecollections/version.go @@ -0,0 +1,10 @@ +package securityuserrulecollections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/securityuserrulecollections/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/securityuserrules/README.md b/resource-manager/network/2024-07-01/securityuserrules/README.md new file mode 100644 index 00000000000..b8aa654e92a --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrules/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securityuserrules` Documentation + +The `securityuserrules` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/securityuserrules" +``` + + +### Client Initialization + +```go +client := securityuserrules.NewSecurityUserRulesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SecurityUserRulesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := securityuserrules.NewRuleCollectionRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName", "ruleCollectionName", "ruleName") + +payload := securityuserrules.SecurityUserRule{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SecurityUserRulesClient.Delete` + +```go +ctx := context.TODO() +id := securityuserrules.NewRuleCollectionRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName", "ruleCollectionName", "ruleName") + +if err := client.DeleteThenPoll(ctx, id, securityuserrules.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `SecurityUserRulesClient.Get` + +```go +ctx := context.TODO() +id := securityuserrules.NewRuleCollectionRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName", "ruleCollectionName", "ruleName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SecurityUserRulesClient.List` + +```go +ctx := context.TODO() +id := securityuserrules.NewSecurityUserConfigurationRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName", "ruleCollectionName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/securityuserrules/client.go b/resource-manager/network/2024-07-01/securityuserrules/client.go new file mode 100644 index 00000000000..bd99ee4be9c --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrules/client.go @@ -0,0 +1,26 @@ +package securityuserrules + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityUserRulesClient struct { + Client *resourcemanager.Client +} + +func NewSecurityUserRulesClientWithBaseURI(sdkApi sdkEnv.Api) (*SecurityUserRulesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "securityuserrules", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SecurityUserRulesClient: %+v", err) + } + + return &SecurityUserRulesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/securityuserrules/constants.go b/resource-manager/network/2024-07-01/securityuserrules/constants.go new file mode 100644 index 00000000000..cb5ed4a5f0a --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrules/constants.go @@ -0,0 +1,195 @@ +package securityuserrules + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressPrefixType string + +const ( + AddressPrefixTypeIPPrefix AddressPrefixType = "IPPrefix" + AddressPrefixTypeNetworkGroup AddressPrefixType = "NetworkGroup" + AddressPrefixTypeServiceTag AddressPrefixType = "ServiceTag" +) + +func PossibleValuesForAddressPrefixType() []string { + return []string{ + string(AddressPrefixTypeIPPrefix), + string(AddressPrefixTypeNetworkGroup), + string(AddressPrefixTypeServiceTag), + } +} + +func (s *AddressPrefixType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAddressPrefixType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAddressPrefixType(input string) (*AddressPrefixType, error) { + vals := map[string]AddressPrefixType{ + "ipprefix": AddressPrefixTypeIPPrefix, + "networkgroup": AddressPrefixTypeNetworkGroup, + "servicetag": AddressPrefixTypeServiceTag, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AddressPrefixType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SecurityConfigurationRuleDirection string + +const ( + SecurityConfigurationRuleDirectionInbound SecurityConfigurationRuleDirection = "Inbound" + SecurityConfigurationRuleDirectionOutbound SecurityConfigurationRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityConfigurationRuleDirection() []string { + return []string{ + string(SecurityConfigurationRuleDirectionInbound), + string(SecurityConfigurationRuleDirectionOutbound), + } +} + +func (s *SecurityConfigurationRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityConfigurationRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityConfigurationRuleDirection(input string) (*SecurityConfigurationRuleDirection, error) { + vals := map[string]SecurityConfigurationRuleDirection{ + "inbound": SecurityConfigurationRuleDirectionInbound, + "outbound": SecurityConfigurationRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityConfigurationRuleDirection(input) + return &out, nil +} + +type SecurityConfigurationRuleProtocol string + +const ( + SecurityConfigurationRuleProtocolAh SecurityConfigurationRuleProtocol = "Ah" + SecurityConfigurationRuleProtocolAny SecurityConfigurationRuleProtocol = "Any" + SecurityConfigurationRuleProtocolEsp SecurityConfigurationRuleProtocol = "Esp" + SecurityConfigurationRuleProtocolIcmp SecurityConfigurationRuleProtocol = "Icmp" + SecurityConfigurationRuleProtocolTcp SecurityConfigurationRuleProtocol = "Tcp" + SecurityConfigurationRuleProtocolUdp SecurityConfigurationRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityConfigurationRuleProtocol() []string { + return []string{ + string(SecurityConfigurationRuleProtocolAh), + string(SecurityConfigurationRuleProtocolAny), + string(SecurityConfigurationRuleProtocolEsp), + string(SecurityConfigurationRuleProtocolIcmp), + string(SecurityConfigurationRuleProtocolTcp), + string(SecurityConfigurationRuleProtocolUdp), + } +} + +func (s *SecurityConfigurationRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityConfigurationRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityConfigurationRuleProtocol(input string) (*SecurityConfigurationRuleProtocol, error) { + vals := map[string]SecurityConfigurationRuleProtocol{ + "ah": SecurityConfigurationRuleProtocolAh, + "any": SecurityConfigurationRuleProtocolAny, + "esp": SecurityConfigurationRuleProtocolEsp, + "icmp": SecurityConfigurationRuleProtocolIcmp, + "tcp": SecurityConfigurationRuleProtocolTcp, + "udp": SecurityConfigurationRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityConfigurationRuleProtocol(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/securityuserrules/id_rulecollectionrule.go b/resource-manager/network/2024-07-01/securityuserrules/id_rulecollectionrule.go new file mode 100644 index 00000000000..0dad04170f3 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrules/id_rulecollectionrule.go @@ -0,0 +1,157 @@ +package securityuserrules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RuleCollectionRuleId{}) +} + +var _ resourceids.ResourceId = &RuleCollectionRuleId{} + +// RuleCollectionRuleId is a struct representing the Resource ID for a Rule Collection Rule +type RuleCollectionRuleId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + SecurityUserConfigurationName string + RuleCollectionName string + RuleName string +} + +// NewRuleCollectionRuleID returns a new RuleCollectionRuleId struct +func NewRuleCollectionRuleID(subscriptionId string, resourceGroupName string, networkManagerName string, securityUserConfigurationName string, ruleCollectionName string, ruleName string) RuleCollectionRuleId { + return RuleCollectionRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + SecurityUserConfigurationName: securityUserConfigurationName, + RuleCollectionName: ruleCollectionName, + RuleName: ruleName, + } +} + +// ParseRuleCollectionRuleID parses 'input' into a RuleCollectionRuleId +func ParseRuleCollectionRuleID(input string) (*RuleCollectionRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleCollectionRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleCollectionRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRuleCollectionRuleIDInsensitively parses 'input' case-insensitively into a RuleCollectionRuleId +// note: this method should only be used for API response data and not user input +func ParseRuleCollectionRuleIDInsensitively(input string) (*RuleCollectionRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&RuleCollectionRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RuleCollectionRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RuleCollectionRuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.SecurityUserConfigurationName, ok = input.Parsed["securityUserConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "securityUserConfigurationName", input) + } + + if id.RuleCollectionName, ok = input.Parsed["ruleCollectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleCollectionName", input) + } + + if id.RuleName, ok = input.Parsed["ruleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleName", input) + } + + return nil +} + +// ValidateRuleCollectionRuleID checks that 'input' can be parsed as a Rule Collection Rule ID +func ValidateRuleCollectionRuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRuleCollectionRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rule Collection Rule ID +func (id RuleCollectionRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/securityUserConfigurations/%s/ruleCollections/%s/rules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.SecurityUserConfigurationName, id.RuleCollectionName, id.RuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rule Collection Rule ID +func (id RuleCollectionRuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticSecurityUserConfigurations", "securityUserConfigurations", "securityUserConfigurations"), + resourceids.UserSpecifiedSegment("securityUserConfigurationName", "securityUserConfigurationName"), + resourceids.StaticSegment("staticRuleCollections", "ruleCollections", "ruleCollections"), + resourceids.UserSpecifiedSegment("ruleCollectionName", "ruleCollectionName"), + resourceids.StaticSegment("staticRules", "rules", "rules"), + resourceids.UserSpecifiedSegment("ruleName", "ruleName"), + } +} + +// String returns a human-readable description of this Rule Collection Rule ID +func (id RuleCollectionRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Security User Configuration Name: %q", id.SecurityUserConfigurationName), + fmt.Sprintf("Rule Collection Name: %q", id.RuleCollectionName), + fmt.Sprintf("Rule Name: %q", id.RuleName), + } + return fmt.Sprintf("Rule Collection Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/securityuserrules/id_rulecollectionrule_test.go b/resource-manager/network/2024-07-01/securityuserrules/id_rulecollectionrule_test.go new file mode 100644 index 00000000000..b98ffe0219b --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrules/id_rulecollectionrule_test.go @@ -0,0 +1,417 @@ +package securityuserrules + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RuleCollectionRuleId{} + +func TestNewRuleCollectionRuleID(t *testing.T) { + id := NewRuleCollectionRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName", "ruleCollectionName", "ruleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.SecurityUserConfigurationName != "securityUserConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'SecurityUserConfigurationName'", id.SecurityUserConfigurationName, "securityUserConfigurationName") + } + + if id.RuleCollectionName != "ruleCollectionName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleCollectionName'", id.RuleCollectionName, "ruleCollectionName") + } + + if id.RuleName != "ruleName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleName'", id.RuleName, "ruleName") + } +} + +func TestFormatRuleCollectionRuleID(t *testing.T) { + actual := NewRuleCollectionRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName", "ruleCollectionName", "ruleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName/rules/ruleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRuleCollectionRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleCollectionRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName/rules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName/rules/ruleName", + Expected: &RuleCollectionRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityUserConfigurationName: "securityUserConfigurationName", + RuleCollectionName: "ruleCollectionName", + RuleName: "ruleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName/rules/ruleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleCollectionRuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityUserConfigurationName != v.Expected.SecurityUserConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityUserConfigurationName", v.Expected.SecurityUserConfigurationName, actual.SecurityUserConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + if actual.RuleName != v.Expected.RuleName { + t.Fatalf("Expected %q but got %q for RuleName", v.Expected.RuleName, actual.RuleName) + } + + } +} + +func TestParseRuleCollectionRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RuleCollectionRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe/rUlEcOlLeCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName/rules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE/rUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName/rules/ruleName", + Expected: &RuleCollectionRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityUserConfigurationName: "securityUserConfigurationName", + RuleCollectionName: "ruleCollectionName", + RuleName: "ruleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName/rules/ruleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE/rUlEs/rUlEnAmE", + Expected: &RuleCollectionRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + SecurityUserConfigurationName: "sEcUrItYuSeRcOnFiGuRaTiOnNaMe", + RuleCollectionName: "rUlEcOlLeCtIoNnAmE", + RuleName: "rUlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE/rUlEs/rUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRuleCollectionRuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityUserConfigurationName != v.Expected.SecurityUserConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityUserConfigurationName", v.Expected.SecurityUserConfigurationName, actual.SecurityUserConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + if actual.RuleName != v.Expected.RuleName { + t.Fatalf("Expected %q but got %q for RuleName", v.Expected.RuleName, actual.RuleName) + } + + } +} + +func TestSegmentsForRuleCollectionRuleId(t *testing.T) { + segments := RuleCollectionRuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RuleCollectionRuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/securityuserrules/id_securityuserconfigurationrulecollection.go b/resource-manager/network/2024-07-01/securityuserrules/id_securityuserconfigurationrulecollection.go new file mode 100644 index 00000000000..208548d7529 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrules/id_securityuserconfigurationrulecollection.go @@ -0,0 +1,148 @@ +package securityuserrules + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SecurityUserConfigurationRuleCollectionId{}) +} + +var _ resourceids.ResourceId = &SecurityUserConfigurationRuleCollectionId{} + +// SecurityUserConfigurationRuleCollectionId is a struct representing the Resource ID for a Security User Configuration Rule Collection +type SecurityUserConfigurationRuleCollectionId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + SecurityUserConfigurationName string + RuleCollectionName string +} + +// NewSecurityUserConfigurationRuleCollectionID returns a new SecurityUserConfigurationRuleCollectionId struct +func NewSecurityUserConfigurationRuleCollectionID(subscriptionId string, resourceGroupName string, networkManagerName string, securityUserConfigurationName string, ruleCollectionName string) SecurityUserConfigurationRuleCollectionId { + return SecurityUserConfigurationRuleCollectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + SecurityUserConfigurationName: securityUserConfigurationName, + RuleCollectionName: ruleCollectionName, + } +} + +// ParseSecurityUserConfigurationRuleCollectionID parses 'input' into a SecurityUserConfigurationRuleCollectionId +func ParseSecurityUserConfigurationRuleCollectionID(input string) (*SecurityUserConfigurationRuleCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityUserConfigurationRuleCollectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityUserConfigurationRuleCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSecurityUserConfigurationRuleCollectionIDInsensitively parses 'input' case-insensitively into a SecurityUserConfigurationRuleCollectionId +// note: this method should only be used for API response data and not user input +func ParseSecurityUserConfigurationRuleCollectionIDInsensitively(input string) (*SecurityUserConfigurationRuleCollectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SecurityUserConfigurationRuleCollectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SecurityUserConfigurationRuleCollectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SecurityUserConfigurationRuleCollectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.SecurityUserConfigurationName, ok = input.Parsed["securityUserConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "securityUserConfigurationName", input) + } + + if id.RuleCollectionName, ok = input.Parsed["ruleCollectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ruleCollectionName", input) + } + + return nil +} + +// ValidateSecurityUserConfigurationRuleCollectionID checks that 'input' can be parsed as a Security User Configuration Rule Collection ID +func ValidateSecurityUserConfigurationRuleCollectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSecurityUserConfigurationRuleCollectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Security User Configuration Rule Collection ID +func (id SecurityUserConfigurationRuleCollectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/securityUserConfigurations/%s/ruleCollections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.SecurityUserConfigurationName, id.RuleCollectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Security User Configuration Rule Collection ID +func (id SecurityUserConfigurationRuleCollectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticSecurityUserConfigurations", "securityUserConfigurations", "securityUserConfigurations"), + resourceids.UserSpecifiedSegment("securityUserConfigurationName", "securityUserConfigurationName"), + resourceids.StaticSegment("staticRuleCollections", "ruleCollections", "ruleCollections"), + resourceids.UserSpecifiedSegment("ruleCollectionName", "ruleCollectionName"), + } +} + +// String returns a human-readable description of this Security User Configuration Rule Collection ID +func (id SecurityUserConfigurationRuleCollectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Security User Configuration Name: %q", id.SecurityUserConfigurationName), + fmt.Sprintf("Rule Collection Name: %q", id.RuleCollectionName), + } + return fmt.Sprintf("Security User Configuration Rule Collection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/securityuserrules/id_securityuserconfigurationrulecollection_test.go b/resource-manager/network/2024-07-01/securityuserrules/id_securityuserconfigurationrulecollection_test.go new file mode 100644 index 00000000000..6704a0c3439 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrules/id_securityuserconfigurationrulecollection_test.go @@ -0,0 +1,372 @@ +package securityuserrules + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SecurityUserConfigurationRuleCollectionId{} + +func TestNewSecurityUserConfigurationRuleCollectionID(t *testing.T) { + id := NewSecurityUserConfigurationRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName", "ruleCollectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.SecurityUserConfigurationName != "securityUserConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'SecurityUserConfigurationName'", id.SecurityUserConfigurationName, "securityUserConfigurationName") + } + + if id.RuleCollectionName != "ruleCollectionName" { + t.Fatalf("Expected %q but got %q for Segment 'RuleCollectionName'", id.RuleCollectionName, "ruleCollectionName") + } +} + +func TestFormatSecurityUserConfigurationRuleCollectionID(t *testing.T) { + actual := NewSecurityUserConfigurationRuleCollectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "securityUserConfigurationName", "ruleCollectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSecurityUserConfigurationRuleCollectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityUserConfigurationRuleCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName", + Expected: &SecurityUserConfigurationRuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityUserConfigurationName: "securityUserConfigurationName", + RuleCollectionName: "ruleCollectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityUserConfigurationRuleCollectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityUserConfigurationName != v.Expected.SecurityUserConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityUserConfigurationName", v.Expected.SecurityUserConfigurationName, actual.SecurityUserConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + } +} + +func TestParseSecurityUserConfigurationRuleCollectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SecurityUserConfigurationRuleCollectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe/rUlEcOlLeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName", + Expected: &SecurityUserConfigurationRuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + SecurityUserConfigurationName: "securityUserConfigurationName", + RuleCollectionName: "ruleCollectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/securityUserConfigurations/securityUserConfigurationName/ruleCollections/ruleCollectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE", + Expected: &SecurityUserConfigurationRuleCollectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + SecurityUserConfigurationName: "sEcUrItYuSeRcOnFiGuRaTiOnNaMe", + RuleCollectionName: "rUlEcOlLeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/sEcUrItYuSeRcOnFiGuRaTiOnS/sEcUrItYuSeRcOnFiGuRaTiOnNaMe/rUlEcOlLeCtIoNs/rUlEcOlLeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSecurityUserConfigurationRuleCollectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.SecurityUserConfigurationName != v.Expected.SecurityUserConfigurationName { + t.Fatalf("Expected %q but got %q for SecurityUserConfigurationName", v.Expected.SecurityUserConfigurationName, actual.SecurityUserConfigurationName) + } + + if actual.RuleCollectionName != v.Expected.RuleCollectionName { + t.Fatalf("Expected %q but got %q for RuleCollectionName", v.Expected.RuleCollectionName, actual.RuleCollectionName) + } + + } +} + +func TestSegmentsForSecurityUserConfigurationRuleCollectionId(t *testing.T) { + segments := SecurityUserConfigurationRuleCollectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SecurityUserConfigurationRuleCollectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/securityuserrules/method_createorupdate.go b/resource-manager/network/2024-07-01/securityuserrules/method_createorupdate.go new file mode 100644 index 00000000000..24dfc0157f4 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrules/method_createorupdate.go @@ -0,0 +1,58 @@ +package securityuserrules + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecurityUserRule +} + +// CreateOrUpdate ... +func (c SecurityUserRulesClient) CreateOrUpdate(ctx context.Context, id RuleCollectionRuleId, input SecurityUserRule) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SecurityUserRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/securityuserrules/method_delete.go b/resource-manager/network/2024-07-01/securityuserrules/method_delete.go new file mode 100644 index 00000000000..b528d5df520 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrules/method_delete.go @@ -0,0 +1,100 @@ +package securityuserrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + Force *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Force != nil { + out.Append("force", fmt.Sprintf("%v", *o.Force)) + } + return &out +} + +// Delete ... +func (c SecurityUserRulesClient) Delete(ctx context.Context, id RuleCollectionRuleId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c SecurityUserRulesClient) DeleteThenPoll(ctx context.Context, id RuleCollectionRuleId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/securityuserrules/method_get.go b/resource-manager/network/2024-07-01/securityuserrules/method_get.go new file mode 100644 index 00000000000..e87f74e1e7f --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrules/method_get.go @@ -0,0 +1,53 @@ +package securityuserrules + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SecurityUserRule +} + +// Get ... +func (c SecurityUserRulesClient) Get(ctx context.Context, id RuleCollectionRuleId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SecurityUserRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/securityuserrules/method_list.go b/resource-manager/network/2024-07-01/securityuserrules/method_list.go new file mode 100644 index 00000000000..0ca8047db25 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrules/method_list.go @@ -0,0 +1,105 @@ +package securityuserrules + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SecurityUserRule +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []SecurityUserRule +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c SecurityUserRulesClient) List(ctx context.Context, id SecurityUserConfigurationRuleCollectionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/rules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SecurityUserRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c SecurityUserRulesClient) ListComplete(ctx context.Context, id SecurityUserConfigurationRuleCollectionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SecurityUserRuleOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SecurityUserRulesClient) ListCompleteMatchingPredicate(ctx context.Context, id SecurityUserConfigurationRuleCollectionId, predicate SecurityUserRuleOperationPredicate) (result ListCompleteResult, err error) { + items := make([]SecurityUserRule, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/securityuserrules/model_addressprefixitem.go b/resource-manager/network/2024-07-01/securityuserrules/model_addressprefixitem.go new file mode 100644 index 00000000000..9105a353284 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrules/model_addressprefixitem.go @@ -0,0 +1,9 @@ +package securityuserrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressPrefixItem struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixType *AddressPrefixType `json:"addressPrefixType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/securityuserrules/model_securityuserrule.go b/resource-manager/network/2024-07-01/securityuserrules/model_securityuserrule.go new file mode 100644 index 00000000000..d5c394c559a --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrules/model_securityuserrule.go @@ -0,0 +1,17 @@ +package securityuserrules + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityUserRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityUserRulePropertiesFormat `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/securityuserrules/model_securityuserrulepropertiesformat.go b/resource-manager/network/2024-07-01/securityuserrules/model_securityuserrulepropertiesformat.go new file mode 100644 index 00000000000..1444e3cd7a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrules/model_securityuserrulepropertiesformat.go @@ -0,0 +1,16 @@ +package securityuserrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityUserRulePropertiesFormat struct { + Description *string `json:"description,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Destinations *[]AddressPrefixItem `json:"destinations,omitempty"` + Direction SecurityConfigurationRuleDirection `json:"direction"` + Protocol SecurityConfigurationRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` + Sources *[]AddressPrefixItem `json:"sources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/securityuserrules/predicates.go b/resource-manager/network/2024-07-01/securityuserrules/predicates.go new file mode 100644 index 00000000000..5e46e378fc2 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrules/predicates.go @@ -0,0 +1,32 @@ +package securityuserrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityUserRuleOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p SecurityUserRuleOperationPredicate) Matches(input SecurityUserRule) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/securityuserrules/version.go b/resource-manager/network/2024-07-01/securityuserrules/version.go new file mode 100644 index 00000000000..f6785b42c16 --- /dev/null +++ b/resource-manager/network/2024-07-01/securityuserrules/version.go @@ -0,0 +1,10 @@ +package securityuserrules + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/securityuserrules/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/README.md b/resource-manager/network/2024-07-01/serviceendpointpolicies/README.md new file mode 100644 index 00000000000..fd6f858ba75 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/serviceendpointpolicies` Documentation + +The `serviceendpointpolicies` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/serviceendpointpolicies" +``` + + +### Client Initialization + +```go +client := serviceendpointpolicies.NewServiceEndpointPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ServiceEndpointPoliciesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := serviceendpointpolicies.NewServiceEndpointPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceEndpointPolicyName") + +payload := serviceendpointpolicies.ServiceEndpointPolicy{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ServiceEndpointPoliciesClient.Delete` + +```go +ctx := context.TODO() +id := serviceendpointpolicies.NewServiceEndpointPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceEndpointPolicyName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ServiceEndpointPoliciesClient.Get` + +```go +ctx := context.TODO() +id := serviceendpointpolicies.NewServiceEndpointPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceEndpointPolicyName") + +read, err := client.Get(ctx, id, serviceendpointpolicies.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ServiceEndpointPoliciesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ServiceEndpointPoliciesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ServiceEndpointPoliciesClient.UpdateTags` + +```go +ctx := context.TODO() +id := serviceendpointpolicies.NewServiceEndpointPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceEndpointPolicyName") + +payload := serviceendpointpolicies.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/client.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/client.go new file mode 100644 index 00000000000..4efc8d43b2a --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/client.go @@ -0,0 +1,26 @@ +package serviceendpointpolicies + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPoliciesClient struct { + Client *resourcemanager.Client +} + +func NewServiceEndpointPoliciesClientWithBaseURI(sdkApi sdkEnv.Api) (*ServiceEndpointPoliciesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "serviceendpointpolicies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServiceEndpointPoliciesClient: %+v", err) + } + + return &ServiceEndpointPoliciesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/constants.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/constants.go new file mode 100644 index 00000000000..e4833c8a310 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/constants.go @@ -0,0 +1,1204 @@ +package serviceendpointpolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/id_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/id_serviceendpointpolicy.go new file mode 100644 index 00000000000..651f7f56783 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/id_serviceendpointpolicy.go @@ -0,0 +1,130 @@ +package serviceendpointpolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ServiceEndpointPolicyId{}) +} + +var _ resourceids.ResourceId = &ServiceEndpointPolicyId{} + +// ServiceEndpointPolicyId is a struct representing the Resource ID for a Service Endpoint Policy +type ServiceEndpointPolicyId struct { + SubscriptionId string + ResourceGroupName string + ServiceEndpointPolicyName string +} + +// NewServiceEndpointPolicyID returns a new ServiceEndpointPolicyId struct +func NewServiceEndpointPolicyID(subscriptionId string, resourceGroupName string, serviceEndpointPolicyName string) ServiceEndpointPolicyId { + return ServiceEndpointPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServiceEndpointPolicyName: serviceEndpointPolicyName, + } +} + +// ParseServiceEndpointPolicyID parses 'input' into a ServiceEndpointPolicyId +func ParseServiceEndpointPolicyID(input string) (*ServiceEndpointPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceEndpointPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceEndpointPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseServiceEndpointPolicyIDInsensitively parses 'input' case-insensitively into a ServiceEndpointPolicyId +// note: this method should only be used for API response data and not user input +func ParseServiceEndpointPolicyIDInsensitively(input string) (*ServiceEndpointPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceEndpointPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceEndpointPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ServiceEndpointPolicyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ServiceEndpointPolicyName, ok = input.Parsed["serviceEndpointPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serviceEndpointPolicyName", input) + } + + return nil +} + +// ValidateServiceEndpointPolicyID checks that 'input' can be parsed as a Service Endpoint Policy ID +func ValidateServiceEndpointPolicyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseServiceEndpointPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Service Endpoint Policy ID +func (id ServiceEndpointPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/serviceEndpointPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServiceEndpointPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Service Endpoint Policy ID +func (id ServiceEndpointPolicyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticServiceEndpointPolicies", "serviceEndpointPolicies", "serviceEndpointPolicies"), + resourceids.UserSpecifiedSegment("serviceEndpointPolicyName", "serviceEndpointPolicyName"), + } +} + +// String returns a human-readable description of this Service Endpoint Policy ID +func (id ServiceEndpointPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Service Endpoint Policy Name: %q", id.ServiceEndpointPolicyName), + } + return fmt.Sprintf("Service Endpoint Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/id_serviceendpointpolicy_test.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/id_serviceendpointpolicy_test.go new file mode 100644 index 00000000000..bb945e9c657 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/id_serviceendpointpolicy_test.go @@ -0,0 +1,282 @@ +package serviceendpointpolicies + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ServiceEndpointPolicyId{} + +func TestNewServiceEndpointPolicyID(t *testing.T) { + id := NewServiceEndpointPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceEndpointPolicyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ServiceEndpointPolicyName != "serviceEndpointPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'ServiceEndpointPolicyName'", id.ServiceEndpointPolicyName, "serviceEndpointPolicyName") + } +} + +func TestFormatServiceEndpointPolicyID(t *testing.T) { + actual := NewServiceEndpointPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceEndpointPolicyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServiceEndpointPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceEndpointPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName", + Expected: &ServiceEndpointPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServiceEndpointPolicyName: "serviceEndpointPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceEndpointPolicyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServiceEndpointPolicyName != v.Expected.ServiceEndpointPolicyName { + t.Fatalf("Expected %q but got %q for ServiceEndpointPolicyName", v.Expected.ServiceEndpointPolicyName, actual.ServiceEndpointPolicyName) + } + + } +} + +func TestParseServiceEndpointPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceEndpointPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/sErViCeEnDpOiNtPoLiCiEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName", + Expected: &ServiceEndpointPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServiceEndpointPolicyName: "serviceEndpointPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/sErViCeEnDpOiNtPoLiCiEs/sErViCeEnDpOiNtPoLiCyNaMe", + Expected: &ServiceEndpointPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServiceEndpointPolicyName: "sErViCeEnDpOiNtPoLiCyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/sErViCeEnDpOiNtPoLiCiEs/sErViCeEnDpOiNtPoLiCyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceEndpointPolicyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServiceEndpointPolicyName != v.Expected.ServiceEndpointPolicyName { + t.Fatalf("Expected %q but got %q for ServiceEndpointPolicyName", v.Expected.ServiceEndpointPolicyName, actual.ServiceEndpointPolicyName) + } + + } +} + +func TestSegmentsForServiceEndpointPolicyId(t *testing.T) { + segments := ServiceEndpointPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServiceEndpointPolicyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/method_createorupdate.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/method_createorupdate.go new file mode 100644 index 00000000000..1912253430d --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/method_createorupdate.go @@ -0,0 +1,75 @@ +package serviceendpointpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ServiceEndpointPolicy +} + +// CreateOrUpdate ... +func (c ServiceEndpointPoliciesClient) CreateOrUpdate(ctx context.Context, id ServiceEndpointPolicyId, input ServiceEndpointPolicy) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ServiceEndpointPoliciesClient) CreateOrUpdateThenPoll(ctx context.Context, id ServiceEndpointPolicyId, input ServiceEndpointPolicy) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/method_delete.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/method_delete.go new file mode 100644 index 00000000000..fbffd77bf76 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/method_delete.go @@ -0,0 +1,71 @@ +package serviceendpointpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ServiceEndpointPoliciesClient) Delete(ctx context.Context, id ServiceEndpointPolicyId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ServiceEndpointPoliciesClient) DeleteThenPoll(ctx context.Context, id ServiceEndpointPolicyId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/method_get.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/method_get.go new file mode 100644 index 00000000000..ce97f45af4d --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/method_get.go @@ -0,0 +1,83 @@ +package serviceendpointpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServiceEndpointPolicy +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c ServiceEndpointPoliciesClient) Get(ctx context.Context, id ServiceEndpointPolicyId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ServiceEndpointPolicy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/method_list.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/method_list.go new file mode 100644 index 00000000000..3a437224556 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/method_list.go @@ -0,0 +1,106 @@ +package serviceendpointpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ServiceEndpointPolicy +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ServiceEndpointPolicy +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ServiceEndpointPoliciesClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/serviceEndpointPolicies", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ServiceEndpointPolicy `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ServiceEndpointPoliciesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ServiceEndpointPolicyOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServiceEndpointPoliciesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ServiceEndpointPolicyOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ServiceEndpointPolicy, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/method_listbyresourcegroup.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/method_listbyresourcegroup.go new file mode 100644 index 00000000000..384f7dc28fe --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package serviceendpointpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ServiceEndpointPolicy +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ServiceEndpointPolicy +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c ServiceEndpointPoliciesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/serviceEndpointPolicies", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ServiceEndpointPolicy `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ServiceEndpointPoliciesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ServiceEndpointPolicyOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServiceEndpointPoliciesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ServiceEndpointPolicyOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ServiceEndpointPolicy, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/method_updatetags.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/method_updatetags.go new file mode 100644 index 00000000000..d260b347033 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/method_updatetags.go @@ -0,0 +1,57 @@ +package serviceendpointpolicies + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServiceEndpointPolicy +} + +// UpdateTags ... +func (c ServiceEndpointPoliciesClient) UpdateTags(ctx context.Context, id ServiceEndpointPolicyId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ServiceEndpointPolicy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..7a1f5258bb4 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..76bca3269ac --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..1e70d427a94 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..7f6bd42e1cc --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..15556d9d646 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..6e7d684d6ab --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..2f704e37983 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_backendaddresspool.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_backendaddresspool.go new file mode 100644 index 00000000000..feb93ad5475 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..4d71c4769d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..9f6fb9fe6e7 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ddossettings.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ddossettings.go new file mode 100644 index 00000000000..de52c73833f --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ddossettings.go @@ -0,0 +1,9 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_delegation.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_delegation.go new file mode 100644 index 00000000000..1e9e6e93b12 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_delegation.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_flowlog.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_flowlog.go new file mode 100644 index 00000000000..9ba393ae2ff --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_flowlog.go @@ -0,0 +1,19 @@ +package serviceendpointpolicies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_flowlogformatparameters.go new file mode 100644 index 00000000000..64ce02b9b62 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..2a057a6f1f7 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_frontendipconfiguration.go new file mode 100644 index 00000000000..3460648e174 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package serviceendpointpolicies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..27c417be79d --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..253d53dc1d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_inboundnatrule.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_inboundnatrule.go new file mode 100644 index 00000000000..691567f1623 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..bcdf56e4388 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..4bb12897f75 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..242e96e5147 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipconfiguration.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipconfiguration.go new file mode 100644 index 00000000000..43160da9e2b --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..cbb4340c474 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..a8340bcc1f3 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..b76d67b91b5 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_iptag.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_iptag.go new file mode 100644 index 00000000000..879d6210923 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_iptag.go @@ -0,0 +1,9 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..bcd25a343d4 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..71bfae4fc90 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_natgateway.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_natgateway.go new file mode 100644 index 00000000000..4fce3c97a62 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_natgateway.go @@ -0,0 +1,20 @@ +package serviceendpointpolicies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..4c898548702 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_natgatewaysku.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_natgatewaysku.go new file mode 100644 index 00000000000..d7c06ad6950 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_natruleportmapping.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_natruleportmapping.go new file mode 100644 index 00000000000..af408670c2d --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterface.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterface.go new file mode 100644 index 00000000000..4576b3d0a24 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterface.go @@ -0,0 +1,19 @@ +package serviceendpointpolicies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..f2f63e673ce --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..efba2a7575d --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..fee33255b2f --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..aae328cad75 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..57afbb37a80 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..373ac218872 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..1a2c2bc8774 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networksecuritygroup.go new file mode 100644 index 00000000000..7babf5dcba3 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..9e417934d4e --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpoint.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpoint.go new file mode 100644 index 00000000000..b9c2640063f --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpoint.go @@ -0,0 +1,19 @@ +package serviceendpointpolicies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpointconnection.go new file mode 100644 index 00000000000..0c67a94b069 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..9468576ebfd --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..25ab508cf68 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..b2b9cd17391 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpointproperties.go new file mode 100644 index 00000000000..b74aa311c14 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkservice.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkservice.go new file mode 100644 index 00000000000..f69adbd0b19 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package serviceendpointpolicies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..f163cad59d9 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..e9560116ef6 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..9accc19fd8b --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..e2a71cb7416 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..6cc9d81d85e --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..324d11d9e4c --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_publicipaddress.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_publicipaddress.go new file mode 100644 index 00000000000..b3722e1f191 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_publicipaddress.go @@ -0,0 +1,22 @@ +package serviceendpointpolicies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..d28111e34e8 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..fe9e93dc57e --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_publicipaddresssku.go new file mode 100644 index 00000000000..5d6c2dd1535 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_resourcenavigationlink.go new file mode 100644 index 00000000000..3a125f5d30e --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..004d9d501d7 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_resourceset.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_resourceset.go new file mode 100644 index 00000000000..33f79b6dd7f --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_resourceset.go @@ -0,0 +1,8 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..98b48093fe5 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_route.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_route.go new file mode 100644 index 00000000000..a08219146cf --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_route.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_routepropertiesformat.go new file mode 100644 index 00000000000..a2d74c7e24a --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_routetable.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_routetable.go new file mode 100644 index 00000000000..fabb0fc336d --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_routetable.go @@ -0,0 +1,14 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..fbf628f66f3 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_securityrule.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_securityrule.go new file mode 100644 index 00000000000..3f50e5ddac6 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_securityrule.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..8d5f321605a --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceassociationlink.go new file mode 100644 index 00000000000..a22d8f42829 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..5b81f28e88b --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..0903abfa70e --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..796d7019b02 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..75928dae7f1 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..31efd2eb7eb --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..fdb4ecd0a7f --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..40b6ccdb10e --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_subnet.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_subnet.go new file mode 100644 index 00000000000..50005077792 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_subnet.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..555ec33d24b --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_subresource.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_subresource.go new file mode 100644 index 00000000000..61370085ffc --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_subresource.go @@ -0,0 +1,8 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_tagsobject.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_tagsobject.go new file mode 100644 index 00000000000..7c5d750fc90 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_tagsobject.go @@ -0,0 +1,8 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..da94c72fe29 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..58889a80476 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_virtualnetworktap.go new file mode 100644 index 00000000000..1d191ff67f0 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..2660ce6a382 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/predicates.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/predicates.go new file mode 100644 index 00000000000..ddd972a1d9d --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/predicates.go @@ -0,0 +1,42 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyOperationPredicate struct { + Etag *string + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p ServiceEndpointPolicyOperationPredicate) Matches(input ServiceEndpointPolicy) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicies/version.go b/resource-manager/network/2024-07-01/serviceendpointpolicies/version.go new file mode 100644 index 00000000000..7fbd208c412 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicies/version.go @@ -0,0 +1,10 @@ +package serviceendpointpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/serviceendpointpolicies/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/README.md b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/README.md new file mode 100644 index 00000000000..dd85b9ed6dc --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions` Documentation + +The `serviceendpointpolicydefinitions` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions" +``` + + +### Client Initialization + +```go +client := serviceendpointpolicydefinitions.NewServiceEndpointPolicyDefinitionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ServiceEndpointPolicyDefinitionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := serviceendpointpolicydefinitions.NewServiceEndpointPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceEndpointPolicyName", "serviceEndpointPolicyDefinitionName") + +payload := serviceendpointpolicydefinitions.ServiceEndpointPolicyDefinition{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ServiceEndpointPolicyDefinitionsClient.Delete` + +```go +ctx := context.TODO() +id := serviceendpointpolicydefinitions.NewServiceEndpointPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceEndpointPolicyName", "serviceEndpointPolicyDefinitionName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ServiceEndpointPolicyDefinitionsClient.Get` + +```go +ctx := context.TODO() +id := serviceendpointpolicydefinitions.NewServiceEndpointPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceEndpointPolicyName", "serviceEndpointPolicyDefinitionName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ServiceEndpointPolicyDefinitionsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := serviceendpointpolicydefinitions.NewServiceEndpointPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceEndpointPolicyName") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/client.go b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/client.go new file mode 100644 index 00000000000..0b0e9163605 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/client.go @@ -0,0 +1,26 @@ +package serviceendpointpolicydefinitions + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionsClient struct { + Client *resourcemanager.Client +} + +func NewServiceEndpointPolicyDefinitionsClientWithBaseURI(sdkApi sdkEnv.Api) (*ServiceEndpointPolicyDefinitionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "serviceendpointpolicydefinitions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServiceEndpointPolicyDefinitionsClient: %+v", err) + } + + return &ServiceEndpointPolicyDefinitionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/constants.go b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/constants.go new file mode 100644 index 00000000000..3e91dc60d4b --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/constants.go @@ -0,0 +1,57 @@ +package serviceendpointpolicydefinitions + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/id_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/id_serviceendpointpolicy.go new file mode 100644 index 00000000000..901a08b5cfc --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/id_serviceendpointpolicy.go @@ -0,0 +1,130 @@ +package serviceendpointpolicydefinitions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ServiceEndpointPolicyId{}) +} + +var _ resourceids.ResourceId = &ServiceEndpointPolicyId{} + +// ServiceEndpointPolicyId is a struct representing the Resource ID for a Service Endpoint Policy +type ServiceEndpointPolicyId struct { + SubscriptionId string + ResourceGroupName string + ServiceEndpointPolicyName string +} + +// NewServiceEndpointPolicyID returns a new ServiceEndpointPolicyId struct +func NewServiceEndpointPolicyID(subscriptionId string, resourceGroupName string, serviceEndpointPolicyName string) ServiceEndpointPolicyId { + return ServiceEndpointPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServiceEndpointPolicyName: serviceEndpointPolicyName, + } +} + +// ParseServiceEndpointPolicyID parses 'input' into a ServiceEndpointPolicyId +func ParseServiceEndpointPolicyID(input string) (*ServiceEndpointPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceEndpointPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceEndpointPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseServiceEndpointPolicyIDInsensitively parses 'input' case-insensitively into a ServiceEndpointPolicyId +// note: this method should only be used for API response data and not user input +func ParseServiceEndpointPolicyIDInsensitively(input string) (*ServiceEndpointPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceEndpointPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceEndpointPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ServiceEndpointPolicyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ServiceEndpointPolicyName, ok = input.Parsed["serviceEndpointPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serviceEndpointPolicyName", input) + } + + return nil +} + +// ValidateServiceEndpointPolicyID checks that 'input' can be parsed as a Service Endpoint Policy ID +func ValidateServiceEndpointPolicyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseServiceEndpointPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Service Endpoint Policy ID +func (id ServiceEndpointPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/serviceEndpointPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServiceEndpointPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Service Endpoint Policy ID +func (id ServiceEndpointPolicyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticServiceEndpointPolicies", "serviceEndpointPolicies", "serviceEndpointPolicies"), + resourceids.UserSpecifiedSegment("serviceEndpointPolicyName", "serviceEndpointPolicyName"), + } +} + +// String returns a human-readable description of this Service Endpoint Policy ID +func (id ServiceEndpointPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Service Endpoint Policy Name: %q", id.ServiceEndpointPolicyName), + } + return fmt.Sprintf("Service Endpoint Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/id_serviceendpointpolicy_test.go b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/id_serviceendpointpolicy_test.go new file mode 100644 index 00000000000..f7515975cc7 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/id_serviceendpointpolicy_test.go @@ -0,0 +1,282 @@ +package serviceendpointpolicydefinitions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ServiceEndpointPolicyId{} + +func TestNewServiceEndpointPolicyID(t *testing.T) { + id := NewServiceEndpointPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceEndpointPolicyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ServiceEndpointPolicyName != "serviceEndpointPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'ServiceEndpointPolicyName'", id.ServiceEndpointPolicyName, "serviceEndpointPolicyName") + } +} + +func TestFormatServiceEndpointPolicyID(t *testing.T) { + actual := NewServiceEndpointPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceEndpointPolicyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServiceEndpointPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceEndpointPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName", + Expected: &ServiceEndpointPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServiceEndpointPolicyName: "serviceEndpointPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceEndpointPolicyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServiceEndpointPolicyName != v.Expected.ServiceEndpointPolicyName { + t.Fatalf("Expected %q but got %q for ServiceEndpointPolicyName", v.Expected.ServiceEndpointPolicyName, actual.ServiceEndpointPolicyName) + } + + } +} + +func TestParseServiceEndpointPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceEndpointPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/sErViCeEnDpOiNtPoLiCiEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName", + Expected: &ServiceEndpointPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServiceEndpointPolicyName: "serviceEndpointPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/sErViCeEnDpOiNtPoLiCiEs/sErViCeEnDpOiNtPoLiCyNaMe", + Expected: &ServiceEndpointPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServiceEndpointPolicyName: "sErViCeEnDpOiNtPoLiCyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/sErViCeEnDpOiNtPoLiCiEs/sErViCeEnDpOiNtPoLiCyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceEndpointPolicyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServiceEndpointPolicyName != v.Expected.ServiceEndpointPolicyName { + t.Fatalf("Expected %q but got %q for ServiceEndpointPolicyName", v.Expected.ServiceEndpointPolicyName, actual.ServiceEndpointPolicyName) + } + + } +} + +func TestSegmentsForServiceEndpointPolicyId(t *testing.T) { + segments := ServiceEndpointPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServiceEndpointPolicyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/id_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/id_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..2af5450738c --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/id_serviceendpointpolicydefinition.go @@ -0,0 +1,139 @@ +package serviceendpointpolicydefinitions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ServiceEndpointPolicyDefinitionId{}) +} + +var _ resourceids.ResourceId = &ServiceEndpointPolicyDefinitionId{} + +// ServiceEndpointPolicyDefinitionId is a struct representing the Resource ID for a Service Endpoint Policy Definition +type ServiceEndpointPolicyDefinitionId struct { + SubscriptionId string + ResourceGroupName string + ServiceEndpointPolicyName string + ServiceEndpointPolicyDefinitionName string +} + +// NewServiceEndpointPolicyDefinitionID returns a new ServiceEndpointPolicyDefinitionId struct +func NewServiceEndpointPolicyDefinitionID(subscriptionId string, resourceGroupName string, serviceEndpointPolicyName string, serviceEndpointPolicyDefinitionName string) ServiceEndpointPolicyDefinitionId { + return ServiceEndpointPolicyDefinitionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServiceEndpointPolicyName: serviceEndpointPolicyName, + ServiceEndpointPolicyDefinitionName: serviceEndpointPolicyDefinitionName, + } +} + +// ParseServiceEndpointPolicyDefinitionID parses 'input' into a ServiceEndpointPolicyDefinitionId +func ParseServiceEndpointPolicyDefinitionID(input string) (*ServiceEndpointPolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceEndpointPolicyDefinitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceEndpointPolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseServiceEndpointPolicyDefinitionIDInsensitively parses 'input' case-insensitively into a ServiceEndpointPolicyDefinitionId +// note: this method should only be used for API response data and not user input +func ParseServiceEndpointPolicyDefinitionIDInsensitively(input string) (*ServiceEndpointPolicyDefinitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServiceEndpointPolicyDefinitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServiceEndpointPolicyDefinitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ServiceEndpointPolicyDefinitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ServiceEndpointPolicyName, ok = input.Parsed["serviceEndpointPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serviceEndpointPolicyName", input) + } + + if id.ServiceEndpointPolicyDefinitionName, ok = input.Parsed["serviceEndpointPolicyDefinitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serviceEndpointPolicyDefinitionName", input) + } + + return nil +} + +// ValidateServiceEndpointPolicyDefinitionID checks that 'input' can be parsed as a Service Endpoint Policy Definition ID +func ValidateServiceEndpointPolicyDefinitionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseServiceEndpointPolicyDefinitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Service Endpoint Policy Definition ID +func (id ServiceEndpointPolicyDefinitionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/serviceEndpointPolicies/%s/serviceEndpointPolicyDefinitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServiceEndpointPolicyName, id.ServiceEndpointPolicyDefinitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Service Endpoint Policy Definition ID +func (id ServiceEndpointPolicyDefinitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticServiceEndpointPolicies", "serviceEndpointPolicies", "serviceEndpointPolicies"), + resourceids.UserSpecifiedSegment("serviceEndpointPolicyName", "serviceEndpointPolicyName"), + resourceids.StaticSegment("staticServiceEndpointPolicyDefinitions", "serviceEndpointPolicyDefinitions", "serviceEndpointPolicyDefinitions"), + resourceids.UserSpecifiedSegment("serviceEndpointPolicyDefinitionName", "serviceEndpointPolicyDefinitionName"), + } +} + +// String returns a human-readable description of this Service Endpoint Policy Definition ID +func (id ServiceEndpointPolicyDefinitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Service Endpoint Policy Name: %q", id.ServiceEndpointPolicyName), + fmt.Sprintf("Service Endpoint Policy Definition Name: %q", id.ServiceEndpointPolicyDefinitionName), + } + return fmt.Sprintf("Service Endpoint Policy Definition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/id_serviceendpointpolicydefinition_test.go b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/id_serviceendpointpolicydefinition_test.go new file mode 100644 index 00000000000..bf31553c9df --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/id_serviceendpointpolicydefinition_test.go @@ -0,0 +1,327 @@ +package serviceendpointpolicydefinitions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ServiceEndpointPolicyDefinitionId{} + +func TestNewServiceEndpointPolicyDefinitionID(t *testing.T) { + id := NewServiceEndpointPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceEndpointPolicyName", "serviceEndpointPolicyDefinitionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ServiceEndpointPolicyName != "serviceEndpointPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'ServiceEndpointPolicyName'", id.ServiceEndpointPolicyName, "serviceEndpointPolicyName") + } + + if id.ServiceEndpointPolicyDefinitionName != "serviceEndpointPolicyDefinitionName" { + t.Fatalf("Expected %q but got %q for Segment 'ServiceEndpointPolicyDefinitionName'", id.ServiceEndpointPolicyDefinitionName, "serviceEndpointPolicyDefinitionName") + } +} + +func TestFormatServiceEndpointPolicyDefinitionID(t *testing.T) { + actual := NewServiceEndpointPolicyDefinitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceEndpointPolicyName", "serviceEndpointPolicyDefinitionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName/serviceEndpointPolicyDefinitions/serviceEndpointPolicyDefinitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServiceEndpointPolicyDefinitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceEndpointPolicyDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName/serviceEndpointPolicyDefinitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName/serviceEndpointPolicyDefinitions/serviceEndpointPolicyDefinitionName", + Expected: &ServiceEndpointPolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServiceEndpointPolicyName: "serviceEndpointPolicyName", + ServiceEndpointPolicyDefinitionName: "serviceEndpointPolicyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName/serviceEndpointPolicyDefinitions/serviceEndpointPolicyDefinitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceEndpointPolicyDefinitionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServiceEndpointPolicyName != v.Expected.ServiceEndpointPolicyName { + t.Fatalf("Expected %q but got %q for ServiceEndpointPolicyName", v.Expected.ServiceEndpointPolicyName, actual.ServiceEndpointPolicyName) + } + + if actual.ServiceEndpointPolicyDefinitionName != v.Expected.ServiceEndpointPolicyDefinitionName { + t.Fatalf("Expected %q but got %q for ServiceEndpointPolicyDefinitionName", v.Expected.ServiceEndpointPolicyDefinitionName, actual.ServiceEndpointPolicyDefinitionName) + } + + } +} + +func TestParseServiceEndpointPolicyDefinitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServiceEndpointPolicyDefinitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/sErViCeEnDpOiNtPoLiCiEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/sErViCeEnDpOiNtPoLiCiEs/sErViCeEnDpOiNtPoLiCyNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName/serviceEndpointPolicyDefinitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/sErViCeEnDpOiNtPoLiCiEs/sErViCeEnDpOiNtPoLiCyNaMe/sErViCeEnDpOiNtPoLiCyDeFiNiTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName/serviceEndpointPolicyDefinitions/serviceEndpointPolicyDefinitionName", + Expected: &ServiceEndpointPolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServiceEndpointPolicyName: "serviceEndpointPolicyName", + ServiceEndpointPolicyDefinitionName: "serviceEndpointPolicyDefinitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/serviceEndpointPolicies/serviceEndpointPolicyName/serviceEndpointPolicyDefinitions/serviceEndpointPolicyDefinitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/sErViCeEnDpOiNtPoLiCiEs/sErViCeEnDpOiNtPoLiCyNaMe/sErViCeEnDpOiNtPoLiCyDeFiNiTiOnS/sErViCeEnDpOiNtPoLiCyDeFiNiTiOnNaMe", + Expected: &ServiceEndpointPolicyDefinitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServiceEndpointPolicyName: "sErViCeEnDpOiNtPoLiCyNaMe", + ServiceEndpointPolicyDefinitionName: "sErViCeEnDpOiNtPoLiCyDeFiNiTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/sErViCeEnDpOiNtPoLiCiEs/sErViCeEnDpOiNtPoLiCyNaMe/sErViCeEnDpOiNtPoLiCyDeFiNiTiOnS/sErViCeEnDpOiNtPoLiCyDeFiNiTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServiceEndpointPolicyDefinitionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServiceEndpointPolicyName != v.Expected.ServiceEndpointPolicyName { + t.Fatalf("Expected %q but got %q for ServiceEndpointPolicyName", v.Expected.ServiceEndpointPolicyName, actual.ServiceEndpointPolicyName) + } + + if actual.ServiceEndpointPolicyDefinitionName != v.Expected.ServiceEndpointPolicyDefinitionName { + t.Fatalf("Expected %q but got %q for ServiceEndpointPolicyDefinitionName", v.Expected.ServiceEndpointPolicyDefinitionName, actual.ServiceEndpointPolicyDefinitionName) + } + + } +} + +func TestSegmentsForServiceEndpointPolicyDefinitionId(t *testing.T) { + segments := ServiceEndpointPolicyDefinitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServiceEndpointPolicyDefinitionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/method_createorupdate.go b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/method_createorupdate.go new file mode 100644 index 00000000000..e75afb9fc02 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/method_createorupdate.go @@ -0,0 +1,75 @@ +package serviceendpointpolicydefinitions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ServiceEndpointPolicyDefinition +} + +// CreateOrUpdate ... +func (c ServiceEndpointPolicyDefinitionsClient) CreateOrUpdate(ctx context.Context, id ServiceEndpointPolicyDefinitionId, input ServiceEndpointPolicyDefinition) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ServiceEndpointPolicyDefinitionsClient) CreateOrUpdateThenPoll(ctx context.Context, id ServiceEndpointPolicyDefinitionId, input ServiceEndpointPolicyDefinition) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/method_delete.go b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/method_delete.go new file mode 100644 index 00000000000..81989f95364 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/method_delete.go @@ -0,0 +1,71 @@ +package serviceendpointpolicydefinitions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ServiceEndpointPolicyDefinitionsClient) Delete(ctx context.Context, id ServiceEndpointPolicyDefinitionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ServiceEndpointPolicyDefinitionsClient) DeleteThenPoll(ctx context.Context, id ServiceEndpointPolicyDefinitionId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/method_get.go b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/method_get.go new file mode 100644 index 00000000000..8aff5f74167 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/method_get.go @@ -0,0 +1,53 @@ +package serviceendpointpolicydefinitions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServiceEndpointPolicyDefinition +} + +// Get ... +func (c ServiceEndpointPolicyDefinitionsClient) Get(ctx context.Context, id ServiceEndpointPolicyDefinitionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ServiceEndpointPolicyDefinition + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/method_listbyresourcegroup.go b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/method_listbyresourcegroup.go new file mode 100644 index 00000000000..a4f79aa4d80 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/method_listbyresourcegroup.go @@ -0,0 +1,105 @@ +package serviceendpointpolicydefinitions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ServiceEndpointPolicyDefinition +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ServiceEndpointPolicyDefinition +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c ServiceEndpointPolicyDefinitionsClient) ListByResourceGroup(ctx context.Context, id ServiceEndpointPolicyId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/serviceEndpointPolicyDefinitions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ServiceEndpointPolicyDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ServiceEndpointPolicyDefinitionsClient) ListByResourceGroupComplete(ctx context.Context, id ServiceEndpointPolicyId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ServiceEndpointPolicyDefinitionOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServiceEndpointPolicyDefinitionsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id ServiceEndpointPolicyId, predicate ServiceEndpointPolicyDefinitionOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ServiceEndpointPolicyDefinition, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..012ba37fe47 --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package serviceendpointpolicydefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..ff7d49d8a5b --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package serviceendpointpolicydefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/predicates.go b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/predicates.go new file mode 100644 index 00000000000..a7a08fa9deb --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/predicates.go @@ -0,0 +1,32 @@ +package serviceendpointpolicydefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p ServiceEndpointPolicyDefinitionOperationPredicate) Matches(input ServiceEndpointPolicyDefinition) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/version.go b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/version.go new file mode 100644 index 00000000000..c6e1fceb26e --- /dev/null +++ b/resource-manager/network/2024-07-01/serviceendpointpolicydefinitions/version.go @@ -0,0 +1,10 @@ +package serviceendpointpolicydefinitions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/serviceendpointpolicydefinitions/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/servicetags/README.md b/resource-manager/network/2024-07-01/servicetags/README.md new file mode 100644 index 00000000000..bd3e20c6a4d --- /dev/null +++ b/resource-manager/network/2024-07-01/servicetags/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/servicetags` Documentation + +The `servicetags` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/servicetags" +``` + + +### Client Initialization + +```go +client := servicetags.NewServiceTagsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ServiceTagsClient.ServiceTagInformationList` + +```go +ctx := context.TODO() +id := servicetags.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.ServiceTagInformationList(ctx, id, servicetags.DefaultServiceTagInformationListOperationOptions())` can be used to do batched pagination +items, err := client.ServiceTagInformationListComplete(ctx, id, servicetags.DefaultServiceTagInformationListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ServiceTagsClient.ServiceTagsList` + +```go +ctx := context.TODO() +id := servicetags.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +read, err := client.ServiceTagsList(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/servicetags/client.go b/resource-manager/network/2024-07-01/servicetags/client.go new file mode 100644 index 00000000000..33295761773 --- /dev/null +++ b/resource-manager/network/2024-07-01/servicetags/client.go @@ -0,0 +1,26 @@ +package servicetags + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceTagsClient struct { + Client *resourcemanager.Client +} + +func NewServiceTagsClientWithBaseURI(sdkApi sdkEnv.Api) (*ServiceTagsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "servicetags", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServiceTagsClient: %+v", err) + } + + return &ServiceTagsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/servicetags/id_location.go b/resource-manager/network/2024-07-01/servicetags/id_location.go new file mode 100644 index 00000000000..5040a3f420a --- /dev/null +++ b/resource-manager/network/2024-07-01/servicetags/id_location.go @@ -0,0 +1,121 @@ +package servicetags + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Network/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/servicetags/id_location_test.go b/resource-manager/network/2024-07-01/servicetags/id_location_test.go new file mode 100644 index 00000000000..003c4b42ddf --- /dev/null +++ b/resource-manager/network/2024-07-01/servicetags/id_location_test.go @@ -0,0 +1,237 @@ +package servicetags + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/servicetags/method_servicetaginformationlist.go b/resource-manager/network/2024-07-01/servicetags/method_servicetaginformationlist.go new file mode 100644 index 00000000000..1150809dc2b --- /dev/null +++ b/resource-manager/network/2024-07-01/servicetags/method_servicetaginformationlist.go @@ -0,0 +1,138 @@ +package servicetags + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceTagInformationListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ServiceTagInformation +} + +type ServiceTagInformationListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ServiceTagInformation +} + +type ServiceTagInformationListOperationOptions struct { + NoAddressPrefixes *bool + TagName *string +} + +func DefaultServiceTagInformationListOperationOptions() ServiceTagInformationListOperationOptions { + return ServiceTagInformationListOperationOptions{} +} + +func (o ServiceTagInformationListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ServiceTagInformationListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ServiceTagInformationListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.NoAddressPrefixes != nil { + out.Append("noAddressPrefixes", fmt.Sprintf("%v", *o.NoAddressPrefixes)) + } + if o.TagName != nil { + out.Append("tagName", fmt.Sprintf("%v", *o.TagName)) + } + return &out +} + +type ServiceTagInformationListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ServiceTagInformationListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ServiceTagInformationList ... +func (c ServiceTagsClient) ServiceTagInformationList(ctx context.Context, id LocationId, options ServiceTagInformationListOperationOptions) (result ServiceTagInformationListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ServiceTagInformationListCustomPager{}, + Path: fmt.Sprintf("%s/serviceTagDetails", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ServiceTagInformation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ServiceTagInformationListComplete retrieves all the results into a single object +func (c ServiceTagsClient) ServiceTagInformationListComplete(ctx context.Context, id LocationId, options ServiceTagInformationListOperationOptions) (ServiceTagInformationListCompleteResult, error) { + return c.ServiceTagInformationListCompleteMatchingPredicate(ctx, id, options, ServiceTagInformationOperationPredicate{}) +} + +// ServiceTagInformationListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServiceTagsClient) ServiceTagInformationListCompleteMatchingPredicate(ctx context.Context, id LocationId, options ServiceTagInformationListOperationOptions, predicate ServiceTagInformationOperationPredicate) (result ServiceTagInformationListCompleteResult, err error) { + items := make([]ServiceTagInformation, 0) + + resp, err := c.ServiceTagInformationList(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ServiceTagInformationListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/servicetags/method_servicetagslist.go b/resource-manager/network/2024-07-01/servicetags/method_servicetagslist.go new file mode 100644 index 00000000000..a25ce187253 --- /dev/null +++ b/resource-manager/network/2024-07-01/servicetags/method_servicetagslist.go @@ -0,0 +1,54 @@ +package servicetags + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceTagsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ServiceTagsListResult +} + +// ServiceTagsList ... +func (c ServiceTagsClient) ServiceTagsList(ctx context.Context, id LocationId) (result ServiceTagsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/serviceTags", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ServiceTagsListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/servicetags/model_servicetaginformation.go b/resource-manager/network/2024-07-01/servicetags/model_servicetaginformation.go new file mode 100644 index 00000000000..705268a5bb9 --- /dev/null +++ b/resource-manager/network/2024-07-01/servicetags/model_servicetaginformation.go @@ -0,0 +1,11 @@ +package servicetags + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceTagInformation struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceTagInformationPropertiesFormat `json:"properties,omitempty"` + ServiceTagChangeNumber *string `json:"serviceTagChangeNumber,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/servicetags/model_servicetaginformationpropertiesformat.go b/resource-manager/network/2024-07-01/servicetags/model_servicetaginformationpropertiesformat.go new file mode 100644 index 00000000000..0d51bfcd8b2 --- /dev/null +++ b/resource-manager/network/2024-07-01/servicetags/model_servicetaginformationpropertiesformat.go @@ -0,0 +1,12 @@ +package servicetags + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceTagInformationPropertiesFormat struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ChangeNumber *string `json:"changeNumber,omitempty"` + Region *string `json:"region,omitempty"` + State *string `json:"state,omitempty"` + SystemService *string `json:"systemService,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/servicetags/model_servicetagslistresult.go b/resource-manager/network/2024-07-01/servicetags/model_servicetagslistresult.go new file mode 100644 index 00000000000..9cfb2fb2afb --- /dev/null +++ b/resource-manager/network/2024-07-01/servicetags/model_servicetagslistresult.go @@ -0,0 +1,14 @@ +package servicetags + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceTagsListResult struct { + ChangeNumber *string `json:"changeNumber,omitempty"` + Cloud *string `json:"cloud,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + NextLink *string `json:"nextLink,omitempty"` + Type *string `json:"type,omitempty"` + Values *[]ServiceTagInformation `json:"values,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/servicetags/predicates.go b/resource-manager/network/2024-07-01/servicetags/predicates.go new file mode 100644 index 00000000000..e10bffe6a4f --- /dev/null +++ b/resource-manager/network/2024-07-01/servicetags/predicates.go @@ -0,0 +1,27 @@ +package servicetags + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceTagInformationOperationPredicate struct { + Id *string + Name *string + ServiceTagChangeNumber *string +} + +func (p ServiceTagInformationOperationPredicate) Matches(input ServiceTagInformation) 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.ServiceTagChangeNumber != nil && (input.ServiceTagChangeNumber == nil || *p.ServiceTagChangeNumber != *input.ServiceTagChangeNumber) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/servicetags/version.go b/resource-manager/network/2024-07-01/servicetags/version.go new file mode 100644 index 00000000000..b11f8a049dd --- /dev/null +++ b/resource-manager/network/2024-07-01/servicetags/version.go @@ -0,0 +1,10 @@ +package servicetags + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/servicetags/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/staticcidrs/README.md b/resource-manager/network/2024-07-01/staticcidrs/README.md new file mode 100644 index 00000000000..58f9bcbcb70 --- /dev/null +++ b/resource-manager/network/2024-07-01/staticcidrs/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/staticcidrs` Documentation + +The `staticcidrs` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/staticcidrs" +``` + + +### Client Initialization + +```go +client := staticcidrs.NewStaticCidrsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `StaticCidrsClient.Create` + +```go +ctx := context.TODO() +id := staticcidrs.NewStaticCidrID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "ipamPoolName", "staticCidrName") + +payload := staticcidrs.StaticCidr{ + // ... +} + + +read, err := client.Create(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticCidrsClient.Delete` + +```go +ctx := context.TODO() +id := staticcidrs.NewStaticCidrID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "ipamPoolName", "staticCidrName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticCidrsClient.Get` + +```go +ctx := context.TODO() +id := staticcidrs.NewStaticCidrID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "ipamPoolName", "staticCidrName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticCidrsClient.List` + +```go +ctx := context.TODO() +id := staticcidrs.NewIPamPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "ipamPoolName") + +// alternatively `client.List(ctx, id, staticcidrs.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, staticcidrs.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/staticcidrs/client.go b/resource-manager/network/2024-07-01/staticcidrs/client.go new file mode 100644 index 00000000000..7ddac3023aa --- /dev/null +++ b/resource-manager/network/2024-07-01/staticcidrs/client.go @@ -0,0 +1,26 @@ +package staticcidrs + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticCidrsClient struct { + Client *resourcemanager.Client +} + +func NewStaticCidrsClientWithBaseURI(sdkApi sdkEnv.Api) (*StaticCidrsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "staticcidrs", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating StaticCidrsClient: %+v", err) + } + + return &StaticCidrsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/staticcidrs/constants.go b/resource-manager/network/2024-07-01/staticcidrs/constants.go new file mode 100644 index 00000000000..adcb11eff66 --- /dev/null +++ b/resource-manager/network/2024-07-01/staticcidrs/constants.go @@ -0,0 +1,63 @@ +package staticcidrs + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/staticcidrs/id_ipampool.go b/resource-manager/network/2024-07-01/staticcidrs/id_ipampool.go new file mode 100644 index 00000000000..364df07ee7e --- /dev/null +++ b/resource-manager/network/2024-07-01/staticcidrs/id_ipampool.go @@ -0,0 +1,139 @@ +package staticcidrs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&IPamPoolId{}) +} + +var _ resourceids.ResourceId = &IPamPoolId{} + +// IPamPoolId is a struct representing the Resource ID for a I Pam Pool +type IPamPoolId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + IpamPoolName string +} + +// NewIPamPoolID returns a new IPamPoolId struct +func NewIPamPoolID(subscriptionId string, resourceGroupName string, networkManagerName string, ipamPoolName string) IPamPoolId { + return IPamPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + IpamPoolName: ipamPoolName, + } +} + +// ParseIPamPoolID parses 'input' into a IPamPoolId +func ParseIPamPoolID(input string) (*IPamPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&IPamPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := IPamPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseIPamPoolIDInsensitively parses 'input' case-insensitively into a IPamPoolId +// note: this method should only be used for API response data and not user input +func ParseIPamPoolIDInsensitively(input string) (*IPamPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&IPamPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := IPamPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *IPamPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.IpamPoolName, ok = input.Parsed["ipamPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ipamPoolName", input) + } + + return nil +} + +// ValidateIPamPoolID checks that 'input' can be parsed as a I Pam Pool ID +func ValidateIPamPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseIPamPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted I Pam Pool ID +func (id IPamPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/ipamPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.IpamPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this I Pam Pool ID +func (id IPamPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticIpamPools", "ipamPools", "ipamPools"), + resourceids.UserSpecifiedSegment("ipamPoolName", "ipamPoolName"), + } +} + +// String returns a human-readable description of this I Pam Pool ID +func (id IPamPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Ipam Pool Name: %q", id.IpamPoolName), + } + return fmt.Sprintf("I Pam Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/staticcidrs/id_ipampool_test.go b/resource-manager/network/2024-07-01/staticcidrs/id_ipampool_test.go new file mode 100644 index 00000000000..8a54f212eb5 --- /dev/null +++ b/resource-manager/network/2024-07-01/staticcidrs/id_ipampool_test.go @@ -0,0 +1,327 @@ +package staticcidrs + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &IPamPoolId{} + +func TestNewIPamPoolID(t *testing.T) { + id := NewIPamPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "ipamPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.IpamPoolName != "ipamPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'IpamPoolName'", id.IpamPoolName, "ipamPoolName") + } +} + +func TestFormatIPamPoolID(t *testing.T) { + actual := NewIPamPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "ipamPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseIPamPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IPamPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName", + Expected: &IPamPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + IpamPoolName: "ipamPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIPamPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.IpamPoolName != v.Expected.IpamPoolName { + t.Fatalf("Expected %q but got %q for IpamPoolName", v.Expected.IpamPoolName, actual.IpamPoolName) + } + + } +} + +func TestParseIPamPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *IPamPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/iPaMpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName", + Expected: &IPamPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + IpamPoolName: "ipamPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/iPaMpOoLs/iPaMpOoLnAmE", + Expected: &IPamPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + IpamPoolName: "iPaMpOoLnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/iPaMpOoLs/iPaMpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseIPamPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.IpamPoolName != v.Expected.IpamPoolName { + t.Fatalf("Expected %q but got %q for IpamPoolName", v.Expected.IpamPoolName, actual.IpamPoolName) + } + + } +} + +func TestSegmentsForIPamPoolId(t *testing.T) { + segments := IPamPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("IPamPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/staticcidrs/id_staticcidr.go b/resource-manager/network/2024-07-01/staticcidrs/id_staticcidr.go new file mode 100644 index 00000000000..52e152d7fcb --- /dev/null +++ b/resource-manager/network/2024-07-01/staticcidrs/id_staticcidr.go @@ -0,0 +1,148 @@ +package staticcidrs + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&StaticCidrId{}) +} + +var _ resourceids.ResourceId = &StaticCidrId{} + +// StaticCidrId is a struct representing the Resource ID for a Static Cidr +type StaticCidrId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + IpamPoolName string + StaticCidrName string +} + +// NewStaticCidrID returns a new StaticCidrId struct +func NewStaticCidrID(subscriptionId string, resourceGroupName string, networkManagerName string, ipamPoolName string, staticCidrName string) StaticCidrId { + return StaticCidrId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + IpamPoolName: ipamPoolName, + StaticCidrName: staticCidrName, + } +} + +// ParseStaticCidrID parses 'input' into a StaticCidrId +func ParseStaticCidrID(input string) (*StaticCidrId, error) { + parser := resourceids.NewParserFromResourceIdType(&StaticCidrId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StaticCidrId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStaticCidrIDInsensitively parses 'input' case-insensitively into a StaticCidrId +// note: this method should only be used for API response data and not user input +func ParseStaticCidrIDInsensitively(input string) (*StaticCidrId, error) { + parser := resourceids.NewParserFromResourceIdType(&StaticCidrId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StaticCidrId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StaticCidrId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.IpamPoolName, ok = input.Parsed["ipamPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "ipamPoolName", input) + } + + if id.StaticCidrName, ok = input.Parsed["staticCidrName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticCidrName", input) + } + + return nil +} + +// ValidateStaticCidrID checks that 'input' can be parsed as a Static Cidr ID +func ValidateStaticCidrID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseStaticCidrID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Static Cidr ID +func (id StaticCidrId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/ipamPools/%s/staticCidrs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.IpamPoolName, id.StaticCidrName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Static Cidr ID +func (id StaticCidrId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticIpamPools", "ipamPools", "ipamPools"), + resourceids.UserSpecifiedSegment("ipamPoolName", "ipamPoolName"), + resourceids.StaticSegment("staticStaticCidrs", "staticCidrs", "staticCidrs"), + resourceids.UserSpecifiedSegment("staticCidrName", "staticCidrName"), + } +} + +// String returns a human-readable description of this Static Cidr ID +func (id StaticCidrId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Ipam Pool Name: %q", id.IpamPoolName), + fmt.Sprintf("Static Cidr Name: %q", id.StaticCidrName), + } + return fmt.Sprintf("Static Cidr (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/staticcidrs/id_staticcidr_test.go b/resource-manager/network/2024-07-01/staticcidrs/id_staticcidr_test.go new file mode 100644 index 00000000000..08d5729564e --- /dev/null +++ b/resource-manager/network/2024-07-01/staticcidrs/id_staticcidr_test.go @@ -0,0 +1,372 @@ +package staticcidrs + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &StaticCidrId{} + +func TestNewStaticCidrID(t *testing.T) { + id := NewStaticCidrID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "ipamPoolName", "staticCidrName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.IpamPoolName != "ipamPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'IpamPoolName'", id.IpamPoolName, "ipamPoolName") + } + + if id.StaticCidrName != "staticCidrName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticCidrName'", id.StaticCidrName, "staticCidrName") + } +} + +func TestFormatStaticCidrID(t *testing.T) { + actual := NewStaticCidrID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "ipamPoolName", "staticCidrName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName/staticCidrs/staticCidrName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStaticCidrID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StaticCidrId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName/staticCidrs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName/staticCidrs/staticCidrName", + Expected: &StaticCidrId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + IpamPoolName: "ipamPoolName", + StaticCidrName: "staticCidrName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName/staticCidrs/staticCidrName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStaticCidrID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.IpamPoolName != v.Expected.IpamPoolName { + t.Fatalf("Expected %q but got %q for IpamPoolName", v.Expected.IpamPoolName, actual.IpamPoolName) + } + + if actual.StaticCidrName != v.Expected.StaticCidrName { + t.Fatalf("Expected %q but got %q for StaticCidrName", v.Expected.StaticCidrName, actual.StaticCidrName) + } + + } +} + +func TestParseStaticCidrIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StaticCidrId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/iPaMpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/iPaMpOoLs/iPaMpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName/staticCidrs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/iPaMpOoLs/iPaMpOoLnAmE/sTaTiCcIdRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName/staticCidrs/staticCidrName", + Expected: &StaticCidrId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + IpamPoolName: "ipamPoolName", + StaticCidrName: "staticCidrName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/ipamPools/ipamPoolName/staticCidrs/staticCidrName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/iPaMpOoLs/iPaMpOoLnAmE/sTaTiCcIdRs/sTaTiCcIdRnAmE", + Expected: &StaticCidrId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + IpamPoolName: "iPaMpOoLnAmE", + StaticCidrName: "sTaTiCcIdRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/iPaMpOoLs/iPaMpOoLnAmE/sTaTiCcIdRs/sTaTiCcIdRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStaticCidrIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.IpamPoolName != v.Expected.IpamPoolName { + t.Fatalf("Expected %q but got %q for IpamPoolName", v.Expected.IpamPoolName, actual.IpamPoolName) + } + + if actual.StaticCidrName != v.Expected.StaticCidrName { + t.Fatalf("Expected %q but got %q for StaticCidrName", v.Expected.StaticCidrName, actual.StaticCidrName) + } + + } +} + +func TestSegmentsForStaticCidrId(t *testing.T) { + segments := StaticCidrId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StaticCidrId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/staticcidrs/method_create.go b/resource-manager/network/2024-07-01/staticcidrs/method_create.go new file mode 100644 index 00000000000..04a198b3a7d --- /dev/null +++ b/resource-manager/network/2024-07-01/staticcidrs/method_create.go @@ -0,0 +1,58 @@ +package staticcidrs + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticCidr +} + +// Create ... +func (c StaticCidrsClient) Create(ctx context.Context, id StaticCidrId, input StaticCidr) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticCidr + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/staticcidrs/method_delete.go b/resource-manager/network/2024-07-01/staticcidrs/method_delete.go new file mode 100644 index 00000000000..6bb693e7ab7 --- /dev/null +++ b/resource-manager/network/2024-07-01/staticcidrs/method_delete.go @@ -0,0 +1,70 @@ +package staticcidrs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c StaticCidrsClient) Delete(ctx context.Context, id StaticCidrId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c StaticCidrsClient) DeleteThenPoll(ctx context.Context, id StaticCidrId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/staticcidrs/method_get.go b/resource-manager/network/2024-07-01/staticcidrs/method_get.go new file mode 100644 index 00000000000..6a9a4c0c74c --- /dev/null +++ b/resource-manager/network/2024-07-01/staticcidrs/method_get.go @@ -0,0 +1,53 @@ +package staticcidrs + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticCidr +} + +// Get ... +func (c StaticCidrsClient) Get(ctx context.Context, id StaticCidrId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticCidr + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/staticcidrs/method_list.go b/resource-manager/network/2024-07-01/staticcidrs/method_list.go new file mode 100644 index 00000000000..a6af83a22fd --- /dev/null +++ b/resource-manager/network/2024-07-01/staticcidrs/method_list.go @@ -0,0 +1,150 @@ +package staticcidrs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticCidr +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticCidr +} + +type ListOperationOptions struct { + Skip *int64 + SkipToken *string + SortKey *string + SortValue *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skip != nil { + out.Append("skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + if o.SortKey != nil { + out.Append("sortKey", fmt.Sprintf("%v", *o.SortKey)) + } + if o.SortValue != nil { + out.Append("sortValue", fmt.Sprintf("%v", *o.SortValue)) + } + if o.Top != nil { + out.Append("top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c StaticCidrsClient) List(ctx context.Context, id IPamPoolId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/staticCidrs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticCidr `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c StaticCidrsClient) ListComplete(ctx context.Context, id IPamPoolId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, StaticCidrOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticCidrsClient) ListCompleteMatchingPredicate(ctx context.Context, id IPamPoolId, options ListOperationOptions, predicate StaticCidrOperationPredicate) (result ListCompleteResult, err error) { + items := make([]StaticCidr, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/staticcidrs/model_staticcidr.go b/resource-manager/network/2024-07-01/staticcidrs/model_staticcidr.go new file mode 100644 index 00000000000..263f84034ef --- /dev/null +++ b/resource-manager/network/2024-07-01/staticcidrs/model_staticcidr.go @@ -0,0 +1,16 @@ +package staticcidrs + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticCidr struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticCidrProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/staticcidrs/model_staticcidrproperties.go b/resource-manager/network/2024-07-01/staticcidrs/model_staticcidrproperties.go new file mode 100644 index 00000000000..7b8be5e1d8b --- /dev/null +++ b/resource-manager/network/2024-07-01/staticcidrs/model_staticcidrproperties.go @@ -0,0 +1,12 @@ +package staticcidrs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticCidrProperties struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + Description *string `json:"description,omitempty"` + NumberOfIPAddressesToAllocate *string `json:"numberOfIPAddressesToAllocate,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + TotalNumberOfIPAddresses *string `json:"totalNumberOfIPAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/staticcidrs/predicates.go b/resource-manager/network/2024-07-01/staticcidrs/predicates.go new file mode 100644 index 00000000000..1cae95a63d6 --- /dev/null +++ b/resource-manager/network/2024-07-01/staticcidrs/predicates.go @@ -0,0 +1,27 @@ +package staticcidrs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticCidrOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p StaticCidrOperationPredicate) Matches(input StaticCidr) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/staticcidrs/version.go b/resource-manager/network/2024-07-01/staticcidrs/version.go new file mode 100644 index 00000000000..49f6a073f02 --- /dev/null +++ b/resource-manager/network/2024-07-01/staticcidrs/version.go @@ -0,0 +1,10 @@ +package staticcidrs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/staticcidrs/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/staticmembers/README.md b/resource-manager/network/2024-07-01/staticmembers/README.md new file mode 100644 index 00000000000..ce3190efd17 --- /dev/null +++ b/resource-manager/network/2024-07-01/staticmembers/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/staticmembers` Documentation + +The `staticmembers` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/staticmembers" +``` + + +### Client Initialization + +```go +client := staticmembers.NewStaticMembersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `StaticMembersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := staticmembers.NewStaticMemberID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "networkGroupName", "staticMemberName") + +payload := staticmembers.StaticMember{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticMembersClient.Delete` + +```go +ctx := context.TODO() +id := staticmembers.NewStaticMemberID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "networkGroupName", "staticMemberName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticMembersClient.Get` + +```go +ctx := context.TODO() +id := staticmembers.NewStaticMemberID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "networkGroupName", "staticMemberName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticMembersClient.List` + +```go +ctx := context.TODO() +id := staticmembers.NewNetworkGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "networkGroupName") + +// alternatively `client.List(ctx, id, staticmembers.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, staticmembers.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/staticmembers/client.go b/resource-manager/network/2024-07-01/staticmembers/client.go new file mode 100644 index 00000000000..9357db6d5f3 --- /dev/null +++ b/resource-manager/network/2024-07-01/staticmembers/client.go @@ -0,0 +1,26 @@ +package staticmembers + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticMembersClient struct { + Client *resourcemanager.Client +} + +func NewStaticMembersClientWithBaseURI(sdkApi sdkEnv.Api) (*StaticMembersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "staticmembers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating StaticMembersClient: %+v", err) + } + + return &StaticMembersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/staticmembers/constants.go b/resource-manager/network/2024-07-01/staticmembers/constants.go new file mode 100644 index 00000000000..3ccbd94262b --- /dev/null +++ b/resource-manager/network/2024-07-01/staticmembers/constants.go @@ -0,0 +1,57 @@ +package staticmembers + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/staticmembers/id_networkgroup.go b/resource-manager/network/2024-07-01/staticmembers/id_networkgroup.go new file mode 100644 index 00000000000..d846cd377f4 --- /dev/null +++ b/resource-manager/network/2024-07-01/staticmembers/id_networkgroup.go @@ -0,0 +1,139 @@ +package staticmembers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkGroupId{}) +} + +var _ resourceids.ResourceId = &NetworkGroupId{} + +// NetworkGroupId is a struct representing the Resource ID for a Network Group +type NetworkGroupId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + NetworkGroupName string +} + +// NewNetworkGroupID returns a new NetworkGroupId struct +func NewNetworkGroupID(subscriptionId string, resourceGroupName string, networkManagerName string, networkGroupName string) NetworkGroupId { + return NetworkGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + NetworkGroupName: networkGroupName, + } +} + +// ParseNetworkGroupID parses 'input' into a NetworkGroupId +func ParseNetworkGroupID(input string) (*NetworkGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkGroupIDInsensitively parses 'input' case-insensitively into a NetworkGroupId +// note: this method should only be used for API response data and not user input +func ParseNetworkGroupIDInsensitively(input string) (*NetworkGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.NetworkGroupName, ok = input.Parsed["networkGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkGroupName", input) + } + + return nil +} + +// ValidateNetworkGroupID checks that 'input' can be parsed as a Network Group ID +func ValidateNetworkGroupID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Group ID +func (id NetworkGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/networkGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.NetworkGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Group ID +func (id NetworkGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticNetworkGroups", "networkGroups", "networkGroups"), + resourceids.UserSpecifiedSegment("networkGroupName", "networkGroupName"), + } +} + +// String returns a human-readable description of this Network Group ID +func (id NetworkGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Network Group Name: %q", id.NetworkGroupName), + } + return fmt.Sprintf("Network Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/staticmembers/id_networkgroup_test.go b/resource-manager/network/2024-07-01/staticmembers/id_networkgroup_test.go new file mode 100644 index 00000000000..b5f53dc2db7 --- /dev/null +++ b/resource-manager/network/2024-07-01/staticmembers/id_networkgroup_test.go @@ -0,0 +1,327 @@ +package staticmembers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkGroupId{} + +func TestNewNetworkGroupID(t *testing.T) { + id := NewNetworkGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "networkGroupName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.NetworkGroupName != "networkGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkGroupName'", id.NetworkGroupName, "networkGroupName") + } +} + +func TestFormatNetworkGroupID(t *testing.T) { + actual := NewNetworkGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "networkGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName", + Expected: &NetworkGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + NetworkGroupName: "networkGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkGroupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.NetworkGroupName != v.Expected.NetworkGroupName { + t.Fatalf("Expected %q but got %q for NetworkGroupName", v.Expected.NetworkGroupName, actual.NetworkGroupName) + } + + } +} + +func TestParseNetworkGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/nEtWoRkGrOuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName", + Expected: &NetworkGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + NetworkGroupName: "networkGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/nEtWoRkGrOuPs/nEtWoRkGrOuPnAmE", + Expected: &NetworkGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + NetworkGroupName: "nEtWoRkGrOuPnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/nEtWoRkGrOuPs/nEtWoRkGrOuPnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkGroupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.NetworkGroupName != v.Expected.NetworkGroupName { + t.Fatalf("Expected %q but got %q for NetworkGroupName", v.Expected.NetworkGroupName, actual.NetworkGroupName) + } + + } +} + +func TestSegmentsForNetworkGroupId(t *testing.T) { + segments := NetworkGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkGroupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/staticmembers/id_staticmember.go b/resource-manager/network/2024-07-01/staticmembers/id_staticmember.go new file mode 100644 index 00000000000..7bbcff626d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/staticmembers/id_staticmember.go @@ -0,0 +1,148 @@ +package staticmembers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&StaticMemberId{}) +} + +var _ resourceids.ResourceId = &StaticMemberId{} + +// StaticMemberId is a struct representing the Resource ID for a Static Member +type StaticMemberId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + NetworkGroupName string + StaticMemberName string +} + +// NewStaticMemberID returns a new StaticMemberId struct +func NewStaticMemberID(subscriptionId string, resourceGroupName string, networkManagerName string, networkGroupName string, staticMemberName string) StaticMemberId { + return StaticMemberId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + NetworkGroupName: networkGroupName, + StaticMemberName: staticMemberName, + } +} + +// ParseStaticMemberID parses 'input' into a StaticMemberId +func ParseStaticMemberID(input string) (*StaticMemberId, error) { + parser := resourceids.NewParserFromResourceIdType(&StaticMemberId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StaticMemberId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStaticMemberIDInsensitively parses 'input' case-insensitively into a StaticMemberId +// note: this method should only be used for API response data and not user input +func ParseStaticMemberIDInsensitively(input string) (*StaticMemberId, error) { + parser := resourceids.NewParserFromResourceIdType(&StaticMemberId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StaticMemberId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StaticMemberId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.NetworkGroupName, ok = input.Parsed["networkGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkGroupName", input) + } + + if id.StaticMemberName, ok = input.Parsed["staticMemberName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticMemberName", input) + } + + return nil +} + +// ValidateStaticMemberID checks that 'input' can be parsed as a Static Member ID +func ValidateStaticMemberID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseStaticMemberID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Static Member ID +func (id StaticMemberId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/networkGroups/%s/staticMembers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.NetworkGroupName, id.StaticMemberName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Static Member ID +func (id StaticMemberId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticNetworkGroups", "networkGroups", "networkGroups"), + resourceids.UserSpecifiedSegment("networkGroupName", "networkGroupName"), + resourceids.StaticSegment("staticStaticMembers", "staticMembers", "staticMembers"), + resourceids.UserSpecifiedSegment("staticMemberName", "staticMemberName"), + } +} + +// String returns a human-readable description of this Static Member ID +func (id StaticMemberId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Network Group Name: %q", id.NetworkGroupName), + fmt.Sprintf("Static Member Name: %q", id.StaticMemberName), + } + return fmt.Sprintf("Static Member (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/staticmembers/id_staticmember_test.go b/resource-manager/network/2024-07-01/staticmembers/id_staticmember_test.go new file mode 100644 index 00000000000..5384dc8139a --- /dev/null +++ b/resource-manager/network/2024-07-01/staticmembers/id_staticmember_test.go @@ -0,0 +1,372 @@ +package staticmembers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &StaticMemberId{} + +func TestNewStaticMemberID(t *testing.T) { + id := NewStaticMemberID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "networkGroupName", "staticMemberName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.NetworkGroupName != "networkGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkGroupName'", id.NetworkGroupName, "networkGroupName") + } + + if id.StaticMemberName != "staticMemberName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticMemberName'", id.StaticMemberName, "staticMemberName") + } +} + +func TestFormatStaticMemberID(t *testing.T) { + actual := NewStaticMemberID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "networkGroupName", "staticMemberName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName/staticMembers/staticMemberName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStaticMemberID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StaticMemberId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName/staticMembers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName/staticMembers/staticMemberName", + Expected: &StaticMemberId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + NetworkGroupName: "networkGroupName", + StaticMemberName: "staticMemberName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName/staticMembers/staticMemberName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStaticMemberID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.NetworkGroupName != v.Expected.NetworkGroupName { + t.Fatalf("Expected %q but got %q for NetworkGroupName", v.Expected.NetworkGroupName, actual.NetworkGroupName) + } + + if actual.StaticMemberName != v.Expected.StaticMemberName { + t.Fatalf("Expected %q but got %q for StaticMemberName", v.Expected.StaticMemberName, actual.StaticMemberName) + } + + } +} + +func TestParseStaticMemberIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StaticMemberId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/nEtWoRkGrOuPs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/nEtWoRkGrOuPs/nEtWoRkGrOuPnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName/staticMembers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/nEtWoRkGrOuPs/nEtWoRkGrOuPnAmE/sTaTiCmEmBeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName/staticMembers/staticMemberName", + Expected: &StaticMemberId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + NetworkGroupName: "networkGroupName", + StaticMemberName: "staticMemberName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/networkGroups/networkGroupName/staticMembers/staticMemberName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/nEtWoRkGrOuPs/nEtWoRkGrOuPnAmE/sTaTiCmEmBeRs/sTaTiCmEmBeRnAmE", + Expected: &StaticMemberId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + NetworkGroupName: "nEtWoRkGrOuPnAmE", + StaticMemberName: "sTaTiCmEmBeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/nEtWoRkGrOuPs/nEtWoRkGrOuPnAmE/sTaTiCmEmBeRs/sTaTiCmEmBeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStaticMemberIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.NetworkGroupName != v.Expected.NetworkGroupName { + t.Fatalf("Expected %q but got %q for NetworkGroupName", v.Expected.NetworkGroupName, actual.NetworkGroupName) + } + + if actual.StaticMemberName != v.Expected.StaticMemberName { + t.Fatalf("Expected %q but got %q for StaticMemberName", v.Expected.StaticMemberName, actual.StaticMemberName) + } + + } +} + +func TestSegmentsForStaticMemberId(t *testing.T) { + segments := StaticMemberId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StaticMemberId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/staticmembers/method_createorupdate.go b/resource-manager/network/2024-07-01/staticmembers/method_createorupdate.go new file mode 100644 index 00000000000..f4ad175116b --- /dev/null +++ b/resource-manager/network/2024-07-01/staticmembers/method_createorupdate.go @@ -0,0 +1,58 @@ +package staticmembers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticMember +} + +// CreateOrUpdate ... +func (c StaticMembersClient) CreateOrUpdate(ctx context.Context, id StaticMemberId, input StaticMember) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticMember + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/staticmembers/method_delete.go b/resource-manager/network/2024-07-01/staticmembers/method_delete.go new file mode 100644 index 00000000000..5709eca59ec --- /dev/null +++ b/resource-manager/network/2024-07-01/staticmembers/method_delete.go @@ -0,0 +1,47 @@ +package staticmembers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c StaticMembersClient) Delete(ctx context.Context, id StaticMemberId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/staticmembers/method_get.go b/resource-manager/network/2024-07-01/staticmembers/method_get.go new file mode 100644 index 00000000000..8f9d30b17ab --- /dev/null +++ b/resource-manager/network/2024-07-01/staticmembers/method_get.go @@ -0,0 +1,53 @@ +package staticmembers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticMember +} + +// Get ... +func (c StaticMembersClient) Get(ctx context.Context, id StaticMemberId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticMember + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/staticmembers/method_list.go b/resource-manager/network/2024-07-01/staticmembers/method_list.go new file mode 100644 index 00000000000..ef104e6865f --- /dev/null +++ b/resource-manager/network/2024-07-01/staticmembers/method_list.go @@ -0,0 +1,134 @@ +package staticmembers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticMember +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticMember +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c StaticMembersClient) List(ctx context.Context, id NetworkGroupId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/staticMembers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticMember `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c StaticMembersClient) ListComplete(ctx context.Context, id NetworkGroupId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, StaticMemberOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticMembersClient) ListCompleteMatchingPredicate(ctx context.Context, id NetworkGroupId, options ListOperationOptions, predicate StaticMemberOperationPredicate) (result ListCompleteResult, err error) { + items := make([]StaticMember, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/staticmembers/model_staticmember.go b/resource-manager/network/2024-07-01/staticmembers/model_staticmember.go new file mode 100644 index 00000000000..b0d518168ea --- /dev/null +++ b/resource-manager/network/2024-07-01/staticmembers/model_staticmember.go @@ -0,0 +1,17 @@ +package staticmembers + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticMember struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticMemberProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/staticmembers/model_staticmemberproperties.go b/resource-manager/network/2024-07-01/staticmembers/model_staticmemberproperties.go new file mode 100644 index 00000000000..513dd3e5b9b --- /dev/null +++ b/resource-manager/network/2024-07-01/staticmembers/model_staticmemberproperties.go @@ -0,0 +1,10 @@ +package staticmembers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticMemberProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Region *string `json:"region,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/staticmembers/predicates.go b/resource-manager/network/2024-07-01/staticmembers/predicates.go new file mode 100644 index 00000000000..0fb08a96da7 --- /dev/null +++ b/resource-manager/network/2024-07-01/staticmembers/predicates.go @@ -0,0 +1,32 @@ +package staticmembers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticMemberOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p StaticMemberOperationPredicate) Matches(input StaticMember) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/staticmembers/version.go b/resource-manager/network/2024-07-01/staticmembers/version.go new file mode 100644 index 00000000000..5338aec7783 --- /dev/null +++ b/resource-manager/network/2024-07-01/staticmembers/version.go @@ -0,0 +1,10 @@ +package staticmembers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/staticmembers/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/subnets/README.md b/resource-manager/network/2024-07-01/subnets/README.md new file mode 100644 index 00000000000..fd8816e072e --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/README.md @@ -0,0 +1,83 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/subnets` Documentation + +The `subnets` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/subnets" +``` + + +### Client Initialization + +```go +client := subnets.NewSubnetsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SubnetsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewSubnetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName", "subnetName") + +payload := subnets.Subnet{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `SubnetsClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewSubnetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName", "subnetName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `SubnetsClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewSubnetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName", "subnetName") + +read, err := client.Get(ctx, id, subnets.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SubnetsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewVirtualNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/subnets/client.go b/resource-manager/network/2024-07-01/subnets/client.go new file mode 100644 index 00000000000..d3ece632ec6 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/client.go @@ -0,0 +1,26 @@ +package subnets + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetsClient struct { + Client *resourcemanager.Client +} + +func NewSubnetsClientWithBaseURI(sdkApi sdkEnv.Api) (*SubnetsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "subnets", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SubnetsClient: %+v", err) + } + + return &SubnetsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/subnets/constants.go b/resource-manager/network/2024-07-01/subnets/constants.go new file mode 100644 index 00000000000..ed5729d90d6 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/constants.go @@ -0,0 +1,1204 @@ +package subnets + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/subnets/method_createorupdate.go b/resource-manager/network/2024-07-01/subnets/method_createorupdate.go new file mode 100644 index 00000000000..2f47359f975 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/method_createorupdate.go @@ -0,0 +1,76 @@ +package subnets + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Subnet +} + +// CreateOrUpdate ... +func (c SubnetsClient) CreateOrUpdate(ctx context.Context, id commonids.SubnetId, input Subnet) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c SubnetsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.SubnetId, input Subnet) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/subnets/method_delete.go b/resource-manager/network/2024-07-01/subnets/method_delete.go new file mode 100644 index 00000000000..8be424289f0 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/method_delete.go @@ -0,0 +1,72 @@ +package subnets + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c SubnetsClient) Delete(ctx context.Context, id commonids.SubnetId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c SubnetsClient) DeleteThenPoll(ctx context.Context, id commonids.SubnetId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/subnets/method_get.go b/resource-manager/network/2024-07-01/subnets/method_get.go new file mode 100644 index 00000000000..9340f66305d --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/method_get.go @@ -0,0 +1,84 @@ +package subnets + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Subnet +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c SubnetsClient) Get(ctx context.Context, id commonids.SubnetId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Subnet + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/subnets/method_list.go b/resource-manager/network/2024-07-01/subnets/method_list.go new file mode 100644 index 00000000000..b9424e85280 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/method_list.go @@ -0,0 +1,106 @@ +package subnets + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Subnet +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Subnet +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c SubnetsClient) List(ctx context.Context, id commonids.VirtualNetworkId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/subnets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Subnet `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c SubnetsClient) ListComplete(ctx context.Context, id commonids.VirtualNetworkId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SubnetOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SubnetsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.VirtualNetworkId, predicate SubnetOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Subnet, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/subnets/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/subnets/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..3788306fb6c --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/subnets/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..916f79f9c4c --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..5cb3ab5e50f --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/subnets/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..2064f06b67c --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..ba5d67b2ce4 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/subnets/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..2b7038a9661 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..0444d465786 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_backendaddresspool.go b/resource-manager/network/2024-07-01/subnets/model_backendaddresspool.go new file mode 100644 index 00000000000..8549e5db3a8 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..561224fe97e --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..b8332f10ecf --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_ddossettings.go b/resource-manager/network/2024-07-01/subnets/model_ddossettings.go new file mode 100644 index 00000000000..d48851a6ba1 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_ddossettings.go @@ -0,0 +1,9 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_delegation.go b/resource-manager/network/2024-07-01/subnets/model_delegation.go new file mode 100644 index 00000000000..541d9d1d34b --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_delegation.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_flowlog.go b/resource-manager/network/2024-07-01/subnets/model_flowlog.go new file mode 100644 index 00000000000..e063f8c7730 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_flowlog.go @@ -0,0 +1,19 @@ +package subnets + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/subnets/model_flowlogformatparameters.go new file mode 100644 index 00000000000..492844afa0c --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..2dd1565d821 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/subnets/model_frontendipconfiguration.go new file mode 100644 index 00000000000..f24121e7c39 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package subnets + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..3c86535825a --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/subnets/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..3d2ff9b3010 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_inboundnatrule.go b/resource-manager/network/2024-07-01/subnets/model_inboundnatrule.go new file mode 100644 index 00000000000..dd23aa7a490 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..ac29e9fd37d --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/subnets/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..52440b83acb --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/subnets/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..8bc0457ea13 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_ipconfiguration.go b/resource-manager/network/2024-07-01/subnets/model_ipconfiguration.go new file mode 100644 index 00000000000..3e2e5516ea9 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/subnets/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..a4d5be3c038 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..bfb28994f14 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..4814acb3e8e --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_iptag.go b/resource-manager/network/2024-07-01/subnets/model_iptag.go new file mode 100644 index 00000000000..8ccc055cb31 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_iptag.go @@ -0,0 +1,9 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/subnets/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..e3b148912e3 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..ee7815f178d --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_natgateway.go b/resource-manager/network/2024-07-01/subnets/model_natgateway.go new file mode 100644 index 00000000000..9a8fad20def --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_natgateway.go @@ -0,0 +1,20 @@ +package subnets + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..ffb5772eb47 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_natgatewaysku.go b/resource-manager/network/2024-07-01/subnets/model_natgatewaysku.go new file mode 100644 index 00000000000..617e7c19ff3 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_natruleportmapping.go b/resource-manager/network/2024-07-01/subnets/model_natruleportmapping.go new file mode 100644 index 00000000000..1e546cf811d --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_networkinterface.go b/resource-manager/network/2024-07-01/subnets/model_networkinterface.go new file mode 100644 index 00000000000..06d849fad90 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_networkinterface.go @@ -0,0 +1,19 @@ +package subnets + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/subnets/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..67fcb29afe7 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/subnets/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..dea0691831d --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/subnets/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..51e7195920f --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..a1064b425b9 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..01f11f18960 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/subnets/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..2cd16be245c --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..1bc23cee100 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/subnets/model_networksecuritygroup.go new file mode 100644 index 00000000000..fa06f5f24cc --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..da7b074dbbf --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_privateendpoint.go b/resource-manager/network/2024-07-01/subnets/model_privateendpoint.go new file mode 100644 index 00000000000..4fa549c3b13 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_privateendpoint.go @@ -0,0 +1,19 @@ +package subnets + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/subnets/model_privateendpointconnection.go new file mode 100644 index 00000000000..1e354419cca --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/subnets/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..ff12b5a54fc --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/subnets/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..20625cb09d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/subnets/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..5d90f3c61bf --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/subnets/model_privateendpointproperties.go new file mode 100644 index 00000000000..4913ece3049 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_privatelinkservice.go b/resource-manager/network/2024-07-01/subnets/model_privatelinkservice.go new file mode 100644 index 00000000000..34c00e7cffb --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package subnets + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..af937a19eda --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..d6ad965c136 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..4072e649f7a --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..c48e1e87c65 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..eccb8844155 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..5c743a480ba --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_publicipaddress.go b/resource-manager/network/2024-07-01/subnets/model_publicipaddress.go new file mode 100644 index 00000000000..9931f78d236 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_publicipaddress.go @@ -0,0 +1,22 @@ +package subnets + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/subnets/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..d002238e788 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..c8c5eb4251a --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/subnets/model_publicipaddresssku.go new file mode 100644 index 00000000000..21dd8f7d664 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/subnets/model_resourcenavigationlink.go new file mode 100644 index 00000000000..fcd37a760e6 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/subnets/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..103426fc9c3 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_resourceset.go b/resource-manager/network/2024-07-01/subnets/model_resourceset.go new file mode 100644 index 00000000000..5daeebab425 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_resourceset.go @@ -0,0 +1,8 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/subnets/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..8ea922b85fe --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_route.go b/resource-manager/network/2024-07-01/subnets/model_route.go new file mode 100644 index 00000000000..e40ded16b00 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_route.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_routepropertiesformat.go new file mode 100644 index 00000000000..c87b62acaed --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_routetable.go b/resource-manager/network/2024-07-01/subnets/model_routetable.go new file mode 100644 index 00000000000..6bb137b8242 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_routetable.go @@ -0,0 +1,14 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..07d88ea8a30 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_securityrule.go b/resource-manager/network/2024-07-01/subnets/model_securityrule.go new file mode 100644 index 00000000000..70772203f7b --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_securityrule.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..cad2dbd820c --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/subnets/model_serviceassociationlink.go new file mode 100644 index 00000000000..c82eae5ac15 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..f1a92b71485 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..1680e52b8a1 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/subnets/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..68813a7b3e8 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/subnets/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..8fa72c305ed --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..b7b56f401a8 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..5e0804aa438 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..e3835d75d21 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_subnet.go b/resource-manager/network/2024-07-01/subnets/model_subnet.go new file mode 100644 index 00000000000..820673d7c16 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_subnet.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..cf58fc115a3 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_subresource.go b/resource-manager/network/2024-07-01/subnets/model_subresource.go new file mode 100644 index 00000000000..d986a303819 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_subresource.go @@ -0,0 +1,8 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/subnets/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..e93599e3f9c --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/subnets/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..fa6abc84aef --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/subnets/model_virtualnetworktap.go new file mode 100644 index 00000000000..f9e8be401f9 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/subnets/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..c8b60852b33 --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/subnets/predicates.go b/resource-manager/network/2024-07-01/subnets/predicates.go new file mode 100644 index 00000000000..33b8979e3cc --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/predicates.go @@ -0,0 +1,32 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p SubnetOperationPredicate) Matches(input Subnet) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/subnets/version.go b/resource-manager/network/2024-07-01/subnets/version.go new file mode 100644 index 00000000000..6c9a1d488ff --- /dev/null +++ b/resource-manager/network/2024-07-01/subnets/version.go @@ -0,0 +1,10 @@ +package subnets + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/subnets/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/trafficanalytics/README.md b/resource-manager/network/2024-07-01/trafficanalytics/README.md new file mode 100644 index 00000000000..570e48932a8 --- /dev/null +++ b/resource-manager/network/2024-07-01/trafficanalytics/README.md @@ -0,0 +1,54 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/trafficanalytics` Documentation + +The `trafficanalytics` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/trafficanalytics" +``` + + +### Client Initialization + +```go +client := trafficanalytics.NewTrafficAnalyticsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `TrafficAnalyticsClient.NetworkWatchersGetFlowLogStatus` + +```go +ctx := context.TODO() +id := trafficanalytics.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +payload := trafficanalytics.FlowLogStatusParameters{ + // ... +} + + +if err := client.NetworkWatchersGetFlowLogStatusThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `TrafficAnalyticsClient.NetworkWatchersSetFlowLogConfiguration` + +```go +ctx := context.TODO() +id := trafficanalytics.NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + +payload := trafficanalytics.FlowLogInformation{ + // ... +} + + +if err := client.NetworkWatchersSetFlowLogConfigurationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/network/2024-07-01/trafficanalytics/client.go b/resource-manager/network/2024-07-01/trafficanalytics/client.go new file mode 100644 index 00000000000..91c746485a3 --- /dev/null +++ b/resource-manager/network/2024-07-01/trafficanalytics/client.go @@ -0,0 +1,26 @@ +package trafficanalytics + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsClient struct { + Client *resourcemanager.Client +} + +func NewTrafficAnalyticsClientWithBaseURI(sdkApi sdkEnv.Api) (*TrafficAnalyticsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "trafficanalytics", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TrafficAnalyticsClient: %+v", err) + } + + return &TrafficAnalyticsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/trafficanalytics/constants.go b/resource-manager/network/2024-07-01/trafficanalytics/constants.go new file mode 100644 index 00000000000..54031e636e9 --- /dev/null +++ b/resource-manager/network/2024-07-01/trafficanalytics/constants.go @@ -0,0 +1,48 @@ +package trafficanalytics + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/trafficanalytics/id_networkwatcher.go b/resource-manager/network/2024-07-01/trafficanalytics/id_networkwatcher.go new file mode 100644 index 00000000000..331d6af7e17 --- /dev/null +++ b/resource-manager/network/2024-07-01/trafficanalytics/id_networkwatcher.go @@ -0,0 +1,130 @@ +package trafficanalytics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkWatcherId{}) +} + +var _ resourceids.ResourceId = &NetworkWatcherId{} + +// NetworkWatcherId is a struct representing the Resource ID for a Network Watcher +type NetworkWatcherId struct { + SubscriptionId string + ResourceGroupName string + NetworkWatcherName string +} + +// NewNetworkWatcherID returns a new NetworkWatcherId struct +func NewNetworkWatcherID(subscriptionId string, resourceGroupName string, networkWatcherName string) NetworkWatcherId { + return NetworkWatcherId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkWatcherName: networkWatcherName, + } +} + +// ParseNetworkWatcherID parses 'input' into a NetworkWatcherId +func ParseNetworkWatcherID(input string) (*NetworkWatcherId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkWatcherId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkWatcherId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkWatcherIDInsensitively parses 'input' case-insensitively into a NetworkWatcherId +// note: this method should only be used for API response data and not user input +func ParseNetworkWatcherIDInsensitively(input string) (*NetworkWatcherId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkWatcherId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkWatcherId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkWatcherId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkWatcherName, ok = input.Parsed["networkWatcherName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkWatcherName", input) + } + + return nil +} + +// ValidateNetworkWatcherID checks that 'input' can be parsed as a Network Watcher ID +func ValidateNetworkWatcherID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkWatcherID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Watcher ID +func (id NetworkWatcherId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkWatchers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkWatcherName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Watcher ID +func (id NetworkWatcherId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkWatchers", "networkWatchers", "networkWatchers"), + resourceids.UserSpecifiedSegment("networkWatcherName", "networkWatcherName"), + } +} + +// String returns a human-readable description of this Network Watcher ID +func (id NetworkWatcherId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Watcher Name: %q", id.NetworkWatcherName), + } + return fmt.Sprintf("Network Watcher (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/trafficanalytics/id_networkwatcher_test.go b/resource-manager/network/2024-07-01/trafficanalytics/id_networkwatcher_test.go new file mode 100644 index 00000000000..98e3fa2abac --- /dev/null +++ b/resource-manager/network/2024-07-01/trafficanalytics/id_networkwatcher_test.go @@ -0,0 +1,282 @@ +package trafficanalytics + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkWatcherId{} + +func TestNewNetworkWatcherID(t *testing.T) { + id := NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkWatcherName != "networkWatcherName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkWatcherName'", id.NetworkWatcherName, "networkWatcherName") + } +} + +func TestFormatNetworkWatcherID(t *testing.T) { + actual := NewNetworkWatcherID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkWatcherName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkWatcherID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkWatcherId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName", + Expected: &NetworkWatcherId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkWatcherName: "networkWatcherName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkWatcherID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkWatcherName != v.Expected.NetworkWatcherName { + t.Fatalf("Expected %q but got %q for NetworkWatcherName", v.Expected.NetworkWatcherName, actual.NetworkWatcherName) + } + + } +} + +func TestParseNetworkWatcherIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkWatcherId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName", + Expected: &NetworkWatcherId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkWatcherName: "networkWatcherName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkWatchers/networkWatcherName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE", + Expected: &NetworkWatcherId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkWatcherName: "nEtWoRkWaTcHeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkWaTcHeRs/nEtWoRkWaTcHeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkWatcherIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkWatcherName != v.Expected.NetworkWatcherName { + t.Fatalf("Expected %q but got %q for NetworkWatcherName", v.Expected.NetworkWatcherName, actual.NetworkWatcherName) + } + + } +} + +func TestSegmentsForNetworkWatcherId(t *testing.T) { + segments := NetworkWatcherId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkWatcherId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/trafficanalytics/method_networkwatchersgetflowlogstatus.go b/resource-manager/network/2024-07-01/trafficanalytics/method_networkwatchersgetflowlogstatus.go new file mode 100644 index 00000000000..279a26b8a48 --- /dev/null +++ b/resource-manager/network/2024-07-01/trafficanalytics/method_networkwatchersgetflowlogstatus.go @@ -0,0 +1,75 @@ +package trafficanalytics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkWatchersGetFlowLogStatusOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *FlowLogInformation +} + +// NetworkWatchersGetFlowLogStatus ... +func (c TrafficAnalyticsClient) NetworkWatchersGetFlowLogStatus(ctx context.Context, id NetworkWatcherId, input FlowLogStatusParameters) (result NetworkWatchersGetFlowLogStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/queryFlowLogStatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// NetworkWatchersGetFlowLogStatusThenPoll performs NetworkWatchersGetFlowLogStatus then polls until it's completed +func (c TrafficAnalyticsClient) NetworkWatchersGetFlowLogStatusThenPoll(ctx context.Context, id NetworkWatcherId, input FlowLogStatusParameters) error { + result, err := c.NetworkWatchersGetFlowLogStatus(ctx, id, input) + if err != nil { + return fmt.Errorf("performing NetworkWatchersGetFlowLogStatus: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after NetworkWatchersGetFlowLogStatus: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/trafficanalytics/method_networkwatcherssetflowlogconfiguration.go b/resource-manager/network/2024-07-01/trafficanalytics/method_networkwatcherssetflowlogconfiguration.go new file mode 100644 index 00000000000..859ca423b3c --- /dev/null +++ b/resource-manager/network/2024-07-01/trafficanalytics/method_networkwatcherssetflowlogconfiguration.go @@ -0,0 +1,75 @@ +package trafficanalytics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkWatchersSetFlowLogConfigurationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *FlowLogInformation +} + +// NetworkWatchersSetFlowLogConfiguration ... +func (c TrafficAnalyticsClient) NetworkWatchersSetFlowLogConfiguration(ctx context.Context, id NetworkWatcherId, input FlowLogInformation) (result NetworkWatchersSetFlowLogConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/configureFlowLog", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// NetworkWatchersSetFlowLogConfigurationThenPoll performs NetworkWatchersSetFlowLogConfiguration then polls until it's completed +func (c TrafficAnalyticsClient) NetworkWatchersSetFlowLogConfigurationThenPoll(ctx context.Context, id NetworkWatcherId, input FlowLogInformation) error { + result, err := c.NetworkWatchersSetFlowLogConfiguration(ctx, id, input) + if err != nil { + return fmt.Errorf("performing NetworkWatchersSetFlowLogConfiguration: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after NetworkWatchersSetFlowLogConfiguration: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/trafficanalytics/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/trafficanalytics/model_flowlogformatparameters.go new file mode 100644 index 00000000000..87ffe400a44 --- /dev/null +++ b/resource-manager/network/2024-07-01/trafficanalytics/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package trafficanalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/trafficanalytics/model_flowloginformation.go b/resource-manager/network/2024-07-01/trafficanalytics/model_flowloginformation.go new file mode 100644 index 00000000000..c4dc94d99f7 --- /dev/null +++ b/resource-manager/network/2024-07-01/trafficanalytics/model_flowloginformation.go @@ -0,0 +1,15 @@ +package trafficanalytics + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogInformation struct { + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Properties FlowLogProperties `json:"properties"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/trafficanalytics/model_flowlogproperties.go b/resource-manager/network/2024-07-01/trafficanalytics/model_flowlogproperties.go new file mode 100644 index 00000000000..cf3b43fdbeb --- /dev/null +++ b/resource-manager/network/2024-07-01/trafficanalytics/model_flowlogproperties.go @@ -0,0 +1,12 @@ +package trafficanalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogProperties struct { + Enabled bool `json:"enabled"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` +} diff --git a/resource-manager/network/2024-07-01/trafficanalytics/model_flowlogstatusparameters.go b/resource-manager/network/2024-07-01/trafficanalytics/model_flowlogstatusparameters.go new file mode 100644 index 00000000000..a066e2ad70a --- /dev/null +++ b/resource-manager/network/2024-07-01/trafficanalytics/model_flowlogstatusparameters.go @@ -0,0 +1,8 @@ +package trafficanalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogStatusParameters struct { + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/trafficanalytics/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/trafficanalytics/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..b432d3a27f0 --- /dev/null +++ b/resource-manager/network/2024-07-01/trafficanalytics/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package trafficanalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/trafficanalytics/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/trafficanalytics/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..01350bb98c2 --- /dev/null +++ b/resource-manager/network/2024-07-01/trafficanalytics/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package trafficanalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/trafficanalytics/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/trafficanalytics/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..94df925e175 --- /dev/null +++ b/resource-manager/network/2024-07-01/trafficanalytics/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package trafficanalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/trafficanalytics/version.go b/resource-manager/network/2024-07-01/trafficanalytics/version.go new file mode 100644 index 00000000000..1ee2ea9b6ce --- /dev/null +++ b/resource-manager/network/2024-07-01/trafficanalytics/version.go @@ -0,0 +1,10 @@ +package trafficanalytics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/trafficanalytics/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/usages/README.md b/resource-manager/network/2024-07-01/usages/README.md new file mode 100644 index 00000000000..309c9b9c636 --- /dev/null +++ b/resource-manager/network/2024-07-01/usages/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/usages` Documentation + +The `usages` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/usages" +``` + + +### Client Initialization + +```go +client := usages.NewUsagesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `UsagesClient.List` + +```go +ctx := context.TODO() +id := usages.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/usages/client.go b/resource-manager/network/2024-07-01/usages/client.go new file mode 100644 index 00000000000..5b6ce18413b --- /dev/null +++ b/resource-manager/network/2024-07-01/usages/client.go @@ -0,0 +1,26 @@ +package usages + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsagesClient struct { + Client *resourcemanager.Client +} + +func NewUsagesClientWithBaseURI(sdkApi sdkEnv.Api) (*UsagesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "usages", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating UsagesClient: %+v", err) + } + + return &UsagesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/usages/constants.go b/resource-manager/network/2024-07-01/usages/constants.go new file mode 100644 index 00000000000..0d8916ba5aa --- /dev/null +++ b/resource-manager/network/2024-07-01/usages/constants.go @@ -0,0 +1,48 @@ +package usages + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsageUnit string + +const ( + UsageUnitCount UsageUnit = "Count" +) + +func PossibleValuesForUsageUnit() []string { + return []string{ + string(UsageUnitCount), + } +} + +func (s *UsageUnit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageUnit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsageUnit(input string) (*UsageUnit, error) { + vals := map[string]UsageUnit{ + "count": UsageUnitCount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsageUnit(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/usages/id_location.go b/resource-manager/network/2024-07-01/usages/id_location.go new file mode 100644 index 00000000000..5f505126c1e --- /dev/null +++ b/resource-manager/network/2024-07-01/usages/id_location.go @@ -0,0 +1,121 @@ +package usages + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Network/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/usages/id_location_test.go b/resource-manager/network/2024-07-01/usages/id_location_test.go new file mode 100644 index 00000000000..8b2dce92bff --- /dev/null +++ b/resource-manager/network/2024-07-01/usages/id_location_test.go @@ -0,0 +1,237 @@ +package usages + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/usages/method_list.go b/resource-manager/network/2024-07-01/usages/method_list.go new file mode 100644 index 00000000000..76d13699e0c --- /dev/null +++ b/resource-manager/network/2024-07-01/usages/method_list.go @@ -0,0 +1,105 @@ +package usages + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Usage +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Usage +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c UsagesClient) List(ctx context.Context, id LocationId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Usage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c UsagesClient) ListComplete(ctx context.Context, id LocationId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, UsageOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c UsagesClient) ListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate UsageOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Usage, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/usages/model_usage.go b/resource-manager/network/2024-07-01/usages/model_usage.go new file mode 100644 index 00000000000..2a734980b2c --- /dev/null +++ b/resource-manager/network/2024-07-01/usages/model_usage.go @@ -0,0 +1,12 @@ +package usages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Usage struct { + CurrentValue int64 `json:"currentValue"` + Id *string `json:"id,omitempty"` + Limit int64 `json:"limit"` + Name UsageName `json:"name"` + Unit UsageUnit `json:"unit"` +} diff --git a/resource-manager/network/2024-07-01/usages/model_usagename.go b/resource-manager/network/2024-07-01/usages/model_usagename.go new file mode 100644 index 00000000000..ff2d9cbdd3e --- /dev/null +++ b/resource-manager/network/2024-07-01/usages/model_usagename.go @@ -0,0 +1,9 @@ +package usages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsageName struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/usages/predicates.go b/resource-manager/network/2024-07-01/usages/predicates.go new file mode 100644 index 00000000000..ad3b401c1ce --- /dev/null +++ b/resource-manager/network/2024-07-01/usages/predicates.go @@ -0,0 +1,27 @@ +package usages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsageOperationPredicate struct { + CurrentValue *int64 + Id *string + Limit *int64 +} + +func (p UsageOperationPredicate) Matches(input Usage) bool { + + if p.CurrentValue != nil && *p.CurrentValue != input.CurrentValue { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Limit != nil && *p.Limit != input.Limit { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/usages/version.go b/resource-manager/network/2024-07-01/usages/version.go new file mode 100644 index 00000000000..3a3873bb891 --- /dev/null +++ b/resource-manager/network/2024-07-01/usages/version.go @@ -0,0 +1,10 @@ +package usages + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/usages/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/README.md b/resource-manager/network/2024-07-01/verifierworkspaces/README.md new file mode 100644 index 00000000000..9b6273e6280 --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/README.md @@ -0,0 +1,107 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/verifierworkspaces` Documentation + +The `verifierworkspaces` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/verifierworkspaces" +``` + + +### Client Initialization + +```go +client := verifierworkspaces.NewVerifierWorkspacesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VerifierWorkspacesClient.Create` + +```go +ctx := context.TODO() +id := verifierworkspaces.NewVerifierWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName") + +payload := verifierworkspaces.VerifierWorkspace{ + // ... +} + + +read, err := client.Create(ctx, id, payload, verifierworkspaces.DefaultCreateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VerifierWorkspacesClient.Delete` + +```go +ctx := context.TODO() +id := verifierworkspaces.NewVerifierWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName") + +if err := client.DeleteThenPoll(ctx, id, verifierworkspaces.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `VerifierWorkspacesClient.Get` + +```go +ctx := context.TODO() +id := verifierworkspaces.NewVerifierWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VerifierWorkspacesClient.List` + +```go +ctx := context.TODO() +id := verifierworkspaces.NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + +// alternatively `client.List(ctx, id, verifierworkspaces.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, verifierworkspaces.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VerifierWorkspacesClient.Update` + +```go +ctx := context.TODO() +id := verifierworkspaces.NewVerifierWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName") + +payload := verifierworkspaces.VerifierWorkspaceUpdate{ + // ... +} + + +read, err := client.Update(ctx, id, payload, verifierworkspaces.DefaultUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/client.go b/resource-manager/network/2024-07-01/verifierworkspaces/client.go new file mode 100644 index 00000000000..606790efb19 --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/client.go @@ -0,0 +1,26 @@ +package verifierworkspaces + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VerifierWorkspacesClient struct { + Client *resourcemanager.Client +} + +func NewVerifierWorkspacesClientWithBaseURI(sdkApi sdkEnv.Api) (*VerifierWorkspacesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "verifierworkspaces", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VerifierWorkspacesClient: %+v", err) + } + + return &VerifierWorkspacesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/constants.go b/resource-manager/network/2024-07-01/verifierworkspaces/constants.go new file mode 100644 index 00000000000..32b714e22e2 --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/constants.go @@ -0,0 +1,63 @@ +package verifierworkspaces + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/id_networkmanager.go b/resource-manager/network/2024-07-01/verifierworkspaces/id_networkmanager.go new file mode 100644 index 00000000000..f332beceaf5 --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/id_networkmanager.go @@ -0,0 +1,130 @@ +package verifierworkspaces + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkManagerId{}) +} + +var _ resourceids.ResourceId = &NetworkManagerId{} + +// NetworkManagerId is a struct representing the Resource ID for a Network Manager +type NetworkManagerId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string +} + +// NewNetworkManagerID returns a new NetworkManagerId struct +func NewNetworkManagerID(subscriptionId string, resourceGroupName string, networkManagerName string) NetworkManagerId { + return NetworkManagerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + } +} + +// ParseNetworkManagerID parses 'input' into a NetworkManagerId +func ParseNetworkManagerID(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkManagerIDInsensitively parses 'input' case-insensitively into a NetworkManagerId +// note: this method should only be used for API response data and not user input +func ParseNetworkManagerIDInsensitively(input string) (*NetworkManagerId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkManagerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkManagerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkManagerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + return nil +} + +// ValidateNetworkManagerID checks that 'input' can be parsed as a Network Manager ID +func ValidateNetworkManagerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkManagerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Manager ID +func (id NetworkManagerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Manager ID +func (id NetworkManagerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + } +} + +// String returns a human-readable description of this Network Manager ID +func (id NetworkManagerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + } + return fmt.Sprintf("Network Manager (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/id_networkmanager_test.go b/resource-manager/network/2024-07-01/verifierworkspaces/id_networkmanager_test.go new file mode 100644 index 00000000000..23b9ed1df26 --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/id_networkmanager_test.go @@ -0,0 +1,282 @@ +package verifierworkspaces + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkManagerId{} + +func TestNewNetworkManagerID(t *testing.T) { + id := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } +} + +func TestFormatNetworkManagerID(t *testing.T) { + actual := NewNetworkManagerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkManagerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestParseNetworkManagerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkManagerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Expected: &NetworkManagerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkManagerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + } +} + +func TestSegmentsForNetworkManagerId(t *testing.T) { + segments := NetworkManagerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkManagerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/id_verifierworkspace.go b/resource-manager/network/2024-07-01/verifierworkspaces/id_verifierworkspace.go new file mode 100644 index 00000000000..68f27c306c6 --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/id_verifierworkspace.go @@ -0,0 +1,139 @@ +package verifierworkspaces + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VerifierWorkspaceId{}) +} + +var _ resourceids.ResourceId = &VerifierWorkspaceId{} + +// VerifierWorkspaceId is a struct representing the Resource ID for a Verifier Workspace +type VerifierWorkspaceId struct { + SubscriptionId string + ResourceGroupName string + NetworkManagerName string + VerifierWorkspaceName string +} + +// NewVerifierWorkspaceID returns a new VerifierWorkspaceId struct +func NewVerifierWorkspaceID(subscriptionId string, resourceGroupName string, networkManagerName string, verifierWorkspaceName string) VerifierWorkspaceId { + return VerifierWorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkManagerName: networkManagerName, + VerifierWorkspaceName: verifierWorkspaceName, + } +} + +// ParseVerifierWorkspaceID parses 'input' into a VerifierWorkspaceId +func ParseVerifierWorkspaceID(input string) (*VerifierWorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&VerifierWorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VerifierWorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVerifierWorkspaceIDInsensitively parses 'input' case-insensitively into a VerifierWorkspaceId +// note: this method should only be used for API response data and not user input +func ParseVerifierWorkspaceIDInsensitively(input string) (*VerifierWorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&VerifierWorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VerifierWorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VerifierWorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkManagerName, ok = input.Parsed["networkManagerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkManagerName", input) + } + + if id.VerifierWorkspaceName, ok = input.Parsed["verifierWorkspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "verifierWorkspaceName", input) + } + + return nil +} + +// ValidateVerifierWorkspaceID checks that 'input' can be parsed as a Verifier Workspace ID +func ValidateVerifierWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVerifierWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Verifier Workspace ID +func (id VerifierWorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkManagers/%s/verifierWorkspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkManagerName, id.VerifierWorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Verifier Workspace ID +func (id VerifierWorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkManagers", "networkManagers", "networkManagers"), + resourceids.UserSpecifiedSegment("networkManagerName", "networkManagerName"), + resourceids.StaticSegment("staticVerifierWorkspaces", "verifierWorkspaces", "verifierWorkspaces"), + resourceids.UserSpecifiedSegment("verifierWorkspaceName", "verifierWorkspaceName"), + } +} + +// String returns a human-readable description of this Verifier Workspace ID +func (id VerifierWorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Manager Name: %q", id.NetworkManagerName), + fmt.Sprintf("Verifier Workspace Name: %q", id.VerifierWorkspaceName), + } + return fmt.Sprintf("Verifier Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/id_verifierworkspace_test.go b/resource-manager/network/2024-07-01/verifierworkspaces/id_verifierworkspace_test.go new file mode 100644 index 00000000000..63837065d28 --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/id_verifierworkspace_test.go @@ -0,0 +1,327 @@ +package verifierworkspaces + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VerifierWorkspaceId{} + +func TestNewVerifierWorkspaceID(t *testing.T) { + id := NewVerifierWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkManagerName != "networkManagerName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkManagerName'", id.NetworkManagerName, "networkManagerName") + } + + if id.VerifierWorkspaceName != "verifierWorkspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'VerifierWorkspaceName'", id.VerifierWorkspaceName, "verifierWorkspaceName") + } +} + +func TestFormatVerifierWorkspaceID(t *testing.T) { + actual := NewVerifierWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkManagerName", "verifierWorkspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVerifierWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VerifierWorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName", + Expected: &VerifierWorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + VerifierWorkspaceName: "verifierWorkspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVerifierWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.VerifierWorkspaceName != v.Expected.VerifierWorkspaceName { + t.Fatalf("Expected %q but got %q for VerifierWorkspaceName", v.Expected.VerifierWorkspaceName, actual.VerifierWorkspaceName) + } + + } +} + +func TestParseVerifierWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VerifierWorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName", + Expected: &VerifierWorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkManagerName: "networkManagerName", + VerifierWorkspaceName: "verifierWorkspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkManagers/networkManagerName/verifierWorkspaces/verifierWorkspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe", + Expected: &VerifierWorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkManagerName: "nEtWoRkMaNaGeRnAmE", + VerifierWorkspaceName: "vErIfIeRwOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkMaNaGeRs/nEtWoRkMaNaGeRnAmE/vErIfIeRwOrKsPaCeS/vErIfIeRwOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVerifierWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkManagerName != v.Expected.NetworkManagerName { + t.Fatalf("Expected %q but got %q for NetworkManagerName", v.Expected.NetworkManagerName, actual.NetworkManagerName) + } + + if actual.VerifierWorkspaceName != v.Expected.VerifierWorkspaceName { + t.Fatalf("Expected %q but got %q for VerifierWorkspaceName", v.Expected.VerifierWorkspaceName, actual.VerifierWorkspaceName) + } + + } +} + +func TestSegmentsForVerifierWorkspaceId(t *testing.T) { + segments := VerifierWorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VerifierWorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/method_create.go b/resource-manager/network/2024-07-01/verifierworkspaces/method_create.go new file mode 100644 index 00000000000..41fe6588862 --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/method_create.go @@ -0,0 +1,88 @@ +package verifierworkspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VerifierWorkspace +} + +type CreateOperationOptions struct { + IfMatch *string +} + +func DefaultCreateOperationOptions() CreateOperationOptions { + return CreateOperationOptions{} +} + +func (o CreateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o CreateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CreateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Create ... +func (c VerifierWorkspacesClient) Create(ctx context.Context, id VerifierWorkspaceId, input VerifierWorkspace, options CreateOperationOptions) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VerifierWorkspace + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/method_delete.go b/resource-manager/network/2024-07-01/verifierworkspaces/method_delete.go new file mode 100644 index 00000000000..6e9093bd1a6 --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/method_delete.go @@ -0,0 +1,99 @@ +package verifierworkspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IfMatch *string +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Delete ... +func (c VerifierWorkspacesClient) Delete(ctx context.Context, id VerifierWorkspaceId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c VerifierWorkspacesClient) DeleteThenPoll(ctx context.Context, id VerifierWorkspaceId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/method_get.go b/resource-manager/network/2024-07-01/verifierworkspaces/method_get.go new file mode 100644 index 00000000000..a74d47a0e16 --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/method_get.go @@ -0,0 +1,53 @@ +package verifierworkspaces + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VerifierWorkspace +} + +// Get ... +func (c VerifierWorkspacesClient) Get(ctx context.Context, id VerifierWorkspaceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VerifierWorkspace + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/method_list.go b/resource-manager/network/2024-07-01/verifierworkspaces/method_list.go new file mode 100644 index 00000000000..2323ebf2877 --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/method_list.go @@ -0,0 +1,150 @@ +package verifierworkspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VerifierWorkspace +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VerifierWorkspace +} + +type ListOperationOptions struct { + Skip *int64 + SkipToken *string + SortKey *string + SortValue *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skip != nil { + out.Append("skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + if o.SortKey != nil { + out.Append("sortKey", fmt.Sprintf("%v", *o.SortKey)) + } + if o.SortValue != nil { + out.Append("sortValue", fmt.Sprintf("%v", *o.SortValue)) + } + if o.Top != nil { + out.Append("top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c VerifierWorkspacesClient) List(ctx context.Context, id NetworkManagerId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/verifierWorkspaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VerifierWorkspace `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c VerifierWorkspacesClient) ListComplete(ctx context.Context, id NetworkManagerId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, VerifierWorkspaceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VerifierWorkspacesClient) ListCompleteMatchingPredicate(ctx context.Context, id NetworkManagerId, options ListOperationOptions, predicate VerifierWorkspaceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]VerifierWorkspace, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/method_update.go b/resource-manager/network/2024-07-01/verifierworkspaces/method_update.go new file mode 100644 index 00000000000..c02982584e7 --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/method_update.go @@ -0,0 +1,87 @@ +package verifierworkspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VerifierWorkspace +} + +type UpdateOperationOptions struct { + IfMatch *string +} + +func DefaultUpdateOperationOptions() UpdateOperationOptions { + return UpdateOperationOptions{} +} + +func (o UpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + if o.IfMatch != nil { + out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch)) + } + return &out +} + +func (o UpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + + return &out +} + +// Update ... +func (c VerifierWorkspacesClient) Update(ctx context.Context, id VerifierWorkspaceId, input VerifierWorkspaceUpdate, options UpdateOperationOptions) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VerifierWorkspace + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/model_verifierworkspace.go b/resource-manager/network/2024-07-01/verifierworkspaces/model_verifierworkspace.go new file mode 100644 index 00000000000..80a4efaad2a --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/model_verifierworkspace.go @@ -0,0 +1,19 @@ +package verifierworkspaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VerifierWorkspace struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *VerifierWorkspaceProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/model_verifierworkspaceproperties.go b/resource-manager/network/2024-07-01/verifierworkspaces/model_verifierworkspaceproperties.go new file mode 100644 index 00000000000..0f9fb5c183b --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/model_verifierworkspaceproperties.go @@ -0,0 +1,9 @@ +package verifierworkspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VerifierWorkspaceProperties struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/model_verifierworkspaceupdate.go b/resource-manager/network/2024-07-01/verifierworkspaces/model_verifierworkspaceupdate.go new file mode 100644 index 00000000000..4372d75e12e --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/model_verifierworkspaceupdate.go @@ -0,0 +1,9 @@ +package verifierworkspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VerifierWorkspaceUpdate struct { + Properties *VerifierWorkspaceUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/model_verifierworkspaceupdateproperties.go b/resource-manager/network/2024-07-01/verifierworkspaces/model_verifierworkspaceupdateproperties.go new file mode 100644 index 00000000000..aae46cc7e85 --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/model_verifierworkspaceupdateproperties.go @@ -0,0 +1,8 @@ +package verifierworkspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VerifierWorkspaceUpdateProperties struct { + Description *string `json:"description,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/predicates.go b/resource-manager/network/2024-07-01/verifierworkspaces/predicates.go new file mode 100644 index 00000000000..da29e7e9103 --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/predicates.go @@ -0,0 +1,37 @@ +package verifierworkspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VerifierWorkspaceOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p VerifierWorkspaceOperationPredicate) Matches(input VerifierWorkspace) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/verifierworkspaces/version.go b/resource-manager/network/2024-07-01/verifierworkspaces/version.go new file mode 100644 index 00000000000..703d723cb8d --- /dev/null +++ b/resource-manager/network/2024-07-01/verifierworkspaces/version.go @@ -0,0 +1,10 @@ +package verifierworkspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/verifierworkspaces/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/vipswap/README.md b/resource-manager/network/2024-07-01/vipswap/README.md new file mode 100644 index 00000000000..c713fab563b --- /dev/null +++ b/resource-manager/network/2024-07-01/vipswap/README.md @@ -0,0 +1,69 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/vipswap` Documentation + +The `vipswap` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/vipswap" +``` + + +### Client Initialization + +```go +client := vipswap.NewVipSwapClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VipSwapClient.Create` + +```go +ctx := context.TODO() +id := vipswap.NewCloudServiceID("12345678-1234-9876-4563-123456789012", "resourceGroupName", "cloudServiceName") + +payload := vipswap.SwapResource{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VipSwapClient.Get` + +```go +ctx := context.TODO() +id := vipswap.NewCloudServiceID("12345678-1234-9876-4563-123456789012", "resourceGroupName", "cloudServiceName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VipSwapClient.List` + +```go +ctx := context.TODO() +id := vipswap.NewCloudServiceID("12345678-1234-9876-4563-123456789012", "resourceGroupName", "cloudServiceName") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/vipswap/client.go b/resource-manager/network/2024-07-01/vipswap/client.go new file mode 100644 index 00000000000..d573391540e --- /dev/null +++ b/resource-manager/network/2024-07-01/vipswap/client.go @@ -0,0 +1,26 @@ +package vipswap + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VipSwapClient struct { + Client *resourcemanager.Client +} + +func NewVipSwapClientWithBaseURI(sdkApi sdkEnv.Api) (*VipSwapClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "vipswap", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VipSwapClient: %+v", err) + } + + return &VipSwapClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/vipswap/constants.go b/resource-manager/network/2024-07-01/vipswap/constants.go new file mode 100644 index 00000000000..c6cf7234532 --- /dev/null +++ b/resource-manager/network/2024-07-01/vipswap/constants.go @@ -0,0 +1,51 @@ +package vipswap + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlotType string + +const ( + SlotTypeProduction SlotType = "Production" + SlotTypeStaging SlotType = "Staging" +) + +func PossibleValuesForSlotType() []string { + return []string{ + string(SlotTypeProduction), + string(SlotTypeStaging), + } +} + +func (s *SlotType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSlotType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSlotType(input string) (*SlotType, error) { + vals := map[string]SlotType{ + "production": SlotTypeProduction, + "staging": SlotTypeStaging, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SlotType(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/vipswap/id_cloudservice.go b/resource-manager/network/2024-07-01/vipswap/id_cloudservice.go new file mode 100644 index 00000000000..93c12d9c01d --- /dev/null +++ b/resource-manager/network/2024-07-01/vipswap/id_cloudservice.go @@ -0,0 +1,130 @@ +package vipswap + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CloudServiceId{}) +} + +var _ resourceids.ResourceId = &CloudServiceId{} + +// CloudServiceId is a struct representing the Resource ID for a Cloud Service +type CloudServiceId struct { + SubscriptionId string + ResourceGroupName string + CloudServiceName string +} + +// NewCloudServiceID returns a new CloudServiceId struct +func NewCloudServiceID(subscriptionId string, resourceGroupName string, cloudServiceName string) CloudServiceId { + return CloudServiceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CloudServiceName: cloudServiceName, + } +} + +// ParseCloudServiceID parses 'input' into a CloudServiceId +func ParseCloudServiceID(input string) (*CloudServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudServiceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCloudServiceIDInsensitively parses 'input' case-insensitively into a CloudServiceId +// note: this method should only be used for API response data and not user input +func ParseCloudServiceIDInsensitively(input string) (*CloudServiceId, error) { + parser := resourceids.NewParserFromResourceIdType(&CloudServiceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CloudServiceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CloudServiceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CloudServiceName, ok = input.Parsed["cloudServiceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "cloudServiceName", input) + } + + return nil +} + +// ValidateCloudServiceID checks that 'input' can be parsed as a Cloud Service ID +func ValidateCloudServiceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCloudServiceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Cloud Service ID +func (id CloudServiceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/cloudServices/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CloudServiceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Cloud Service ID +func (id CloudServiceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.UserSpecifiedSegment("resourceGroupName", "resourceGroupName"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCompute", "Microsoft.Compute", "Microsoft.Compute"), + resourceids.StaticSegment("staticCloudServices", "cloudServices", "cloudServices"), + resourceids.UserSpecifiedSegment("cloudServiceName", "cloudServiceName"), + } +} + +// String returns a human-readable description of this Cloud Service ID +func (id CloudServiceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Cloud Service Name: %q", id.CloudServiceName), + } + return fmt.Sprintf("Cloud Service (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/vipswap/id_cloudservice_test.go b/resource-manager/network/2024-07-01/vipswap/id_cloudservice_test.go new file mode 100644 index 00000000000..4bc26e07dc5 --- /dev/null +++ b/resource-manager/network/2024-07-01/vipswap/id_cloudservice_test.go @@ -0,0 +1,282 @@ +package vipswap + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CloudServiceId{} + +func TestNewCloudServiceID(t *testing.T) { + id := NewCloudServiceID("12345678-1234-9876-4563-123456789012", "resourceGroupName", "cloudServiceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "resourceGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "resourceGroupName") + } + + if id.CloudServiceName != "cloudServiceName" { + t.Fatalf("Expected %q but got %q for Segment 'CloudServiceName'", id.CloudServiceName, "cloudServiceName") + } +} + +func TestFormatCloudServiceID(t *testing.T) { + actual := NewCloudServiceID("12345678-1234-9876-4563-123456789012", "resourceGroupName", "cloudServiceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Compute/cloudServices/cloudServiceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCloudServiceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Compute/cloudServices", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Compute/cloudServices/cloudServiceName", + Expected: &CloudServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "resourceGroupName", + CloudServiceName: "cloudServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Compute/cloudServices/cloudServiceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudServiceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudServiceName != v.Expected.CloudServiceName { + t.Fatalf("Expected %q but got %q for CloudServiceName", v.Expected.CloudServiceName, actual.CloudServiceName) + } + + } +} + +func TestParseCloudServiceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CloudServiceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.cOmPuTe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Compute/cloudServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Compute/cloudServices/cloudServiceName", + Expected: &CloudServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "resourceGroupName", + CloudServiceName: "cloudServiceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resourceGroupName/providers/Microsoft.Compute/cloudServices/cloudServiceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs/cLoUdSeRvIcEnAmE", + Expected: &CloudServiceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "rEsOuRcEgRoUpNaMe", + CloudServiceName: "cLoUdSeRvIcEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/rEsOuRcEgRoUpNaMe/pRoViDeRs/mIcRoSoFt.cOmPuTe/cLoUdSeRvIcEs/cLoUdSeRvIcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCloudServiceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CloudServiceName != v.Expected.CloudServiceName { + t.Fatalf("Expected %q but got %q for CloudServiceName", v.Expected.CloudServiceName, actual.CloudServiceName) + } + + } +} + +func TestSegmentsForCloudServiceId(t *testing.T) { + segments := CloudServiceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CloudServiceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/vipswap/method_create.go b/resource-manager/network/2024-07-01/vipswap/method_create.go new file mode 100644 index 00000000000..c7db22cb3af --- /dev/null +++ b/resource-manager/network/2024-07-01/vipswap/method_create.go @@ -0,0 +1,74 @@ +package vipswap + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Create ... +func (c VipSwapClient) Create(ctx context.Context, id CloudServiceId, input SwapResource) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/cloudServiceSlots/swap", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c VipSwapClient) CreateThenPoll(ctx context.Context, id CloudServiceId, input SwapResource) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/vipswap/method_get.go b/resource-manager/network/2024-07-01/vipswap/method_get.go new file mode 100644 index 00000000000..598d2371676 --- /dev/null +++ b/resource-manager/network/2024-07-01/vipswap/method_get.go @@ -0,0 +1,54 @@ +package vipswap + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwapResource +} + +// Get ... +func (c VipSwapClient) Get(ctx context.Context, id CloudServiceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/cloudServiceSlots/swap", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SwapResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/vipswap/method_list.go b/resource-manager/network/2024-07-01/vipswap/method_list.go new file mode 100644 index 00000000000..35cd678f8c4 --- /dev/null +++ b/resource-manager/network/2024-07-01/vipswap/method_list.go @@ -0,0 +1,54 @@ +package vipswap + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwapResourceListResult +} + +// List ... +func (c VipSwapClient) List(ctx context.Context, id CloudServiceId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/cloudServiceSlots", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SwapResourceListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/vipswap/model_swapresource.go b/resource-manager/network/2024-07-01/vipswap/model_swapresource.go new file mode 100644 index 00000000000..cd135639ade --- /dev/null +++ b/resource-manager/network/2024-07-01/vipswap/model_swapresource.go @@ -0,0 +1,11 @@ +package vipswap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwapResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SwapResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vipswap/model_swapresourcelistresult.go b/resource-manager/network/2024-07-01/vipswap/model_swapresourcelistresult.go new file mode 100644 index 00000000000..d4cb9490d3a --- /dev/null +++ b/resource-manager/network/2024-07-01/vipswap/model_swapresourcelistresult.go @@ -0,0 +1,8 @@ +package vipswap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwapResourceListResult struct { + Value *[]SwapResource `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vipswap/model_swapresourceproperties.go b/resource-manager/network/2024-07-01/vipswap/model_swapresourceproperties.go new file mode 100644 index 00000000000..8254763b326 --- /dev/null +++ b/resource-manager/network/2024-07-01/vipswap/model_swapresourceproperties.go @@ -0,0 +1,8 @@ +package vipswap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwapResourceProperties struct { + SlotType *SlotType `json:"slotType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vipswap/version.go b/resource-manager/network/2024-07-01/vipswap/version.go new file mode 100644 index 00000000000..446d4d0e65a --- /dev/null +++ b/resource-manager/network/2024-07-01/vipswap/version.go @@ -0,0 +1,10 @@ +package vipswap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/vipswap/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/virtualappliancesites/README.md b/resource-manager/network/2024-07-01/virtualappliancesites/README.md new file mode 100644 index 00000000000..319f6392dbd --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualappliancesites/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualappliancesites` Documentation + +The `virtualappliancesites` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualappliancesites" +``` + + +### Client Initialization + +```go +client := virtualappliancesites.NewVirtualApplianceSitesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VirtualApplianceSitesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualappliancesites.NewVirtualApplianceSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName", "virtualApplianceSiteName") + +payload := virtualappliancesites.VirtualApplianceSite{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualApplianceSitesClient.Delete` + +```go +ctx := context.TODO() +id := virtualappliancesites.NewVirtualApplianceSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName", "virtualApplianceSiteName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualApplianceSitesClient.Get` + +```go +ctx := context.TODO() +id := virtualappliancesites.NewVirtualApplianceSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName", "virtualApplianceSiteName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualApplianceSitesClient.List` + +```go +ctx := context.TODO() +id := virtualappliancesites.NewNetworkVirtualApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/virtualappliancesites/client.go b/resource-manager/network/2024-07-01/virtualappliancesites/client.go new file mode 100644 index 00000000000..e99ff0ccd1b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualappliancesites/client.go @@ -0,0 +1,26 @@ +package virtualappliancesites + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplianceSitesClient struct { + Client *resourcemanager.Client +} + +func NewVirtualApplianceSitesClientWithBaseURI(sdkApi sdkEnv.Api) (*VirtualApplianceSitesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "virtualappliancesites", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VirtualApplianceSitesClient: %+v", err) + } + + return &VirtualApplianceSitesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/virtualappliancesites/constants.go b/resource-manager/network/2024-07-01/virtualappliancesites/constants.go new file mode 100644 index 00000000000..bd413f43290 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualappliancesites/constants.go @@ -0,0 +1,57 @@ +package virtualappliancesites + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/virtualappliancesites/id_networkvirtualappliance.go b/resource-manager/network/2024-07-01/virtualappliancesites/id_networkvirtualappliance.go new file mode 100644 index 00000000000..acb6a0d7413 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualappliancesites/id_networkvirtualappliance.go @@ -0,0 +1,130 @@ +package virtualappliancesites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkVirtualApplianceId{}) +} + +var _ resourceids.ResourceId = &NetworkVirtualApplianceId{} + +// NetworkVirtualApplianceId is a struct representing the Resource ID for a Network Virtual Appliance +type NetworkVirtualApplianceId struct { + SubscriptionId string + ResourceGroupName string + NetworkVirtualApplianceName string +} + +// NewNetworkVirtualApplianceID returns a new NetworkVirtualApplianceId struct +func NewNetworkVirtualApplianceID(subscriptionId string, resourceGroupName string, networkVirtualApplianceName string) NetworkVirtualApplianceId { + return NetworkVirtualApplianceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkVirtualApplianceName: networkVirtualApplianceName, + } +} + +// ParseNetworkVirtualApplianceID parses 'input' into a NetworkVirtualApplianceId +func ParseNetworkVirtualApplianceID(input string) (*NetworkVirtualApplianceId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkVirtualApplianceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkVirtualApplianceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkVirtualApplianceIDInsensitively parses 'input' case-insensitively into a NetworkVirtualApplianceId +// note: this method should only be used for API response data and not user input +func ParseNetworkVirtualApplianceIDInsensitively(input string) (*NetworkVirtualApplianceId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkVirtualApplianceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkVirtualApplianceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkVirtualApplianceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkVirtualApplianceName, ok = input.Parsed["networkVirtualApplianceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkVirtualApplianceName", input) + } + + return nil +} + +// ValidateNetworkVirtualApplianceID checks that 'input' can be parsed as a Network Virtual Appliance ID +func ValidateNetworkVirtualApplianceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkVirtualApplianceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Virtual Appliance ID +func (id NetworkVirtualApplianceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkVirtualAppliances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkVirtualApplianceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Virtual Appliance ID +func (id NetworkVirtualApplianceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkVirtualAppliances", "networkVirtualAppliances", "networkVirtualAppliances"), + resourceids.UserSpecifiedSegment("networkVirtualApplianceName", "networkVirtualApplianceName"), + } +} + +// String returns a human-readable description of this Network Virtual Appliance ID +func (id NetworkVirtualApplianceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Virtual Appliance Name: %q", id.NetworkVirtualApplianceName), + } + return fmt.Sprintf("Network Virtual Appliance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualappliancesites/id_networkvirtualappliance_test.go b/resource-manager/network/2024-07-01/virtualappliancesites/id_networkvirtualappliance_test.go new file mode 100644 index 00000000000..4a0e9bb93bd --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualappliancesites/id_networkvirtualappliance_test.go @@ -0,0 +1,282 @@ +package virtualappliancesites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkVirtualApplianceId{} + +func TestNewNetworkVirtualApplianceID(t *testing.T) { + id := NewNetworkVirtualApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkVirtualApplianceName != "networkVirtualApplianceName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkVirtualApplianceName'", id.NetworkVirtualApplianceName, "networkVirtualApplianceName") + } +} + +func TestFormatNetworkVirtualApplianceID(t *testing.T) { + actual := NewNetworkVirtualApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkVirtualApplianceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkVirtualApplianceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName", + Expected: &NetworkVirtualApplianceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkVirtualApplianceName: "networkVirtualApplianceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkVirtualApplianceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkVirtualApplianceName != v.Expected.NetworkVirtualApplianceName { + t.Fatalf("Expected %q but got %q for NetworkVirtualApplianceName", v.Expected.NetworkVirtualApplianceName, actual.NetworkVirtualApplianceName) + } + + } +} + +func TestParseNetworkVirtualApplianceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkVirtualApplianceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName", + Expected: &NetworkVirtualApplianceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkVirtualApplianceName: "networkVirtualApplianceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe", + Expected: &NetworkVirtualApplianceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkVirtualApplianceName: "nEtWoRkViRtUaLaPpLiAnCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkVirtualApplianceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkVirtualApplianceName != v.Expected.NetworkVirtualApplianceName { + t.Fatalf("Expected %q but got %q for NetworkVirtualApplianceName", v.Expected.NetworkVirtualApplianceName, actual.NetworkVirtualApplianceName) + } + + } +} + +func TestSegmentsForNetworkVirtualApplianceId(t *testing.T) { + segments := NetworkVirtualApplianceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkVirtualApplianceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualappliancesites/id_virtualappliancesite.go b/resource-manager/network/2024-07-01/virtualappliancesites/id_virtualappliancesite.go new file mode 100644 index 00000000000..592f4f47427 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualappliancesites/id_virtualappliancesite.go @@ -0,0 +1,139 @@ +package virtualappliancesites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualApplianceSiteId{}) +} + +var _ resourceids.ResourceId = &VirtualApplianceSiteId{} + +// VirtualApplianceSiteId is a struct representing the Resource ID for a Virtual Appliance Site +type VirtualApplianceSiteId struct { + SubscriptionId string + ResourceGroupName string + NetworkVirtualApplianceName string + VirtualApplianceSiteName string +} + +// NewVirtualApplianceSiteID returns a new VirtualApplianceSiteId struct +func NewVirtualApplianceSiteID(subscriptionId string, resourceGroupName string, networkVirtualApplianceName string, virtualApplianceSiteName string) VirtualApplianceSiteId { + return VirtualApplianceSiteId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkVirtualApplianceName: networkVirtualApplianceName, + VirtualApplianceSiteName: virtualApplianceSiteName, + } +} + +// ParseVirtualApplianceSiteID parses 'input' into a VirtualApplianceSiteId +func ParseVirtualApplianceSiteID(input string) (*VirtualApplianceSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualApplianceSiteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualApplianceSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualApplianceSiteIDInsensitively parses 'input' case-insensitively into a VirtualApplianceSiteId +// note: this method should only be used for API response data and not user input +func ParseVirtualApplianceSiteIDInsensitively(input string) (*VirtualApplianceSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualApplianceSiteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualApplianceSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualApplianceSiteId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkVirtualApplianceName, ok = input.Parsed["networkVirtualApplianceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkVirtualApplianceName", input) + } + + if id.VirtualApplianceSiteName, ok = input.Parsed["virtualApplianceSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualApplianceSiteName", input) + } + + return nil +} + +// ValidateVirtualApplianceSiteID checks that 'input' can be parsed as a Virtual Appliance Site ID +func ValidateVirtualApplianceSiteID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVirtualApplianceSiteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Appliance Site ID +func (id VirtualApplianceSiteId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkVirtualAppliances/%s/virtualApplianceSites/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkVirtualApplianceName, id.VirtualApplianceSiteName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Appliance Site ID +func (id VirtualApplianceSiteId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkVirtualAppliances", "networkVirtualAppliances", "networkVirtualAppliances"), + resourceids.UserSpecifiedSegment("networkVirtualApplianceName", "networkVirtualApplianceName"), + resourceids.StaticSegment("staticVirtualApplianceSites", "virtualApplianceSites", "virtualApplianceSites"), + resourceids.UserSpecifiedSegment("virtualApplianceSiteName", "virtualApplianceSiteName"), + } +} + +// String returns a human-readable description of this Virtual Appliance Site ID +func (id VirtualApplianceSiteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Virtual Appliance Name: %q", id.NetworkVirtualApplianceName), + fmt.Sprintf("Virtual Appliance Site Name: %q", id.VirtualApplianceSiteName), + } + return fmt.Sprintf("Virtual Appliance Site (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualappliancesites/id_virtualappliancesite_test.go b/resource-manager/network/2024-07-01/virtualappliancesites/id_virtualappliancesite_test.go new file mode 100644 index 00000000000..672639aa072 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualappliancesites/id_virtualappliancesite_test.go @@ -0,0 +1,327 @@ +package virtualappliancesites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualApplianceSiteId{} + +func TestNewVirtualApplianceSiteID(t *testing.T) { + id := NewVirtualApplianceSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName", "virtualApplianceSiteName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkVirtualApplianceName != "networkVirtualApplianceName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkVirtualApplianceName'", id.NetworkVirtualApplianceName, "networkVirtualApplianceName") + } + + if id.VirtualApplianceSiteName != "virtualApplianceSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualApplianceSiteName'", id.VirtualApplianceSiteName, "virtualApplianceSiteName") + } +} + +func TestFormatVirtualApplianceSiteID(t *testing.T) { + actual := NewVirtualApplianceSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName", "virtualApplianceSiteName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/virtualApplianceSites/virtualApplianceSiteName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualApplianceSiteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualApplianceSiteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/virtualApplianceSites", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/virtualApplianceSites/virtualApplianceSiteName", + Expected: &VirtualApplianceSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkVirtualApplianceName: "networkVirtualApplianceName", + VirtualApplianceSiteName: "virtualApplianceSiteName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/virtualApplianceSites/virtualApplianceSiteName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualApplianceSiteID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkVirtualApplianceName != v.Expected.NetworkVirtualApplianceName { + t.Fatalf("Expected %q but got %q for NetworkVirtualApplianceName", v.Expected.NetworkVirtualApplianceName, actual.NetworkVirtualApplianceName) + } + + if actual.VirtualApplianceSiteName != v.Expected.VirtualApplianceSiteName { + t.Fatalf("Expected %q but got %q for VirtualApplianceSiteName", v.Expected.VirtualApplianceSiteName, actual.VirtualApplianceSiteName) + } + + } +} + +func TestParseVirtualApplianceSiteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualApplianceSiteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/virtualApplianceSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe/vIrTuAlApPlIaNcEsItEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/virtualApplianceSites/virtualApplianceSiteName", + Expected: &VirtualApplianceSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkVirtualApplianceName: "networkVirtualApplianceName", + VirtualApplianceSiteName: "virtualApplianceSiteName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/virtualApplianceSites/virtualApplianceSiteName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe/vIrTuAlApPlIaNcEsItEs/vIrTuAlApPlIaNcEsItEnAmE", + Expected: &VirtualApplianceSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkVirtualApplianceName: "nEtWoRkViRtUaLaPpLiAnCeNaMe", + VirtualApplianceSiteName: "vIrTuAlApPlIaNcEsItEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe/vIrTuAlApPlIaNcEsItEs/vIrTuAlApPlIaNcEsItEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualApplianceSiteIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkVirtualApplianceName != v.Expected.NetworkVirtualApplianceName { + t.Fatalf("Expected %q but got %q for NetworkVirtualApplianceName", v.Expected.NetworkVirtualApplianceName, actual.NetworkVirtualApplianceName) + } + + if actual.VirtualApplianceSiteName != v.Expected.VirtualApplianceSiteName { + t.Fatalf("Expected %q but got %q for VirtualApplianceSiteName", v.Expected.VirtualApplianceSiteName, actual.VirtualApplianceSiteName) + } + + } +} + +func TestSegmentsForVirtualApplianceSiteId(t *testing.T) { + segments := VirtualApplianceSiteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualApplianceSiteId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualappliancesites/method_createorupdate.go b/resource-manager/network/2024-07-01/virtualappliancesites/method_createorupdate.go new file mode 100644 index 00000000000..2022580c6d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualappliancesites/method_createorupdate.go @@ -0,0 +1,75 @@ +package virtualappliancesites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualApplianceSite +} + +// CreateOrUpdate ... +func (c VirtualApplianceSitesClient) CreateOrUpdate(ctx context.Context, id VirtualApplianceSiteId, input VirtualApplianceSite) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c VirtualApplianceSitesClient) CreateOrUpdateThenPoll(ctx context.Context, id VirtualApplianceSiteId, input VirtualApplianceSite) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualappliancesites/method_delete.go b/resource-manager/network/2024-07-01/virtualappliancesites/method_delete.go new file mode 100644 index 00000000000..50e7f186f39 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualappliancesites/method_delete.go @@ -0,0 +1,71 @@ +package virtualappliancesites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c VirtualApplianceSitesClient) Delete(ctx context.Context, id VirtualApplianceSiteId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c VirtualApplianceSitesClient) DeleteThenPoll(ctx context.Context, id VirtualApplianceSiteId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualappliancesites/method_get.go b/resource-manager/network/2024-07-01/virtualappliancesites/method_get.go new file mode 100644 index 00000000000..820f76d71d2 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualappliancesites/method_get.go @@ -0,0 +1,53 @@ +package virtualappliancesites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualApplianceSite +} + +// Get ... +func (c VirtualApplianceSitesClient) Get(ctx context.Context, id VirtualApplianceSiteId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualApplianceSite + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualappliancesites/method_list.go b/resource-manager/network/2024-07-01/virtualappliancesites/method_list.go new file mode 100644 index 00000000000..ed83c3497ea --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualappliancesites/method_list.go @@ -0,0 +1,105 @@ +package virtualappliancesites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualApplianceSite +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualApplianceSite +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c VirtualApplianceSitesClient) List(ctx context.Context, id NetworkVirtualApplianceId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/virtualApplianceSites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualApplianceSite `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c VirtualApplianceSitesClient) ListComplete(ctx context.Context, id NetworkVirtualApplianceId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, VirtualApplianceSiteOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualApplianceSitesClient) ListCompleteMatchingPredicate(ctx context.Context, id NetworkVirtualApplianceId, predicate VirtualApplianceSiteOperationPredicate) (result ListCompleteResult, err error) { + items := make([]VirtualApplianceSite, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualappliancesites/model_breakoutcategorypolicies.go b/resource-manager/network/2024-07-01/virtualappliancesites/model_breakoutcategorypolicies.go new file mode 100644 index 00000000000..6a2b15ecb1d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualappliancesites/model_breakoutcategorypolicies.go @@ -0,0 +1,10 @@ +package virtualappliancesites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BreakOutCategoryPolicies struct { + Allow *bool `json:"allow,omitempty"` + Default *bool `json:"default,omitempty"` + Optimize *bool `json:"optimize,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualappliancesites/model_office365policyproperties.go b/resource-manager/network/2024-07-01/virtualappliancesites/model_office365policyproperties.go new file mode 100644 index 00000000000..b891141a5ba --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualappliancesites/model_office365policyproperties.go @@ -0,0 +1,8 @@ +package virtualappliancesites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Office365PolicyProperties struct { + BreakOutCategories *BreakOutCategoryPolicies `json:"breakOutCategories,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualappliancesites/model_virtualappliancesite.go b/resource-manager/network/2024-07-01/virtualappliancesites/model_virtualappliancesite.go new file mode 100644 index 00000000000..1b84d25c56d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualappliancesites/model_virtualappliancesite.go @@ -0,0 +1,12 @@ +package virtualappliancesites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplianceSite struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualApplianceSiteProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualappliancesites/model_virtualappliancesiteproperties.go b/resource-manager/network/2024-07-01/virtualappliancesites/model_virtualappliancesiteproperties.go new file mode 100644 index 00000000000..5d01b6ab8f8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualappliancesites/model_virtualappliancesiteproperties.go @@ -0,0 +1,10 @@ +package virtualappliancesites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplianceSiteProperties struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + O365Policy *Office365PolicyProperties `json:"o365Policy,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualappliancesites/predicates.go b/resource-manager/network/2024-07-01/virtualappliancesites/predicates.go new file mode 100644 index 00000000000..af31f940d24 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualappliancesites/predicates.go @@ -0,0 +1,32 @@ +package virtualappliancesites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplianceSiteOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p VirtualApplianceSiteOperationPredicate) Matches(input VirtualApplianceSite) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/virtualappliancesites/version.go b/resource-manager/network/2024-07-01/virtualappliancesites/version.go new file mode 100644 index 00000000000..100e67ed753 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualappliancesites/version.go @@ -0,0 +1,10 @@ +package virtualappliancesites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/virtualappliancesites/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/virtualapplianceskus/README.md b/resource-manager/network/2024-07-01/virtualapplianceskus/README.md new file mode 100644 index 00000000000..96c55d62fec --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualapplianceskus/README.md @@ -0,0 +1,54 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualapplianceskus` Documentation + +The `virtualapplianceskus` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualapplianceskus" +``` + + +### Client Initialization + +```go +client := virtualapplianceskus.NewVirtualApplianceSkusClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VirtualApplianceSkusClient.Get` + +```go +ctx := context.TODO() +id := virtualapplianceskus.NewNetworkVirtualApplianceSkuID("12345678-1234-9876-4563-123456789012", "networkVirtualApplianceSkuName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualApplianceSkusClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/virtualapplianceskus/client.go b/resource-manager/network/2024-07-01/virtualapplianceskus/client.go new file mode 100644 index 00000000000..90d73eb6104 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualapplianceskus/client.go @@ -0,0 +1,26 @@ +package virtualapplianceskus + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplianceSkusClient struct { + Client *resourcemanager.Client +} + +func NewVirtualApplianceSkusClientWithBaseURI(sdkApi sdkEnv.Api) (*VirtualApplianceSkusClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "virtualapplianceskus", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VirtualApplianceSkusClient: %+v", err) + } + + return &VirtualApplianceSkusClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/virtualapplianceskus/id_networkvirtualappliancesku.go b/resource-manager/network/2024-07-01/virtualapplianceskus/id_networkvirtualappliancesku.go new file mode 100644 index 00000000000..5eb920193a9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualapplianceskus/id_networkvirtualappliancesku.go @@ -0,0 +1,121 @@ +package virtualapplianceskus + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkVirtualApplianceSkuId{}) +} + +var _ resourceids.ResourceId = &NetworkVirtualApplianceSkuId{} + +// NetworkVirtualApplianceSkuId is a struct representing the Resource ID for a Network Virtual Appliance Sku +type NetworkVirtualApplianceSkuId struct { + SubscriptionId string + NetworkVirtualApplianceSkuName string +} + +// NewNetworkVirtualApplianceSkuID returns a new NetworkVirtualApplianceSkuId struct +func NewNetworkVirtualApplianceSkuID(subscriptionId string, networkVirtualApplianceSkuName string) NetworkVirtualApplianceSkuId { + return NetworkVirtualApplianceSkuId{ + SubscriptionId: subscriptionId, + NetworkVirtualApplianceSkuName: networkVirtualApplianceSkuName, + } +} + +// ParseNetworkVirtualApplianceSkuID parses 'input' into a NetworkVirtualApplianceSkuId +func ParseNetworkVirtualApplianceSkuID(input string) (*NetworkVirtualApplianceSkuId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkVirtualApplianceSkuId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkVirtualApplianceSkuId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkVirtualApplianceSkuIDInsensitively parses 'input' case-insensitively into a NetworkVirtualApplianceSkuId +// note: this method should only be used for API response data and not user input +func ParseNetworkVirtualApplianceSkuIDInsensitively(input string) (*NetworkVirtualApplianceSkuId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkVirtualApplianceSkuId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkVirtualApplianceSkuId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkVirtualApplianceSkuId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.NetworkVirtualApplianceSkuName, ok = input.Parsed["networkVirtualApplianceSkuName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkVirtualApplianceSkuName", input) + } + + return nil +} + +// ValidateNetworkVirtualApplianceSkuID checks that 'input' can be parsed as a Network Virtual Appliance Sku ID +func ValidateNetworkVirtualApplianceSkuID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkVirtualApplianceSkuID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Virtual Appliance Sku ID +func (id NetworkVirtualApplianceSkuId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Network/networkVirtualApplianceSkus/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.NetworkVirtualApplianceSkuName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Virtual Appliance Sku ID +func (id NetworkVirtualApplianceSkuId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkVirtualApplianceSkus", "networkVirtualApplianceSkus", "networkVirtualApplianceSkus"), + resourceids.UserSpecifiedSegment("networkVirtualApplianceSkuName", "networkVirtualApplianceSkuName"), + } +} + +// String returns a human-readable description of this Network Virtual Appliance Sku ID +func (id NetworkVirtualApplianceSkuId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Network Virtual Appliance Sku Name: %q", id.NetworkVirtualApplianceSkuName), + } + return fmt.Sprintf("Network Virtual Appliance Sku (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualapplianceskus/id_networkvirtualappliancesku_test.go b/resource-manager/network/2024-07-01/virtualapplianceskus/id_networkvirtualappliancesku_test.go new file mode 100644 index 00000000000..7ca3e924a1e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualapplianceskus/id_networkvirtualappliancesku_test.go @@ -0,0 +1,237 @@ +package virtualapplianceskus + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkVirtualApplianceSkuId{} + +func TestNewNetworkVirtualApplianceSkuID(t *testing.T) { + id := NewNetworkVirtualApplianceSkuID("12345678-1234-9876-4563-123456789012", "networkVirtualApplianceSkuName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.NetworkVirtualApplianceSkuName != "networkVirtualApplianceSkuName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkVirtualApplianceSkuName'", id.NetworkVirtualApplianceSkuName, "networkVirtualApplianceSkuName") + } +} + +func TestFormatNetworkVirtualApplianceSkuID(t *testing.T) { + actual := NewNetworkVirtualApplianceSkuID("12345678-1234-9876-4563-123456789012", "networkVirtualApplianceSkuName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/networkVirtualApplianceSkus/networkVirtualApplianceSkuName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkVirtualApplianceSkuID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkVirtualApplianceSkuId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/networkVirtualApplianceSkus", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/networkVirtualApplianceSkus/networkVirtualApplianceSkuName", + Expected: &NetworkVirtualApplianceSkuId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + NetworkVirtualApplianceSkuName: "networkVirtualApplianceSkuName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/networkVirtualApplianceSkus/networkVirtualApplianceSkuName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkVirtualApplianceSkuID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.NetworkVirtualApplianceSkuName != v.Expected.NetworkVirtualApplianceSkuName { + t.Fatalf("Expected %q but got %q for NetworkVirtualApplianceSkuName", v.Expected.NetworkVirtualApplianceSkuName, actual.NetworkVirtualApplianceSkuName) + } + + } +} + +func TestParseNetworkVirtualApplianceSkuIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkVirtualApplianceSkuId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/networkVirtualApplianceSkus", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeSkUs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/networkVirtualApplianceSkus/networkVirtualApplianceSkuName", + Expected: &NetworkVirtualApplianceSkuId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + NetworkVirtualApplianceSkuName: "networkVirtualApplianceSkuName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/networkVirtualApplianceSkus/networkVirtualApplianceSkuName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeSkUs/nEtWoRkViRtUaLaPpLiAnCeSkUnAmE", + Expected: &NetworkVirtualApplianceSkuId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + NetworkVirtualApplianceSkuName: "nEtWoRkViRtUaLaPpLiAnCeSkUnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeSkUs/nEtWoRkViRtUaLaPpLiAnCeSkUnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkVirtualApplianceSkuIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.NetworkVirtualApplianceSkuName != v.Expected.NetworkVirtualApplianceSkuName { + t.Fatalf("Expected %q but got %q for NetworkVirtualApplianceSkuName", v.Expected.NetworkVirtualApplianceSkuName, actual.NetworkVirtualApplianceSkuName) + } + + } +} + +func TestSegmentsForNetworkVirtualApplianceSkuId(t *testing.T) { + segments := NetworkVirtualApplianceSkuId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkVirtualApplianceSkuId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualapplianceskus/method_get.go b/resource-manager/network/2024-07-01/virtualapplianceskus/method_get.go new file mode 100644 index 00000000000..c570427c4a3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualapplianceskus/method_get.go @@ -0,0 +1,53 @@ +package virtualapplianceskus + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkVirtualApplianceSku +} + +// Get ... +func (c VirtualApplianceSkusClient) Get(ctx context.Context, id NetworkVirtualApplianceSkuId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkVirtualApplianceSku + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualapplianceskus/method_list.go b/resource-manager/network/2024-07-01/virtualapplianceskus/method_list.go new file mode 100644 index 00000000000..a4af9a60bb6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualapplianceskus/method_list.go @@ -0,0 +1,106 @@ +package virtualapplianceskus + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkVirtualApplianceSku +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkVirtualApplianceSku +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c VirtualApplianceSkusClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/networkVirtualApplianceSkus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkVirtualApplianceSku `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c VirtualApplianceSkusClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, NetworkVirtualApplianceSkuOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualApplianceSkusClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate NetworkVirtualApplianceSkuOperationPredicate) (result ListCompleteResult, err error) { + items := make([]NetworkVirtualApplianceSku, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualapplianceskus/model_networkvirtualappliancesku.go b/resource-manager/network/2024-07-01/virtualapplianceskus/model_networkvirtualappliancesku.go new file mode 100644 index 00000000000..93719c4daa2 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualapplianceskus/model_networkvirtualappliancesku.go @@ -0,0 +1,14 @@ +package virtualapplianceskus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualApplianceSku struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkVirtualApplianceSkuPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualapplianceskus/model_networkvirtualapplianceskuinstances.go b/resource-manager/network/2024-07-01/virtualapplianceskus/model_networkvirtualapplianceskuinstances.go new file mode 100644 index 00000000000..99b52442ed2 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualapplianceskus/model_networkvirtualapplianceskuinstances.go @@ -0,0 +1,9 @@ +package virtualapplianceskus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualApplianceSkuInstances struct { + InstanceCount *int64 `json:"instanceCount,omitempty"` + ScaleUnit *string `json:"scaleUnit,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualapplianceskus/model_networkvirtualapplianceskupropertiesformat.go b/resource-manager/network/2024-07-01/virtualapplianceskus/model_networkvirtualapplianceskupropertiesformat.go new file mode 100644 index 00000000000..5df8c3c3b00 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualapplianceskus/model_networkvirtualapplianceskupropertiesformat.go @@ -0,0 +1,10 @@ +package virtualapplianceskus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualApplianceSkuPropertiesFormat struct { + AvailableScaleUnits *[]NetworkVirtualApplianceSkuInstances `json:"availableScaleUnits,omitempty"` + AvailableVersions *[]string `json:"availableVersions,omitempty"` + Vendor *string `json:"vendor,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualapplianceskus/predicates.go b/resource-manager/network/2024-07-01/virtualapplianceskus/predicates.go new file mode 100644 index 00000000000..758bba40370 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualapplianceskus/predicates.go @@ -0,0 +1,37 @@ +package virtualapplianceskus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualApplianceSkuOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p NetworkVirtualApplianceSkuOperationPredicate) Matches(input NetworkVirtualApplianceSku) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/virtualapplianceskus/version.go b/resource-manager/network/2024-07-01/virtualapplianceskus/version.go new file mode 100644 index 00000000000..347f3bd86e2 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualapplianceskus/version.go @@ -0,0 +1,10 @@ +package virtualapplianceskus + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/virtualapplianceskus/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/README.md b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/README.md new file mode 100644 index 00000000000..9eb21f17346 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/README.md @@ -0,0 +1,208 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections` Documentation + +The `virtualnetworkgatewayconnections` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections" +``` + + +### Client Initialization + +```go +client := virtualnetworkgatewayconnections.NewVirtualNetworkGatewayConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VirtualNetworkGatewayConnectionsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualnetworkgatewayconnections.NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectionName") + +payload := virtualnetworkgatewayconnections.VirtualNetworkGatewayConnection{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewayConnectionsClient.Delete` + +```go +ctx := context.TODO() +id := virtualnetworkgatewayconnections.NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectionName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewayConnectionsClient.Get` + +```go +ctx := context.TODO() +id := virtualnetworkgatewayconnections.NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectionName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualNetworkGatewayConnectionsClient.GetIkeSas` + +```go +ctx := context.TODO() +id := virtualnetworkgatewayconnections.NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectionName") + +if err := client.GetIkeSasThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewayConnectionsClient.GetSharedKey` + +```go +ctx := context.TODO() +id := virtualnetworkgatewayconnections.NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectionName") + +read, err := client.GetSharedKey(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualNetworkGatewayConnectionsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualNetworkGatewayConnectionsClient.ResetConnection` + +```go +ctx := context.TODO() +id := virtualnetworkgatewayconnections.NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectionName") + +if err := client.ResetConnectionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewayConnectionsClient.ResetSharedKey` + +```go +ctx := context.TODO() +id := virtualnetworkgatewayconnections.NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectionName") + +payload := virtualnetworkgatewayconnections.ConnectionResetSharedKey{ + // ... +} + + +if err := client.ResetSharedKeyThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewayConnectionsClient.SetSharedKey` + +```go +ctx := context.TODO() +id := virtualnetworkgatewayconnections.NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectionName") + +payload := virtualnetworkgatewayconnections.ConnectionSharedKey{ + // ... +} + + +if err := client.SetSharedKeyThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewayConnectionsClient.StartPacketCapture` + +```go +ctx := context.TODO() +id := virtualnetworkgatewayconnections.NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectionName") + +payload := virtualnetworkgatewayconnections.VpnPacketCaptureStartParameters{ + // ... +} + + +if err := client.StartPacketCaptureThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewayConnectionsClient.StopPacketCapture` + +```go +ctx := context.TODO() +id := virtualnetworkgatewayconnections.NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectionName") + +payload := virtualnetworkgatewayconnections.VpnPacketCaptureStopParameters{ + // ... +} + + +if err := client.StopPacketCaptureThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewayConnectionsClient.UpdateTags` + +```go +ctx := context.TODO() +id := virtualnetworkgatewayconnections.NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectionName") + +payload := virtualnetworkgatewayconnections.TagsObject{ + // ... +} + + +if err := client.UpdateTagsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/client.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/client.go new file mode 100644 index 00000000000..b74a1276981 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/client.go @@ -0,0 +1,26 @@ +package virtualnetworkgatewayconnections + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewVirtualNetworkGatewayConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*VirtualNetworkGatewayConnectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "virtualnetworkgatewayconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VirtualNetworkGatewayConnectionsClient: %+v", err) + } + + return &VirtualNetworkGatewayConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/constants.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/constants.go new file mode 100644 index 00000000000..79eb9c497dd --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/constants.go @@ -0,0 +1,1334 @@ +package virtualnetworkgatewayconnections + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdminState string + +const ( + AdminStateDisabled AdminState = "Disabled" + AdminStateEnabled AdminState = "Enabled" +) + +func PossibleValuesForAdminState() []string { + return []string{ + string(AdminStateDisabled), + string(AdminStateEnabled), + } +} + +func (s *AdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAdminState(input string) (*AdminState, error) { + vals := map[string]AdminState{ + "disabled": AdminStateDisabled, + "enabled": AdminStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AdminState(input) + return &out, nil +} + +type DhGroup string + +const ( + DhGroupDHGroupOne DhGroup = "DHGroup1" + DhGroupDHGroupOneFour DhGroup = "DHGroup14" + DhGroupDHGroupTwo DhGroup = "DHGroup2" + DhGroupDHGroupTwoFour DhGroup = "DHGroup24" + DhGroupDHGroupTwoZeroFourEight DhGroup = "DHGroup2048" + DhGroupECPThreeEightFour DhGroup = "ECP384" + DhGroupECPTwoFiveSix DhGroup = "ECP256" + DhGroupNone DhGroup = "None" +) + +func PossibleValuesForDhGroup() []string { + return []string{ + string(DhGroupDHGroupOne), + string(DhGroupDHGroupOneFour), + string(DhGroupDHGroupTwo), + string(DhGroupDHGroupTwoFour), + string(DhGroupDHGroupTwoZeroFourEight), + string(DhGroupECPThreeEightFour), + string(DhGroupECPTwoFiveSix), + string(DhGroupNone), + } +} + +func (s *DhGroup) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDhGroup(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDhGroup(input string) (*DhGroup, error) { + vals := map[string]DhGroup{ + "dhgroup1": DhGroupDHGroupOne, + "dhgroup14": DhGroupDHGroupOneFour, + "dhgroup2": DhGroupDHGroupTwo, + "dhgroup24": DhGroupDHGroupTwoFour, + "dhgroup2048": DhGroupDHGroupTwoZeroFourEight, + "ecp384": DhGroupECPThreeEightFour, + "ecp256": DhGroupECPTwoFiveSix, + "none": DhGroupNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DhGroup(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPsecEncryption string + +const ( + IPsecEncryptionAESOneNineTwo IPsecEncryption = "AES192" + IPsecEncryptionAESOneTwoEight IPsecEncryption = "AES128" + IPsecEncryptionAESTwoFiveSix IPsecEncryption = "AES256" + IPsecEncryptionDES IPsecEncryption = "DES" + IPsecEncryptionDESThree IPsecEncryption = "DES3" + IPsecEncryptionGCMAESOneNineTwo IPsecEncryption = "GCMAES192" + IPsecEncryptionGCMAESOneTwoEight IPsecEncryption = "GCMAES128" + IPsecEncryptionGCMAESTwoFiveSix IPsecEncryption = "GCMAES256" + IPsecEncryptionNone IPsecEncryption = "None" +) + +func PossibleValuesForIPsecEncryption() []string { + return []string{ + string(IPsecEncryptionAESOneNineTwo), + string(IPsecEncryptionAESOneTwoEight), + string(IPsecEncryptionAESTwoFiveSix), + string(IPsecEncryptionDES), + string(IPsecEncryptionDESThree), + string(IPsecEncryptionGCMAESOneNineTwo), + string(IPsecEncryptionGCMAESOneTwoEight), + string(IPsecEncryptionGCMAESTwoFiveSix), + string(IPsecEncryptionNone), + } +} + +func (s *IPsecEncryption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPsecEncryption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPsecEncryption(input string) (*IPsecEncryption, error) { + vals := map[string]IPsecEncryption{ + "aes192": IPsecEncryptionAESOneNineTwo, + "aes128": IPsecEncryptionAESOneTwoEight, + "aes256": IPsecEncryptionAESTwoFiveSix, + "des": IPsecEncryptionDES, + "des3": IPsecEncryptionDESThree, + "gcmaes192": IPsecEncryptionGCMAESOneNineTwo, + "gcmaes128": IPsecEncryptionGCMAESOneTwoEight, + "gcmaes256": IPsecEncryptionGCMAESTwoFiveSix, + "none": IPsecEncryptionNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPsecEncryption(input) + return &out, nil +} + +type IPsecIntegrity string + +const ( + IPsecIntegrityGCMAESOneNineTwo IPsecIntegrity = "GCMAES192" + IPsecIntegrityGCMAESOneTwoEight IPsecIntegrity = "GCMAES128" + IPsecIntegrityGCMAESTwoFiveSix IPsecIntegrity = "GCMAES256" + IPsecIntegrityMDFive IPsecIntegrity = "MD5" + IPsecIntegritySHAOne IPsecIntegrity = "SHA1" + IPsecIntegritySHATwoFiveSix IPsecIntegrity = "SHA256" +) + +func PossibleValuesForIPsecIntegrity() []string { + return []string{ + string(IPsecIntegrityGCMAESOneNineTwo), + string(IPsecIntegrityGCMAESOneTwoEight), + string(IPsecIntegrityGCMAESTwoFiveSix), + string(IPsecIntegrityMDFive), + string(IPsecIntegritySHAOne), + string(IPsecIntegritySHATwoFiveSix), + } +} + +func (s *IPsecIntegrity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPsecIntegrity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPsecIntegrity(input string) (*IPsecIntegrity, error) { + vals := map[string]IPsecIntegrity{ + "gcmaes192": IPsecIntegrityGCMAESOneNineTwo, + "gcmaes128": IPsecIntegrityGCMAESOneTwoEight, + "gcmaes256": IPsecIntegrityGCMAESTwoFiveSix, + "md5": IPsecIntegrityMDFive, + "sha1": IPsecIntegritySHAOne, + "sha256": IPsecIntegritySHATwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPsecIntegrity(input) + return &out, nil +} + +type IkeEncryption string + +const ( + IkeEncryptionAESOneNineTwo IkeEncryption = "AES192" + IkeEncryptionAESOneTwoEight IkeEncryption = "AES128" + IkeEncryptionAESTwoFiveSix IkeEncryption = "AES256" + IkeEncryptionDES IkeEncryption = "DES" + IkeEncryptionDESThree IkeEncryption = "DES3" + IkeEncryptionGCMAESOneTwoEight IkeEncryption = "GCMAES128" + IkeEncryptionGCMAESTwoFiveSix IkeEncryption = "GCMAES256" +) + +func PossibleValuesForIkeEncryption() []string { + return []string{ + string(IkeEncryptionAESOneNineTwo), + string(IkeEncryptionAESOneTwoEight), + string(IkeEncryptionAESTwoFiveSix), + string(IkeEncryptionDES), + string(IkeEncryptionDESThree), + string(IkeEncryptionGCMAESOneTwoEight), + string(IkeEncryptionGCMAESTwoFiveSix), + } +} + +func (s *IkeEncryption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIkeEncryption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIkeEncryption(input string) (*IkeEncryption, error) { + vals := map[string]IkeEncryption{ + "aes192": IkeEncryptionAESOneNineTwo, + "aes128": IkeEncryptionAESOneTwoEight, + "aes256": IkeEncryptionAESTwoFiveSix, + "des": IkeEncryptionDES, + "des3": IkeEncryptionDESThree, + "gcmaes128": IkeEncryptionGCMAESOneTwoEight, + "gcmaes256": IkeEncryptionGCMAESTwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IkeEncryption(input) + return &out, nil +} + +type IkeIntegrity string + +const ( + IkeIntegrityGCMAESOneTwoEight IkeIntegrity = "GCMAES128" + IkeIntegrityGCMAESTwoFiveSix IkeIntegrity = "GCMAES256" + IkeIntegrityMDFive IkeIntegrity = "MD5" + IkeIntegritySHAOne IkeIntegrity = "SHA1" + IkeIntegritySHAThreeEightFour IkeIntegrity = "SHA384" + IkeIntegritySHATwoFiveSix IkeIntegrity = "SHA256" +) + +func PossibleValuesForIkeIntegrity() []string { + return []string{ + string(IkeIntegrityGCMAESOneTwoEight), + string(IkeIntegrityGCMAESTwoFiveSix), + string(IkeIntegrityMDFive), + string(IkeIntegritySHAOne), + string(IkeIntegritySHAThreeEightFour), + string(IkeIntegritySHATwoFiveSix), + } +} + +func (s *IkeIntegrity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIkeIntegrity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIkeIntegrity(input string) (*IkeIntegrity, error) { + vals := map[string]IkeIntegrity{ + "gcmaes128": IkeIntegrityGCMAESOneTwoEight, + "gcmaes256": IkeIntegrityGCMAESTwoFiveSix, + "md5": IkeIntegrityMDFive, + "sha1": IkeIntegritySHAOne, + "sha384": IkeIntegritySHAThreeEightFour, + "sha256": IkeIntegritySHATwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IkeIntegrity(input) + return &out, nil +} + +type PfsGroup string + +const ( + PfsGroupECPThreeEightFour PfsGroup = "ECP384" + PfsGroupECPTwoFiveSix PfsGroup = "ECP256" + PfsGroupNone PfsGroup = "None" + PfsGroupPFSMM PfsGroup = "PFSMM" + PfsGroupPFSOne PfsGroup = "PFS1" + PfsGroupPFSOneFour PfsGroup = "PFS14" + PfsGroupPFSTwo PfsGroup = "PFS2" + PfsGroupPFSTwoFour PfsGroup = "PFS24" + PfsGroupPFSTwoZeroFourEight PfsGroup = "PFS2048" +) + +func PossibleValuesForPfsGroup() []string { + return []string{ + string(PfsGroupECPThreeEightFour), + string(PfsGroupECPTwoFiveSix), + string(PfsGroupNone), + string(PfsGroupPFSMM), + string(PfsGroupPFSOne), + string(PfsGroupPFSOneFour), + string(PfsGroupPFSTwo), + string(PfsGroupPFSTwoFour), + string(PfsGroupPFSTwoZeroFourEight), + } +} + +func (s *PfsGroup) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePfsGroup(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePfsGroup(input string) (*PfsGroup, error) { + vals := map[string]PfsGroup{ + "ecp384": PfsGroupECPThreeEightFour, + "ecp256": PfsGroupECPTwoFiveSix, + "none": PfsGroupNone, + "pfsmm": PfsGroupPFSMM, + "pfs1": PfsGroupPFSOne, + "pfs14": PfsGroupPFSOneFour, + "pfs2": PfsGroupPFSTwo, + "pfs24": PfsGroupPFSTwoFour, + "pfs2048": PfsGroupPFSTwoZeroFourEight, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PfsGroup(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ResiliencyModel string + +const ( + ResiliencyModelMultiHomed ResiliencyModel = "MultiHomed" + ResiliencyModelSingleHomed ResiliencyModel = "SingleHomed" +) + +func PossibleValuesForResiliencyModel() []string { + return []string{ + string(ResiliencyModelMultiHomed), + string(ResiliencyModelSingleHomed), + } +} + +func (s *ResiliencyModel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResiliencyModel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResiliencyModel(input string) (*ResiliencyModel, error) { + vals := map[string]ResiliencyModel{ + "multihomed": ResiliencyModelMultiHomed, + "singlehomed": ResiliencyModelSingleHomed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResiliencyModel(input) + return &out, nil +} + +type VirtualNetworkGatewayConnectionMode string + +const ( + VirtualNetworkGatewayConnectionModeDefault VirtualNetworkGatewayConnectionMode = "Default" + VirtualNetworkGatewayConnectionModeInitiatorOnly VirtualNetworkGatewayConnectionMode = "InitiatorOnly" + VirtualNetworkGatewayConnectionModeResponderOnly VirtualNetworkGatewayConnectionMode = "ResponderOnly" +) + +func PossibleValuesForVirtualNetworkGatewayConnectionMode() []string { + return []string{ + string(VirtualNetworkGatewayConnectionModeDefault), + string(VirtualNetworkGatewayConnectionModeInitiatorOnly), + string(VirtualNetworkGatewayConnectionModeResponderOnly), + } +} + +func (s *VirtualNetworkGatewayConnectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewayConnectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewayConnectionMode(input string) (*VirtualNetworkGatewayConnectionMode, error) { + vals := map[string]VirtualNetworkGatewayConnectionMode{ + "default": VirtualNetworkGatewayConnectionModeDefault, + "initiatoronly": VirtualNetworkGatewayConnectionModeInitiatorOnly, + "responderonly": VirtualNetworkGatewayConnectionModeResponderOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewayConnectionMode(input) + return &out, nil +} + +type VirtualNetworkGatewayConnectionProtocol string + +const ( + VirtualNetworkGatewayConnectionProtocolIKEvOne VirtualNetworkGatewayConnectionProtocol = "IKEv1" + VirtualNetworkGatewayConnectionProtocolIKEvTwo VirtualNetworkGatewayConnectionProtocol = "IKEv2" +) + +func PossibleValuesForVirtualNetworkGatewayConnectionProtocol() []string { + return []string{ + string(VirtualNetworkGatewayConnectionProtocolIKEvOne), + string(VirtualNetworkGatewayConnectionProtocolIKEvTwo), + } +} + +func (s *VirtualNetworkGatewayConnectionProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewayConnectionProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewayConnectionProtocol(input string) (*VirtualNetworkGatewayConnectionProtocol, error) { + vals := map[string]VirtualNetworkGatewayConnectionProtocol{ + "ikev1": VirtualNetworkGatewayConnectionProtocolIKEvOne, + "ikev2": VirtualNetworkGatewayConnectionProtocolIKEvTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewayConnectionProtocol(input) + return &out, nil +} + +type VirtualNetworkGatewayConnectionStatus string + +const ( + VirtualNetworkGatewayConnectionStatusConnected VirtualNetworkGatewayConnectionStatus = "Connected" + VirtualNetworkGatewayConnectionStatusConnecting VirtualNetworkGatewayConnectionStatus = "Connecting" + VirtualNetworkGatewayConnectionStatusNotConnected VirtualNetworkGatewayConnectionStatus = "NotConnected" + VirtualNetworkGatewayConnectionStatusUnknown VirtualNetworkGatewayConnectionStatus = "Unknown" +) + +func PossibleValuesForVirtualNetworkGatewayConnectionStatus() []string { + return []string{ + string(VirtualNetworkGatewayConnectionStatusConnected), + string(VirtualNetworkGatewayConnectionStatusConnecting), + string(VirtualNetworkGatewayConnectionStatusNotConnected), + string(VirtualNetworkGatewayConnectionStatusUnknown), + } +} + +func (s *VirtualNetworkGatewayConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewayConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewayConnectionStatus(input string) (*VirtualNetworkGatewayConnectionStatus, error) { + vals := map[string]VirtualNetworkGatewayConnectionStatus{ + "connected": VirtualNetworkGatewayConnectionStatusConnected, + "connecting": VirtualNetworkGatewayConnectionStatusConnecting, + "notconnected": VirtualNetworkGatewayConnectionStatusNotConnected, + "unknown": VirtualNetworkGatewayConnectionStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewayConnectionStatus(input) + return &out, nil +} + +type VirtualNetworkGatewayConnectionType string + +const ( + VirtualNetworkGatewayConnectionTypeExpressRoute VirtualNetworkGatewayConnectionType = "ExpressRoute" + VirtualNetworkGatewayConnectionTypeIPsec VirtualNetworkGatewayConnectionType = "IPsec" + VirtualNetworkGatewayConnectionTypeVPNClient VirtualNetworkGatewayConnectionType = "VPNClient" + VirtualNetworkGatewayConnectionTypeVnetTwoVnet VirtualNetworkGatewayConnectionType = "Vnet2Vnet" +) + +func PossibleValuesForVirtualNetworkGatewayConnectionType() []string { + return []string{ + string(VirtualNetworkGatewayConnectionTypeExpressRoute), + string(VirtualNetworkGatewayConnectionTypeIPsec), + string(VirtualNetworkGatewayConnectionTypeVPNClient), + string(VirtualNetworkGatewayConnectionTypeVnetTwoVnet), + } +} + +func (s *VirtualNetworkGatewayConnectionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewayConnectionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewayConnectionType(input string) (*VirtualNetworkGatewayConnectionType, error) { + vals := map[string]VirtualNetworkGatewayConnectionType{ + "expressroute": VirtualNetworkGatewayConnectionTypeExpressRoute, + "ipsec": VirtualNetworkGatewayConnectionTypeIPsec, + "vpnclient": VirtualNetworkGatewayConnectionTypeVPNClient, + "vnet2vnet": VirtualNetworkGatewayConnectionTypeVnetTwoVnet, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewayConnectionType(input) + return &out, nil +} + +type VirtualNetworkGatewayMigrationPhase string + +const ( + VirtualNetworkGatewayMigrationPhaseAbort VirtualNetworkGatewayMigrationPhase = "Abort" + VirtualNetworkGatewayMigrationPhaseAbortSucceeded VirtualNetworkGatewayMigrationPhase = "AbortSucceeded" + VirtualNetworkGatewayMigrationPhaseCommit VirtualNetworkGatewayMigrationPhase = "Commit" + VirtualNetworkGatewayMigrationPhaseCommitSucceeded VirtualNetworkGatewayMigrationPhase = "CommitSucceeded" + VirtualNetworkGatewayMigrationPhaseExecute VirtualNetworkGatewayMigrationPhase = "Execute" + VirtualNetworkGatewayMigrationPhaseExecuteSucceeded VirtualNetworkGatewayMigrationPhase = "ExecuteSucceeded" + VirtualNetworkGatewayMigrationPhaseNone VirtualNetworkGatewayMigrationPhase = "None" + VirtualNetworkGatewayMigrationPhasePrepare VirtualNetworkGatewayMigrationPhase = "Prepare" + VirtualNetworkGatewayMigrationPhasePrepareSucceeded VirtualNetworkGatewayMigrationPhase = "PrepareSucceeded" +) + +func PossibleValuesForVirtualNetworkGatewayMigrationPhase() []string { + return []string{ + string(VirtualNetworkGatewayMigrationPhaseAbort), + string(VirtualNetworkGatewayMigrationPhaseAbortSucceeded), + string(VirtualNetworkGatewayMigrationPhaseCommit), + string(VirtualNetworkGatewayMigrationPhaseCommitSucceeded), + string(VirtualNetworkGatewayMigrationPhaseExecute), + string(VirtualNetworkGatewayMigrationPhaseExecuteSucceeded), + string(VirtualNetworkGatewayMigrationPhaseNone), + string(VirtualNetworkGatewayMigrationPhasePrepare), + string(VirtualNetworkGatewayMigrationPhasePrepareSucceeded), + } +} + +func (s *VirtualNetworkGatewayMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewayMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewayMigrationPhase(input string) (*VirtualNetworkGatewayMigrationPhase, error) { + vals := map[string]VirtualNetworkGatewayMigrationPhase{ + "abort": VirtualNetworkGatewayMigrationPhaseAbort, + "abortsucceeded": VirtualNetworkGatewayMigrationPhaseAbortSucceeded, + "commit": VirtualNetworkGatewayMigrationPhaseCommit, + "commitsucceeded": VirtualNetworkGatewayMigrationPhaseCommitSucceeded, + "execute": VirtualNetworkGatewayMigrationPhaseExecute, + "executesucceeded": VirtualNetworkGatewayMigrationPhaseExecuteSucceeded, + "none": VirtualNetworkGatewayMigrationPhaseNone, + "prepare": VirtualNetworkGatewayMigrationPhasePrepare, + "preparesucceeded": VirtualNetworkGatewayMigrationPhasePrepareSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewayMigrationPhase(input) + return &out, nil +} + +type VirtualNetworkGatewayMigrationState string + +const ( + VirtualNetworkGatewayMigrationStateFailed VirtualNetworkGatewayMigrationState = "Failed" + VirtualNetworkGatewayMigrationStateInProgress VirtualNetworkGatewayMigrationState = "InProgress" + VirtualNetworkGatewayMigrationStateNone VirtualNetworkGatewayMigrationState = "None" + VirtualNetworkGatewayMigrationStateSucceeded VirtualNetworkGatewayMigrationState = "Succeeded" +) + +func PossibleValuesForVirtualNetworkGatewayMigrationState() []string { + return []string{ + string(VirtualNetworkGatewayMigrationStateFailed), + string(VirtualNetworkGatewayMigrationStateInProgress), + string(VirtualNetworkGatewayMigrationStateNone), + string(VirtualNetworkGatewayMigrationStateSucceeded), + } +} + +func (s *VirtualNetworkGatewayMigrationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewayMigrationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewayMigrationState(input string) (*VirtualNetworkGatewayMigrationState, error) { + vals := map[string]VirtualNetworkGatewayMigrationState{ + "failed": VirtualNetworkGatewayMigrationStateFailed, + "inprogress": VirtualNetworkGatewayMigrationStateInProgress, + "none": VirtualNetworkGatewayMigrationStateNone, + "succeeded": VirtualNetworkGatewayMigrationStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewayMigrationState(input) + return &out, nil +} + +type VirtualNetworkGatewaySkuName string + +const ( + VirtualNetworkGatewaySkuNameBasic VirtualNetworkGatewaySkuName = "Basic" + VirtualNetworkGatewaySkuNameErGwOneAZ VirtualNetworkGatewaySkuName = "ErGw1AZ" + VirtualNetworkGatewaySkuNameErGwScale VirtualNetworkGatewaySkuName = "ErGwScale" + VirtualNetworkGatewaySkuNameErGwThreeAZ VirtualNetworkGatewaySkuName = "ErGw3AZ" + VirtualNetworkGatewaySkuNameErGwTwoAZ VirtualNetworkGatewaySkuName = "ErGw2AZ" + VirtualNetworkGatewaySkuNameHighPerformance VirtualNetworkGatewaySkuName = "HighPerformance" + VirtualNetworkGatewaySkuNameStandard VirtualNetworkGatewaySkuName = "Standard" + VirtualNetworkGatewaySkuNameUltraPerformance VirtualNetworkGatewaySkuName = "UltraPerformance" + VirtualNetworkGatewaySkuNameVpnGwFive VirtualNetworkGatewaySkuName = "VpnGw5" + VirtualNetworkGatewaySkuNameVpnGwFiveAZ VirtualNetworkGatewaySkuName = "VpnGw5AZ" + VirtualNetworkGatewaySkuNameVpnGwFour VirtualNetworkGatewaySkuName = "VpnGw4" + VirtualNetworkGatewaySkuNameVpnGwFourAZ VirtualNetworkGatewaySkuName = "VpnGw4AZ" + VirtualNetworkGatewaySkuNameVpnGwOne VirtualNetworkGatewaySkuName = "VpnGw1" + VirtualNetworkGatewaySkuNameVpnGwOneAZ VirtualNetworkGatewaySkuName = "VpnGw1AZ" + VirtualNetworkGatewaySkuNameVpnGwThree VirtualNetworkGatewaySkuName = "VpnGw3" + VirtualNetworkGatewaySkuNameVpnGwThreeAZ VirtualNetworkGatewaySkuName = "VpnGw3AZ" + VirtualNetworkGatewaySkuNameVpnGwTwo VirtualNetworkGatewaySkuName = "VpnGw2" + VirtualNetworkGatewaySkuNameVpnGwTwoAZ VirtualNetworkGatewaySkuName = "VpnGw2AZ" +) + +func PossibleValuesForVirtualNetworkGatewaySkuName() []string { + return []string{ + string(VirtualNetworkGatewaySkuNameBasic), + string(VirtualNetworkGatewaySkuNameErGwOneAZ), + string(VirtualNetworkGatewaySkuNameErGwScale), + string(VirtualNetworkGatewaySkuNameErGwThreeAZ), + string(VirtualNetworkGatewaySkuNameErGwTwoAZ), + string(VirtualNetworkGatewaySkuNameHighPerformance), + string(VirtualNetworkGatewaySkuNameStandard), + string(VirtualNetworkGatewaySkuNameUltraPerformance), + string(VirtualNetworkGatewaySkuNameVpnGwFive), + string(VirtualNetworkGatewaySkuNameVpnGwFiveAZ), + string(VirtualNetworkGatewaySkuNameVpnGwFour), + string(VirtualNetworkGatewaySkuNameVpnGwFourAZ), + string(VirtualNetworkGatewaySkuNameVpnGwOne), + string(VirtualNetworkGatewaySkuNameVpnGwOneAZ), + string(VirtualNetworkGatewaySkuNameVpnGwThree), + string(VirtualNetworkGatewaySkuNameVpnGwThreeAZ), + string(VirtualNetworkGatewaySkuNameVpnGwTwo), + string(VirtualNetworkGatewaySkuNameVpnGwTwoAZ), + } +} + +func (s *VirtualNetworkGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewaySkuName(input string) (*VirtualNetworkGatewaySkuName, error) { + vals := map[string]VirtualNetworkGatewaySkuName{ + "basic": VirtualNetworkGatewaySkuNameBasic, + "ergw1az": VirtualNetworkGatewaySkuNameErGwOneAZ, + "ergwscale": VirtualNetworkGatewaySkuNameErGwScale, + "ergw3az": VirtualNetworkGatewaySkuNameErGwThreeAZ, + "ergw2az": VirtualNetworkGatewaySkuNameErGwTwoAZ, + "highperformance": VirtualNetworkGatewaySkuNameHighPerformance, + "standard": VirtualNetworkGatewaySkuNameStandard, + "ultraperformance": VirtualNetworkGatewaySkuNameUltraPerformance, + "vpngw5": VirtualNetworkGatewaySkuNameVpnGwFive, + "vpngw5az": VirtualNetworkGatewaySkuNameVpnGwFiveAZ, + "vpngw4": VirtualNetworkGatewaySkuNameVpnGwFour, + "vpngw4az": VirtualNetworkGatewaySkuNameVpnGwFourAZ, + "vpngw1": VirtualNetworkGatewaySkuNameVpnGwOne, + "vpngw1az": VirtualNetworkGatewaySkuNameVpnGwOneAZ, + "vpngw3": VirtualNetworkGatewaySkuNameVpnGwThree, + "vpngw3az": VirtualNetworkGatewaySkuNameVpnGwThreeAZ, + "vpngw2": VirtualNetworkGatewaySkuNameVpnGwTwo, + "vpngw2az": VirtualNetworkGatewaySkuNameVpnGwTwoAZ, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewaySkuName(input) + return &out, nil +} + +type VirtualNetworkGatewaySkuTier string + +const ( + VirtualNetworkGatewaySkuTierBasic VirtualNetworkGatewaySkuTier = "Basic" + VirtualNetworkGatewaySkuTierErGwOneAZ VirtualNetworkGatewaySkuTier = "ErGw1AZ" + VirtualNetworkGatewaySkuTierErGwScale VirtualNetworkGatewaySkuTier = "ErGwScale" + VirtualNetworkGatewaySkuTierErGwThreeAZ VirtualNetworkGatewaySkuTier = "ErGw3AZ" + VirtualNetworkGatewaySkuTierErGwTwoAZ VirtualNetworkGatewaySkuTier = "ErGw2AZ" + VirtualNetworkGatewaySkuTierHighPerformance VirtualNetworkGatewaySkuTier = "HighPerformance" + VirtualNetworkGatewaySkuTierStandard VirtualNetworkGatewaySkuTier = "Standard" + VirtualNetworkGatewaySkuTierUltraPerformance VirtualNetworkGatewaySkuTier = "UltraPerformance" + VirtualNetworkGatewaySkuTierVpnGwFive VirtualNetworkGatewaySkuTier = "VpnGw5" + VirtualNetworkGatewaySkuTierVpnGwFiveAZ VirtualNetworkGatewaySkuTier = "VpnGw5AZ" + VirtualNetworkGatewaySkuTierVpnGwFour VirtualNetworkGatewaySkuTier = "VpnGw4" + VirtualNetworkGatewaySkuTierVpnGwFourAZ VirtualNetworkGatewaySkuTier = "VpnGw4AZ" + VirtualNetworkGatewaySkuTierVpnGwOne VirtualNetworkGatewaySkuTier = "VpnGw1" + VirtualNetworkGatewaySkuTierVpnGwOneAZ VirtualNetworkGatewaySkuTier = "VpnGw1AZ" + VirtualNetworkGatewaySkuTierVpnGwThree VirtualNetworkGatewaySkuTier = "VpnGw3" + VirtualNetworkGatewaySkuTierVpnGwThreeAZ VirtualNetworkGatewaySkuTier = "VpnGw3AZ" + VirtualNetworkGatewaySkuTierVpnGwTwo VirtualNetworkGatewaySkuTier = "VpnGw2" + VirtualNetworkGatewaySkuTierVpnGwTwoAZ VirtualNetworkGatewaySkuTier = "VpnGw2AZ" +) + +func PossibleValuesForVirtualNetworkGatewaySkuTier() []string { + return []string{ + string(VirtualNetworkGatewaySkuTierBasic), + string(VirtualNetworkGatewaySkuTierErGwOneAZ), + string(VirtualNetworkGatewaySkuTierErGwScale), + string(VirtualNetworkGatewaySkuTierErGwThreeAZ), + string(VirtualNetworkGatewaySkuTierErGwTwoAZ), + string(VirtualNetworkGatewaySkuTierHighPerformance), + string(VirtualNetworkGatewaySkuTierStandard), + string(VirtualNetworkGatewaySkuTierUltraPerformance), + string(VirtualNetworkGatewaySkuTierVpnGwFive), + string(VirtualNetworkGatewaySkuTierVpnGwFiveAZ), + string(VirtualNetworkGatewaySkuTierVpnGwFour), + string(VirtualNetworkGatewaySkuTierVpnGwFourAZ), + string(VirtualNetworkGatewaySkuTierVpnGwOne), + string(VirtualNetworkGatewaySkuTierVpnGwOneAZ), + string(VirtualNetworkGatewaySkuTierVpnGwThree), + string(VirtualNetworkGatewaySkuTierVpnGwThreeAZ), + string(VirtualNetworkGatewaySkuTierVpnGwTwo), + string(VirtualNetworkGatewaySkuTierVpnGwTwoAZ), + } +} + +func (s *VirtualNetworkGatewaySkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewaySkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewaySkuTier(input string) (*VirtualNetworkGatewaySkuTier, error) { + vals := map[string]VirtualNetworkGatewaySkuTier{ + "basic": VirtualNetworkGatewaySkuTierBasic, + "ergw1az": VirtualNetworkGatewaySkuTierErGwOneAZ, + "ergwscale": VirtualNetworkGatewaySkuTierErGwScale, + "ergw3az": VirtualNetworkGatewaySkuTierErGwThreeAZ, + "ergw2az": VirtualNetworkGatewaySkuTierErGwTwoAZ, + "highperformance": VirtualNetworkGatewaySkuTierHighPerformance, + "standard": VirtualNetworkGatewaySkuTierStandard, + "ultraperformance": VirtualNetworkGatewaySkuTierUltraPerformance, + "vpngw5": VirtualNetworkGatewaySkuTierVpnGwFive, + "vpngw5az": VirtualNetworkGatewaySkuTierVpnGwFiveAZ, + "vpngw4": VirtualNetworkGatewaySkuTierVpnGwFour, + "vpngw4az": VirtualNetworkGatewaySkuTierVpnGwFourAZ, + "vpngw1": VirtualNetworkGatewaySkuTierVpnGwOne, + "vpngw1az": VirtualNetworkGatewaySkuTierVpnGwOneAZ, + "vpngw3": VirtualNetworkGatewaySkuTierVpnGwThree, + "vpngw3az": VirtualNetworkGatewaySkuTierVpnGwThreeAZ, + "vpngw2": VirtualNetworkGatewaySkuTierVpnGwTwo, + "vpngw2az": VirtualNetworkGatewaySkuTierVpnGwTwoAZ, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewaySkuTier(input) + return &out, nil +} + +type VirtualNetworkGatewayType string + +const ( + VirtualNetworkGatewayTypeExpressRoute VirtualNetworkGatewayType = "ExpressRoute" + VirtualNetworkGatewayTypeLocalGateway VirtualNetworkGatewayType = "LocalGateway" + VirtualNetworkGatewayTypeVpn VirtualNetworkGatewayType = "Vpn" +) + +func PossibleValuesForVirtualNetworkGatewayType() []string { + return []string{ + string(VirtualNetworkGatewayTypeExpressRoute), + string(VirtualNetworkGatewayTypeLocalGateway), + string(VirtualNetworkGatewayTypeVpn), + } +} + +func (s *VirtualNetworkGatewayType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewayType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewayType(input string) (*VirtualNetworkGatewayType, error) { + vals := map[string]VirtualNetworkGatewayType{ + "expressroute": VirtualNetworkGatewayTypeExpressRoute, + "localgateway": VirtualNetworkGatewayTypeLocalGateway, + "vpn": VirtualNetworkGatewayTypeVpn, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewayType(input) + return &out, nil +} + +type VpnAuthenticationType string + +const ( + VpnAuthenticationTypeAAD VpnAuthenticationType = "AAD" + VpnAuthenticationTypeCertificate VpnAuthenticationType = "Certificate" + VpnAuthenticationTypeRadius VpnAuthenticationType = "Radius" +) + +func PossibleValuesForVpnAuthenticationType() []string { + return []string{ + string(VpnAuthenticationTypeAAD), + string(VpnAuthenticationTypeCertificate), + string(VpnAuthenticationTypeRadius), + } +} + +func (s *VpnAuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnAuthenticationType(input string) (*VpnAuthenticationType, error) { + vals := map[string]VpnAuthenticationType{ + "aad": VpnAuthenticationTypeAAD, + "certificate": VpnAuthenticationTypeCertificate, + "radius": VpnAuthenticationTypeRadius, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnAuthenticationType(input) + return &out, nil +} + +type VpnClientProtocol string + +const ( + VpnClientProtocolIkeVTwo VpnClientProtocol = "IkeV2" + VpnClientProtocolOpenVPN VpnClientProtocol = "OpenVPN" + VpnClientProtocolSSTP VpnClientProtocol = "SSTP" +) + +func PossibleValuesForVpnClientProtocol() []string { + return []string{ + string(VpnClientProtocolIkeVTwo), + string(VpnClientProtocolOpenVPN), + string(VpnClientProtocolSSTP), + } +} + +func (s *VpnClientProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnClientProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnClientProtocol(input string) (*VpnClientProtocol, error) { + vals := map[string]VpnClientProtocol{ + "ikev2": VpnClientProtocolIkeVTwo, + "openvpn": VpnClientProtocolOpenVPN, + "sstp": VpnClientProtocolSSTP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnClientProtocol(input) + return &out, nil +} + +type VpnGatewayGeneration string + +const ( + VpnGatewayGenerationGenerationOne VpnGatewayGeneration = "Generation1" + VpnGatewayGenerationGenerationTwo VpnGatewayGeneration = "Generation2" + VpnGatewayGenerationNone VpnGatewayGeneration = "None" +) + +func PossibleValuesForVpnGatewayGeneration() []string { + return []string{ + string(VpnGatewayGenerationGenerationOne), + string(VpnGatewayGenerationGenerationTwo), + string(VpnGatewayGenerationNone), + } +} + +func (s *VpnGatewayGeneration) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnGatewayGeneration(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnGatewayGeneration(input string) (*VpnGatewayGeneration, error) { + vals := map[string]VpnGatewayGeneration{ + "generation1": VpnGatewayGenerationGenerationOne, + "generation2": VpnGatewayGenerationGenerationTwo, + "none": VpnGatewayGenerationNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnGatewayGeneration(input) + return &out, nil +} + +type VpnNatRuleMode string + +const ( + VpnNatRuleModeEgressSnat VpnNatRuleMode = "EgressSnat" + VpnNatRuleModeIngressSnat VpnNatRuleMode = "IngressSnat" +) + +func PossibleValuesForVpnNatRuleMode() []string { + return []string{ + string(VpnNatRuleModeEgressSnat), + string(VpnNatRuleModeIngressSnat), + } +} + +func (s *VpnNatRuleMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnNatRuleMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnNatRuleMode(input string) (*VpnNatRuleMode, error) { + vals := map[string]VpnNatRuleMode{ + "egresssnat": VpnNatRuleModeEgressSnat, + "ingresssnat": VpnNatRuleModeIngressSnat, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnNatRuleMode(input) + return &out, nil +} + +type VpnNatRuleType string + +const ( + VpnNatRuleTypeDynamic VpnNatRuleType = "Dynamic" + VpnNatRuleTypeStatic VpnNatRuleType = "Static" +) + +func PossibleValuesForVpnNatRuleType() []string { + return []string{ + string(VpnNatRuleTypeDynamic), + string(VpnNatRuleTypeStatic), + } +} + +func (s *VpnNatRuleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnNatRuleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnNatRuleType(input string) (*VpnNatRuleType, error) { + vals := map[string]VpnNatRuleType{ + "dynamic": VpnNatRuleTypeDynamic, + "static": VpnNatRuleTypeStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnNatRuleType(input) + return &out, nil +} + +type VpnPolicyMemberAttributeType string + +const ( + VpnPolicyMemberAttributeTypeAADGroupId VpnPolicyMemberAttributeType = "AADGroupId" + VpnPolicyMemberAttributeTypeCertificateGroupId VpnPolicyMemberAttributeType = "CertificateGroupId" + VpnPolicyMemberAttributeTypeRadiusAzureGroupId VpnPolicyMemberAttributeType = "RadiusAzureGroupId" +) + +func PossibleValuesForVpnPolicyMemberAttributeType() []string { + return []string{ + string(VpnPolicyMemberAttributeTypeAADGroupId), + string(VpnPolicyMemberAttributeTypeCertificateGroupId), + string(VpnPolicyMemberAttributeTypeRadiusAzureGroupId), + } +} + +func (s *VpnPolicyMemberAttributeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnPolicyMemberAttributeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnPolicyMemberAttributeType(input string) (*VpnPolicyMemberAttributeType, error) { + vals := map[string]VpnPolicyMemberAttributeType{ + "aadgroupid": VpnPolicyMemberAttributeTypeAADGroupId, + "certificategroupid": VpnPolicyMemberAttributeTypeCertificateGroupId, + "radiusazuregroupid": VpnPolicyMemberAttributeTypeRadiusAzureGroupId, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnPolicyMemberAttributeType(input) + return &out, nil +} + +type VpnType string + +const ( + VpnTypePolicyBased VpnType = "PolicyBased" + VpnTypeRouteBased VpnType = "RouteBased" +) + +func PossibleValuesForVpnType() []string { + return []string{ + string(VpnTypePolicyBased), + string(VpnTypeRouteBased), + } +} + +func (s *VpnType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnType(input string) (*VpnType, error) { + vals := map[string]VpnType{ + "policybased": VpnTypePolicyBased, + "routebased": VpnTypeRouteBased, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnType(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/id_connection.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/id_connection.go new file mode 100644 index 00000000000..25fa92d5238 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/id_connection.go @@ -0,0 +1,130 @@ +package virtualnetworkgatewayconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConnectionId{}) +} + +var _ resourceids.ResourceId = &ConnectionId{} + +// ConnectionId is a struct representing the Resource ID for a Connection +type ConnectionId struct { + SubscriptionId string + ResourceGroupName string + ConnectionName string +} + +// NewConnectionID returns a new ConnectionId struct +func NewConnectionID(subscriptionId string, resourceGroupName string, connectionName string) ConnectionId { + return ConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ConnectionName: connectionName, + } +} + +// ParseConnectionID parses 'input' into a ConnectionId +func ParseConnectionID(input string) (*ConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConnectionIDInsensitively parses 'input' case-insensitively into a ConnectionId +// note: this method should only be used for API response data and not user input +func ParseConnectionIDInsensitively(input string) (*ConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ConnectionName, ok = input.Parsed["connectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectionName", input) + } + + return nil +} + +// ValidateConnectionID checks that 'input' can be parsed as a Connection ID +func ValidateConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Connection ID +func (id ConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/connections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Connection ID +func (id ConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticConnections", "connections", "connections"), + resourceids.UserSpecifiedSegment("connectionName", "connectionName"), + } +} + +// String returns a human-readable description of this Connection ID +func (id ConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Connection Name: %q", id.ConnectionName), + } + return fmt.Sprintf("Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/id_connection_test.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/id_connection_test.go new file mode 100644 index 00000000000..271fc3c17bd --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/id_connection_test.go @@ -0,0 +1,282 @@ +package virtualnetworkgatewayconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ConnectionId{} + +func TestNewConnectionID(t *testing.T) { + id := NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ConnectionName != "connectionName" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectionName'", id.ConnectionName, "connectionName") + } +} + +func TestFormatConnectionID(t *testing.T) { + actual := NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/connections/connectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/connections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/connections/connectionName", + Expected: &ConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectionName: "connectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/connections/connectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectionName != v.Expected.ConnectionName { + t.Fatalf("Expected %q but got %q for ConnectionName", v.Expected.ConnectionName, actual.ConnectionName) + } + + } +} + +func TestParseConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/connections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/cOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/connections/connectionName", + Expected: &ConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectionName: "connectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/connections/connectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/cOnNeCtIoNs/cOnNeCtIoNnAmE", + Expected: &ConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ConnectionName: "cOnNeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/cOnNeCtIoNs/cOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectionName != v.Expected.ConnectionName { + t.Fatalf("Expected %q but got %q for ConnectionName", v.Expected.ConnectionName, actual.ConnectionName) + } + + } +} + +func TestSegmentsForConnectionId(t *testing.T) { + segments := ConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_createorupdate.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_createorupdate.go new file mode 100644 index 00000000000..2c95ee84254 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_createorupdate.go @@ -0,0 +1,75 @@ +package virtualnetworkgatewayconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetworkGatewayConnection +} + +// CreateOrUpdate ... +func (c VirtualNetworkGatewayConnectionsClient) CreateOrUpdate(ctx context.Context, id ConnectionId, input VirtualNetworkGatewayConnection) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c VirtualNetworkGatewayConnectionsClient) CreateOrUpdateThenPoll(ctx context.Context, id ConnectionId, input VirtualNetworkGatewayConnection) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_delete.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_delete.go new file mode 100644 index 00000000000..4d46161ff40 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_delete.go @@ -0,0 +1,71 @@ +package virtualnetworkgatewayconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c VirtualNetworkGatewayConnectionsClient) Delete(ctx context.Context, id ConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c VirtualNetworkGatewayConnectionsClient) DeleteThenPoll(ctx context.Context, id ConnectionId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_get.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_get.go new file mode 100644 index 00000000000..842bab814e9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_get.go @@ -0,0 +1,53 @@ +package virtualnetworkgatewayconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetworkGatewayConnection +} + +// Get ... +func (c VirtualNetworkGatewayConnectionsClient) Get(ctx context.Context, id ConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualNetworkGatewayConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_getikesas.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_getikesas.go new file mode 100644 index 00000000000..f146120f19e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_getikesas.go @@ -0,0 +1,71 @@ +package virtualnetworkgatewayconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetIkeSasOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// GetIkeSas ... +func (c VirtualNetworkGatewayConnectionsClient) GetIkeSas(ctx context.Context, id ConnectionId) (result GetIkeSasOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getikesas", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetIkeSasThenPoll performs GetIkeSas then polls until it's completed +func (c VirtualNetworkGatewayConnectionsClient) GetIkeSasThenPoll(ctx context.Context, id ConnectionId) error { + result, err := c.GetIkeSas(ctx, id) + if err != nil { + return fmt.Errorf("performing GetIkeSas: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetIkeSas: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_getsharedkey.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_getsharedkey.go new file mode 100644 index 00000000000..3606b2efb65 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_getsharedkey.go @@ -0,0 +1,54 @@ +package virtualnetworkgatewayconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSharedKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionSharedKey +} + +// GetSharedKey ... +func (c VirtualNetworkGatewayConnectionsClient) GetSharedKey(ctx context.Context, id ConnectionId) (result GetSharedKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sharedkey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectionSharedKey + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_list.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_list.go new file mode 100644 index 00000000000..34dc525dce4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_list.go @@ -0,0 +1,106 @@ +package virtualnetworkgatewayconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualNetworkGatewayConnection +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualNetworkGatewayConnection +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c VirtualNetworkGatewayConnectionsClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/connections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualNetworkGatewayConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c VirtualNetworkGatewayConnectionsClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, VirtualNetworkGatewayConnectionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualNetworkGatewayConnectionsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate VirtualNetworkGatewayConnectionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]VirtualNetworkGatewayConnection, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_resetconnection.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_resetconnection.go new file mode 100644 index 00000000000..7898a434030 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_resetconnection.go @@ -0,0 +1,69 @@ +package virtualnetworkgatewayconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResetConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ResetConnection ... +func (c VirtualNetworkGatewayConnectionsClient) ResetConnection(ctx context.Context, id ConnectionId) (result ResetConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetconnection", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResetConnectionThenPoll performs ResetConnection then polls until it's completed +func (c VirtualNetworkGatewayConnectionsClient) ResetConnectionThenPoll(ctx context.Context, id ConnectionId) error { + result, err := c.ResetConnection(ctx, id) + if err != nil { + return fmt.Errorf("performing ResetConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResetConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_resetsharedkey.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_resetsharedkey.go new file mode 100644 index 00000000000..37c842b0ba1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_resetsharedkey.go @@ -0,0 +1,75 @@ +package virtualnetworkgatewayconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResetSharedKeyOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionResetSharedKey +} + +// ResetSharedKey ... +func (c VirtualNetworkGatewayConnectionsClient) ResetSharedKey(ctx context.Context, id ConnectionId, input ConnectionResetSharedKey) (result ResetSharedKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sharedkey/reset", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResetSharedKeyThenPoll performs ResetSharedKey then polls until it's completed +func (c VirtualNetworkGatewayConnectionsClient) ResetSharedKeyThenPoll(ctx context.Context, id ConnectionId, input ConnectionResetSharedKey) error { + result, err := c.ResetSharedKey(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ResetSharedKey: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResetSharedKey: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_setsharedkey.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_setsharedkey.go new file mode 100644 index 00000000000..7cce553c953 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_setsharedkey.go @@ -0,0 +1,75 @@ +package virtualnetworkgatewayconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SetSharedKeyOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionSharedKey +} + +// SetSharedKey ... +func (c VirtualNetworkGatewayConnectionsClient) SetSharedKey(ctx context.Context, id ConnectionId, input ConnectionSharedKey) (result SetSharedKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/sharedkey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SetSharedKeyThenPoll performs SetSharedKey then polls until it's completed +func (c VirtualNetworkGatewayConnectionsClient) SetSharedKeyThenPoll(ctx context.Context, id ConnectionId, input ConnectionSharedKey) error { + result, err := c.SetSharedKey(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SetSharedKey: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SetSharedKey: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_startpacketcapture.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_startpacketcapture.go new file mode 100644 index 00000000000..d0bd4f6819d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_startpacketcapture.go @@ -0,0 +1,75 @@ +package virtualnetworkgatewayconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartPacketCaptureOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// StartPacketCapture ... +func (c VirtualNetworkGatewayConnectionsClient) StartPacketCapture(ctx context.Context, id ConnectionId, input VpnPacketCaptureStartParameters) (result StartPacketCaptureOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startPacketCapture", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StartPacketCaptureThenPoll performs StartPacketCapture then polls until it's completed +func (c VirtualNetworkGatewayConnectionsClient) StartPacketCaptureThenPoll(ctx context.Context, id ConnectionId, input VpnPacketCaptureStartParameters) error { + result, err := c.StartPacketCapture(ctx, id, input) + if err != nil { + return fmt.Errorf("performing StartPacketCapture: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartPacketCapture: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_stoppacketcapture.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_stoppacketcapture.go new file mode 100644 index 00000000000..8741b058a40 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_stoppacketcapture.go @@ -0,0 +1,75 @@ +package virtualnetworkgatewayconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopPacketCaptureOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// StopPacketCapture ... +func (c VirtualNetworkGatewayConnectionsClient) StopPacketCapture(ctx context.Context, id ConnectionId, input VpnPacketCaptureStopParameters) (result StopPacketCaptureOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stopPacketCapture", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StopPacketCaptureThenPoll performs StopPacketCapture then polls until it's completed +func (c VirtualNetworkGatewayConnectionsClient) StopPacketCaptureThenPoll(ctx context.Context, id ConnectionId, input VpnPacketCaptureStopParameters) error { + result, err := c.StopPacketCapture(ctx, id, input) + if err != nil { + return fmt.Errorf("performing StopPacketCapture: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StopPacketCapture: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_updatetags.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_updatetags.go new file mode 100644 index 00000000000..6a0ba8aaae8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/method_updatetags.go @@ -0,0 +1,75 @@ +package virtualnetworkgatewayconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetworkGatewayConnection +} + +// UpdateTags ... +func (c VirtualNetworkGatewayConnectionsClient) UpdateTags(ctx context.Context, id ConnectionId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateTagsThenPoll performs UpdateTags then polls until it's completed +func (c VirtualNetworkGatewayConnectionsClient) UpdateTagsThenPoll(ctx context.Context, id ConnectionId, input TagsObject) error { + result, err := c.UpdateTags(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UpdateTags: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpdateTags: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_addressspace.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_addressspace.go new file mode 100644 index 00000000000..190d97ceec9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_addressspace.go @@ -0,0 +1,9 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressSpace struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_bgpsettings.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_bgpsettings.go new file mode 100644 index 00000000000..e03680282e6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_bgpsettings.go @@ -0,0 +1,11 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BgpSettings struct { + Asn *int64 `json:"asn,omitempty"` + BgpPeeringAddress *string `json:"bgpPeeringAddress,omitempty"` + BgpPeeringAddresses *[]IPConfigurationBgpPeeringAddress `json:"bgpPeeringAddresses,omitempty"` + PeerWeight *int64 `json:"peerWeight,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_connectionresetsharedkey.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_connectionresetsharedkey.go new file mode 100644 index 00000000000..3e1887b9d36 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_connectionresetsharedkey.go @@ -0,0 +1,8 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionResetSharedKey struct { + KeyLength int64 `json:"keyLength"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_connectionsharedkey.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_connectionsharedkey.go new file mode 100644 index 00000000000..069812d03a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_connectionsharedkey.go @@ -0,0 +1,9 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionSharedKey struct { + Id *string `json:"id,omitempty"` + Value string `json:"value"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_gatewaycustombgpipaddressipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_gatewaycustombgpipaddressipconfiguration.go new file mode 100644 index 00000000000..7fda76a8317 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_gatewaycustombgpipaddressipconfiguration.go @@ -0,0 +1,9 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayCustomBgpIPAddressIPConfiguration struct { + CustomBgpIPAddress string `json:"customBgpIpAddress"` + IPConfigurationId string `json:"ipConfigurationId"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..b893f772d9c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..8aa24adb071 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_ipconfigurationbgppeeringaddress.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_ipconfigurationbgppeeringaddress.go new file mode 100644 index 00000000000..dd6001591ee --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_ipconfigurationbgppeeringaddress.go @@ -0,0 +1,11 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationBgpPeeringAddress struct { + CustomBgpIPAddresses *[]string `json:"customBgpIpAddresses,omitempty"` + DefaultBgpIPAddresses *[]string `json:"defaultBgpIpAddresses,omitempty"` + IPconfigurationId *string `json:"ipconfigurationId,omitempty"` + TunnelIPAddresses *[]string `json:"tunnelIpAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_ipsecpolicy.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_ipsecpolicy.go new file mode 100644 index 00000000000..e36e053ac75 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_ipsecpolicy.go @@ -0,0 +1,15 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPsecPolicy struct { + DhGroup DhGroup `json:"dhGroup"` + IPsecEncryption IPsecEncryption `json:"ipsecEncryption"` + IPsecIntegrity IPsecIntegrity `json:"ipsecIntegrity"` + IkeEncryption IkeEncryption `json:"ikeEncryption"` + IkeIntegrity IkeIntegrity `json:"ikeIntegrity"` + PfsGroup PfsGroup `json:"pfsGroup"` + SaDataSizeKilobytes int64 `json:"saDataSizeKilobytes"` + SaLifeTimeSeconds int64 `json:"saLifeTimeSeconds"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_localnetworkgateway.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_localnetworkgateway.go new file mode 100644 index 00000000000..9ddafdd0d6e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_localnetworkgateway.go @@ -0,0 +1,14 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalNetworkGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties LocalNetworkGatewayPropertiesFormat `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_localnetworkgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_localnetworkgatewaypropertiesformat.go new file mode 100644 index 00000000000..bf0176c3023 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_localnetworkgatewaypropertiesformat.go @@ -0,0 +1,13 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalNetworkGatewayPropertiesFormat struct { + BgpSettings *BgpSettings `json:"bgpSettings,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + GatewayIPAddress *string `json:"gatewayIpAddress,omitempty"` + LocalNetworkAddressSpace *AddressSpace `json:"localNetworkAddressSpace,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_radiusserver.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_radiusserver.go new file mode 100644 index 00000000000..ffc93e64965 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_radiusserver.go @@ -0,0 +1,10 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RadiusServer struct { + RadiusServerAddress string `json:"radiusServerAddress"` + RadiusServerScore *int64 `json:"radiusServerScore,omitempty"` + RadiusServerSecret *string `json:"radiusServerSecret,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_subresource.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_subresource.go new file mode 100644 index 00000000000..25e6382622d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_subresource.go @@ -0,0 +1,8 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_tagsobject.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_tagsobject.go new file mode 100644 index 00000000000..5f1bce5d03d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_tagsobject.go @@ -0,0 +1,8 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_trafficselectorpolicy.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_trafficselectorpolicy.go new file mode 100644 index 00000000000..7d824402850 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_trafficselectorpolicy.go @@ -0,0 +1,9 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficSelectorPolicy struct { + LocalAddressRanges []string `json:"localAddressRanges"` + RemoteAddressRanges []string `json:"remoteAddressRanges"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_tunnelconnectionhealth.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_tunnelconnectionhealth.go new file mode 100644 index 00000000000..71722a9b5e7 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_tunnelconnectionhealth.go @@ -0,0 +1,12 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TunnelConnectionHealth struct { + ConnectionStatus *VirtualNetworkGatewayConnectionStatus `json:"connectionStatus,omitempty"` + EgressBytesTransferred *int64 `json:"egressBytesTransferred,omitempty"` + IngressBytesTransferred *int64 `json:"ingressBytesTransferred,omitempty"` + LastConnectionEstablishedUtcTime *string `json:"lastConnectionEstablishedUtcTime,omitempty"` + Tunnel *string `json:"tunnel,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgateway.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgateway.go new file mode 100644 index 00000000000..4fc1211e31d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgateway.go @@ -0,0 +1,21 @@ +package virtualnetworkgatewayconnections + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGateway struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties VirtualNetworkGatewayPropertiesFormat `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayautoscalebounds.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayautoscalebounds.go new file mode 100644 index 00000000000..1c546e60aa6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayautoscalebounds.go @@ -0,0 +1,9 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayAutoScaleBounds struct { + Max *int64 `json:"max,omitempty"` + Min *int64 `json:"min,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayautoscaleconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayautoscaleconfiguration.go new file mode 100644 index 00000000000..5fd318f0446 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayautoscaleconfiguration.go @@ -0,0 +1,8 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayAutoScaleConfiguration struct { + Bounds *VirtualNetworkGatewayAutoScaleBounds `json:"bounds,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayconnection.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayconnection.go new file mode 100644 index 00000000000..05a6ea7eb90 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayconnection.go @@ -0,0 +1,14 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties VirtualNetworkGatewayConnectionPropertiesFormat `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayconnectionpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayconnectionpropertiesformat.go new file mode 100644 index 00000000000..1ea5dfc5338 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayconnectionpropertiesformat.go @@ -0,0 +1,35 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayConnectionPropertiesFormat struct { + AuthorizationKey *string `json:"authorizationKey,omitempty"` + ConnectionMode *VirtualNetworkGatewayConnectionMode `json:"connectionMode,omitempty"` + ConnectionProtocol *VirtualNetworkGatewayConnectionProtocol `json:"connectionProtocol,omitempty"` + ConnectionStatus *VirtualNetworkGatewayConnectionStatus `json:"connectionStatus,omitempty"` + ConnectionType VirtualNetworkGatewayConnectionType `json:"connectionType"` + DpdTimeoutSeconds *int64 `json:"dpdTimeoutSeconds,omitempty"` + EgressBytesTransferred *int64 `json:"egressBytesTransferred,omitempty"` + EgressNatRules *[]SubResource `json:"egressNatRules,omitempty"` + EnableBgp *bool `json:"enableBgp,omitempty"` + EnablePrivateLinkFastPath *bool `json:"enablePrivateLinkFastPath,omitempty"` + ExpressRouteGatewayBypass *bool `json:"expressRouteGatewayBypass,omitempty"` + GatewayCustomBgpIPAddresses *[]GatewayCustomBgpIPAddressIPConfiguration `json:"gatewayCustomBgpIpAddresses,omitempty"` + IPsecPolicies *[]IPsecPolicy `json:"ipsecPolicies,omitempty"` + IngressBytesTransferred *int64 `json:"ingressBytesTransferred,omitempty"` + IngressNatRules *[]SubResource `json:"ingressNatRules,omitempty"` + LocalNetworkGateway2 *LocalNetworkGateway `json:"localNetworkGateway2,omitempty"` + Peer *SubResource `json:"peer,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + RoutingWeight *int64 `json:"routingWeight,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` + TrafficSelectorPolicies *[]TrafficSelectorPolicy `json:"trafficSelectorPolicies,omitempty"` + TunnelConnectionStatus *[]TunnelConnectionHealth `json:"tunnelConnectionStatus,omitempty"` + TunnelProperties *[]VirtualNetworkGatewayConnectionTunnelProperties `json:"tunnelProperties,omitempty"` + UseLocalAzureIPAddress *bool `json:"useLocalAzureIpAddress,omitempty"` + UsePolicyBasedTrafficSelectors *bool `json:"usePolicyBasedTrafficSelectors,omitempty"` + VirtualNetworkGateway1 VirtualNetworkGateway `json:"virtualNetworkGateway1"` + VirtualNetworkGateway2 *VirtualNetworkGateway `json:"virtualNetworkGateway2,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayconnectiontunnelproperties.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayconnectiontunnelproperties.go new file mode 100644 index 00000000000..5df3e8f46cd --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayconnectiontunnelproperties.go @@ -0,0 +1,9 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayConnectionTunnelProperties struct { + BgpPeeringAddress *string `json:"bgpPeeringAddress,omitempty"` + TunnelIPAddress *string `json:"tunnelIpAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayipconfiguration.go new file mode 100644 index 00000000000..30467eb2ed1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayipconfiguration.go @@ -0,0 +1,11 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..863c3769296 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayIPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *SubResource `json:"publicIPAddress,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaymigrationstatus.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaymigrationstatus.go new file mode 100644 index 00000000000..fcc16d0da39 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaymigrationstatus.go @@ -0,0 +1,10 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayMigrationStatus struct { + ErrorMessage *string `json:"errorMessage,omitempty"` + Phase *VirtualNetworkGatewayMigrationPhase `json:"phase,omitempty"` + State *VirtualNetworkGatewayMigrationState `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaynatrule.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaynatrule.go new file mode 100644 index 00000000000..ff6c91b0d66 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaynatrule.go @@ -0,0 +1,12 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkGatewayNatRuleProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaynatruleproperties.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaynatruleproperties.go new file mode 100644 index 00000000000..75185bb4a84 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaynatruleproperties.go @@ -0,0 +1,13 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayNatRuleProperties struct { + ExternalMappings *[]VpnNatRuleMapping `json:"externalMappings,omitempty"` + IPConfigurationId *string `json:"ipConfigurationId,omitempty"` + InternalMappings *[]VpnNatRuleMapping `json:"internalMappings,omitempty"` + Mode *VpnNatRuleMode `json:"mode,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Type *VpnNatRuleType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaypolicygroup.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaypolicygroup.go new file mode 100644 index 00000000000..cd507b1d533 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaypolicygroup.go @@ -0,0 +1,11 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayPolicyGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkGatewayPolicyGroupProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaypolicygroupmember.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaypolicygroupmember.go new file mode 100644 index 00000000000..632e3bda52f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaypolicygroupmember.go @@ -0,0 +1,10 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayPolicyGroupMember struct { + AttributeType *VpnPolicyMemberAttributeType `json:"attributeType,omitempty"` + AttributeValue *string `json:"attributeValue,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaypolicygroupproperties.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaypolicygroupproperties.go new file mode 100644 index 00000000000..6b20992105c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaypolicygroupproperties.go @@ -0,0 +1,12 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayPolicyGroupProperties struct { + IsDefault bool `json:"isDefault"` + PolicyMembers []VirtualNetworkGatewayPolicyGroupMember `json:"policyMembers"` + Priority int64 `json:"priority"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VngClientConnectionConfigurations *[]SubResource `json:"vngClientConnectionConfigurations,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaypropertiesformat.go new file mode 100644 index 00000000000..8172fe5ce21 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaypropertiesformat.go @@ -0,0 +1,35 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayPropertiesFormat struct { + ActiveActive *bool `json:"activeActive,omitempty"` + AdminState *AdminState `json:"adminState,omitempty"` + AllowRemoteVnetTraffic *bool `json:"allowRemoteVnetTraffic,omitempty"` + AllowVirtualWanTraffic *bool `json:"allowVirtualWanTraffic,omitempty"` + AutoScaleConfiguration *VirtualNetworkGatewayAutoScaleConfiguration `json:"autoScaleConfiguration,omitempty"` + BgpSettings *BgpSettings `json:"bgpSettings,omitempty"` + CustomRoutes *AddressSpace `json:"customRoutes,omitempty"` + DisableIPSecReplayProtection *bool `json:"disableIPSecReplayProtection,omitempty"` + EnableBgp *bool `json:"enableBgp,omitempty"` + EnableBgpRouteTranslationForNat *bool `json:"enableBgpRouteTranslationForNat,omitempty"` + EnableDnsForwarding *bool `json:"enableDnsForwarding,omitempty"` + EnableHighBandwidthVpnGateway *bool `json:"enableHighBandwidthVpnGateway,omitempty"` + EnablePrivateIPAddress *bool `json:"enablePrivateIpAddress,omitempty"` + GatewayDefaultSite *SubResource `json:"gatewayDefaultSite,omitempty"` + GatewayType *VirtualNetworkGatewayType `json:"gatewayType,omitempty"` + IPConfigurations *[]VirtualNetworkGatewayIPConfiguration `json:"ipConfigurations,omitempty"` + InboundDnsForwardingEndpoint *string `json:"inboundDnsForwardingEndpoint,omitempty"` + NatRules *[]VirtualNetworkGatewayNatRule `json:"natRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResiliencyModel *ResiliencyModel `json:"resiliencyModel,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Sku *VirtualNetworkGatewaySku `json:"sku,omitempty"` + VNetExtendedLocationResourceId *string `json:"vNetExtendedLocationResourceId,omitempty"` + VirtualNetworkGatewayMigrationStatus *VirtualNetworkGatewayMigrationStatus `json:"virtualNetworkGatewayMigrationStatus,omitempty"` + VirtualNetworkGatewayPolicyGroups *[]VirtualNetworkGatewayPolicyGroup `json:"virtualNetworkGatewayPolicyGroups,omitempty"` + VpnClientConfiguration *VpnClientConfiguration `json:"vpnClientConfiguration,omitempty"` + VpnGatewayGeneration *VpnGatewayGeneration `json:"vpnGatewayGeneration,omitempty"` + VpnType *VpnType `json:"vpnType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaysku.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaysku.go new file mode 100644 index 00000000000..301f66896ac --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_virtualnetworkgatewaysku.go @@ -0,0 +1,10 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewaySku struct { + Capacity *int64 `json:"capacity,omitempty"` + Name *VirtualNetworkGatewaySkuName `json:"name,omitempty"` + Tier *VirtualNetworkGatewaySkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vngclientconnectionconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vngclientconnectionconfiguration.go new file mode 100644 index 00000000000..744d5505a17 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vngclientconnectionconfiguration.go @@ -0,0 +1,11 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VngClientConnectionConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VngClientConnectionConfigurationProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vngclientconnectionconfigurationproperties.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vngclientconnectionconfigurationproperties.go new file mode 100644 index 00000000000..531c18a0419 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vngclientconnectionconfigurationproperties.go @@ -0,0 +1,10 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VngClientConnectionConfigurationProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkGatewayPolicyGroups []SubResource `json:"virtualNetworkGatewayPolicyGroups"` + VpnClientAddressPool AddressSpace `json:"vpnClientAddressPool"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnclientconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnclientconfiguration.go new file mode 100644 index 00000000000..f7da3943c5a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnclientconfiguration.go @@ -0,0 +1,20 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnClientConfiguration struct { + AadAudience *string `json:"aadAudience,omitempty"` + AadIssuer *string `json:"aadIssuer,omitempty"` + AadTenant *string `json:"aadTenant,omitempty"` + RadiusServerAddress *string `json:"radiusServerAddress,omitempty"` + RadiusServerSecret *string `json:"radiusServerSecret,omitempty"` + RadiusServers *[]RadiusServer `json:"radiusServers,omitempty"` + VngClientConnectionConfigurations *[]VngClientConnectionConfiguration `json:"vngClientConnectionConfigurations,omitempty"` + VpnAuthenticationTypes *[]VpnAuthenticationType `json:"vpnAuthenticationTypes,omitempty"` + VpnClientAddressPool *AddressSpace `json:"vpnClientAddressPool,omitempty"` + VpnClientIPsecPolicies *[]IPsecPolicy `json:"vpnClientIpsecPolicies,omitempty"` + VpnClientProtocols *[]VpnClientProtocol `json:"vpnClientProtocols,omitempty"` + VpnClientRevokedCertificates *[]VpnClientRevokedCertificate `json:"vpnClientRevokedCertificates,omitempty"` + VpnClientRootCertificates *[]VpnClientRootCertificate `json:"vpnClientRootCertificates,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnclientrevokedcertificate.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnclientrevokedcertificate.go new file mode 100644 index 00000000000..7f83a9053a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnclientrevokedcertificate.go @@ -0,0 +1,11 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnClientRevokedCertificate struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnClientRevokedCertificatePropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnclientrevokedcertificatepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnclientrevokedcertificatepropertiesformat.go new file mode 100644 index 00000000000..0155228d4d1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnclientrevokedcertificatepropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnClientRevokedCertificatePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnclientrootcertificate.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnclientrootcertificate.go new file mode 100644 index 00000000000..6eb8d073f4f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnclientrootcertificate.go @@ -0,0 +1,11 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnClientRootCertificate struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties VpnClientRootCertificatePropertiesFormat `json:"properties"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnclientrootcertificatepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnclientrootcertificatepropertiesformat.go new file mode 100644 index 00000000000..f5048e1ed78 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnclientrootcertificatepropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnClientRootCertificatePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicCertData string `json:"publicCertData"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnnatrulemapping.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnnatrulemapping.go new file mode 100644 index 00000000000..394cabc619d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnnatrulemapping.go @@ -0,0 +1,9 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnNatRuleMapping struct { + AddressSpace *string `json:"addressSpace,omitempty"` + PortRange *string `json:"portRange,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnpacketcapturestartparameters.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnpacketcapturestartparameters.go new file mode 100644 index 00000000000..52273329f1d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnpacketcapturestartparameters.go @@ -0,0 +1,8 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnPacketCaptureStartParameters struct { + FilterData *string `json:"filterData,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnpacketcapturestopparameters.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnpacketcapturestopparameters.go new file mode 100644 index 00000000000..34b83087000 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/model_vpnpacketcapturestopparameters.go @@ -0,0 +1,8 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnPacketCaptureStopParameters struct { + SasURL *string `json:"sasUrl,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/predicates.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/predicates.go new file mode 100644 index 00000000000..c1fe558dd66 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/predicates.go @@ -0,0 +1,37 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayConnectionOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p VirtualNetworkGatewayConnectionOperationPredicate) Matches(input VirtualNetworkGatewayConnection) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/version.go b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/version.go new file mode 100644 index 00000000000..dbc5f05c535 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgatewayconnections/version.go @@ -0,0 +1,10 @@ +package virtualnetworkgatewayconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/virtualnetworkgatewayconnections/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/README.md b/resource-manager/network/2024-07-01/virtualnetworkgateways/README.md new file mode 100644 index 00000000000..e51cab437b3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/README.md @@ -0,0 +1,544 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworkgateways` Documentation + +The `virtualnetworkgateways` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworkgateways" +``` + + +### Client Initialization + +```go +client := virtualnetworkgateways.NewVirtualNetworkGatewaysClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +payload := virtualnetworkgateways.VirtualNetworkGateway{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.Delete` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.DisconnectVirtualNetworkGatewayVpnConnections` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +payload := virtualnetworkgateways.P2SVpnConnectionRequest{ + // ... +} + + +if err := client.DisconnectVirtualNetworkGatewayVpnConnectionsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.GenerateVpnProfile` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +payload := virtualnetworkgateways.VpnClientParameters{ + // ... +} + + +if err := client.GenerateVpnProfileThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.Generatevpnclientpackage` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +payload := virtualnetworkgateways.VpnClientParameters{ + // ... +} + + +if err := client.GeneratevpnclientpackageThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.Get` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.GetAdvertisedRoutes` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +if err := client.GetAdvertisedRoutesThenPoll(ctx, id, virtualnetworkgateways.DefaultGetAdvertisedRoutesOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.GetBgpPeerStatus` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +if err := client.GetBgpPeerStatusThenPoll(ctx, id, virtualnetworkgateways.DefaultGetBgpPeerStatusOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.GetFailoverAllTestDetails` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +if err := client.GetFailoverAllTestDetailsThenPoll(ctx, id, virtualnetworkgateways.DefaultGetFailoverAllTestDetailsOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.GetFailoverSingleTestDetails` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +if err := client.GetFailoverSingleTestDetailsThenPoll(ctx, id, virtualnetworkgateways.DefaultGetFailoverSingleTestDetailsOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.GetLearnedRoutes` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +if err := client.GetLearnedRoutesThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.GetResiliencyInformation` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +if err := client.GetResiliencyInformationThenPoll(ctx, id, virtualnetworkgateways.DefaultGetResiliencyInformationOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.GetRoutesInformation` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +if err := client.GetRoutesInformationThenPoll(ctx, id, virtualnetworkgateways.DefaultGetRoutesInformationOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.GetVpnProfilePackageURL` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +if err := client.GetVpnProfilePackageURLThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.GetVpnclientConnectionHealth` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +if err := client.GetVpnclientConnectionHealthThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.GetVpnclientIPsecParameters` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +if err := client.GetVpnclientIPsecParametersThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.ListConnections` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +// alternatively `client.ListConnections(ctx, id)` can be used to do batched pagination +items, err := client.ListConnectionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.Reset` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +if err := client.ResetThenPoll(ctx, id, virtualnetworkgateways.DefaultResetOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.ResetVpnClientSharedKey` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +if err := client.ResetVpnClientSharedKeyThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.SetVpnclientIPsecParameters` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +payload := virtualnetworkgateways.VpnClientIPsecParameters{ + // ... +} + + +if err := client.SetVpnclientIPsecParametersThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.StartExpressRouteSiteFailoverSimulation` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +if err := client.StartExpressRouteSiteFailoverSimulationThenPoll(ctx, id, virtualnetworkgateways.DefaultStartExpressRouteSiteFailoverSimulationOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.StartPacketCapture` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +payload := virtualnetworkgateways.VpnPacketCaptureStartParameters{ + // ... +} + + +if err := client.StartPacketCaptureThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.StopExpressRouteSiteFailoverSimulation` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +payload := virtualnetworkgateways.ExpressRouteFailoverStopApiParameters{ + // ... +} + + +if err := client.StopExpressRouteSiteFailoverSimulationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.StopPacketCapture` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +payload := virtualnetworkgateways.VpnPacketCaptureStopParameters{ + // ... +} + + +if err := client.StopPacketCaptureThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.SupportedVpnDevices` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +read, err := client.SupportedVpnDevices(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.UpdateTags` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +payload := virtualnetworkgateways.TagsObject{ + // ... +} + + +if err := client.UpdateTagsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.VirtualNetworkGatewayNatRulesCreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayNatRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName", "natRuleName") + +payload := virtualnetworkgateways.VirtualNetworkGatewayNatRule{ + // ... +} + + +if err := client.VirtualNetworkGatewayNatRulesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.VirtualNetworkGatewayNatRulesDelete` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayNatRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName", "natRuleName") + +if err := client.VirtualNetworkGatewayNatRulesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.VirtualNetworkGatewayNatRulesGet` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayNatRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName", "natRuleName") + +read, err := client.VirtualNetworkGatewayNatRulesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.VirtualNetworkGatewayNatRulesListByVirtualNetworkGateway` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +// alternatively `client.VirtualNetworkGatewayNatRulesListByVirtualNetworkGateway(ctx, id)` can be used to do batched pagination +items, err := client.VirtualNetworkGatewayNatRulesListByVirtualNetworkGatewayComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.VirtualNetworkGatewaysInvokeAbortMigration` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +if err := client.VirtualNetworkGatewaysInvokeAbortMigrationThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.VirtualNetworkGatewaysInvokeCommitMigration` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +if err := client.VirtualNetworkGatewaysInvokeCommitMigrationThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.VirtualNetworkGatewaysInvokeExecuteMigration` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +if err := client.VirtualNetworkGatewaysInvokeExecuteMigrationThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.VirtualNetworkGatewaysInvokePrepareMigration` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + +payload := virtualnetworkgateways.VirtualNetworkGatewayMigrationParameters{ + // ... +} + + +if err := client.VirtualNetworkGatewaysInvokePrepareMigrationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkGatewaysClient.VpnDeviceConfigurationScript` + +```go +ctx := context.TODO() +id := virtualnetworkgateways.NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectionName") + +payload := virtualnetworkgateways.VpnDeviceScriptParameters{ + // ... +} + + +read, err := client.VpnDeviceConfigurationScript(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/client.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/client.go new file mode 100644 index 00000000000..56907b3d1b4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/client.go @@ -0,0 +1,26 @@ +package virtualnetworkgateways + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewaysClient struct { + Client *resourcemanager.Client +} + +func NewVirtualNetworkGatewaysClientWithBaseURI(sdkApi sdkEnv.Api) (*VirtualNetworkGatewaysClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "virtualnetworkgateways", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VirtualNetworkGatewaysClient: %+v", err) + } + + return &VirtualNetworkGatewaysClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/constants.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/constants.go new file mode 100644 index 00000000000..4fcc296b0e2 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/constants.go @@ -0,0 +1,1713 @@ +package virtualnetworkgateways + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AdminState string + +const ( + AdminStateDisabled AdminState = "Disabled" + AdminStateEnabled AdminState = "Enabled" +) + +func PossibleValuesForAdminState() []string { + return []string{ + string(AdminStateDisabled), + string(AdminStateEnabled), + } +} + +func (s *AdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAdminState(input string) (*AdminState, error) { + vals := map[string]AdminState{ + "disabled": AdminStateDisabled, + "enabled": AdminStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AdminState(input) + return &out, nil +} + +type AuthenticationMethod string + +const ( + AuthenticationMethodEAPMSCHAPvTwo AuthenticationMethod = "EAPMSCHAPv2" + AuthenticationMethodEAPTLS AuthenticationMethod = "EAPTLS" +) + +func PossibleValuesForAuthenticationMethod() []string { + return []string{ + string(AuthenticationMethodEAPMSCHAPvTwo), + string(AuthenticationMethodEAPTLS), + } +} + +func (s *AuthenticationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationMethod(input string) (*AuthenticationMethod, error) { + vals := map[string]AuthenticationMethod{ + "eapmschapv2": AuthenticationMethodEAPMSCHAPvTwo, + "eaptls": AuthenticationMethodEAPTLS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationMethod(input) + return &out, nil +} + +type BgpPeerState string + +const ( + BgpPeerStateConnected BgpPeerState = "Connected" + BgpPeerStateConnecting BgpPeerState = "Connecting" + BgpPeerStateIdle BgpPeerState = "Idle" + BgpPeerStateStopped BgpPeerState = "Stopped" + BgpPeerStateUnknown BgpPeerState = "Unknown" +) + +func PossibleValuesForBgpPeerState() []string { + return []string{ + string(BgpPeerStateConnected), + string(BgpPeerStateConnecting), + string(BgpPeerStateIdle), + string(BgpPeerStateStopped), + string(BgpPeerStateUnknown), + } +} + +func (s *BgpPeerState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBgpPeerState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBgpPeerState(input string) (*BgpPeerState, error) { + vals := map[string]BgpPeerState{ + "connected": BgpPeerStateConnected, + "connecting": BgpPeerStateConnecting, + "idle": BgpPeerStateIdle, + "stopped": BgpPeerStateStopped, + "unknown": BgpPeerStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BgpPeerState(input) + return &out, nil +} + +type DhGroup string + +const ( + DhGroupDHGroupOne DhGroup = "DHGroup1" + DhGroupDHGroupOneFour DhGroup = "DHGroup14" + DhGroupDHGroupTwo DhGroup = "DHGroup2" + DhGroupDHGroupTwoFour DhGroup = "DHGroup24" + DhGroupDHGroupTwoZeroFourEight DhGroup = "DHGroup2048" + DhGroupECPThreeEightFour DhGroup = "ECP384" + DhGroupECPTwoFiveSix DhGroup = "ECP256" + DhGroupNone DhGroup = "None" +) + +func PossibleValuesForDhGroup() []string { + return []string{ + string(DhGroupDHGroupOne), + string(DhGroupDHGroupOneFour), + string(DhGroupDHGroupTwo), + string(DhGroupDHGroupTwoFour), + string(DhGroupDHGroupTwoZeroFourEight), + string(DhGroupECPThreeEightFour), + string(DhGroupECPTwoFiveSix), + string(DhGroupNone), + } +} + +func (s *DhGroup) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDhGroup(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDhGroup(input string) (*DhGroup, error) { + vals := map[string]DhGroup{ + "dhgroup1": DhGroupDHGroupOne, + "dhgroup14": DhGroupDHGroupOneFour, + "dhgroup2": DhGroupDHGroupTwo, + "dhgroup24": DhGroupDHGroupTwoFour, + "dhgroup2048": DhGroupDHGroupTwoZeroFourEight, + "ecp384": DhGroupECPThreeEightFour, + "ecp256": DhGroupECPTwoFiveSix, + "none": DhGroupNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DhGroup(input) + return &out, nil +} + +type FailoverConnectionStatus string + +const ( + FailoverConnectionStatusConnected FailoverConnectionStatus = "Connected" + FailoverConnectionStatusDisconnected FailoverConnectionStatus = "Disconnected" +) + +func PossibleValuesForFailoverConnectionStatus() []string { + return []string{ + string(FailoverConnectionStatusConnected), + string(FailoverConnectionStatusDisconnected), + } +} + +func (s *FailoverConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFailoverConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFailoverConnectionStatus(input string) (*FailoverConnectionStatus, error) { + vals := map[string]FailoverConnectionStatus{ + "connected": FailoverConnectionStatusConnected, + "disconnected": FailoverConnectionStatusDisconnected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FailoverConnectionStatus(input) + return &out, nil +} + +type FailoverTestStatus string + +const ( + FailoverTestStatusCompleted FailoverTestStatus = "Completed" + FailoverTestStatusExpired FailoverTestStatus = "Expired" + FailoverTestStatusInvalid FailoverTestStatus = "Invalid" + FailoverTestStatusNotStarted FailoverTestStatus = "NotStarted" + FailoverTestStatusRunning FailoverTestStatus = "Running" + FailoverTestStatusStartFailed FailoverTestStatus = "StartFailed" + FailoverTestStatusStarting FailoverTestStatus = "Starting" + FailoverTestStatusStopFailed FailoverTestStatus = "StopFailed" + FailoverTestStatusStopping FailoverTestStatus = "Stopping" +) + +func PossibleValuesForFailoverTestStatus() []string { + return []string{ + string(FailoverTestStatusCompleted), + string(FailoverTestStatusExpired), + string(FailoverTestStatusInvalid), + string(FailoverTestStatusNotStarted), + string(FailoverTestStatusRunning), + string(FailoverTestStatusStartFailed), + string(FailoverTestStatusStarting), + string(FailoverTestStatusStopFailed), + string(FailoverTestStatusStopping), + } +} + +func (s *FailoverTestStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFailoverTestStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFailoverTestStatus(input string) (*FailoverTestStatus, error) { + vals := map[string]FailoverTestStatus{ + "completed": FailoverTestStatusCompleted, + "expired": FailoverTestStatusExpired, + "invalid": FailoverTestStatusInvalid, + "notstarted": FailoverTestStatusNotStarted, + "running": FailoverTestStatusRunning, + "startfailed": FailoverTestStatusStartFailed, + "starting": FailoverTestStatusStarting, + "stopfailed": FailoverTestStatusStopFailed, + "stopping": FailoverTestStatusStopping, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FailoverTestStatus(input) + return &out, nil +} + +type FailoverTestStatusForSingleTest string + +const ( + FailoverTestStatusForSingleTestCompleted FailoverTestStatusForSingleTest = "Completed" + FailoverTestStatusForSingleTestExpired FailoverTestStatusForSingleTest = "Expired" + FailoverTestStatusForSingleTestInvalid FailoverTestStatusForSingleTest = "Invalid" + FailoverTestStatusForSingleTestNotStarted FailoverTestStatusForSingleTest = "NotStarted" + FailoverTestStatusForSingleTestRunning FailoverTestStatusForSingleTest = "Running" + FailoverTestStatusForSingleTestStartFailed FailoverTestStatusForSingleTest = "StartFailed" + FailoverTestStatusForSingleTestStarting FailoverTestStatusForSingleTest = "Starting" + FailoverTestStatusForSingleTestStopFailed FailoverTestStatusForSingleTest = "StopFailed" + FailoverTestStatusForSingleTestStopping FailoverTestStatusForSingleTest = "Stopping" +) + +func PossibleValuesForFailoverTestStatusForSingleTest() []string { + return []string{ + string(FailoverTestStatusForSingleTestCompleted), + string(FailoverTestStatusForSingleTestExpired), + string(FailoverTestStatusForSingleTestInvalid), + string(FailoverTestStatusForSingleTestNotStarted), + string(FailoverTestStatusForSingleTestRunning), + string(FailoverTestStatusForSingleTestStartFailed), + string(FailoverTestStatusForSingleTestStarting), + string(FailoverTestStatusForSingleTestStopFailed), + string(FailoverTestStatusForSingleTestStopping), + } +} + +func (s *FailoverTestStatusForSingleTest) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFailoverTestStatusForSingleTest(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFailoverTestStatusForSingleTest(input string) (*FailoverTestStatusForSingleTest, error) { + vals := map[string]FailoverTestStatusForSingleTest{ + "completed": FailoverTestStatusForSingleTestCompleted, + "expired": FailoverTestStatusForSingleTestExpired, + "invalid": FailoverTestStatusForSingleTestInvalid, + "notstarted": FailoverTestStatusForSingleTestNotStarted, + "running": FailoverTestStatusForSingleTestRunning, + "startfailed": FailoverTestStatusForSingleTestStartFailed, + "starting": FailoverTestStatusForSingleTestStarting, + "stopfailed": FailoverTestStatusForSingleTestStopFailed, + "stopping": FailoverTestStatusForSingleTestStopping, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FailoverTestStatusForSingleTest(input) + return &out, nil +} + +type FailoverTestType string + +const ( + FailoverTestTypeAll FailoverTestType = "All" + FailoverTestTypeMultiSiteFailover FailoverTestType = "MultiSiteFailover" + FailoverTestTypeSingleSiteFailover FailoverTestType = "SingleSiteFailover" +) + +func PossibleValuesForFailoverTestType() []string { + return []string{ + string(FailoverTestTypeAll), + string(FailoverTestTypeMultiSiteFailover), + string(FailoverTestTypeSingleSiteFailover), + } +} + +func (s *FailoverTestType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFailoverTestType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFailoverTestType(input string) (*FailoverTestType, error) { + vals := map[string]FailoverTestType{ + "all": FailoverTestTypeAll, + "multisitefailover": FailoverTestTypeMultiSiteFailover, + "singlesitefailover": FailoverTestTypeSingleSiteFailover, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FailoverTestType(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPsecEncryption string + +const ( + IPsecEncryptionAESOneNineTwo IPsecEncryption = "AES192" + IPsecEncryptionAESOneTwoEight IPsecEncryption = "AES128" + IPsecEncryptionAESTwoFiveSix IPsecEncryption = "AES256" + IPsecEncryptionDES IPsecEncryption = "DES" + IPsecEncryptionDESThree IPsecEncryption = "DES3" + IPsecEncryptionGCMAESOneNineTwo IPsecEncryption = "GCMAES192" + IPsecEncryptionGCMAESOneTwoEight IPsecEncryption = "GCMAES128" + IPsecEncryptionGCMAESTwoFiveSix IPsecEncryption = "GCMAES256" + IPsecEncryptionNone IPsecEncryption = "None" +) + +func PossibleValuesForIPsecEncryption() []string { + return []string{ + string(IPsecEncryptionAESOneNineTwo), + string(IPsecEncryptionAESOneTwoEight), + string(IPsecEncryptionAESTwoFiveSix), + string(IPsecEncryptionDES), + string(IPsecEncryptionDESThree), + string(IPsecEncryptionGCMAESOneNineTwo), + string(IPsecEncryptionGCMAESOneTwoEight), + string(IPsecEncryptionGCMAESTwoFiveSix), + string(IPsecEncryptionNone), + } +} + +func (s *IPsecEncryption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPsecEncryption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPsecEncryption(input string) (*IPsecEncryption, error) { + vals := map[string]IPsecEncryption{ + "aes192": IPsecEncryptionAESOneNineTwo, + "aes128": IPsecEncryptionAESOneTwoEight, + "aes256": IPsecEncryptionAESTwoFiveSix, + "des": IPsecEncryptionDES, + "des3": IPsecEncryptionDESThree, + "gcmaes192": IPsecEncryptionGCMAESOneNineTwo, + "gcmaes128": IPsecEncryptionGCMAESOneTwoEight, + "gcmaes256": IPsecEncryptionGCMAESTwoFiveSix, + "none": IPsecEncryptionNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPsecEncryption(input) + return &out, nil +} + +type IPsecIntegrity string + +const ( + IPsecIntegrityGCMAESOneNineTwo IPsecIntegrity = "GCMAES192" + IPsecIntegrityGCMAESOneTwoEight IPsecIntegrity = "GCMAES128" + IPsecIntegrityGCMAESTwoFiveSix IPsecIntegrity = "GCMAES256" + IPsecIntegrityMDFive IPsecIntegrity = "MD5" + IPsecIntegritySHAOne IPsecIntegrity = "SHA1" + IPsecIntegritySHATwoFiveSix IPsecIntegrity = "SHA256" +) + +func PossibleValuesForIPsecIntegrity() []string { + return []string{ + string(IPsecIntegrityGCMAESOneNineTwo), + string(IPsecIntegrityGCMAESOneTwoEight), + string(IPsecIntegrityGCMAESTwoFiveSix), + string(IPsecIntegrityMDFive), + string(IPsecIntegritySHAOne), + string(IPsecIntegritySHATwoFiveSix), + } +} + +func (s *IPsecIntegrity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPsecIntegrity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPsecIntegrity(input string) (*IPsecIntegrity, error) { + vals := map[string]IPsecIntegrity{ + "gcmaes192": IPsecIntegrityGCMAESOneNineTwo, + "gcmaes128": IPsecIntegrityGCMAESOneTwoEight, + "gcmaes256": IPsecIntegrityGCMAESTwoFiveSix, + "md5": IPsecIntegrityMDFive, + "sha1": IPsecIntegritySHAOne, + "sha256": IPsecIntegritySHATwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPsecIntegrity(input) + return &out, nil +} + +type IkeEncryption string + +const ( + IkeEncryptionAESOneNineTwo IkeEncryption = "AES192" + IkeEncryptionAESOneTwoEight IkeEncryption = "AES128" + IkeEncryptionAESTwoFiveSix IkeEncryption = "AES256" + IkeEncryptionDES IkeEncryption = "DES" + IkeEncryptionDESThree IkeEncryption = "DES3" + IkeEncryptionGCMAESOneTwoEight IkeEncryption = "GCMAES128" + IkeEncryptionGCMAESTwoFiveSix IkeEncryption = "GCMAES256" +) + +func PossibleValuesForIkeEncryption() []string { + return []string{ + string(IkeEncryptionAESOneNineTwo), + string(IkeEncryptionAESOneTwoEight), + string(IkeEncryptionAESTwoFiveSix), + string(IkeEncryptionDES), + string(IkeEncryptionDESThree), + string(IkeEncryptionGCMAESOneTwoEight), + string(IkeEncryptionGCMAESTwoFiveSix), + } +} + +func (s *IkeEncryption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIkeEncryption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIkeEncryption(input string) (*IkeEncryption, error) { + vals := map[string]IkeEncryption{ + "aes192": IkeEncryptionAESOneNineTwo, + "aes128": IkeEncryptionAESOneTwoEight, + "aes256": IkeEncryptionAESTwoFiveSix, + "des": IkeEncryptionDES, + "des3": IkeEncryptionDESThree, + "gcmaes128": IkeEncryptionGCMAESOneTwoEight, + "gcmaes256": IkeEncryptionGCMAESTwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IkeEncryption(input) + return &out, nil +} + +type IkeIntegrity string + +const ( + IkeIntegrityGCMAESOneTwoEight IkeIntegrity = "GCMAES128" + IkeIntegrityGCMAESTwoFiveSix IkeIntegrity = "GCMAES256" + IkeIntegrityMDFive IkeIntegrity = "MD5" + IkeIntegritySHAOne IkeIntegrity = "SHA1" + IkeIntegritySHAThreeEightFour IkeIntegrity = "SHA384" + IkeIntegritySHATwoFiveSix IkeIntegrity = "SHA256" +) + +func PossibleValuesForIkeIntegrity() []string { + return []string{ + string(IkeIntegrityGCMAESOneTwoEight), + string(IkeIntegrityGCMAESTwoFiveSix), + string(IkeIntegrityMDFive), + string(IkeIntegritySHAOne), + string(IkeIntegritySHAThreeEightFour), + string(IkeIntegritySHATwoFiveSix), + } +} + +func (s *IkeIntegrity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIkeIntegrity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIkeIntegrity(input string) (*IkeIntegrity, error) { + vals := map[string]IkeIntegrity{ + "gcmaes128": IkeIntegrityGCMAESOneTwoEight, + "gcmaes256": IkeIntegrityGCMAESTwoFiveSix, + "md5": IkeIntegrityMDFive, + "sha1": IkeIntegritySHAOne, + "sha384": IkeIntegritySHAThreeEightFour, + "sha256": IkeIntegritySHATwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IkeIntegrity(input) + return &out, nil +} + +type PfsGroup string + +const ( + PfsGroupECPThreeEightFour PfsGroup = "ECP384" + PfsGroupECPTwoFiveSix PfsGroup = "ECP256" + PfsGroupNone PfsGroup = "None" + PfsGroupPFSMM PfsGroup = "PFSMM" + PfsGroupPFSOne PfsGroup = "PFS1" + PfsGroupPFSOneFour PfsGroup = "PFS14" + PfsGroupPFSTwo PfsGroup = "PFS2" + PfsGroupPFSTwoFour PfsGroup = "PFS24" + PfsGroupPFSTwoZeroFourEight PfsGroup = "PFS2048" +) + +func PossibleValuesForPfsGroup() []string { + return []string{ + string(PfsGroupECPThreeEightFour), + string(PfsGroupECPTwoFiveSix), + string(PfsGroupNone), + string(PfsGroupPFSMM), + string(PfsGroupPFSOne), + string(PfsGroupPFSOneFour), + string(PfsGroupPFSTwo), + string(PfsGroupPFSTwoFour), + string(PfsGroupPFSTwoZeroFourEight), + } +} + +func (s *PfsGroup) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePfsGroup(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePfsGroup(input string) (*PfsGroup, error) { + vals := map[string]PfsGroup{ + "ecp384": PfsGroupECPThreeEightFour, + "ecp256": PfsGroupECPTwoFiveSix, + "none": PfsGroupNone, + "pfsmm": PfsGroupPFSMM, + "pfs1": PfsGroupPFSOne, + "pfs14": PfsGroupPFSOneFour, + "pfs2": PfsGroupPFSTwo, + "pfs24": PfsGroupPFSTwoFour, + "pfs2048": PfsGroupPFSTwoZeroFourEight, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PfsGroup(input) + return &out, nil +} + +type ProcessorArchitecture string + +const ( + ProcessorArchitectureAmdSixFour ProcessorArchitecture = "Amd64" + ProcessorArchitectureXEightSix ProcessorArchitecture = "X86" +) + +func PossibleValuesForProcessorArchitecture() []string { + return []string{ + string(ProcessorArchitectureAmdSixFour), + string(ProcessorArchitectureXEightSix), + } +} + +func (s *ProcessorArchitecture) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProcessorArchitecture(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProcessorArchitecture(input string) (*ProcessorArchitecture, error) { + vals := map[string]ProcessorArchitecture{ + "amd64": ProcessorArchitectureAmdSixFour, + "x86": ProcessorArchitectureXEightSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProcessorArchitecture(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ResiliencyModel string + +const ( + ResiliencyModelMultiHomed ResiliencyModel = "MultiHomed" + ResiliencyModelSingleHomed ResiliencyModel = "SingleHomed" +) + +func PossibleValuesForResiliencyModel() []string { + return []string{ + string(ResiliencyModelMultiHomed), + string(ResiliencyModelSingleHomed), + } +} + +func (s *ResiliencyModel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResiliencyModel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResiliencyModel(input string) (*ResiliencyModel, error) { + vals := map[string]ResiliencyModel{ + "multihomed": ResiliencyModelMultiHomed, + "singlehomed": ResiliencyModelSingleHomed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResiliencyModel(input) + return &out, nil +} + +type VirtualNetworkGatewayConnectionMode string + +const ( + VirtualNetworkGatewayConnectionModeDefault VirtualNetworkGatewayConnectionMode = "Default" + VirtualNetworkGatewayConnectionModeInitiatorOnly VirtualNetworkGatewayConnectionMode = "InitiatorOnly" + VirtualNetworkGatewayConnectionModeResponderOnly VirtualNetworkGatewayConnectionMode = "ResponderOnly" +) + +func PossibleValuesForVirtualNetworkGatewayConnectionMode() []string { + return []string{ + string(VirtualNetworkGatewayConnectionModeDefault), + string(VirtualNetworkGatewayConnectionModeInitiatorOnly), + string(VirtualNetworkGatewayConnectionModeResponderOnly), + } +} + +func (s *VirtualNetworkGatewayConnectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewayConnectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewayConnectionMode(input string) (*VirtualNetworkGatewayConnectionMode, error) { + vals := map[string]VirtualNetworkGatewayConnectionMode{ + "default": VirtualNetworkGatewayConnectionModeDefault, + "initiatoronly": VirtualNetworkGatewayConnectionModeInitiatorOnly, + "responderonly": VirtualNetworkGatewayConnectionModeResponderOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewayConnectionMode(input) + return &out, nil +} + +type VirtualNetworkGatewayConnectionProtocol string + +const ( + VirtualNetworkGatewayConnectionProtocolIKEvOne VirtualNetworkGatewayConnectionProtocol = "IKEv1" + VirtualNetworkGatewayConnectionProtocolIKEvTwo VirtualNetworkGatewayConnectionProtocol = "IKEv2" +) + +func PossibleValuesForVirtualNetworkGatewayConnectionProtocol() []string { + return []string{ + string(VirtualNetworkGatewayConnectionProtocolIKEvOne), + string(VirtualNetworkGatewayConnectionProtocolIKEvTwo), + } +} + +func (s *VirtualNetworkGatewayConnectionProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewayConnectionProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewayConnectionProtocol(input string) (*VirtualNetworkGatewayConnectionProtocol, error) { + vals := map[string]VirtualNetworkGatewayConnectionProtocol{ + "ikev1": VirtualNetworkGatewayConnectionProtocolIKEvOne, + "ikev2": VirtualNetworkGatewayConnectionProtocolIKEvTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewayConnectionProtocol(input) + return &out, nil +} + +type VirtualNetworkGatewayConnectionStatus string + +const ( + VirtualNetworkGatewayConnectionStatusConnected VirtualNetworkGatewayConnectionStatus = "Connected" + VirtualNetworkGatewayConnectionStatusConnecting VirtualNetworkGatewayConnectionStatus = "Connecting" + VirtualNetworkGatewayConnectionStatusNotConnected VirtualNetworkGatewayConnectionStatus = "NotConnected" + VirtualNetworkGatewayConnectionStatusUnknown VirtualNetworkGatewayConnectionStatus = "Unknown" +) + +func PossibleValuesForVirtualNetworkGatewayConnectionStatus() []string { + return []string{ + string(VirtualNetworkGatewayConnectionStatusConnected), + string(VirtualNetworkGatewayConnectionStatusConnecting), + string(VirtualNetworkGatewayConnectionStatusNotConnected), + string(VirtualNetworkGatewayConnectionStatusUnknown), + } +} + +func (s *VirtualNetworkGatewayConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewayConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewayConnectionStatus(input string) (*VirtualNetworkGatewayConnectionStatus, error) { + vals := map[string]VirtualNetworkGatewayConnectionStatus{ + "connected": VirtualNetworkGatewayConnectionStatusConnected, + "connecting": VirtualNetworkGatewayConnectionStatusConnecting, + "notconnected": VirtualNetworkGatewayConnectionStatusNotConnected, + "unknown": VirtualNetworkGatewayConnectionStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewayConnectionStatus(input) + return &out, nil +} + +type VirtualNetworkGatewayConnectionType string + +const ( + VirtualNetworkGatewayConnectionTypeExpressRoute VirtualNetworkGatewayConnectionType = "ExpressRoute" + VirtualNetworkGatewayConnectionTypeIPsec VirtualNetworkGatewayConnectionType = "IPsec" + VirtualNetworkGatewayConnectionTypeVPNClient VirtualNetworkGatewayConnectionType = "VPNClient" + VirtualNetworkGatewayConnectionTypeVnetTwoVnet VirtualNetworkGatewayConnectionType = "Vnet2Vnet" +) + +func PossibleValuesForVirtualNetworkGatewayConnectionType() []string { + return []string{ + string(VirtualNetworkGatewayConnectionTypeExpressRoute), + string(VirtualNetworkGatewayConnectionTypeIPsec), + string(VirtualNetworkGatewayConnectionTypeVPNClient), + string(VirtualNetworkGatewayConnectionTypeVnetTwoVnet), + } +} + +func (s *VirtualNetworkGatewayConnectionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewayConnectionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewayConnectionType(input string) (*VirtualNetworkGatewayConnectionType, error) { + vals := map[string]VirtualNetworkGatewayConnectionType{ + "expressroute": VirtualNetworkGatewayConnectionTypeExpressRoute, + "ipsec": VirtualNetworkGatewayConnectionTypeIPsec, + "vpnclient": VirtualNetworkGatewayConnectionTypeVPNClient, + "vnet2vnet": VirtualNetworkGatewayConnectionTypeVnetTwoVnet, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewayConnectionType(input) + return &out, nil +} + +type VirtualNetworkGatewayMigrationPhase string + +const ( + VirtualNetworkGatewayMigrationPhaseAbort VirtualNetworkGatewayMigrationPhase = "Abort" + VirtualNetworkGatewayMigrationPhaseAbortSucceeded VirtualNetworkGatewayMigrationPhase = "AbortSucceeded" + VirtualNetworkGatewayMigrationPhaseCommit VirtualNetworkGatewayMigrationPhase = "Commit" + VirtualNetworkGatewayMigrationPhaseCommitSucceeded VirtualNetworkGatewayMigrationPhase = "CommitSucceeded" + VirtualNetworkGatewayMigrationPhaseExecute VirtualNetworkGatewayMigrationPhase = "Execute" + VirtualNetworkGatewayMigrationPhaseExecuteSucceeded VirtualNetworkGatewayMigrationPhase = "ExecuteSucceeded" + VirtualNetworkGatewayMigrationPhaseNone VirtualNetworkGatewayMigrationPhase = "None" + VirtualNetworkGatewayMigrationPhasePrepare VirtualNetworkGatewayMigrationPhase = "Prepare" + VirtualNetworkGatewayMigrationPhasePrepareSucceeded VirtualNetworkGatewayMigrationPhase = "PrepareSucceeded" +) + +func PossibleValuesForVirtualNetworkGatewayMigrationPhase() []string { + return []string{ + string(VirtualNetworkGatewayMigrationPhaseAbort), + string(VirtualNetworkGatewayMigrationPhaseAbortSucceeded), + string(VirtualNetworkGatewayMigrationPhaseCommit), + string(VirtualNetworkGatewayMigrationPhaseCommitSucceeded), + string(VirtualNetworkGatewayMigrationPhaseExecute), + string(VirtualNetworkGatewayMigrationPhaseExecuteSucceeded), + string(VirtualNetworkGatewayMigrationPhaseNone), + string(VirtualNetworkGatewayMigrationPhasePrepare), + string(VirtualNetworkGatewayMigrationPhasePrepareSucceeded), + } +} + +func (s *VirtualNetworkGatewayMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewayMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewayMigrationPhase(input string) (*VirtualNetworkGatewayMigrationPhase, error) { + vals := map[string]VirtualNetworkGatewayMigrationPhase{ + "abort": VirtualNetworkGatewayMigrationPhaseAbort, + "abortsucceeded": VirtualNetworkGatewayMigrationPhaseAbortSucceeded, + "commit": VirtualNetworkGatewayMigrationPhaseCommit, + "commitsucceeded": VirtualNetworkGatewayMigrationPhaseCommitSucceeded, + "execute": VirtualNetworkGatewayMigrationPhaseExecute, + "executesucceeded": VirtualNetworkGatewayMigrationPhaseExecuteSucceeded, + "none": VirtualNetworkGatewayMigrationPhaseNone, + "prepare": VirtualNetworkGatewayMigrationPhasePrepare, + "preparesucceeded": VirtualNetworkGatewayMigrationPhasePrepareSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewayMigrationPhase(input) + return &out, nil +} + +type VirtualNetworkGatewayMigrationState string + +const ( + VirtualNetworkGatewayMigrationStateFailed VirtualNetworkGatewayMigrationState = "Failed" + VirtualNetworkGatewayMigrationStateInProgress VirtualNetworkGatewayMigrationState = "InProgress" + VirtualNetworkGatewayMigrationStateNone VirtualNetworkGatewayMigrationState = "None" + VirtualNetworkGatewayMigrationStateSucceeded VirtualNetworkGatewayMigrationState = "Succeeded" +) + +func PossibleValuesForVirtualNetworkGatewayMigrationState() []string { + return []string{ + string(VirtualNetworkGatewayMigrationStateFailed), + string(VirtualNetworkGatewayMigrationStateInProgress), + string(VirtualNetworkGatewayMigrationStateNone), + string(VirtualNetworkGatewayMigrationStateSucceeded), + } +} + +func (s *VirtualNetworkGatewayMigrationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewayMigrationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewayMigrationState(input string) (*VirtualNetworkGatewayMigrationState, error) { + vals := map[string]VirtualNetworkGatewayMigrationState{ + "failed": VirtualNetworkGatewayMigrationStateFailed, + "inprogress": VirtualNetworkGatewayMigrationStateInProgress, + "none": VirtualNetworkGatewayMigrationStateNone, + "succeeded": VirtualNetworkGatewayMigrationStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewayMigrationState(input) + return &out, nil +} + +type VirtualNetworkGatewayMigrationType string + +const ( + VirtualNetworkGatewayMigrationTypeUpgradeDeploymentToStandardIP VirtualNetworkGatewayMigrationType = "UpgradeDeploymentToStandardIP" +) + +func PossibleValuesForVirtualNetworkGatewayMigrationType() []string { + return []string{ + string(VirtualNetworkGatewayMigrationTypeUpgradeDeploymentToStandardIP), + } +} + +func (s *VirtualNetworkGatewayMigrationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewayMigrationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewayMigrationType(input string) (*VirtualNetworkGatewayMigrationType, error) { + vals := map[string]VirtualNetworkGatewayMigrationType{ + "upgradedeploymenttostandardip": VirtualNetworkGatewayMigrationTypeUpgradeDeploymentToStandardIP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewayMigrationType(input) + return &out, nil +} + +type VirtualNetworkGatewaySkuName string + +const ( + VirtualNetworkGatewaySkuNameBasic VirtualNetworkGatewaySkuName = "Basic" + VirtualNetworkGatewaySkuNameErGwOneAZ VirtualNetworkGatewaySkuName = "ErGw1AZ" + VirtualNetworkGatewaySkuNameErGwScale VirtualNetworkGatewaySkuName = "ErGwScale" + VirtualNetworkGatewaySkuNameErGwThreeAZ VirtualNetworkGatewaySkuName = "ErGw3AZ" + VirtualNetworkGatewaySkuNameErGwTwoAZ VirtualNetworkGatewaySkuName = "ErGw2AZ" + VirtualNetworkGatewaySkuNameHighPerformance VirtualNetworkGatewaySkuName = "HighPerformance" + VirtualNetworkGatewaySkuNameStandard VirtualNetworkGatewaySkuName = "Standard" + VirtualNetworkGatewaySkuNameUltraPerformance VirtualNetworkGatewaySkuName = "UltraPerformance" + VirtualNetworkGatewaySkuNameVpnGwFive VirtualNetworkGatewaySkuName = "VpnGw5" + VirtualNetworkGatewaySkuNameVpnGwFiveAZ VirtualNetworkGatewaySkuName = "VpnGw5AZ" + VirtualNetworkGatewaySkuNameVpnGwFour VirtualNetworkGatewaySkuName = "VpnGw4" + VirtualNetworkGatewaySkuNameVpnGwFourAZ VirtualNetworkGatewaySkuName = "VpnGw4AZ" + VirtualNetworkGatewaySkuNameVpnGwOne VirtualNetworkGatewaySkuName = "VpnGw1" + VirtualNetworkGatewaySkuNameVpnGwOneAZ VirtualNetworkGatewaySkuName = "VpnGw1AZ" + VirtualNetworkGatewaySkuNameVpnGwThree VirtualNetworkGatewaySkuName = "VpnGw3" + VirtualNetworkGatewaySkuNameVpnGwThreeAZ VirtualNetworkGatewaySkuName = "VpnGw3AZ" + VirtualNetworkGatewaySkuNameVpnGwTwo VirtualNetworkGatewaySkuName = "VpnGw2" + VirtualNetworkGatewaySkuNameVpnGwTwoAZ VirtualNetworkGatewaySkuName = "VpnGw2AZ" +) + +func PossibleValuesForVirtualNetworkGatewaySkuName() []string { + return []string{ + string(VirtualNetworkGatewaySkuNameBasic), + string(VirtualNetworkGatewaySkuNameErGwOneAZ), + string(VirtualNetworkGatewaySkuNameErGwScale), + string(VirtualNetworkGatewaySkuNameErGwThreeAZ), + string(VirtualNetworkGatewaySkuNameErGwTwoAZ), + string(VirtualNetworkGatewaySkuNameHighPerformance), + string(VirtualNetworkGatewaySkuNameStandard), + string(VirtualNetworkGatewaySkuNameUltraPerformance), + string(VirtualNetworkGatewaySkuNameVpnGwFive), + string(VirtualNetworkGatewaySkuNameVpnGwFiveAZ), + string(VirtualNetworkGatewaySkuNameVpnGwFour), + string(VirtualNetworkGatewaySkuNameVpnGwFourAZ), + string(VirtualNetworkGatewaySkuNameVpnGwOne), + string(VirtualNetworkGatewaySkuNameVpnGwOneAZ), + string(VirtualNetworkGatewaySkuNameVpnGwThree), + string(VirtualNetworkGatewaySkuNameVpnGwThreeAZ), + string(VirtualNetworkGatewaySkuNameVpnGwTwo), + string(VirtualNetworkGatewaySkuNameVpnGwTwoAZ), + } +} + +func (s *VirtualNetworkGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewaySkuName(input string) (*VirtualNetworkGatewaySkuName, error) { + vals := map[string]VirtualNetworkGatewaySkuName{ + "basic": VirtualNetworkGatewaySkuNameBasic, + "ergw1az": VirtualNetworkGatewaySkuNameErGwOneAZ, + "ergwscale": VirtualNetworkGatewaySkuNameErGwScale, + "ergw3az": VirtualNetworkGatewaySkuNameErGwThreeAZ, + "ergw2az": VirtualNetworkGatewaySkuNameErGwTwoAZ, + "highperformance": VirtualNetworkGatewaySkuNameHighPerformance, + "standard": VirtualNetworkGatewaySkuNameStandard, + "ultraperformance": VirtualNetworkGatewaySkuNameUltraPerformance, + "vpngw5": VirtualNetworkGatewaySkuNameVpnGwFive, + "vpngw5az": VirtualNetworkGatewaySkuNameVpnGwFiveAZ, + "vpngw4": VirtualNetworkGatewaySkuNameVpnGwFour, + "vpngw4az": VirtualNetworkGatewaySkuNameVpnGwFourAZ, + "vpngw1": VirtualNetworkGatewaySkuNameVpnGwOne, + "vpngw1az": VirtualNetworkGatewaySkuNameVpnGwOneAZ, + "vpngw3": VirtualNetworkGatewaySkuNameVpnGwThree, + "vpngw3az": VirtualNetworkGatewaySkuNameVpnGwThreeAZ, + "vpngw2": VirtualNetworkGatewaySkuNameVpnGwTwo, + "vpngw2az": VirtualNetworkGatewaySkuNameVpnGwTwoAZ, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewaySkuName(input) + return &out, nil +} + +type VirtualNetworkGatewaySkuTier string + +const ( + VirtualNetworkGatewaySkuTierBasic VirtualNetworkGatewaySkuTier = "Basic" + VirtualNetworkGatewaySkuTierErGwOneAZ VirtualNetworkGatewaySkuTier = "ErGw1AZ" + VirtualNetworkGatewaySkuTierErGwScale VirtualNetworkGatewaySkuTier = "ErGwScale" + VirtualNetworkGatewaySkuTierErGwThreeAZ VirtualNetworkGatewaySkuTier = "ErGw3AZ" + VirtualNetworkGatewaySkuTierErGwTwoAZ VirtualNetworkGatewaySkuTier = "ErGw2AZ" + VirtualNetworkGatewaySkuTierHighPerformance VirtualNetworkGatewaySkuTier = "HighPerformance" + VirtualNetworkGatewaySkuTierStandard VirtualNetworkGatewaySkuTier = "Standard" + VirtualNetworkGatewaySkuTierUltraPerformance VirtualNetworkGatewaySkuTier = "UltraPerformance" + VirtualNetworkGatewaySkuTierVpnGwFive VirtualNetworkGatewaySkuTier = "VpnGw5" + VirtualNetworkGatewaySkuTierVpnGwFiveAZ VirtualNetworkGatewaySkuTier = "VpnGw5AZ" + VirtualNetworkGatewaySkuTierVpnGwFour VirtualNetworkGatewaySkuTier = "VpnGw4" + VirtualNetworkGatewaySkuTierVpnGwFourAZ VirtualNetworkGatewaySkuTier = "VpnGw4AZ" + VirtualNetworkGatewaySkuTierVpnGwOne VirtualNetworkGatewaySkuTier = "VpnGw1" + VirtualNetworkGatewaySkuTierVpnGwOneAZ VirtualNetworkGatewaySkuTier = "VpnGw1AZ" + VirtualNetworkGatewaySkuTierVpnGwThree VirtualNetworkGatewaySkuTier = "VpnGw3" + VirtualNetworkGatewaySkuTierVpnGwThreeAZ VirtualNetworkGatewaySkuTier = "VpnGw3AZ" + VirtualNetworkGatewaySkuTierVpnGwTwo VirtualNetworkGatewaySkuTier = "VpnGw2" + VirtualNetworkGatewaySkuTierVpnGwTwoAZ VirtualNetworkGatewaySkuTier = "VpnGw2AZ" +) + +func PossibleValuesForVirtualNetworkGatewaySkuTier() []string { + return []string{ + string(VirtualNetworkGatewaySkuTierBasic), + string(VirtualNetworkGatewaySkuTierErGwOneAZ), + string(VirtualNetworkGatewaySkuTierErGwScale), + string(VirtualNetworkGatewaySkuTierErGwThreeAZ), + string(VirtualNetworkGatewaySkuTierErGwTwoAZ), + string(VirtualNetworkGatewaySkuTierHighPerformance), + string(VirtualNetworkGatewaySkuTierStandard), + string(VirtualNetworkGatewaySkuTierUltraPerformance), + string(VirtualNetworkGatewaySkuTierVpnGwFive), + string(VirtualNetworkGatewaySkuTierVpnGwFiveAZ), + string(VirtualNetworkGatewaySkuTierVpnGwFour), + string(VirtualNetworkGatewaySkuTierVpnGwFourAZ), + string(VirtualNetworkGatewaySkuTierVpnGwOne), + string(VirtualNetworkGatewaySkuTierVpnGwOneAZ), + string(VirtualNetworkGatewaySkuTierVpnGwThree), + string(VirtualNetworkGatewaySkuTierVpnGwThreeAZ), + string(VirtualNetworkGatewaySkuTierVpnGwTwo), + string(VirtualNetworkGatewaySkuTierVpnGwTwoAZ), + } +} + +func (s *VirtualNetworkGatewaySkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewaySkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewaySkuTier(input string) (*VirtualNetworkGatewaySkuTier, error) { + vals := map[string]VirtualNetworkGatewaySkuTier{ + "basic": VirtualNetworkGatewaySkuTierBasic, + "ergw1az": VirtualNetworkGatewaySkuTierErGwOneAZ, + "ergwscale": VirtualNetworkGatewaySkuTierErGwScale, + "ergw3az": VirtualNetworkGatewaySkuTierErGwThreeAZ, + "ergw2az": VirtualNetworkGatewaySkuTierErGwTwoAZ, + "highperformance": VirtualNetworkGatewaySkuTierHighPerformance, + "standard": VirtualNetworkGatewaySkuTierStandard, + "ultraperformance": VirtualNetworkGatewaySkuTierUltraPerformance, + "vpngw5": VirtualNetworkGatewaySkuTierVpnGwFive, + "vpngw5az": VirtualNetworkGatewaySkuTierVpnGwFiveAZ, + "vpngw4": VirtualNetworkGatewaySkuTierVpnGwFour, + "vpngw4az": VirtualNetworkGatewaySkuTierVpnGwFourAZ, + "vpngw1": VirtualNetworkGatewaySkuTierVpnGwOne, + "vpngw1az": VirtualNetworkGatewaySkuTierVpnGwOneAZ, + "vpngw3": VirtualNetworkGatewaySkuTierVpnGwThree, + "vpngw3az": VirtualNetworkGatewaySkuTierVpnGwThreeAZ, + "vpngw2": VirtualNetworkGatewaySkuTierVpnGwTwo, + "vpngw2az": VirtualNetworkGatewaySkuTierVpnGwTwoAZ, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewaySkuTier(input) + return &out, nil +} + +type VirtualNetworkGatewayType string + +const ( + VirtualNetworkGatewayTypeExpressRoute VirtualNetworkGatewayType = "ExpressRoute" + VirtualNetworkGatewayTypeLocalGateway VirtualNetworkGatewayType = "LocalGateway" + VirtualNetworkGatewayTypeVpn VirtualNetworkGatewayType = "Vpn" +) + +func PossibleValuesForVirtualNetworkGatewayType() []string { + return []string{ + string(VirtualNetworkGatewayTypeExpressRoute), + string(VirtualNetworkGatewayTypeLocalGateway), + string(VirtualNetworkGatewayTypeVpn), + } +} + +func (s *VirtualNetworkGatewayType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewayType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewayType(input string) (*VirtualNetworkGatewayType, error) { + vals := map[string]VirtualNetworkGatewayType{ + "expressroute": VirtualNetworkGatewayTypeExpressRoute, + "localgateway": VirtualNetworkGatewayTypeLocalGateway, + "vpn": VirtualNetworkGatewayTypeVpn, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewayType(input) + return &out, nil +} + +type VpnAuthenticationType string + +const ( + VpnAuthenticationTypeAAD VpnAuthenticationType = "AAD" + VpnAuthenticationTypeCertificate VpnAuthenticationType = "Certificate" + VpnAuthenticationTypeRadius VpnAuthenticationType = "Radius" +) + +func PossibleValuesForVpnAuthenticationType() []string { + return []string{ + string(VpnAuthenticationTypeAAD), + string(VpnAuthenticationTypeCertificate), + string(VpnAuthenticationTypeRadius), + } +} + +func (s *VpnAuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnAuthenticationType(input string) (*VpnAuthenticationType, error) { + vals := map[string]VpnAuthenticationType{ + "aad": VpnAuthenticationTypeAAD, + "certificate": VpnAuthenticationTypeCertificate, + "radius": VpnAuthenticationTypeRadius, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnAuthenticationType(input) + return &out, nil +} + +type VpnClientProtocol string + +const ( + VpnClientProtocolIkeVTwo VpnClientProtocol = "IkeV2" + VpnClientProtocolOpenVPN VpnClientProtocol = "OpenVPN" + VpnClientProtocolSSTP VpnClientProtocol = "SSTP" +) + +func PossibleValuesForVpnClientProtocol() []string { + return []string{ + string(VpnClientProtocolIkeVTwo), + string(VpnClientProtocolOpenVPN), + string(VpnClientProtocolSSTP), + } +} + +func (s *VpnClientProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnClientProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnClientProtocol(input string) (*VpnClientProtocol, error) { + vals := map[string]VpnClientProtocol{ + "ikev2": VpnClientProtocolIkeVTwo, + "openvpn": VpnClientProtocolOpenVPN, + "sstp": VpnClientProtocolSSTP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnClientProtocol(input) + return &out, nil +} + +type VpnGatewayGeneration string + +const ( + VpnGatewayGenerationGenerationOne VpnGatewayGeneration = "Generation1" + VpnGatewayGenerationGenerationTwo VpnGatewayGeneration = "Generation2" + VpnGatewayGenerationNone VpnGatewayGeneration = "None" +) + +func PossibleValuesForVpnGatewayGeneration() []string { + return []string{ + string(VpnGatewayGenerationGenerationOne), + string(VpnGatewayGenerationGenerationTwo), + string(VpnGatewayGenerationNone), + } +} + +func (s *VpnGatewayGeneration) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnGatewayGeneration(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnGatewayGeneration(input string) (*VpnGatewayGeneration, error) { + vals := map[string]VpnGatewayGeneration{ + "generation1": VpnGatewayGenerationGenerationOne, + "generation2": VpnGatewayGenerationGenerationTwo, + "none": VpnGatewayGenerationNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnGatewayGeneration(input) + return &out, nil +} + +type VpnNatRuleMode string + +const ( + VpnNatRuleModeEgressSnat VpnNatRuleMode = "EgressSnat" + VpnNatRuleModeIngressSnat VpnNatRuleMode = "IngressSnat" +) + +func PossibleValuesForVpnNatRuleMode() []string { + return []string{ + string(VpnNatRuleModeEgressSnat), + string(VpnNatRuleModeIngressSnat), + } +} + +func (s *VpnNatRuleMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnNatRuleMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnNatRuleMode(input string) (*VpnNatRuleMode, error) { + vals := map[string]VpnNatRuleMode{ + "egresssnat": VpnNatRuleModeEgressSnat, + "ingresssnat": VpnNatRuleModeIngressSnat, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnNatRuleMode(input) + return &out, nil +} + +type VpnNatRuleType string + +const ( + VpnNatRuleTypeDynamic VpnNatRuleType = "Dynamic" + VpnNatRuleTypeStatic VpnNatRuleType = "Static" +) + +func PossibleValuesForVpnNatRuleType() []string { + return []string{ + string(VpnNatRuleTypeDynamic), + string(VpnNatRuleTypeStatic), + } +} + +func (s *VpnNatRuleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnNatRuleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnNatRuleType(input string) (*VpnNatRuleType, error) { + vals := map[string]VpnNatRuleType{ + "dynamic": VpnNatRuleTypeDynamic, + "static": VpnNatRuleTypeStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnNatRuleType(input) + return &out, nil +} + +type VpnPolicyMemberAttributeType string + +const ( + VpnPolicyMemberAttributeTypeAADGroupId VpnPolicyMemberAttributeType = "AADGroupId" + VpnPolicyMemberAttributeTypeCertificateGroupId VpnPolicyMemberAttributeType = "CertificateGroupId" + VpnPolicyMemberAttributeTypeRadiusAzureGroupId VpnPolicyMemberAttributeType = "RadiusAzureGroupId" +) + +func PossibleValuesForVpnPolicyMemberAttributeType() []string { + return []string{ + string(VpnPolicyMemberAttributeTypeAADGroupId), + string(VpnPolicyMemberAttributeTypeCertificateGroupId), + string(VpnPolicyMemberAttributeTypeRadiusAzureGroupId), + } +} + +func (s *VpnPolicyMemberAttributeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnPolicyMemberAttributeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnPolicyMemberAttributeType(input string) (*VpnPolicyMemberAttributeType, error) { + vals := map[string]VpnPolicyMemberAttributeType{ + "aadgroupid": VpnPolicyMemberAttributeTypeAADGroupId, + "certificategroupid": VpnPolicyMemberAttributeTypeCertificateGroupId, + "radiusazuregroupid": VpnPolicyMemberAttributeTypeRadiusAzureGroupId, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnPolicyMemberAttributeType(input) + return &out, nil +} + +type VpnType string + +const ( + VpnTypePolicyBased VpnType = "PolicyBased" + VpnTypeRouteBased VpnType = "RouteBased" +) + +func PossibleValuesForVpnType() []string { + return []string{ + string(VpnTypePolicyBased), + string(VpnTypeRouteBased), + } +} + +func (s *VpnType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnType(input string) (*VpnType, error) { + vals := map[string]VpnType{ + "policybased": VpnTypePolicyBased, + "routebased": VpnTypeRouteBased, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnType(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/id_connection.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/id_connection.go new file mode 100644 index 00000000000..7e0a849bdfd --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/id_connection.go @@ -0,0 +1,130 @@ +package virtualnetworkgateways + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConnectionId{}) +} + +var _ resourceids.ResourceId = &ConnectionId{} + +// ConnectionId is a struct representing the Resource ID for a Connection +type ConnectionId struct { + SubscriptionId string + ResourceGroupName string + ConnectionName string +} + +// NewConnectionID returns a new ConnectionId struct +func NewConnectionID(subscriptionId string, resourceGroupName string, connectionName string) ConnectionId { + return ConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ConnectionName: connectionName, + } +} + +// ParseConnectionID parses 'input' into a ConnectionId +func ParseConnectionID(input string) (*ConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConnectionIDInsensitively parses 'input' case-insensitively into a ConnectionId +// note: this method should only be used for API response data and not user input +func ParseConnectionIDInsensitively(input string) (*ConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ConnectionName, ok = input.Parsed["connectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectionName", input) + } + + return nil +} + +// ValidateConnectionID checks that 'input' can be parsed as a Connection ID +func ValidateConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Connection ID +func (id ConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/connections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Connection ID +func (id ConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticConnections", "connections", "connections"), + resourceids.UserSpecifiedSegment("connectionName", "connectionName"), + } +} + +// String returns a human-readable description of this Connection ID +func (id ConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Connection Name: %q", id.ConnectionName), + } + return fmt.Sprintf("Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/id_connection_test.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/id_connection_test.go new file mode 100644 index 00000000000..f523578a93d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/id_connection_test.go @@ -0,0 +1,282 @@ +package virtualnetworkgateways + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ConnectionId{} + +func TestNewConnectionID(t *testing.T) { + id := NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ConnectionName != "connectionName" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectionName'", id.ConnectionName, "connectionName") + } +} + +func TestFormatConnectionID(t *testing.T) { + actual := NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/connections/connectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/connections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/connections/connectionName", + Expected: &ConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectionName: "connectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/connections/connectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectionName != v.Expected.ConnectionName { + t.Fatalf("Expected %q but got %q for ConnectionName", v.Expected.ConnectionName, actual.ConnectionName) + } + + } +} + +func TestParseConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/connections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/cOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/connections/connectionName", + Expected: &ConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectionName: "connectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/connections/connectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/cOnNeCtIoNs/cOnNeCtIoNnAmE", + Expected: &ConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ConnectionName: "cOnNeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/cOnNeCtIoNs/cOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ConnectionName != v.Expected.ConnectionName { + t.Fatalf("Expected %q but got %q for ConnectionName", v.Expected.ConnectionName, actual.ConnectionName) + } + + } +} + +func TestSegmentsForConnectionId(t *testing.T) { + segments := ConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/id_virtualnetworkgateway.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/id_virtualnetworkgateway.go new file mode 100644 index 00000000000..37161e508ae --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/id_virtualnetworkgateway.go @@ -0,0 +1,130 @@ +package virtualnetworkgateways + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualNetworkGatewayId{}) +} + +var _ resourceids.ResourceId = &VirtualNetworkGatewayId{} + +// VirtualNetworkGatewayId is a struct representing the Resource ID for a Virtual Network Gateway +type VirtualNetworkGatewayId struct { + SubscriptionId string + ResourceGroupName string + VirtualNetworkGatewayName string +} + +// NewVirtualNetworkGatewayID returns a new VirtualNetworkGatewayId struct +func NewVirtualNetworkGatewayID(subscriptionId string, resourceGroupName string, virtualNetworkGatewayName string) VirtualNetworkGatewayId { + return VirtualNetworkGatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualNetworkGatewayName: virtualNetworkGatewayName, + } +} + +// ParseVirtualNetworkGatewayID parses 'input' into a VirtualNetworkGatewayId +func ParseVirtualNetworkGatewayID(input string) (*VirtualNetworkGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkGatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualNetworkGatewayIDInsensitively parses 'input' case-insensitively into a VirtualNetworkGatewayId +// note: this method should only be used for API response data and not user input +func ParseVirtualNetworkGatewayIDInsensitively(input string) (*VirtualNetworkGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkGatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualNetworkGatewayId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VirtualNetworkGatewayName, ok = input.Parsed["virtualNetworkGatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkGatewayName", input) + } + + return nil +} + +// ValidateVirtualNetworkGatewayID checks that 'input' can be parsed as a Virtual Network Gateway ID +func ValidateVirtualNetworkGatewayID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVirtualNetworkGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Network Gateway ID +func (id VirtualNetworkGatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualNetworkGateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualNetworkGatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Network Gateway ID +func (id VirtualNetworkGatewayId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVirtualNetworkGateways", "virtualNetworkGateways", "virtualNetworkGateways"), + resourceids.UserSpecifiedSegment("virtualNetworkGatewayName", "virtualNetworkGatewayName"), + } +} + +// String returns a human-readable description of this Virtual Network Gateway ID +func (id VirtualNetworkGatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Network Gateway Name: %q", id.VirtualNetworkGatewayName), + } + return fmt.Sprintf("Virtual Network Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/id_virtualnetworkgateway_test.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/id_virtualnetworkgateway_test.go new file mode 100644 index 00000000000..5bde6077817 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/id_virtualnetworkgateway_test.go @@ -0,0 +1,282 @@ +package virtualnetworkgateways + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualNetworkGatewayId{} + +func TestNewVirtualNetworkGatewayID(t *testing.T) { + id := NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VirtualNetworkGatewayName != "virtualNetworkGatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkGatewayName'", id.VirtualNetworkGatewayName, "virtualNetworkGatewayName") + } +} + +func TestFormatVirtualNetworkGatewayID(t *testing.T) { + actual := NewVirtualNetworkGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways/virtualNetworkGatewayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualNetworkGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways/virtualNetworkGatewayName", + Expected: &VirtualNetworkGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualNetworkGatewayName: "virtualNetworkGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways/virtualNetworkGatewayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkGatewayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualNetworkGatewayName != v.Expected.VirtualNetworkGatewayName { + t.Fatalf("Expected %q but got %q for VirtualNetworkGatewayName", v.Expected.VirtualNetworkGatewayName, actual.VirtualNetworkGatewayName) + } + + } +} + +func TestParseVirtualNetworkGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlNeTwOrKgAtEwAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways/virtualNetworkGatewayName", + Expected: &VirtualNetworkGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualNetworkGatewayName: "virtualNetworkGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways/virtualNetworkGatewayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlNeTwOrKgAtEwAyS/vIrTuAlNeTwOrKgAtEwAyNaMe", + Expected: &VirtualNetworkGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualNetworkGatewayName: "vIrTuAlNeTwOrKgAtEwAyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlNeTwOrKgAtEwAyS/vIrTuAlNeTwOrKgAtEwAyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkGatewayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualNetworkGatewayName != v.Expected.VirtualNetworkGatewayName { + t.Fatalf("Expected %q but got %q for VirtualNetworkGatewayName", v.Expected.VirtualNetworkGatewayName, actual.VirtualNetworkGatewayName) + } + + } +} + +func TestSegmentsForVirtualNetworkGatewayId(t *testing.T) { + segments := VirtualNetworkGatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualNetworkGatewayId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/id_virtualnetworkgatewaynatrule.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/id_virtualnetworkgatewaynatrule.go new file mode 100644 index 00000000000..eefda2a39b1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/id_virtualnetworkgatewaynatrule.go @@ -0,0 +1,139 @@ +package virtualnetworkgateways + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualNetworkGatewayNatRuleId{}) +} + +var _ resourceids.ResourceId = &VirtualNetworkGatewayNatRuleId{} + +// VirtualNetworkGatewayNatRuleId is a struct representing the Resource ID for a Virtual Network Gateway Nat Rule +type VirtualNetworkGatewayNatRuleId struct { + SubscriptionId string + ResourceGroupName string + VirtualNetworkGatewayName string + NatRuleName string +} + +// NewVirtualNetworkGatewayNatRuleID returns a new VirtualNetworkGatewayNatRuleId struct +func NewVirtualNetworkGatewayNatRuleID(subscriptionId string, resourceGroupName string, virtualNetworkGatewayName string, natRuleName string) VirtualNetworkGatewayNatRuleId { + return VirtualNetworkGatewayNatRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualNetworkGatewayName: virtualNetworkGatewayName, + NatRuleName: natRuleName, + } +} + +// ParseVirtualNetworkGatewayNatRuleID parses 'input' into a VirtualNetworkGatewayNatRuleId +func ParseVirtualNetworkGatewayNatRuleID(input string) (*VirtualNetworkGatewayNatRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkGatewayNatRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkGatewayNatRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualNetworkGatewayNatRuleIDInsensitively parses 'input' case-insensitively into a VirtualNetworkGatewayNatRuleId +// note: this method should only be used for API response data and not user input +func ParseVirtualNetworkGatewayNatRuleIDInsensitively(input string) (*VirtualNetworkGatewayNatRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkGatewayNatRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkGatewayNatRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualNetworkGatewayNatRuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VirtualNetworkGatewayName, ok = input.Parsed["virtualNetworkGatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkGatewayName", input) + } + + if id.NatRuleName, ok = input.Parsed["natRuleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "natRuleName", input) + } + + return nil +} + +// ValidateVirtualNetworkGatewayNatRuleID checks that 'input' can be parsed as a Virtual Network Gateway Nat Rule ID +func ValidateVirtualNetworkGatewayNatRuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVirtualNetworkGatewayNatRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Network Gateway Nat Rule ID +func (id VirtualNetworkGatewayNatRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualNetworkGateways/%s/natRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualNetworkGatewayName, id.NatRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Network Gateway Nat Rule ID +func (id VirtualNetworkGatewayNatRuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVirtualNetworkGateways", "virtualNetworkGateways", "virtualNetworkGateways"), + resourceids.UserSpecifiedSegment("virtualNetworkGatewayName", "virtualNetworkGatewayName"), + resourceids.StaticSegment("staticNatRules", "natRules", "natRules"), + resourceids.UserSpecifiedSegment("natRuleName", "natRuleName"), + } +} + +// String returns a human-readable description of this Virtual Network Gateway Nat Rule ID +func (id VirtualNetworkGatewayNatRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Network Gateway Name: %q", id.VirtualNetworkGatewayName), + fmt.Sprintf("Nat Rule Name: %q", id.NatRuleName), + } + return fmt.Sprintf("Virtual Network Gateway Nat Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/id_virtualnetworkgatewaynatrule_test.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/id_virtualnetworkgatewaynatrule_test.go new file mode 100644 index 00000000000..7ea05c070ec --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/id_virtualnetworkgatewaynatrule_test.go @@ -0,0 +1,327 @@ +package virtualnetworkgateways + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualNetworkGatewayNatRuleId{} + +func TestNewVirtualNetworkGatewayNatRuleID(t *testing.T) { + id := NewVirtualNetworkGatewayNatRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName", "natRuleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VirtualNetworkGatewayName != "virtualNetworkGatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkGatewayName'", id.VirtualNetworkGatewayName, "virtualNetworkGatewayName") + } + + if id.NatRuleName != "natRuleName" { + t.Fatalf("Expected %q but got %q for Segment 'NatRuleName'", id.NatRuleName, "natRuleName") + } +} + +func TestFormatVirtualNetworkGatewayNatRuleID(t *testing.T) { + actual := NewVirtualNetworkGatewayNatRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkGatewayName", "natRuleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways/virtualNetworkGatewayName/natRules/natRuleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualNetworkGatewayNatRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkGatewayNatRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways/virtualNetworkGatewayName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways/virtualNetworkGatewayName/natRules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways/virtualNetworkGatewayName/natRules/natRuleName", + Expected: &VirtualNetworkGatewayNatRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualNetworkGatewayName: "virtualNetworkGatewayName", + NatRuleName: "natRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways/virtualNetworkGatewayName/natRules/natRuleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkGatewayNatRuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualNetworkGatewayName != v.Expected.VirtualNetworkGatewayName { + t.Fatalf("Expected %q but got %q for VirtualNetworkGatewayName", v.Expected.VirtualNetworkGatewayName, actual.VirtualNetworkGatewayName) + } + + if actual.NatRuleName != v.Expected.NatRuleName { + t.Fatalf("Expected %q but got %q for NatRuleName", v.Expected.NatRuleName, actual.NatRuleName) + } + + } +} + +func TestParseVirtualNetworkGatewayNatRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkGatewayNatRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlNeTwOrKgAtEwAyS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways/virtualNetworkGatewayName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlNeTwOrKgAtEwAyS/vIrTuAlNeTwOrKgAtEwAyNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways/virtualNetworkGatewayName/natRules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlNeTwOrKgAtEwAyS/vIrTuAlNeTwOrKgAtEwAyNaMe/nAtRuLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways/virtualNetworkGatewayName/natRules/natRuleName", + Expected: &VirtualNetworkGatewayNatRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualNetworkGatewayName: "virtualNetworkGatewayName", + NatRuleName: "natRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkGateways/virtualNetworkGatewayName/natRules/natRuleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlNeTwOrKgAtEwAyS/vIrTuAlNeTwOrKgAtEwAyNaMe/nAtRuLeS/nAtRuLeNaMe", + Expected: &VirtualNetworkGatewayNatRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualNetworkGatewayName: "vIrTuAlNeTwOrKgAtEwAyNaMe", + NatRuleName: "nAtRuLeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlNeTwOrKgAtEwAyS/vIrTuAlNeTwOrKgAtEwAyNaMe/nAtRuLeS/nAtRuLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkGatewayNatRuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualNetworkGatewayName != v.Expected.VirtualNetworkGatewayName { + t.Fatalf("Expected %q but got %q for VirtualNetworkGatewayName", v.Expected.VirtualNetworkGatewayName, actual.VirtualNetworkGatewayName) + } + + if actual.NatRuleName != v.Expected.NatRuleName { + t.Fatalf("Expected %q but got %q for NatRuleName", v.Expected.NatRuleName, actual.NatRuleName) + } + + } +} + +func TestSegmentsForVirtualNetworkGatewayNatRuleId(t *testing.T) { + segments := VirtualNetworkGatewayNatRuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualNetworkGatewayNatRuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_createorupdate.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_createorupdate.go new file mode 100644 index 00000000000..1f22024e4a6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_createorupdate.go @@ -0,0 +1,75 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetworkGateway +} + +// CreateOrUpdate ... +func (c VirtualNetworkGatewaysClient) CreateOrUpdate(ctx context.Context, id VirtualNetworkGatewayId, input VirtualNetworkGateway) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c VirtualNetworkGatewaysClient) CreateOrUpdateThenPoll(ctx context.Context, id VirtualNetworkGatewayId, input VirtualNetworkGateway) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_delete.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_delete.go new file mode 100644 index 00000000000..06878f245a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_delete.go @@ -0,0 +1,71 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c VirtualNetworkGatewaysClient) Delete(ctx context.Context, id VirtualNetworkGatewayId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c VirtualNetworkGatewaysClient) DeleteThenPoll(ctx context.Context, id VirtualNetworkGatewayId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_disconnectvirtualnetworkgatewayvpnconnections.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_disconnectvirtualnetworkgatewayvpnconnections.go new file mode 100644 index 00000000000..6a0589d67d6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_disconnectvirtualnetworkgatewayvpnconnections.go @@ -0,0 +1,74 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DisconnectVirtualNetworkGatewayVpnConnectionsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DisconnectVirtualNetworkGatewayVpnConnections ... +func (c VirtualNetworkGatewaysClient) DisconnectVirtualNetworkGatewayVpnConnections(ctx context.Context, id VirtualNetworkGatewayId, input P2SVpnConnectionRequest) (result DisconnectVirtualNetworkGatewayVpnConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disconnectVirtualNetworkGatewayVpnConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DisconnectVirtualNetworkGatewayVpnConnectionsThenPoll performs DisconnectVirtualNetworkGatewayVpnConnections then polls until it's completed +func (c VirtualNetworkGatewaysClient) DisconnectVirtualNetworkGatewayVpnConnectionsThenPoll(ctx context.Context, id VirtualNetworkGatewayId, input P2SVpnConnectionRequest) error { + result, err := c.DisconnectVirtualNetworkGatewayVpnConnections(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DisconnectVirtualNetworkGatewayVpnConnections: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DisconnectVirtualNetworkGatewayVpnConnections: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_generatevpnclientpackage.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_generatevpnclientpackage.go new file mode 100644 index 00000000000..a08869751a8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_generatevpnclientpackage.go @@ -0,0 +1,75 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GeneratevpnclientpackageOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// Generatevpnclientpackage ... +func (c VirtualNetworkGatewaysClient) Generatevpnclientpackage(ctx context.Context, id VirtualNetworkGatewayId, input VpnClientParameters) (result GeneratevpnclientpackageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/generatevpnclientpackage", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GeneratevpnclientpackageThenPoll performs Generatevpnclientpackage then polls until it's completed +func (c VirtualNetworkGatewaysClient) GeneratevpnclientpackageThenPoll(ctx context.Context, id VirtualNetworkGatewayId, input VpnClientParameters) error { + result, err := c.Generatevpnclientpackage(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Generatevpnclientpackage: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Generatevpnclientpackage: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_generatevpnprofile.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_generatevpnprofile.go new file mode 100644 index 00000000000..3b9f9f9815e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_generatevpnprofile.go @@ -0,0 +1,75 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GenerateVpnProfileOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// GenerateVpnProfile ... +func (c VirtualNetworkGatewaysClient) GenerateVpnProfile(ctx context.Context, id VirtualNetworkGatewayId, input VpnClientParameters) (result GenerateVpnProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/generatevpnprofile", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GenerateVpnProfileThenPoll performs GenerateVpnProfile then polls until it's completed +func (c VirtualNetworkGatewaysClient) GenerateVpnProfileThenPoll(ctx context.Context, id VirtualNetworkGatewayId, input VpnClientParameters) error { + result, err := c.GenerateVpnProfile(ctx, id, input) + if err != nil { + return fmt.Errorf("performing GenerateVpnProfile: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GenerateVpnProfile: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_get.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_get.go new file mode 100644 index 00000000000..403f9e12374 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_get.go @@ -0,0 +1,53 @@ +package virtualnetworkgateways + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetworkGateway +} + +// Get ... +func (c VirtualNetworkGatewaysClient) Get(ctx context.Context, id VirtualNetworkGatewayId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualNetworkGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getadvertisedroutes.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getadvertisedroutes.go new file mode 100644 index 00000000000..969c71ee317 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getadvertisedroutes.go @@ -0,0 +1,100 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAdvertisedRoutesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *GatewayRouteListResult +} + +type GetAdvertisedRoutesOperationOptions struct { + Peer *string +} + +func DefaultGetAdvertisedRoutesOperationOptions() GetAdvertisedRoutesOperationOptions { + return GetAdvertisedRoutesOperationOptions{} +} + +func (o GetAdvertisedRoutesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetAdvertisedRoutesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetAdvertisedRoutesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Peer != nil { + out.Append("peer", fmt.Sprintf("%v", *o.Peer)) + } + return &out +} + +// GetAdvertisedRoutes ... +func (c VirtualNetworkGatewaysClient) GetAdvertisedRoutes(ctx context.Context, id VirtualNetworkGatewayId, options GetAdvertisedRoutesOperationOptions) (result GetAdvertisedRoutesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/getAdvertisedRoutes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetAdvertisedRoutesThenPoll performs GetAdvertisedRoutes then polls until it's completed +func (c VirtualNetworkGatewaysClient) GetAdvertisedRoutesThenPoll(ctx context.Context, id VirtualNetworkGatewayId, options GetAdvertisedRoutesOperationOptions) error { + result, err := c.GetAdvertisedRoutes(ctx, id, options) + if err != nil { + return fmt.Errorf("performing GetAdvertisedRoutes: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetAdvertisedRoutes: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getbgppeerstatus.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getbgppeerstatus.go new file mode 100644 index 00000000000..33e243af246 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getbgppeerstatus.go @@ -0,0 +1,100 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBgpPeerStatusOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BgpPeerStatusListResult +} + +type GetBgpPeerStatusOperationOptions struct { + Peer *string +} + +func DefaultGetBgpPeerStatusOperationOptions() GetBgpPeerStatusOperationOptions { + return GetBgpPeerStatusOperationOptions{} +} + +func (o GetBgpPeerStatusOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetBgpPeerStatusOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetBgpPeerStatusOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Peer != nil { + out.Append("peer", fmt.Sprintf("%v", *o.Peer)) + } + return &out +} + +// GetBgpPeerStatus ... +func (c VirtualNetworkGatewaysClient) GetBgpPeerStatus(ctx context.Context, id VirtualNetworkGatewayId, options GetBgpPeerStatusOperationOptions) (result GetBgpPeerStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/getBgpPeerStatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetBgpPeerStatusThenPoll performs GetBgpPeerStatus then polls until it's completed +func (c VirtualNetworkGatewaysClient) GetBgpPeerStatusThenPoll(ctx context.Context, id VirtualNetworkGatewayId, options GetBgpPeerStatusOperationOptions) error { + result, err := c.GetBgpPeerStatus(ctx, id, options) + if err != nil { + return fmt.Errorf("performing GetBgpPeerStatus: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetBgpPeerStatus: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getfailoveralltestdetails.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getfailoveralltestdetails.go new file mode 100644 index 00000000000..131d61979b8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getfailoveralltestdetails.go @@ -0,0 +1,104 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetFailoverAllTestDetailsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteFailoverTestDetails +} + +type GetFailoverAllTestDetailsOperationOptions struct { + FetchLatest *bool + Type *string +} + +func DefaultGetFailoverAllTestDetailsOperationOptions() GetFailoverAllTestDetailsOperationOptions { + return GetFailoverAllTestDetailsOperationOptions{} +} + +func (o GetFailoverAllTestDetailsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetFailoverAllTestDetailsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetFailoverAllTestDetailsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.FetchLatest != nil { + out.Append("fetchLatest", fmt.Sprintf("%v", *o.FetchLatest)) + } + if o.Type != nil { + out.Append("type", fmt.Sprintf("%v", *o.Type)) + } + return &out +} + +// GetFailoverAllTestDetails ... +func (c VirtualNetworkGatewaysClient) GetFailoverAllTestDetails(ctx context.Context, id VirtualNetworkGatewayId, options GetFailoverAllTestDetailsOperationOptions) (result GetFailoverAllTestDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/getFailoverAllTestsDetails", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetFailoverAllTestDetailsThenPoll performs GetFailoverAllTestDetails then polls until it's completed +func (c VirtualNetworkGatewaysClient) GetFailoverAllTestDetailsThenPoll(ctx context.Context, id VirtualNetworkGatewayId, options GetFailoverAllTestDetailsOperationOptions) error { + result, err := c.GetFailoverAllTestDetails(ctx, id, options) + if err != nil { + return fmt.Errorf("performing GetFailoverAllTestDetails: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetFailoverAllTestDetails: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getfailoversingletestdetails.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getfailoversingletestdetails.go new file mode 100644 index 00000000000..31704bd9f58 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getfailoversingletestdetails.go @@ -0,0 +1,104 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetFailoverSingleTestDetailsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]ExpressRouteFailoverSingleTestDetails +} + +type GetFailoverSingleTestDetailsOperationOptions struct { + FailoverTestId *string + PeeringLocation *string +} + +func DefaultGetFailoverSingleTestDetailsOperationOptions() GetFailoverSingleTestDetailsOperationOptions { + return GetFailoverSingleTestDetailsOperationOptions{} +} + +func (o GetFailoverSingleTestDetailsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetFailoverSingleTestDetailsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetFailoverSingleTestDetailsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.FailoverTestId != nil { + out.Append("failoverTestId", fmt.Sprintf("%v", *o.FailoverTestId)) + } + if o.PeeringLocation != nil { + out.Append("peeringLocation", fmt.Sprintf("%v", *o.PeeringLocation)) + } + return &out +} + +// GetFailoverSingleTestDetails ... +func (c VirtualNetworkGatewaysClient) GetFailoverSingleTestDetails(ctx context.Context, id VirtualNetworkGatewayId, options GetFailoverSingleTestDetailsOperationOptions) (result GetFailoverSingleTestDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/getFailoverSingleTestDetails", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetFailoverSingleTestDetailsThenPoll performs GetFailoverSingleTestDetails then polls until it's completed +func (c VirtualNetworkGatewaysClient) GetFailoverSingleTestDetailsThenPoll(ctx context.Context, id VirtualNetworkGatewayId, options GetFailoverSingleTestDetailsOperationOptions) error { + result, err := c.GetFailoverSingleTestDetails(ctx, id, options) + if err != nil { + return fmt.Errorf("performing GetFailoverSingleTestDetails: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetFailoverSingleTestDetails: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getlearnedroutes.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getlearnedroutes.go new file mode 100644 index 00000000000..3cfd0aa16a8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getlearnedroutes.go @@ -0,0 +1,71 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetLearnedRoutesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *GatewayRouteListResult +} + +// GetLearnedRoutes ... +func (c VirtualNetworkGatewaysClient) GetLearnedRoutes(ctx context.Context, id VirtualNetworkGatewayId) (result GetLearnedRoutesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getLearnedRoutes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetLearnedRoutesThenPoll performs GetLearnedRoutes then polls until it's completed +func (c VirtualNetworkGatewaysClient) GetLearnedRoutesThenPoll(ctx context.Context, id VirtualNetworkGatewayId) error { + result, err := c.GetLearnedRoutes(ctx, id) + if err != nil { + return fmt.Errorf("performing GetLearnedRoutes: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetLearnedRoutes: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getresiliencyinformation.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getresiliencyinformation.go new file mode 100644 index 00000000000..889c306120d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getresiliencyinformation.go @@ -0,0 +1,100 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetResiliencyInformationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *GatewayResiliencyInformation +} + +type GetResiliencyInformationOperationOptions struct { + AttemptRefresh *bool +} + +func DefaultGetResiliencyInformationOperationOptions() GetResiliencyInformationOperationOptions { + return GetResiliencyInformationOperationOptions{} +} + +func (o GetResiliencyInformationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetResiliencyInformationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetResiliencyInformationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AttemptRefresh != nil { + out.Append("attemptRefresh", fmt.Sprintf("%v", *o.AttemptRefresh)) + } + return &out +} + +// GetResiliencyInformation ... +func (c VirtualNetworkGatewaysClient) GetResiliencyInformation(ctx context.Context, id VirtualNetworkGatewayId, options GetResiliencyInformationOperationOptions) (result GetResiliencyInformationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/getResiliencyInformation", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetResiliencyInformationThenPoll performs GetResiliencyInformation then polls until it's completed +func (c VirtualNetworkGatewaysClient) GetResiliencyInformationThenPoll(ctx context.Context, id VirtualNetworkGatewayId, options GetResiliencyInformationOperationOptions) error { + result, err := c.GetResiliencyInformation(ctx, id, options) + if err != nil { + return fmt.Errorf("performing GetResiliencyInformation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetResiliencyInformation: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getroutesinformation.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getroutesinformation.go new file mode 100644 index 00000000000..4a6ccd7f63f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getroutesinformation.go @@ -0,0 +1,100 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetRoutesInformationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *GatewayRouteSetsInformation +} + +type GetRoutesInformationOperationOptions struct { + AttemptRefresh *bool +} + +func DefaultGetRoutesInformationOperationOptions() GetRoutesInformationOperationOptions { + return GetRoutesInformationOperationOptions{} +} + +func (o GetRoutesInformationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetRoutesInformationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetRoutesInformationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AttemptRefresh != nil { + out.Append("attemptRefresh", fmt.Sprintf("%v", *o.AttemptRefresh)) + } + return &out +} + +// GetRoutesInformation ... +func (c VirtualNetworkGatewaysClient) GetRoutesInformation(ctx context.Context, id VirtualNetworkGatewayId, options GetRoutesInformationOperationOptions) (result GetRoutesInformationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/getRoutesInformation", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetRoutesInformationThenPoll performs GetRoutesInformation then polls until it's completed +func (c VirtualNetworkGatewaysClient) GetRoutesInformationThenPoll(ctx context.Context, id VirtualNetworkGatewayId, options GetRoutesInformationOperationOptions) error { + result, err := c.GetRoutesInformation(ctx, id, options) + if err != nil { + return fmt.Errorf("performing GetRoutesInformation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetRoutesInformation: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getvpnclientconnectionhealth.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getvpnclientconnectionhealth.go new file mode 100644 index 00000000000..8b7f93d0b5c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getvpnclientconnectionhealth.go @@ -0,0 +1,71 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetVpnclientConnectionHealthOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VpnClientConnectionHealthDetailListResult +} + +// GetVpnclientConnectionHealth ... +func (c VirtualNetworkGatewaysClient) GetVpnclientConnectionHealth(ctx context.Context, id VirtualNetworkGatewayId) (result GetVpnclientConnectionHealthOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getVpnClientConnectionHealth", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetVpnclientConnectionHealthThenPoll performs GetVpnclientConnectionHealth then polls until it's completed +func (c VirtualNetworkGatewaysClient) GetVpnclientConnectionHealthThenPoll(ctx context.Context, id VirtualNetworkGatewayId) error { + result, err := c.GetVpnclientConnectionHealth(ctx, id) + if err != nil { + return fmt.Errorf("performing GetVpnclientConnectionHealth: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetVpnclientConnectionHealth: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getvpnclientipsecparameters.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getvpnclientipsecparameters.go new file mode 100644 index 00000000000..43dd02230df --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getvpnclientipsecparameters.go @@ -0,0 +1,70 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetVpnclientIPsecParametersOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VpnClientIPsecParameters +} + +// GetVpnclientIPsecParameters ... +func (c VirtualNetworkGatewaysClient) GetVpnclientIPsecParameters(ctx context.Context, id VirtualNetworkGatewayId) (result GetVpnclientIPsecParametersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getvpnclientipsecparameters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetVpnclientIPsecParametersThenPoll performs GetVpnclientIPsecParameters then polls until it's completed +func (c VirtualNetworkGatewaysClient) GetVpnclientIPsecParametersThenPoll(ctx context.Context, id VirtualNetworkGatewayId) error { + result, err := c.GetVpnclientIPsecParameters(ctx, id) + if err != nil { + return fmt.Errorf("performing GetVpnclientIPsecParameters: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetVpnclientIPsecParameters: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getvpnprofilepackageurl.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getvpnprofilepackageurl.go new file mode 100644 index 00000000000..e814c6eff38 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_getvpnprofilepackageurl.go @@ -0,0 +1,71 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetVpnProfilePackageURLOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// GetVpnProfilePackageURL ... +func (c VirtualNetworkGatewaysClient) GetVpnProfilePackageURL(ctx context.Context, id VirtualNetworkGatewayId) (result GetVpnProfilePackageURLOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getvpnprofilepackageurl", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GetVpnProfilePackageURLThenPoll performs GetVpnProfilePackageURL then polls until it's completed +func (c VirtualNetworkGatewaysClient) GetVpnProfilePackageURLThenPoll(ctx context.Context, id VirtualNetworkGatewayId) error { + result, err := c.GetVpnProfilePackageURL(ctx, id) + if err != nil { + return fmt.Errorf("performing GetVpnProfilePackageURL: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after GetVpnProfilePackageURL: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_list.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_list.go new file mode 100644 index 00000000000..8266a51728d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_list.go @@ -0,0 +1,106 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualNetworkGateway +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualNetworkGateway +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c VirtualNetworkGatewaysClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/virtualNetworkGateways", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualNetworkGateway `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c VirtualNetworkGatewaysClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, VirtualNetworkGatewayOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualNetworkGatewaysClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate VirtualNetworkGatewayOperationPredicate) (result ListCompleteResult, err error) { + items := make([]VirtualNetworkGateway, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_listconnections.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_listconnections.go new file mode 100644 index 00000000000..2f13ca7b97c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_listconnections.go @@ -0,0 +1,105 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualNetworkGatewayConnectionListEntity +} + +type ListConnectionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualNetworkGatewayConnectionListEntity +} + +type ListConnectionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListConnectionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListConnections ... +func (c VirtualNetworkGatewaysClient) ListConnections(ctx context.Context, id VirtualNetworkGatewayId) (result ListConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListConnectionsCustomPager{}, + Path: fmt.Sprintf("%s/connections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualNetworkGatewayConnectionListEntity `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListConnectionsComplete retrieves all the results into a single object +func (c VirtualNetworkGatewaysClient) ListConnectionsComplete(ctx context.Context, id VirtualNetworkGatewayId) (ListConnectionsCompleteResult, error) { + return c.ListConnectionsCompleteMatchingPredicate(ctx, id, VirtualNetworkGatewayConnectionListEntityOperationPredicate{}) +} + +// ListConnectionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualNetworkGatewaysClient) ListConnectionsCompleteMatchingPredicate(ctx context.Context, id VirtualNetworkGatewayId, predicate VirtualNetworkGatewayConnectionListEntityOperationPredicate) (result ListConnectionsCompleteResult, err error) { + items := make([]VirtualNetworkGatewayConnectionListEntity, 0) + + resp, err := c.ListConnections(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListConnectionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_reset.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_reset.go new file mode 100644 index 00000000000..fb6210d0c1e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_reset.go @@ -0,0 +1,100 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResetOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetworkGateway +} + +type ResetOperationOptions struct { + GatewayVip *string +} + +func DefaultResetOperationOptions() ResetOperationOptions { + return ResetOperationOptions{} +} + +func (o ResetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ResetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ResetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.GatewayVip != nil { + out.Append("gatewayVip", fmt.Sprintf("%v", *o.GatewayVip)) + } + return &out +} + +// Reset ... +func (c VirtualNetworkGatewaysClient) Reset(ctx context.Context, id VirtualNetworkGatewayId, options ResetOperationOptions) (result ResetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/reset", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResetThenPoll performs Reset then polls until it's completed +func (c VirtualNetworkGatewaysClient) ResetThenPoll(ctx context.Context, id VirtualNetworkGatewayId, options ResetOperationOptions) error { + result, err := c.Reset(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Reset: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Reset: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_resetvpnclientsharedkey.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_resetvpnclientsharedkey.go new file mode 100644 index 00000000000..3e10b92aa05 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_resetvpnclientsharedkey.go @@ -0,0 +1,70 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResetVpnClientSharedKeyOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ResetVpnClientSharedKey ... +func (c VirtualNetworkGatewaysClient) ResetVpnClientSharedKey(ctx context.Context, id VirtualNetworkGatewayId) (result ResetVpnClientSharedKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetvpnclientsharedkey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResetVpnClientSharedKeyThenPoll performs ResetVpnClientSharedKey then polls until it's completed +func (c VirtualNetworkGatewaysClient) ResetVpnClientSharedKeyThenPoll(ctx context.Context, id VirtualNetworkGatewayId) error { + result, err := c.ResetVpnClientSharedKey(ctx, id) + if err != nil { + return fmt.Errorf("performing ResetVpnClientSharedKey: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResetVpnClientSharedKey: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_setvpnclientipsecparameters.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_setvpnclientipsecparameters.go new file mode 100644 index 00000000000..c6ce6809b83 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_setvpnclientipsecparameters.go @@ -0,0 +1,75 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SetVpnclientIPsecParametersOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VpnClientIPsecParameters +} + +// SetVpnclientIPsecParameters ... +func (c VirtualNetworkGatewaysClient) SetVpnclientIPsecParameters(ctx context.Context, id VirtualNetworkGatewayId, input VpnClientIPsecParameters) (result SetVpnclientIPsecParametersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/setvpnclientipsecparameters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SetVpnclientIPsecParametersThenPoll performs SetVpnclientIPsecParameters then polls until it's completed +func (c VirtualNetworkGatewaysClient) SetVpnclientIPsecParametersThenPoll(ctx context.Context, id VirtualNetworkGatewayId, input VpnClientIPsecParameters) error { + result, err := c.SetVpnclientIPsecParameters(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SetVpnclientIPsecParameters: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SetVpnclientIPsecParameters: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_startexpressroutesitefailoversimulation.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_startexpressroutesitefailoversimulation.go new file mode 100644 index 00000000000..2807029e4ff --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_startexpressroutesitefailoversimulation.go @@ -0,0 +1,100 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartExpressRouteSiteFailoverSimulationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +type StartExpressRouteSiteFailoverSimulationOperationOptions struct { + PeeringLocation *string +} + +func DefaultStartExpressRouteSiteFailoverSimulationOperationOptions() StartExpressRouteSiteFailoverSimulationOperationOptions { + return StartExpressRouteSiteFailoverSimulationOperationOptions{} +} + +func (o StartExpressRouteSiteFailoverSimulationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartExpressRouteSiteFailoverSimulationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o StartExpressRouteSiteFailoverSimulationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.PeeringLocation != nil { + out.Append("peeringLocation", fmt.Sprintf("%v", *o.PeeringLocation)) + } + return &out +} + +// StartExpressRouteSiteFailoverSimulation ... +func (c VirtualNetworkGatewaysClient) StartExpressRouteSiteFailoverSimulation(ctx context.Context, id VirtualNetworkGatewayId, options StartExpressRouteSiteFailoverSimulationOperationOptions) (result StartExpressRouteSiteFailoverSimulationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/startSiteFailoverTest", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StartExpressRouteSiteFailoverSimulationThenPoll performs StartExpressRouteSiteFailoverSimulation then polls until it's completed +func (c VirtualNetworkGatewaysClient) StartExpressRouteSiteFailoverSimulationThenPoll(ctx context.Context, id VirtualNetworkGatewayId, options StartExpressRouteSiteFailoverSimulationOperationOptions) error { + result, err := c.StartExpressRouteSiteFailoverSimulation(ctx, id, options) + if err != nil { + return fmt.Errorf("performing StartExpressRouteSiteFailoverSimulation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartExpressRouteSiteFailoverSimulation: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_startpacketcapture.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_startpacketcapture.go new file mode 100644 index 00000000000..6aae280247b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_startpacketcapture.go @@ -0,0 +1,75 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartPacketCaptureOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// StartPacketCapture ... +func (c VirtualNetworkGatewaysClient) StartPacketCapture(ctx context.Context, id VirtualNetworkGatewayId, input VpnPacketCaptureStartParameters) (result StartPacketCaptureOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startPacketCapture", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StartPacketCaptureThenPoll performs StartPacketCapture then polls until it's completed +func (c VirtualNetworkGatewaysClient) StartPacketCaptureThenPoll(ctx context.Context, id VirtualNetworkGatewayId, input VpnPacketCaptureStartParameters) error { + result, err := c.StartPacketCapture(ctx, id, input) + if err != nil { + return fmt.Errorf("performing StartPacketCapture: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartPacketCapture: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_stopexpressroutesitefailoversimulation.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_stopexpressroutesitefailoversimulation.go new file mode 100644 index 00000000000..6ac35ccdd75 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_stopexpressroutesitefailoversimulation.go @@ -0,0 +1,75 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopExpressRouteSiteFailoverSimulationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// StopExpressRouteSiteFailoverSimulation ... +func (c VirtualNetworkGatewaysClient) StopExpressRouteSiteFailoverSimulation(ctx context.Context, id VirtualNetworkGatewayId, input ExpressRouteFailoverStopApiParameters) (result StopExpressRouteSiteFailoverSimulationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stopSiteFailoverTest", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StopExpressRouteSiteFailoverSimulationThenPoll performs StopExpressRouteSiteFailoverSimulation then polls until it's completed +func (c VirtualNetworkGatewaysClient) StopExpressRouteSiteFailoverSimulationThenPoll(ctx context.Context, id VirtualNetworkGatewayId, input ExpressRouteFailoverStopApiParameters) error { + result, err := c.StopExpressRouteSiteFailoverSimulation(ctx, id, input) + if err != nil { + return fmt.Errorf("performing StopExpressRouteSiteFailoverSimulation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StopExpressRouteSiteFailoverSimulation: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_stoppacketcapture.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_stoppacketcapture.go new file mode 100644 index 00000000000..b193430e431 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_stoppacketcapture.go @@ -0,0 +1,75 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopPacketCaptureOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// StopPacketCapture ... +func (c VirtualNetworkGatewaysClient) StopPacketCapture(ctx context.Context, id VirtualNetworkGatewayId, input VpnPacketCaptureStopParameters) (result StopPacketCaptureOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stopPacketCapture", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StopPacketCaptureThenPoll performs StopPacketCapture then polls until it's completed +func (c VirtualNetworkGatewaysClient) StopPacketCaptureThenPoll(ctx context.Context, id VirtualNetworkGatewayId, input VpnPacketCaptureStopParameters) error { + result, err := c.StopPacketCapture(ctx, id, input) + if err != nil { + return fmt.Errorf("performing StopPacketCapture: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StopPacketCapture: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_supportedvpndevices.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_supportedvpndevices.go new file mode 100644 index 00000000000..7b81cd2d32c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_supportedvpndevices.go @@ -0,0 +1,54 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedVpnDevicesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// SupportedVpnDevices ... +func (c VirtualNetworkGatewaysClient) SupportedVpnDevices(ctx context.Context, id VirtualNetworkGatewayId) (result SupportedVpnDevicesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/supportedvpndevices", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model string + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_updatetags.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_updatetags.go new file mode 100644 index 00000000000..a374667f9a3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_updatetags.go @@ -0,0 +1,75 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetworkGateway +} + +// UpdateTags ... +func (c VirtualNetworkGatewaysClient) UpdateTags(ctx context.Context, id VirtualNetworkGatewayId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateTagsThenPoll performs UpdateTags then polls until it's completed +func (c VirtualNetworkGatewaysClient) UpdateTagsThenPoll(ctx context.Context, id VirtualNetworkGatewayId, input TagsObject) error { + result, err := c.UpdateTags(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UpdateTags: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpdateTags: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaynatrulescreateorupdate.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaynatrulescreateorupdate.go new file mode 100644 index 00000000000..b68cd3bf17c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaynatrulescreateorupdate.go @@ -0,0 +1,75 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayNatRulesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetworkGatewayNatRule +} + +// VirtualNetworkGatewayNatRulesCreateOrUpdate ... +func (c VirtualNetworkGatewaysClient) VirtualNetworkGatewayNatRulesCreateOrUpdate(ctx context.Context, id VirtualNetworkGatewayNatRuleId, input VirtualNetworkGatewayNatRule) (result VirtualNetworkGatewayNatRulesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VirtualNetworkGatewayNatRulesCreateOrUpdateThenPoll performs VirtualNetworkGatewayNatRulesCreateOrUpdate then polls until it's completed +func (c VirtualNetworkGatewaysClient) VirtualNetworkGatewayNatRulesCreateOrUpdateThenPoll(ctx context.Context, id VirtualNetworkGatewayNatRuleId, input VirtualNetworkGatewayNatRule) error { + result, err := c.VirtualNetworkGatewayNatRulesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VirtualNetworkGatewayNatRulesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualNetworkGatewayNatRulesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaynatrulesdelete.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaynatrulesdelete.go new file mode 100644 index 00000000000..4d041050bd2 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaynatrulesdelete.go @@ -0,0 +1,71 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayNatRulesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VirtualNetworkGatewayNatRulesDelete ... +func (c VirtualNetworkGatewaysClient) VirtualNetworkGatewayNatRulesDelete(ctx context.Context, id VirtualNetworkGatewayNatRuleId) (result VirtualNetworkGatewayNatRulesDeleteOperationResponse, 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 +} + +// VirtualNetworkGatewayNatRulesDeleteThenPoll performs VirtualNetworkGatewayNatRulesDelete then polls until it's completed +func (c VirtualNetworkGatewaysClient) VirtualNetworkGatewayNatRulesDeleteThenPoll(ctx context.Context, id VirtualNetworkGatewayNatRuleId) error { + result, err := c.VirtualNetworkGatewayNatRulesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing VirtualNetworkGatewayNatRulesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualNetworkGatewayNatRulesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaynatrulesget.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaynatrulesget.go new file mode 100644 index 00000000000..10dc0fac1a6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaynatrulesget.go @@ -0,0 +1,53 @@ +package virtualnetworkgateways + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayNatRulesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetworkGatewayNatRule +} + +// VirtualNetworkGatewayNatRulesGet ... +func (c VirtualNetworkGatewaysClient) VirtualNetworkGatewayNatRulesGet(ctx context.Context, id VirtualNetworkGatewayNatRuleId) (result VirtualNetworkGatewayNatRulesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualNetworkGatewayNatRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaynatruleslistbyvirtualnetworkgateway.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaynatruleslistbyvirtualnetworkgateway.go new file mode 100644 index 00000000000..ce8ee5c4965 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaynatruleslistbyvirtualnetworkgateway.go @@ -0,0 +1,105 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayNatRulesListByVirtualNetworkGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualNetworkGatewayNatRule +} + +type VirtualNetworkGatewayNatRulesListByVirtualNetworkGatewayCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualNetworkGatewayNatRule +} + +type VirtualNetworkGatewayNatRulesListByVirtualNetworkGatewayCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VirtualNetworkGatewayNatRulesListByVirtualNetworkGatewayCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VirtualNetworkGatewayNatRulesListByVirtualNetworkGateway ... +func (c VirtualNetworkGatewaysClient) VirtualNetworkGatewayNatRulesListByVirtualNetworkGateway(ctx context.Context, id VirtualNetworkGatewayId) (result VirtualNetworkGatewayNatRulesListByVirtualNetworkGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VirtualNetworkGatewayNatRulesListByVirtualNetworkGatewayCustomPager{}, + Path: fmt.Sprintf("%s/natRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualNetworkGatewayNatRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VirtualNetworkGatewayNatRulesListByVirtualNetworkGatewayComplete retrieves all the results into a single object +func (c VirtualNetworkGatewaysClient) VirtualNetworkGatewayNatRulesListByVirtualNetworkGatewayComplete(ctx context.Context, id VirtualNetworkGatewayId) (VirtualNetworkGatewayNatRulesListByVirtualNetworkGatewayCompleteResult, error) { + return c.VirtualNetworkGatewayNatRulesListByVirtualNetworkGatewayCompleteMatchingPredicate(ctx, id, VirtualNetworkGatewayNatRuleOperationPredicate{}) +} + +// VirtualNetworkGatewayNatRulesListByVirtualNetworkGatewayCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualNetworkGatewaysClient) VirtualNetworkGatewayNatRulesListByVirtualNetworkGatewayCompleteMatchingPredicate(ctx context.Context, id VirtualNetworkGatewayId, predicate VirtualNetworkGatewayNatRuleOperationPredicate) (result VirtualNetworkGatewayNatRulesListByVirtualNetworkGatewayCompleteResult, err error) { + items := make([]VirtualNetworkGatewayNatRule, 0) + + resp, err := c.VirtualNetworkGatewayNatRulesListByVirtualNetworkGateway(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VirtualNetworkGatewayNatRulesListByVirtualNetworkGatewayCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaysinvokeabortmigration.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaysinvokeabortmigration.go new file mode 100644 index 00000000000..9fc5ab8a3a1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaysinvokeabortmigration.go @@ -0,0 +1,69 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewaysInvokeAbortMigrationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VirtualNetworkGatewaysInvokeAbortMigration ... +func (c VirtualNetworkGatewaysClient) VirtualNetworkGatewaysInvokeAbortMigration(ctx context.Context, id VirtualNetworkGatewayId) (result VirtualNetworkGatewaysInvokeAbortMigrationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/abortMigration", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VirtualNetworkGatewaysInvokeAbortMigrationThenPoll performs VirtualNetworkGatewaysInvokeAbortMigration then polls until it's completed +func (c VirtualNetworkGatewaysClient) VirtualNetworkGatewaysInvokeAbortMigrationThenPoll(ctx context.Context, id VirtualNetworkGatewayId) error { + result, err := c.VirtualNetworkGatewaysInvokeAbortMigration(ctx, id) + if err != nil { + return fmt.Errorf("performing VirtualNetworkGatewaysInvokeAbortMigration: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualNetworkGatewaysInvokeAbortMigration: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaysinvokecommitmigration.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaysinvokecommitmigration.go new file mode 100644 index 00000000000..418812a83b0 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaysinvokecommitmigration.go @@ -0,0 +1,69 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewaysInvokeCommitMigrationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VirtualNetworkGatewaysInvokeCommitMigration ... +func (c VirtualNetworkGatewaysClient) VirtualNetworkGatewaysInvokeCommitMigration(ctx context.Context, id VirtualNetworkGatewayId) (result VirtualNetworkGatewaysInvokeCommitMigrationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/commitMigration", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VirtualNetworkGatewaysInvokeCommitMigrationThenPoll performs VirtualNetworkGatewaysInvokeCommitMigration then polls until it's completed +func (c VirtualNetworkGatewaysClient) VirtualNetworkGatewaysInvokeCommitMigrationThenPoll(ctx context.Context, id VirtualNetworkGatewayId) error { + result, err := c.VirtualNetworkGatewaysInvokeCommitMigration(ctx, id) + if err != nil { + return fmt.Errorf("performing VirtualNetworkGatewaysInvokeCommitMigration: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualNetworkGatewaysInvokeCommitMigration: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaysinvokeexecutemigration.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaysinvokeexecutemigration.go new file mode 100644 index 00000000000..d02c674354f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaysinvokeexecutemigration.go @@ -0,0 +1,69 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewaysInvokeExecuteMigrationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VirtualNetworkGatewaysInvokeExecuteMigration ... +func (c VirtualNetworkGatewaysClient) VirtualNetworkGatewaysInvokeExecuteMigration(ctx context.Context, id VirtualNetworkGatewayId) (result VirtualNetworkGatewaysInvokeExecuteMigrationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/executeMigration", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VirtualNetworkGatewaysInvokeExecuteMigrationThenPoll performs VirtualNetworkGatewaysInvokeExecuteMigration then polls until it's completed +func (c VirtualNetworkGatewaysClient) VirtualNetworkGatewaysInvokeExecuteMigrationThenPoll(ctx context.Context, id VirtualNetworkGatewayId) error { + result, err := c.VirtualNetworkGatewaysInvokeExecuteMigration(ctx, id) + if err != nil { + return fmt.Errorf("performing VirtualNetworkGatewaysInvokeExecuteMigration: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualNetworkGatewaysInvokeExecuteMigration: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaysinvokepreparemigration.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaysinvokepreparemigration.go new file mode 100644 index 00000000000..07ffb3287af --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_virtualnetworkgatewaysinvokepreparemigration.go @@ -0,0 +1,73 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewaysInvokePrepareMigrationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VirtualNetworkGatewaysInvokePrepareMigration ... +func (c VirtualNetworkGatewaysClient) VirtualNetworkGatewaysInvokePrepareMigration(ctx context.Context, id VirtualNetworkGatewayId, input VirtualNetworkGatewayMigrationParameters) (result VirtualNetworkGatewaysInvokePrepareMigrationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/prepareMigration", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VirtualNetworkGatewaysInvokePrepareMigrationThenPoll performs VirtualNetworkGatewaysInvokePrepareMigration then polls until it's completed +func (c VirtualNetworkGatewaysClient) VirtualNetworkGatewaysInvokePrepareMigrationThenPoll(ctx context.Context, id VirtualNetworkGatewayId, input VirtualNetworkGatewayMigrationParameters) error { + result, err := c.VirtualNetworkGatewaysInvokePrepareMigration(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VirtualNetworkGatewaysInvokePrepareMigration: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualNetworkGatewaysInvokePrepareMigration: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/method_vpndeviceconfigurationscript.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_vpndeviceconfigurationscript.go new file mode 100644 index 00000000000..0dbfcf3f88f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/method_vpndeviceconfigurationscript.go @@ -0,0 +1,58 @@ +package virtualnetworkgateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnDeviceConfigurationScriptOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// VpnDeviceConfigurationScript ... +func (c VirtualNetworkGatewaysClient) VpnDeviceConfigurationScript(ctx context.Context, id ConnectionId, input VpnDeviceScriptParameters) (result VpnDeviceConfigurationScriptOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/vpndeviceconfigurationscript", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model string + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_addressspace.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_addressspace.go new file mode 100644 index 00000000000..87f7d9c56bf --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_addressspace.go @@ -0,0 +1,9 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressSpace struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_bgppeerstatus.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_bgppeerstatus.go new file mode 100644 index 00000000000..8b54be7d7ae --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_bgppeerstatus.go @@ -0,0 +1,15 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BgpPeerStatus struct { + Asn *int64 `json:"asn,omitempty"` + ConnectedDuration *string `json:"connectedDuration,omitempty"` + LocalAddress *string `json:"localAddress,omitempty"` + MessagesReceived *int64 `json:"messagesReceived,omitempty"` + MessagesSent *int64 `json:"messagesSent,omitempty"` + Neighbor *string `json:"neighbor,omitempty"` + RoutesReceived *int64 `json:"routesReceived,omitempty"` + State *BgpPeerState `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_bgppeerstatuslistresult.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_bgppeerstatuslistresult.go new file mode 100644 index 00000000000..4affff1a309 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_bgppeerstatuslistresult.go @@ -0,0 +1,8 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BgpPeerStatusListResult struct { + Value *[]BgpPeerStatus `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_bgpsettings.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_bgpsettings.go new file mode 100644 index 00000000000..38b1165bfa1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_bgpsettings.go @@ -0,0 +1,11 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BgpSettings struct { + Asn *int64 `json:"asn,omitempty"` + BgpPeeringAddress *string `json:"bgpPeeringAddress,omitempty"` + BgpPeeringAddresses *[]IPConfigurationBgpPeeringAddress `json:"bgpPeeringAddresses,omitempty"` + PeerWeight *int64 `json:"peerWeight,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_circuitmetadatamap.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_circuitmetadatamap.go new file mode 100644 index 00000000000..712ed0ecdf9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_circuitmetadatamap.go @@ -0,0 +1,10 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CircuitMetadataMap struct { + Link *string `json:"link,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailovercircuitresourcedetails.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailovercircuitresourcedetails.go new file mode 100644 index 00000000000..c472f193b1c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailovercircuitresourcedetails.go @@ -0,0 +1,10 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteFailoverCircuitResourceDetails struct { + ConnectionName *string `json:"connectionName,omitempty"` + Name *string `json:"name,omitempty"` + NrpResourceUri *string `json:"nrpResourceUri,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailoverconnectionresourcedetails.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailoverconnectionresourcedetails.go new file mode 100644 index 00000000000..6f6d9be99d1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailoverconnectionresourcedetails.go @@ -0,0 +1,11 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteFailoverConnectionResourceDetails struct { + LastUpdatedTime *string `json:"lastUpdatedTime,omitempty"` + Name *string `json:"name,omitempty"` + NrpResourceUri *string `json:"nrpResourceUri,omitempty"` + Status *FailoverConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailoverredundantroute.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailoverredundantroute.go new file mode 100644 index 00000000000..536b04fafb3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailoverredundantroute.go @@ -0,0 +1,9 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteFailoverRedundantRoute struct { + PeeringLocations *[]string `json:"peeringLocations,omitempty"` + Routes *[]string `json:"routes,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailoversingletestdetails.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailoversingletestdetails.go new file mode 100644 index 00000000000..cfc73148f29 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailoversingletestdetails.go @@ -0,0 +1,15 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteFailoverSingleTestDetails struct { + EndTimeUtc *string `json:"endTimeUtc,omitempty"` + FailoverConnectionDetails *[]FailoverConnectionDetails `json:"failoverConnectionDetails,omitempty"` + NonRedundantRoutes *[]string `json:"nonRedundantRoutes,omitempty"` + PeeringLocation *string `json:"peeringLocation,omitempty"` + RedundantRoutes *[]ExpressRouteFailoverRedundantRoute `json:"redundantRoutes,omitempty"` + StartTimeUtc *string `json:"startTimeUtc,omitempty"` + Status *FailoverTestStatusForSingleTest `json:"status,omitempty"` + WasSimulationSuccessful *bool `json:"wasSimulationSuccessful,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailoverstopapiparameters.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailoverstopapiparameters.go new file mode 100644 index 00000000000..cca1354d2b5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailoverstopapiparameters.go @@ -0,0 +1,10 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteFailoverStopApiParameters struct { + Details *[]FailoverConnectionDetails `json:"details,omitempty"` + PeeringLocation *string `json:"peeringLocation,omitempty"` + WasSimulationSuccessful *bool `json:"wasSimulationSuccessful,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailovertestdetails.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailovertestdetails.go new file mode 100644 index 00000000000..e0860ad589d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_expressroutefailovertestdetails.go @@ -0,0 +1,16 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExpressRouteFailoverTestDetails struct { + Circuits *[]ExpressRouteFailoverCircuitResourceDetails `json:"circuits,omitempty"` + Connections *[]ExpressRouteFailoverConnectionResourceDetails `json:"connections,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Issues *[]string `json:"issues,omitempty"` + PeeringLocation *string `json:"peeringLocation,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *FailoverTestStatus `json:"status,omitempty"` + TestGuid *string `json:"testGuid,omitempty"` + TestType *FailoverTestType `json:"testType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_failoverconnectiondetails.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_failoverconnectiondetails.go new file mode 100644 index 00000000000..19b8eb853e4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_failoverconnectiondetails.go @@ -0,0 +1,10 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FailoverConnectionDetails struct { + FailoverConnectionName *string `json:"failoverConnectionName,omitempty"` + FailoverLocation *string `json:"failoverLocation,omitempty"` + IsVerified *bool `json:"isVerified,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewaycustombgpipaddressipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewaycustombgpipaddressipconfiguration.go new file mode 100644 index 00000000000..6bb7f5aa055 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewaycustombgpipaddressipconfiguration.go @@ -0,0 +1,9 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayCustomBgpIPAddressIPConfiguration struct { + CustomBgpIPAddress string `json:"customBgpIpAddress"` + IPConfigurationId string `json:"ipConfigurationId"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayresiliencyinformation.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayresiliencyinformation.go new file mode 100644 index 00000000000..a3ebbe5cedc --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayresiliencyinformation.go @@ -0,0 +1,44 @@ +package virtualnetworkgateways + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayResiliencyInformation struct { + Components *[]ResiliencyRecommendationComponents `json:"components,omitempty"` + LastComputedTime *string `json:"lastComputedTime,omitempty"` + MaxScoreFromRecommendations *string `json:"maxScoreFromRecommendations,omitempty"` + MinScoreFromRecommendations *string `json:"minScoreFromRecommendations,omitempty"` + NextEligibleComputeTime *string `json:"nextEligibleComputeTime,omitempty"` + OverallScore *string `json:"overallScore,omitempty"` + ScoreChange *string `json:"scoreChange,omitempty"` +} + +func (o *GatewayResiliencyInformation) GetLastComputedTimeAsTime() (*time.Time, error) { + if o.LastComputedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastComputedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *GatewayResiliencyInformation) SetLastComputedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastComputedTime = &formatted +} + +func (o *GatewayResiliencyInformation) GetNextEligibleComputeTimeAsTime() (*time.Time, error) { + if o.NextEligibleComputeTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextEligibleComputeTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *GatewayResiliencyInformation) SetNextEligibleComputeTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextEligibleComputeTime = &formatted +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayresiliencyrecommendation.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayresiliencyrecommendation.go new file mode 100644 index 00000000000..2b79e5df832 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayresiliencyrecommendation.go @@ -0,0 +1,13 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayResiliencyRecommendation struct { + CallToActionLink *string `json:"callToActionLink,omitempty"` + CallToActionText *string `json:"callToActionText,omitempty"` + RecommendationId *string `json:"recommendationId,omitempty"` + RecommendationText *string `json:"recommendationText,omitempty"` + RecommendationTitle *string `json:"recommendationTitle,omitempty"` + Severity *string `json:"severity,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayroute.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayroute.go new file mode 100644 index 00000000000..038e61f22d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayroute.go @@ -0,0 +1,14 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayRoute struct { + AsPath *string `json:"asPath,omitempty"` + LocalAddress *string `json:"localAddress,omitempty"` + Network *string `json:"network,omitempty"` + NextHop *string `json:"nextHop,omitempty"` + Origin *string `json:"origin,omitempty"` + SourcePeer *string `json:"sourcePeer,omitempty"` + Weight *int64 `json:"weight,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayroutelistresult.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayroutelistresult.go new file mode 100644 index 00000000000..d0ab95ca8fb --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayroutelistresult.go @@ -0,0 +1,8 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayRouteListResult struct { + Value *[]GatewayRoute `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayrouteset.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayrouteset.go new file mode 100644 index 00000000000..bc167c96712 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayrouteset.go @@ -0,0 +1,10 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayRouteSet struct { + Details *map[string][]RouteSourceDetails `json:"details,omitempty"` + Locations *[]string `json:"locations,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayroutesetsinformation.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayroutesetsinformation.go new file mode 100644 index 00000000000..d403ff4a21f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_gatewayroutesetsinformation.go @@ -0,0 +1,42 @@ +package virtualnetworkgateways + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayRouteSetsInformation struct { + CircuitsMetadataMap *map[string]CircuitMetadataMap `json:"circuitsMetadataMap,omitempty"` + LastComputedTime *string `json:"lastComputedTime,omitempty"` + NextEligibleComputeTime *string `json:"nextEligibleComputeTime,omitempty"` + RouteSetVersion *string `json:"routeSetVersion,omitempty"` + RouteSets *[]GatewayRouteSet `json:"routeSets,omitempty"` +} + +func (o *GatewayRouteSetsInformation) GetLastComputedTimeAsTime() (*time.Time, error) { + if o.LastComputedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastComputedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *GatewayRouteSetsInformation) SetLastComputedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastComputedTime = &formatted +} + +func (o *GatewayRouteSetsInformation) GetNextEligibleComputeTimeAsTime() (*time.Time, error) { + if o.NextEligibleComputeTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextEligibleComputeTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *GatewayRouteSetsInformation) SetNextEligibleComputeTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextEligibleComputeTime = &formatted +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..8ad39869074 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..38fccb30a41 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_ipconfigurationbgppeeringaddress.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_ipconfigurationbgppeeringaddress.go new file mode 100644 index 00000000000..bfda111f40f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_ipconfigurationbgppeeringaddress.go @@ -0,0 +1,11 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationBgpPeeringAddress struct { + CustomBgpIPAddresses *[]string `json:"customBgpIpAddresses,omitempty"` + DefaultBgpIPAddresses *[]string `json:"defaultBgpIpAddresses,omitempty"` + IPconfigurationId *string `json:"ipconfigurationId,omitempty"` + TunnelIPAddresses *[]string `json:"tunnelIpAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_ipsecpolicy.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_ipsecpolicy.go new file mode 100644 index 00000000000..6db4ac44425 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_ipsecpolicy.go @@ -0,0 +1,15 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPsecPolicy struct { + DhGroup DhGroup `json:"dhGroup"` + IPsecEncryption IPsecEncryption `json:"ipsecEncryption"` + IPsecIntegrity IPsecIntegrity `json:"ipsecIntegrity"` + IkeEncryption IkeEncryption `json:"ikeEncryption"` + IkeIntegrity IkeIntegrity `json:"ikeIntegrity"` + PfsGroup PfsGroup `json:"pfsGroup"` + SaDataSizeKilobytes int64 `json:"saDataSizeKilobytes"` + SaLifeTimeSeconds int64 `json:"saLifeTimeSeconds"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_p2svpnconnectionrequest.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_p2svpnconnectionrequest.go new file mode 100644 index 00000000000..dafc643bcef --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_p2svpnconnectionrequest.go @@ -0,0 +1,8 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2SVpnConnectionRequest struct { + VpnConnectionIds *[]string `json:"vpnConnectionIds,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_radiusserver.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_radiusserver.go new file mode 100644 index 00000000000..eb891246991 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_radiusserver.go @@ -0,0 +1,10 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RadiusServer struct { + RadiusServerAddress string `json:"radiusServerAddress"` + RadiusServerScore *int64 `json:"radiusServerScore,omitempty"` + RadiusServerSecret *string `json:"radiusServerSecret,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_resiliencyrecommendationcomponents.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_resiliencyrecommendationcomponents.go new file mode 100644 index 00000000000..a28bfd3108d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_resiliencyrecommendationcomponents.go @@ -0,0 +1,11 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResiliencyRecommendationComponents struct { + CurrentScore *string `json:"currentScore,omitempty"` + MaxScore *string `json:"maxScore,omitempty"` + Name *string `json:"name,omitempty"` + Recommendations *[]GatewayResiliencyRecommendation `json:"recommendations,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_routesourcedetails.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_routesourcedetails.go new file mode 100644 index 00000000000..d6b38c8888a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_routesourcedetails.go @@ -0,0 +1,10 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteSourceDetails struct { + Circuit *string `json:"circuit,omitempty"` + Pri *string `json:"pri,omitempty"` + Sec *string `json:"sec,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_subresource.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_subresource.go new file mode 100644 index 00000000000..5e20a09efb4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_subresource.go @@ -0,0 +1,8 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_tagsobject.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_tagsobject.go new file mode 100644 index 00000000000..1208ffee7eb --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_tagsobject.go @@ -0,0 +1,8 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_trafficselectorpolicy.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_trafficselectorpolicy.go new file mode 100644 index 00000000000..6dbeefcf439 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_trafficselectorpolicy.go @@ -0,0 +1,9 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficSelectorPolicy struct { + LocalAddressRanges []string `json:"localAddressRanges"` + RemoteAddressRanges []string `json:"remoteAddressRanges"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_tunnelconnectionhealth.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_tunnelconnectionhealth.go new file mode 100644 index 00000000000..786b8730363 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_tunnelconnectionhealth.go @@ -0,0 +1,12 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TunnelConnectionHealth struct { + ConnectionStatus *VirtualNetworkGatewayConnectionStatus `json:"connectionStatus,omitempty"` + EgressBytesTransferred *int64 `json:"egressBytesTransferred,omitempty"` + IngressBytesTransferred *int64 `json:"ingressBytesTransferred,omitempty"` + LastConnectionEstablishedUtcTime *string `json:"lastConnectionEstablishedUtcTime,omitempty"` + Tunnel *string `json:"tunnel,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkconnectiongatewayreference.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkconnectiongatewayreference.go new file mode 100644 index 00000000000..f9ddd43a0b5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkconnectiongatewayreference.go @@ -0,0 +1,8 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkConnectionGatewayReference struct { + Id string `json:"id"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgateway.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgateway.go new file mode 100644 index 00000000000..09ed1954ed6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgateway.go @@ -0,0 +1,21 @@ +package virtualnetworkgateways + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGateway struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties VirtualNetworkGatewayPropertiesFormat `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayautoscalebounds.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayautoscalebounds.go new file mode 100644 index 00000000000..ba8082fea07 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayautoscalebounds.go @@ -0,0 +1,9 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayAutoScaleBounds struct { + Max *int64 `json:"max,omitempty"` + Min *int64 `json:"min,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayautoscaleconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayautoscaleconfiguration.go new file mode 100644 index 00000000000..c2bf005d067 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayautoscaleconfiguration.go @@ -0,0 +1,8 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayAutoScaleConfiguration struct { + Bounds *VirtualNetworkGatewayAutoScaleBounds `json:"bounds,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayconnectionlistentity.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayconnectionlistentity.go new file mode 100644 index 00000000000..fc88052ded9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayconnectionlistentity.go @@ -0,0 +1,14 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayConnectionListEntity struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties VirtualNetworkGatewayConnectionListEntityPropertiesFormat `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayconnectionlistentitypropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayconnectionlistentitypropertiesformat.go new file mode 100644 index 00000000000..ad063d3db47 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayconnectionlistentitypropertiesformat.go @@ -0,0 +1,30 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayConnectionListEntityPropertiesFormat struct { + AuthorizationKey *string `json:"authorizationKey,omitempty"` + ConnectionMode *VirtualNetworkGatewayConnectionMode `json:"connectionMode,omitempty"` + ConnectionProtocol *VirtualNetworkGatewayConnectionProtocol `json:"connectionProtocol,omitempty"` + ConnectionStatus *VirtualNetworkGatewayConnectionStatus `json:"connectionStatus,omitempty"` + ConnectionType VirtualNetworkGatewayConnectionType `json:"connectionType"` + EgressBytesTransferred *int64 `json:"egressBytesTransferred,omitempty"` + EnableBgp *bool `json:"enableBgp,omitempty"` + EnablePrivateLinkFastPath *bool `json:"enablePrivateLinkFastPath,omitempty"` + ExpressRouteGatewayBypass *bool `json:"expressRouteGatewayBypass,omitempty"` + GatewayCustomBgpIPAddresses *[]GatewayCustomBgpIPAddressIPConfiguration `json:"gatewayCustomBgpIpAddresses,omitempty"` + IPsecPolicies *[]IPsecPolicy `json:"ipsecPolicies,omitempty"` + IngressBytesTransferred *int64 `json:"ingressBytesTransferred,omitempty"` + LocalNetworkGateway2 *VirtualNetworkConnectionGatewayReference `json:"localNetworkGateway2,omitempty"` + Peer *SubResource `json:"peer,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + RoutingWeight *int64 `json:"routingWeight,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` + TrafficSelectorPolicies *[]TrafficSelectorPolicy `json:"trafficSelectorPolicies,omitempty"` + TunnelConnectionStatus *[]TunnelConnectionHealth `json:"tunnelConnectionStatus,omitempty"` + UsePolicyBasedTrafficSelectors *bool `json:"usePolicyBasedTrafficSelectors,omitempty"` + VirtualNetworkGateway1 VirtualNetworkConnectionGatewayReference `json:"virtualNetworkGateway1"` + VirtualNetworkGateway2 *VirtualNetworkConnectionGatewayReference `json:"virtualNetworkGateway2,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayipconfiguration.go new file mode 100644 index 00000000000..b0f988e9a2c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayipconfiguration.go @@ -0,0 +1,11 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..f4396964e0a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayIPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *SubResource `json:"publicIPAddress,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaymigrationparameters.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaymigrationparameters.go new file mode 100644 index 00000000000..bf5c5090fca --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaymigrationparameters.go @@ -0,0 +1,9 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayMigrationParameters struct { + MigrationType VirtualNetworkGatewayMigrationType `json:"migrationType"` + ResourceURL *string `json:"resourceUrl,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaymigrationstatus.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaymigrationstatus.go new file mode 100644 index 00000000000..ba9612aaacb --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaymigrationstatus.go @@ -0,0 +1,10 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayMigrationStatus struct { + ErrorMessage *string `json:"errorMessage,omitempty"` + Phase *VirtualNetworkGatewayMigrationPhase `json:"phase,omitempty"` + State *VirtualNetworkGatewayMigrationState `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaynatrule.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaynatrule.go new file mode 100644 index 00000000000..f8d6791d170 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaynatrule.go @@ -0,0 +1,12 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkGatewayNatRuleProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaynatruleproperties.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaynatruleproperties.go new file mode 100644 index 00000000000..6227a89e253 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaynatruleproperties.go @@ -0,0 +1,13 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayNatRuleProperties struct { + ExternalMappings *[]VpnNatRuleMapping `json:"externalMappings,omitempty"` + IPConfigurationId *string `json:"ipConfigurationId,omitempty"` + InternalMappings *[]VpnNatRuleMapping `json:"internalMappings,omitempty"` + Mode *VpnNatRuleMode `json:"mode,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Type *VpnNatRuleType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaypolicygroup.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaypolicygroup.go new file mode 100644 index 00000000000..ebd198d261e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaypolicygroup.go @@ -0,0 +1,11 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayPolicyGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkGatewayPolicyGroupProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaypolicygroupmember.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaypolicygroupmember.go new file mode 100644 index 00000000000..466e643ddd8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaypolicygroupmember.go @@ -0,0 +1,10 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayPolicyGroupMember struct { + AttributeType *VpnPolicyMemberAttributeType `json:"attributeType,omitempty"` + AttributeValue *string `json:"attributeValue,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaypolicygroupproperties.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaypolicygroupproperties.go new file mode 100644 index 00000000000..ab108714ff3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaypolicygroupproperties.go @@ -0,0 +1,12 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayPolicyGroupProperties struct { + IsDefault bool `json:"isDefault"` + PolicyMembers []VirtualNetworkGatewayPolicyGroupMember `json:"policyMembers"` + Priority int64 `json:"priority"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VngClientConnectionConfigurations *[]SubResource `json:"vngClientConnectionConfigurations,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaypropertiesformat.go new file mode 100644 index 00000000000..64d8eb2a3d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaypropertiesformat.go @@ -0,0 +1,35 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayPropertiesFormat struct { + ActiveActive *bool `json:"activeActive,omitempty"` + AdminState *AdminState `json:"adminState,omitempty"` + AllowRemoteVnetTraffic *bool `json:"allowRemoteVnetTraffic,omitempty"` + AllowVirtualWanTraffic *bool `json:"allowVirtualWanTraffic,omitempty"` + AutoScaleConfiguration *VirtualNetworkGatewayAutoScaleConfiguration `json:"autoScaleConfiguration,omitempty"` + BgpSettings *BgpSettings `json:"bgpSettings,omitempty"` + CustomRoutes *AddressSpace `json:"customRoutes,omitempty"` + DisableIPSecReplayProtection *bool `json:"disableIPSecReplayProtection,omitempty"` + EnableBgp *bool `json:"enableBgp,omitempty"` + EnableBgpRouteTranslationForNat *bool `json:"enableBgpRouteTranslationForNat,omitempty"` + EnableDnsForwarding *bool `json:"enableDnsForwarding,omitempty"` + EnableHighBandwidthVpnGateway *bool `json:"enableHighBandwidthVpnGateway,omitempty"` + EnablePrivateIPAddress *bool `json:"enablePrivateIpAddress,omitempty"` + GatewayDefaultSite *SubResource `json:"gatewayDefaultSite,omitempty"` + GatewayType *VirtualNetworkGatewayType `json:"gatewayType,omitempty"` + IPConfigurations *[]VirtualNetworkGatewayIPConfiguration `json:"ipConfigurations,omitempty"` + InboundDnsForwardingEndpoint *string `json:"inboundDnsForwardingEndpoint,omitempty"` + NatRules *[]VirtualNetworkGatewayNatRule `json:"natRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResiliencyModel *ResiliencyModel `json:"resiliencyModel,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Sku *VirtualNetworkGatewaySku `json:"sku,omitempty"` + VNetExtendedLocationResourceId *string `json:"vNetExtendedLocationResourceId,omitempty"` + VirtualNetworkGatewayMigrationStatus *VirtualNetworkGatewayMigrationStatus `json:"virtualNetworkGatewayMigrationStatus,omitempty"` + VirtualNetworkGatewayPolicyGroups *[]VirtualNetworkGatewayPolicyGroup `json:"virtualNetworkGatewayPolicyGroups,omitempty"` + VpnClientConfiguration *VpnClientConfiguration `json:"vpnClientConfiguration,omitempty"` + VpnGatewayGeneration *VpnGatewayGeneration `json:"vpnGatewayGeneration,omitempty"` + VpnType *VpnType `json:"vpnType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaysku.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaysku.go new file mode 100644 index 00000000000..b96386d7651 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_virtualnetworkgatewaysku.go @@ -0,0 +1,10 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewaySku struct { + Capacity *int64 `json:"capacity,omitempty"` + Name *VirtualNetworkGatewaySkuName `json:"name,omitempty"` + Tier *VirtualNetworkGatewaySkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vngclientconnectionconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vngclientconnectionconfiguration.go new file mode 100644 index 00000000000..44c61c02167 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vngclientconnectionconfiguration.go @@ -0,0 +1,11 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VngClientConnectionConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VngClientConnectionConfigurationProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vngclientconnectionconfigurationproperties.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vngclientconnectionconfigurationproperties.go new file mode 100644 index 00000000000..8bf37c29734 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vngclientconnectionconfigurationproperties.go @@ -0,0 +1,10 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VngClientConnectionConfigurationProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkGatewayPolicyGroups []SubResource `json:"virtualNetworkGatewayPolicyGroups"` + VpnClientAddressPool AddressSpace `json:"vpnClientAddressPool"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientconfiguration.go new file mode 100644 index 00000000000..947582e3da9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientconfiguration.go @@ -0,0 +1,20 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnClientConfiguration struct { + AadAudience *string `json:"aadAudience,omitempty"` + AadIssuer *string `json:"aadIssuer,omitempty"` + AadTenant *string `json:"aadTenant,omitempty"` + RadiusServerAddress *string `json:"radiusServerAddress,omitempty"` + RadiusServerSecret *string `json:"radiusServerSecret,omitempty"` + RadiusServers *[]RadiusServer `json:"radiusServers,omitempty"` + VngClientConnectionConfigurations *[]VngClientConnectionConfiguration `json:"vngClientConnectionConfigurations,omitempty"` + VpnAuthenticationTypes *[]VpnAuthenticationType `json:"vpnAuthenticationTypes,omitempty"` + VpnClientAddressPool *AddressSpace `json:"vpnClientAddressPool,omitempty"` + VpnClientIPsecPolicies *[]IPsecPolicy `json:"vpnClientIpsecPolicies,omitempty"` + VpnClientProtocols *[]VpnClientProtocol `json:"vpnClientProtocols,omitempty"` + VpnClientRevokedCertificates *[]VpnClientRevokedCertificate `json:"vpnClientRevokedCertificates,omitempty"` + VpnClientRootCertificates *[]VpnClientRootCertificate `json:"vpnClientRootCertificates,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientconnectionhealthdetail.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientconnectionhealthdetail.go new file mode 100644 index 00000000000..c1bd5bd01b8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientconnectionhealthdetail.go @@ -0,0 +1,19 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnClientConnectionHealthDetail struct { + EgressBytesTransferred *int64 `json:"egressBytesTransferred,omitempty"` + EgressPacketsTransferred *int64 `json:"egressPacketsTransferred,omitempty"` + IngressBytesTransferred *int64 `json:"ingressBytesTransferred,omitempty"` + IngressPacketsTransferred *int64 `json:"ingressPacketsTransferred,omitempty"` + MaxBandwidth *int64 `json:"maxBandwidth,omitempty"` + MaxPacketsPerSecond *int64 `json:"maxPacketsPerSecond,omitempty"` + PrivateIPAddress *string `json:"privateIpAddress,omitempty"` + PublicIPAddress *string `json:"publicIpAddress,omitempty"` + VpnConnectionDuration *int64 `json:"vpnConnectionDuration,omitempty"` + VpnConnectionId *string `json:"vpnConnectionId,omitempty"` + VpnConnectionTime *string `json:"vpnConnectionTime,omitempty"` + VpnUserName *string `json:"vpnUserName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientconnectionhealthdetaillistresult.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientconnectionhealthdetaillistresult.go new file mode 100644 index 00000000000..d0c7c1a3f22 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientconnectionhealthdetaillistresult.go @@ -0,0 +1,8 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnClientConnectionHealthDetailListResult struct { + Value *[]VpnClientConnectionHealthDetail `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientipsecparameters.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientipsecparameters.go new file mode 100644 index 00000000000..d972e45d72e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientipsecparameters.go @@ -0,0 +1,15 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnClientIPsecParameters struct { + DhGroup DhGroup `json:"dhGroup"` + IPsecEncryption IPsecEncryption `json:"ipsecEncryption"` + IPsecIntegrity IPsecIntegrity `json:"ipsecIntegrity"` + IkeEncryption IkeEncryption `json:"ikeEncryption"` + IkeIntegrity IkeIntegrity `json:"ikeIntegrity"` + PfsGroup PfsGroup `json:"pfsGroup"` + SaDataSizeKilobytes int64 `json:"saDataSizeKilobytes"` + SaLifeTimeSeconds int64 `json:"saLifeTimeSeconds"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientparameters.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientparameters.go new file mode 100644 index 00000000000..dbfa84e1c67 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientparameters.go @@ -0,0 +1,11 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnClientParameters struct { + AuthenticationMethod *AuthenticationMethod `json:"authenticationMethod,omitempty"` + ClientRootCertificates *[]string `json:"clientRootCertificates,omitempty"` + ProcessorArchitecture *ProcessorArchitecture `json:"processorArchitecture,omitempty"` + RadiusServerAuthCertificate *string `json:"radiusServerAuthCertificate,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientrevokedcertificate.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientrevokedcertificate.go new file mode 100644 index 00000000000..2151e3bf02b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientrevokedcertificate.go @@ -0,0 +1,11 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnClientRevokedCertificate struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnClientRevokedCertificatePropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientrevokedcertificatepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientrevokedcertificatepropertiesformat.go new file mode 100644 index 00000000000..9a5fb25ca9b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientrevokedcertificatepropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnClientRevokedCertificatePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientrootcertificate.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientrootcertificate.go new file mode 100644 index 00000000000..db4850a95ff --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientrootcertificate.go @@ -0,0 +1,11 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnClientRootCertificate struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties VpnClientRootCertificatePropertiesFormat `json:"properties"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientrootcertificatepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientrootcertificatepropertiesformat.go new file mode 100644 index 00000000000..4a44a811b2a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnclientrootcertificatepropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnClientRootCertificatePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicCertData string `json:"publicCertData"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpndevicescriptparameters.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpndevicescriptparameters.go new file mode 100644 index 00000000000..61ec4f46b54 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpndevicescriptparameters.go @@ -0,0 +1,10 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnDeviceScriptParameters struct { + DeviceFamily *string `json:"deviceFamily,omitempty"` + FirmwareVersion *string `json:"firmwareVersion,omitempty"` + Vendor *string `json:"vendor,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnnatrulemapping.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnnatrulemapping.go new file mode 100644 index 00000000000..d903f625a58 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnnatrulemapping.go @@ -0,0 +1,9 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnNatRuleMapping struct { + AddressSpace *string `json:"addressSpace,omitempty"` + PortRange *string `json:"portRange,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnpacketcapturestartparameters.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnpacketcapturestartparameters.go new file mode 100644 index 00000000000..014f699e436 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnpacketcapturestartparameters.go @@ -0,0 +1,8 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnPacketCaptureStartParameters struct { + FilterData *string `json:"filterData,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnpacketcapturestopparameters.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnpacketcapturestopparameters.go new file mode 100644 index 00000000000..25f6fba8d55 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/model_vpnpacketcapturestopparameters.go @@ -0,0 +1,8 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnPacketCaptureStopParameters struct { + SasURL *string `json:"sasUrl,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/predicates.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/predicates.go new file mode 100644 index 00000000000..e03cad8f7b6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/predicates.go @@ -0,0 +1,98 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkGatewayOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p VirtualNetworkGatewayOperationPredicate) Matches(input VirtualNetworkGateway) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type VirtualNetworkGatewayConnectionListEntityOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p VirtualNetworkGatewayConnectionListEntityOperationPredicate) Matches(input VirtualNetworkGatewayConnectionListEntity) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type VirtualNetworkGatewayNatRuleOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p VirtualNetworkGatewayNatRuleOperationPredicate) Matches(input VirtualNetworkGatewayNatRule) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkgateways/version.go b/resource-manager/network/2024-07-01/virtualnetworkgateways/version.go new file mode 100644 index 00000000000..c144b7ec8fe --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkgateways/version.go @@ -0,0 +1,10 @@ +package virtualnetworkgateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/virtualnetworkgateways/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/README.md b/resource-manager/network/2024-07-01/virtualnetworkpeerings/README.md new file mode 100644 index 00000000000..30552c98a7a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/README.md @@ -0,0 +1,83 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworkpeerings` Documentation + +The `virtualnetworkpeerings` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworkpeerings" +``` + + +### Client Initialization + +```go +client := virtualnetworkpeerings.NewVirtualNetworkPeeringsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VirtualNetworkPeeringsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualnetworkpeerings.NewVirtualNetworkPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName", "virtualNetworkPeeringName") + +payload := virtualnetworkpeerings.VirtualNetworkPeering{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload, virtualnetworkpeerings.DefaultCreateOrUpdateOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkPeeringsClient.Delete` + +```go +ctx := context.TODO() +id := virtualnetworkpeerings.NewVirtualNetworkPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName", "virtualNetworkPeeringName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkPeeringsClient.Get` + +```go +ctx := context.TODO() +id := virtualnetworkpeerings.NewVirtualNetworkPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName", "virtualNetworkPeeringName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualNetworkPeeringsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewVirtualNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/client.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/client.go new file mode 100644 index 00000000000..a8632e2ec55 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/client.go @@ -0,0 +1,26 @@ +package virtualnetworkpeerings + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkPeeringsClient struct { + Client *resourcemanager.Client +} + +func NewVirtualNetworkPeeringsClientWithBaseURI(sdkApi sdkEnv.Api) (*VirtualNetworkPeeringsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "virtualnetworkpeerings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VirtualNetworkPeeringsClient: %+v", err) + } + + return &VirtualNetworkPeeringsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/constants.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/constants.go new file mode 100644 index 00000000000..0cb41da70fc --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/constants.go @@ -0,0 +1,227 @@ +package virtualnetworkpeerings + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SyncRemoteAddressSpace string + +const ( + SyncRemoteAddressSpaceTrue SyncRemoteAddressSpace = "true" +) + +func PossibleValuesForSyncRemoteAddressSpace() []string { + return []string{ + string(SyncRemoteAddressSpaceTrue), + } +} + +func (s *SyncRemoteAddressSpace) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncRemoteAddressSpace(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncRemoteAddressSpace(input string) (*SyncRemoteAddressSpace, error) { + vals := map[string]SyncRemoteAddressSpace{ + "true": SyncRemoteAddressSpaceTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncRemoteAddressSpace(input) + return &out, nil +} + +type VirtualNetworkEncryptionEnforcement string + +const ( + VirtualNetworkEncryptionEnforcementAllowUnencrypted VirtualNetworkEncryptionEnforcement = "AllowUnencrypted" + VirtualNetworkEncryptionEnforcementDropUnencrypted VirtualNetworkEncryptionEnforcement = "DropUnencrypted" +) + +func PossibleValuesForVirtualNetworkEncryptionEnforcement() []string { + return []string{ + string(VirtualNetworkEncryptionEnforcementAllowUnencrypted), + string(VirtualNetworkEncryptionEnforcementDropUnencrypted), + } +} + +func (s *VirtualNetworkEncryptionEnforcement) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkEncryptionEnforcement(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkEncryptionEnforcement(input string) (*VirtualNetworkEncryptionEnforcement, error) { + vals := map[string]VirtualNetworkEncryptionEnforcement{ + "allowunencrypted": VirtualNetworkEncryptionEnforcementAllowUnencrypted, + "dropunencrypted": VirtualNetworkEncryptionEnforcementDropUnencrypted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkEncryptionEnforcement(input) + return &out, nil +} + +type VirtualNetworkPeeringLevel string + +const ( + VirtualNetworkPeeringLevelFullyInSync VirtualNetworkPeeringLevel = "FullyInSync" + VirtualNetworkPeeringLevelLocalAndRemoteNotInSync VirtualNetworkPeeringLevel = "LocalAndRemoteNotInSync" + VirtualNetworkPeeringLevelLocalNotInSync VirtualNetworkPeeringLevel = "LocalNotInSync" + VirtualNetworkPeeringLevelRemoteNotInSync VirtualNetworkPeeringLevel = "RemoteNotInSync" +) + +func PossibleValuesForVirtualNetworkPeeringLevel() []string { + return []string{ + string(VirtualNetworkPeeringLevelFullyInSync), + string(VirtualNetworkPeeringLevelLocalAndRemoteNotInSync), + string(VirtualNetworkPeeringLevelLocalNotInSync), + string(VirtualNetworkPeeringLevelRemoteNotInSync), + } +} + +func (s *VirtualNetworkPeeringLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPeeringLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPeeringLevel(input string) (*VirtualNetworkPeeringLevel, error) { + vals := map[string]VirtualNetworkPeeringLevel{ + "fullyinsync": VirtualNetworkPeeringLevelFullyInSync, + "localandremotenotinsync": VirtualNetworkPeeringLevelLocalAndRemoteNotInSync, + "localnotinsync": VirtualNetworkPeeringLevelLocalNotInSync, + "remotenotinsync": VirtualNetworkPeeringLevelRemoteNotInSync, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPeeringLevel(input) + return &out, nil +} + +type VirtualNetworkPeeringState string + +const ( + VirtualNetworkPeeringStateConnected VirtualNetworkPeeringState = "Connected" + VirtualNetworkPeeringStateDisconnected VirtualNetworkPeeringState = "Disconnected" + VirtualNetworkPeeringStateInitiated VirtualNetworkPeeringState = "Initiated" +) + +func PossibleValuesForVirtualNetworkPeeringState() []string { + return []string{ + string(VirtualNetworkPeeringStateConnected), + string(VirtualNetworkPeeringStateDisconnected), + string(VirtualNetworkPeeringStateInitiated), + } +} + +func (s *VirtualNetworkPeeringState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPeeringState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPeeringState(input string) (*VirtualNetworkPeeringState, error) { + vals := map[string]VirtualNetworkPeeringState{ + "connected": VirtualNetworkPeeringStateConnected, + "disconnected": VirtualNetworkPeeringStateDisconnected, + "initiated": VirtualNetworkPeeringStateInitiated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPeeringState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/id_virtualnetworkpeering.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/id_virtualnetworkpeering.go new file mode 100644 index 00000000000..03298e7f706 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/id_virtualnetworkpeering.go @@ -0,0 +1,139 @@ +package virtualnetworkpeerings + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualNetworkPeeringId{}) +} + +var _ resourceids.ResourceId = &VirtualNetworkPeeringId{} + +// VirtualNetworkPeeringId is a struct representing the Resource ID for a Virtual Network Peering +type VirtualNetworkPeeringId struct { + SubscriptionId string + ResourceGroupName string + VirtualNetworkName string + VirtualNetworkPeeringName string +} + +// NewVirtualNetworkPeeringID returns a new VirtualNetworkPeeringId struct +func NewVirtualNetworkPeeringID(subscriptionId string, resourceGroupName string, virtualNetworkName string, virtualNetworkPeeringName string) VirtualNetworkPeeringId { + return VirtualNetworkPeeringId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualNetworkName: virtualNetworkName, + VirtualNetworkPeeringName: virtualNetworkPeeringName, + } +} + +// ParseVirtualNetworkPeeringID parses 'input' into a VirtualNetworkPeeringId +func ParseVirtualNetworkPeeringID(input string) (*VirtualNetworkPeeringId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkPeeringId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkPeeringId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualNetworkPeeringIDInsensitively parses 'input' case-insensitively into a VirtualNetworkPeeringId +// note: this method should only be used for API response data and not user input +func ParseVirtualNetworkPeeringIDInsensitively(input string) (*VirtualNetworkPeeringId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkPeeringId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkPeeringId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualNetworkPeeringId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VirtualNetworkName, ok = input.Parsed["virtualNetworkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkName", input) + } + + if id.VirtualNetworkPeeringName, ok = input.Parsed["virtualNetworkPeeringName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkPeeringName", input) + } + + return nil +} + +// ValidateVirtualNetworkPeeringID checks that 'input' can be parsed as a Virtual Network Peering ID +func ValidateVirtualNetworkPeeringID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVirtualNetworkPeeringID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Network Peering ID +func (id VirtualNetworkPeeringId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualNetworks/%s/virtualNetworkPeerings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualNetworkName, id.VirtualNetworkPeeringName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Network Peering ID +func (id VirtualNetworkPeeringId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVirtualNetworks", "virtualNetworks", "virtualNetworks"), + resourceids.UserSpecifiedSegment("virtualNetworkName", "virtualNetworkName"), + resourceids.StaticSegment("staticVirtualNetworkPeerings", "virtualNetworkPeerings", "virtualNetworkPeerings"), + resourceids.UserSpecifiedSegment("virtualNetworkPeeringName", "virtualNetworkPeeringName"), + } +} + +// String returns a human-readable description of this Virtual Network Peering ID +func (id VirtualNetworkPeeringId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Network Name: %q", id.VirtualNetworkName), + fmt.Sprintf("Virtual Network Peering Name: %q", id.VirtualNetworkPeeringName), + } + return fmt.Sprintf("Virtual Network Peering (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/id_virtualnetworkpeering_test.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/id_virtualnetworkpeering_test.go new file mode 100644 index 00000000000..239951e8c5f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/id_virtualnetworkpeering_test.go @@ -0,0 +1,327 @@ +package virtualnetworkpeerings + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualNetworkPeeringId{} + +func TestNewVirtualNetworkPeeringID(t *testing.T) { + id := NewVirtualNetworkPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName", "virtualNetworkPeeringName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VirtualNetworkName != "virtualNetworkName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkName'", id.VirtualNetworkName, "virtualNetworkName") + } + + if id.VirtualNetworkPeeringName != "virtualNetworkPeeringName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkPeeringName'", id.VirtualNetworkPeeringName, "virtualNetworkPeeringName") + } +} + +func TestFormatVirtualNetworkPeeringID(t *testing.T) { + actual := NewVirtualNetworkPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName", "virtualNetworkPeeringName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworks/virtualNetworkName/virtualNetworkPeerings/virtualNetworkPeeringName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualNetworkPeeringID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkPeeringId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworks/virtualNetworkName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworks/virtualNetworkName/virtualNetworkPeerings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworks/virtualNetworkName/virtualNetworkPeerings/virtualNetworkPeeringName", + Expected: &VirtualNetworkPeeringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualNetworkName: "virtualNetworkName", + VirtualNetworkPeeringName: "virtualNetworkPeeringName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworks/virtualNetworkName/virtualNetworkPeerings/virtualNetworkPeeringName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkPeeringID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualNetworkName != v.Expected.VirtualNetworkName { + t.Fatalf("Expected %q but got %q for VirtualNetworkName", v.Expected.VirtualNetworkName, actual.VirtualNetworkName) + } + + if actual.VirtualNetworkPeeringName != v.Expected.VirtualNetworkPeeringName { + t.Fatalf("Expected %q but got %q for VirtualNetworkPeeringName", v.Expected.VirtualNetworkPeeringName, actual.VirtualNetworkPeeringName) + } + + } +} + +func TestParseVirtualNetworkPeeringIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkPeeringId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlNeTwOrKs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworks/virtualNetworkName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlNeTwOrKs/vIrTuAlNeTwOrKnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworks/virtualNetworkName/virtualNetworkPeerings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlNeTwOrKs/vIrTuAlNeTwOrKnAmE/vIrTuAlNeTwOrKpEeRiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworks/virtualNetworkName/virtualNetworkPeerings/virtualNetworkPeeringName", + Expected: &VirtualNetworkPeeringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualNetworkName: "virtualNetworkName", + VirtualNetworkPeeringName: "virtualNetworkPeeringName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworks/virtualNetworkName/virtualNetworkPeerings/virtualNetworkPeeringName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlNeTwOrKs/vIrTuAlNeTwOrKnAmE/vIrTuAlNeTwOrKpEeRiNgS/vIrTuAlNeTwOrKpEeRiNgNaMe", + Expected: &VirtualNetworkPeeringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualNetworkName: "vIrTuAlNeTwOrKnAmE", + VirtualNetworkPeeringName: "vIrTuAlNeTwOrKpEeRiNgNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlNeTwOrKs/vIrTuAlNeTwOrKnAmE/vIrTuAlNeTwOrKpEeRiNgS/vIrTuAlNeTwOrKpEeRiNgNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkPeeringIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualNetworkName != v.Expected.VirtualNetworkName { + t.Fatalf("Expected %q but got %q for VirtualNetworkName", v.Expected.VirtualNetworkName, actual.VirtualNetworkName) + } + + if actual.VirtualNetworkPeeringName != v.Expected.VirtualNetworkPeeringName { + t.Fatalf("Expected %q but got %q for VirtualNetworkPeeringName", v.Expected.VirtualNetworkPeeringName, actual.VirtualNetworkPeeringName) + } + + } +} + +func TestSegmentsForVirtualNetworkPeeringId(t *testing.T) { + segments := VirtualNetworkPeeringId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualNetworkPeeringId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/method_createorupdate.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/method_createorupdate.go new file mode 100644 index 00000000000..950797b7302 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/method_createorupdate.go @@ -0,0 +1,104 @@ +package virtualnetworkpeerings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetworkPeering +} + +type CreateOrUpdateOperationOptions struct { + SyncRemoteAddressSpace *SyncRemoteAddressSpace +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SyncRemoteAddressSpace != nil { + out.Append("syncRemoteAddressSpace", fmt.Sprintf("%v", *o.SyncRemoteAddressSpace)) + } + return &out +} + +// CreateOrUpdate ... +func (c VirtualNetworkPeeringsClient) CreateOrUpdate(ctx context.Context, id VirtualNetworkPeeringId, input VirtualNetworkPeering, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c VirtualNetworkPeeringsClient) CreateOrUpdateThenPoll(ctx context.Context, id VirtualNetworkPeeringId, input VirtualNetworkPeering, options CreateOrUpdateOperationOptions) error { + result, err := c.CreateOrUpdate(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/method_delete.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/method_delete.go new file mode 100644 index 00000000000..0d0ded252a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/method_delete.go @@ -0,0 +1,71 @@ +package virtualnetworkpeerings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c VirtualNetworkPeeringsClient) Delete(ctx context.Context, id VirtualNetworkPeeringId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c VirtualNetworkPeeringsClient) DeleteThenPoll(ctx context.Context, id VirtualNetworkPeeringId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/method_get.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/method_get.go new file mode 100644 index 00000000000..8bc92358897 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/method_get.go @@ -0,0 +1,53 @@ +package virtualnetworkpeerings + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetworkPeering +} + +// Get ... +func (c VirtualNetworkPeeringsClient) Get(ctx context.Context, id VirtualNetworkPeeringId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualNetworkPeering + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/method_list.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/method_list.go new file mode 100644 index 00000000000..a18c0885cc9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/method_list.go @@ -0,0 +1,106 @@ +package virtualnetworkpeerings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualNetworkPeering +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualNetworkPeering +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c VirtualNetworkPeeringsClient) List(ctx context.Context, id commonids.VirtualNetworkId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/virtualNetworkPeerings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualNetworkPeering `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c VirtualNetworkPeeringsClient) ListComplete(ctx context.Context, id commonids.VirtualNetworkId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, VirtualNetworkPeeringOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualNetworkPeeringsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.VirtualNetworkId, predicate VirtualNetworkPeeringOperationPredicate) (result ListCompleteResult, err error) { + items := make([]VirtualNetworkPeering, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_addressspace.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_addressspace.go new file mode 100644 index 00000000000..62c939fafe8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_addressspace.go @@ -0,0 +1,9 @@ +package virtualnetworkpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressSpace struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..5cab441ca6e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package virtualnetworkpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..89e1a893cd9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package virtualnetworkpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_subresource.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_subresource.go new file mode 100644 index 00000000000..07cc63aadbb --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_subresource.go @@ -0,0 +1,8 @@ +package virtualnetworkpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_virtualnetworkbgpcommunities.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_virtualnetworkbgpcommunities.go new file mode 100644 index 00000000000..a1302f81779 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_virtualnetworkbgpcommunities.go @@ -0,0 +1,9 @@ +package virtualnetworkpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkBgpCommunities struct { + RegionalCommunity *string `json:"regionalCommunity,omitempty"` + VirtualNetworkCommunity string `json:"virtualNetworkCommunity"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_virtualnetworkencryption.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_virtualnetworkencryption.go new file mode 100644 index 00000000000..82989ac5992 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_virtualnetworkencryption.go @@ -0,0 +1,9 @@ +package virtualnetworkpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkEncryption struct { + Enabled bool `json:"enabled"` + Enforcement *VirtualNetworkEncryptionEnforcement `json:"enforcement,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_virtualnetworkpeering.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_virtualnetworkpeering.go new file mode 100644 index 00000000000..4b0c5a50abf --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_virtualnetworkpeering.go @@ -0,0 +1,12 @@ +package virtualnetworkpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkPeering struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkPeeringPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_virtualnetworkpeeringpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_virtualnetworkpeeringpropertiesformat.go new file mode 100644 index 00000000000..4081538e08f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/model_virtualnetworkpeeringpropertiesformat.go @@ -0,0 +1,27 @@ +package virtualnetworkpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkPeeringPropertiesFormat struct { + AllowForwardedTraffic *bool `json:"allowForwardedTraffic,omitempty"` + AllowGatewayTransit *bool `json:"allowGatewayTransit,omitempty"` + AllowVirtualNetworkAccess *bool `json:"allowVirtualNetworkAccess,omitempty"` + DoNotVerifyRemoteGateways *bool `json:"doNotVerifyRemoteGateways,omitempty"` + EnableOnlyIPv6Peering *bool `json:"enableOnlyIPv6Peering,omitempty"` + LocalAddressSpace *AddressSpace `json:"localAddressSpace,omitempty"` + LocalSubnetNames *[]string `json:"localSubnetNames,omitempty"` + LocalVirtualNetworkAddressSpace *AddressSpace `json:"localVirtualNetworkAddressSpace,omitempty"` + PeerCompleteVnets *bool `json:"peerCompleteVnets,omitempty"` + PeeringState *VirtualNetworkPeeringState `json:"peeringState,omitempty"` + PeeringSyncLevel *VirtualNetworkPeeringLevel `json:"peeringSyncLevel,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RemoteAddressSpace *AddressSpace `json:"remoteAddressSpace,omitempty"` + RemoteBgpCommunities *VirtualNetworkBgpCommunities `json:"remoteBgpCommunities,omitempty"` + RemoteSubnetNames *[]string `json:"remoteSubnetNames,omitempty"` + RemoteVirtualNetwork *SubResource `json:"remoteVirtualNetwork,omitempty"` + RemoteVirtualNetworkAddressSpace *AddressSpace `json:"remoteVirtualNetworkAddressSpace,omitempty"` + RemoteVirtualNetworkEncryption *VirtualNetworkEncryption `json:"remoteVirtualNetworkEncryption,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + UseRemoteGateways *bool `json:"useRemoteGateways,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/predicates.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/predicates.go new file mode 100644 index 00000000000..a945839e0b2 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/predicates.go @@ -0,0 +1,32 @@ +package virtualnetworkpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkPeeringOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p VirtualNetworkPeeringOperationPredicate) Matches(input VirtualNetworkPeering) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/virtualnetworkpeerings/version.go b/resource-manager/network/2024-07-01/virtualnetworkpeerings/version.go new file mode 100644 index 00000000000..d152c4f9183 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworkpeerings/version.go @@ -0,0 +1,10 @@ +package virtualnetworkpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/virtualnetworkpeerings/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/README.md b/resource-manager/network/2024-07-01/virtualnetworks/README.md new file mode 100644 index 00000000000..d32b5620a38 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/README.md @@ -0,0 +1,239 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworks` Documentation + +The `virtualnetworks` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworks" +``` + + +### Client Initialization + +```go +client := virtualnetworks.NewVirtualNetworksClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VirtualNetworksClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewVirtualNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName") + +payload := virtualnetworks.VirtualNetwork{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworksClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewVirtualNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworksClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewVirtualNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName") + +read, err := client.Get(ctx, id, virtualnetworks.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualNetworksClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualNetworksClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualNetworksClient.ResourceNavigationLinksList` + +```go +ctx := context.TODO() +id := commonids.NewSubnetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName", "subnetName") + +// alternatively `client.ResourceNavigationLinksList(ctx, id)` can be used to do batched pagination +items, err := client.ResourceNavigationLinksListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualNetworksClient.ServiceAssociationLinksList` + +```go +ctx := context.TODO() +id := commonids.NewSubnetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName", "subnetName") + +// alternatively `client.ServiceAssociationLinksList(ctx, id)` can be used to do batched pagination +items, err := client.ServiceAssociationLinksListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualNetworksClient.SubnetsPrepareNetworkPolicies` + +```go +ctx := context.TODO() +id := commonids.NewSubnetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName", "subnetName") + +payload := virtualnetworks.PrepareNetworkPoliciesRequest{ + // ... +} + + +if err := client.SubnetsPrepareNetworkPoliciesThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworksClient.SubnetsUnprepareNetworkPolicies` + +```go +ctx := context.TODO() +id := commonids.NewSubnetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName", "subnetName") + +payload := virtualnetworks.UnprepareNetworkPoliciesRequest{ + // ... +} + + +if err := client.SubnetsUnprepareNetworkPoliciesThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworksClient.UpdateTags` + +```go +ctx := context.TODO() +id := commonids.NewVirtualNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName") + +payload := virtualnetworks.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualNetworksClient.VirtualNetworksCheckIPAddressAvailability` + +```go +ctx := context.TODO() +id := commonids.NewVirtualNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName") + +read, err := client.VirtualNetworksCheckIPAddressAvailability(ctx, id, virtualnetworks.DefaultVirtualNetworksCheckIPAddressAvailabilityOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualNetworksClient.VirtualNetworksListDdosProtectionStatus` + +```go +ctx := context.TODO() +id := commonids.NewVirtualNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName") + +// alternatively `client.VirtualNetworksListDdosProtectionStatus(ctx, id, virtualnetworks.DefaultVirtualNetworksListDdosProtectionStatusOperationOptions())` can be used to do batched pagination +items, err := client.VirtualNetworksListDdosProtectionStatusComplete(ctx, id, virtualnetworks.DefaultVirtualNetworksListDdosProtectionStatusOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualNetworksClient.VirtualNetworksListUsage` + +```go +ctx := context.TODO() +id := commonids.NewVirtualNetworkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkName") + +// alternatively `client.VirtualNetworksListUsage(ctx, id)` can be used to do batched pagination +items, err := client.VirtualNetworksListUsageComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/virtualnetworks/client.go b/resource-manager/network/2024-07-01/virtualnetworks/client.go new file mode 100644 index 00000000000..9acbb6c1027 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/client.go @@ -0,0 +1,26 @@ +package virtualnetworks + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworksClient struct { + Client *resourcemanager.Client +} + +func NewVirtualNetworksClientWithBaseURI(sdkApi sdkEnv.Api) (*VirtualNetworksClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "virtualnetworks", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VirtualNetworksClient: %+v", err) + } + + return &VirtualNetworksClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/constants.go b/resource-manager/network/2024-07-01/virtualnetworks/constants.go new file mode 100644 index 00000000000..378681025b3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/constants.go @@ -0,0 +1,1418 @@ +package virtualnetworks + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type IsWorkloadProtected string + +const ( + IsWorkloadProtectedFalse IsWorkloadProtected = "False" + IsWorkloadProtectedTrue IsWorkloadProtected = "True" +) + +func PossibleValuesForIsWorkloadProtected() []string { + return []string{ + string(IsWorkloadProtectedFalse), + string(IsWorkloadProtectedTrue), + } +} + +func (s *IsWorkloadProtected) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsWorkloadProtected(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIsWorkloadProtected(input string) (*IsWorkloadProtected, error) { + vals := map[string]IsWorkloadProtected{ + "false": IsWorkloadProtectedFalse, + "true": IsWorkloadProtectedTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IsWorkloadProtected(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type PrivateEndpointVNetPolicies string + +const ( + PrivateEndpointVNetPoliciesBasic PrivateEndpointVNetPolicies = "Basic" + PrivateEndpointVNetPoliciesDisabled PrivateEndpointVNetPolicies = "Disabled" +) + +func PossibleValuesForPrivateEndpointVNetPolicies() []string { + return []string{ + string(PrivateEndpointVNetPoliciesBasic), + string(PrivateEndpointVNetPoliciesDisabled), + } +} + +func (s *PrivateEndpointVNetPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointVNetPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointVNetPolicies(input string) (*PrivateEndpointVNetPolicies, error) { + vals := map[string]PrivateEndpointVNetPolicies{ + "basic": PrivateEndpointVNetPoliciesBasic, + "disabled": PrivateEndpointVNetPoliciesDisabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointVNetPolicies(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkEncryptionEnforcement string + +const ( + VirtualNetworkEncryptionEnforcementAllowUnencrypted VirtualNetworkEncryptionEnforcement = "AllowUnencrypted" + VirtualNetworkEncryptionEnforcementDropUnencrypted VirtualNetworkEncryptionEnforcement = "DropUnencrypted" +) + +func PossibleValuesForVirtualNetworkEncryptionEnforcement() []string { + return []string{ + string(VirtualNetworkEncryptionEnforcementAllowUnencrypted), + string(VirtualNetworkEncryptionEnforcementDropUnencrypted), + } +} + +func (s *VirtualNetworkEncryptionEnforcement) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkEncryptionEnforcement(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkEncryptionEnforcement(input string) (*VirtualNetworkEncryptionEnforcement, error) { + vals := map[string]VirtualNetworkEncryptionEnforcement{ + "allowunencrypted": VirtualNetworkEncryptionEnforcementAllowUnencrypted, + "dropunencrypted": VirtualNetworkEncryptionEnforcementDropUnencrypted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkEncryptionEnforcement(input) + return &out, nil +} + +type VirtualNetworkPeeringLevel string + +const ( + VirtualNetworkPeeringLevelFullyInSync VirtualNetworkPeeringLevel = "FullyInSync" + VirtualNetworkPeeringLevelLocalAndRemoteNotInSync VirtualNetworkPeeringLevel = "LocalAndRemoteNotInSync" + VirtualNetworkPeeringLevelLocalNotInSync VirtualNetworkPeeringLevel = "LocalNotInSync" + VirtualNetworkPeeringLevelRemoteNotInSync VirtualNetworkPeeringLevel = "RemoteNotInSync" +) + +func PossibleValuesForVirtualNetworkPeeringLevel() []string { + return []string{ + string(VirtualNetworkPeeringLevelFullyInSync), + string(VirtualNetworkPeeringLevelLocalAndRemoteNotInSync), + string(VirtualNetworkPeeringLevelLocalNotInSync), + string(VirtualNetworkPeeringLevelRemoteNotInSync), + } +} + +func (s *VirtualNetworkPeeringLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPeeringLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPeeringLevel(input string) (*VirtualNetworkPeeringLevel, error) { + vals := map[string]VirtualNetworkPeeringLevel{ + "fullyinsync": VirtualNetworkPeeringLevelFullyInSync, + "localandremotenotinsync": VirtualNetworkPeeringLevelLocalAndRemoteNotInSync, + "localnotinsync": VirtualNetworkPeeringLevelLocalNotInSync, + "remotenotinsync": VirtualNetworkPeeringLevelRemoteNotInSync, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPeeringLevel(input) + return &out, nil +} + +type VirtualNetworkPeeringState string + +const ( + VirtualNetworkPeeringStateConnected VirtualNetworkPeeringState = "Connected" + VirtualNetworkPeeringStateDisconnected VirtualNetworkPeeringState = "Disconnected" + VirtualNetworkPeeringStateInitiated VirtualNetworkPeeringState = "Initiated" +) + +func PossibleValuesForVirtualNetworkPeeringState() []string { + return []string{ + string(VirtualNetworkPeeringStateConnected), + string(VirtualNetworkPeeringStateDisconnected), + string(VirtualNetworkPeeringStateInitiated), + } +} + +func (s *VirtualNetworkPeeringState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPeeringState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPeeringState(input string) (*VirtualNetworkPeeringState, error) { + vals := map[string]VirtualNetworkPeeringState{ + "connected": VirtualNetworkPeeringStateConnected, + "disconnected": VirtualNetworkPeeringStateDisconnected, + "initiated": VirtualNetworkPeeringStateInitiated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPeeringState(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/method_createorupdate.go b/resource-manager/network/2024-07-01/virtualnetworks/method_createorupdate.go new file mode 100644 index 00000000000..fb27efb9d4b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/method_createorupdate.go @@ -0,0 +1,76 @@ +package virtualnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetwork +} + +// CreateOrUpdate ... +func (c VirtualNetworksClient) CreateOrUpdate(ctx context.Context, id commonids.VirtualNetworkId, input VirtualNetwork) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c VirtualNetworksClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.VirtualNetworkId, input VirtualNetwork) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/method_delete.go b/resource-manager/network/2024-07-01/virtualnetworks/method_delete.go new file mode 100644 index 00000000000..53212cd5aba --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/method_delete.go @@ -0,0 +1,72 @@ +package virtualnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c VirtualNetworksClient) Delete(ctx context.Context, id commonids.VirtualNetworkId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c VirtualNetworksClient) DeleteThenPoll(ctx context.Context, id commonids.VirtualNetworkId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/method_get.go b/resource-manager/network/2024-07-01/virtualnetworks/method_get.go new file mode 100644 index 00000000000..db1b8807d3e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/method_get.go @@ -0,0 +1,84 @@ +package virtualnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetwork +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c VirtualNetworksClient) Get(ctx context.Context, id commonids.VirtualNetworkId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/method_list.go b/resource-manager/network/2024-07-01/virtualnetworks/method_list.go new file mode 100644 index 00000000000..e540706223a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/method_list.go @@ -0,0 +1,106 @@ +package virtualnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualNetwork +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualNetwork +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c VirtualNetworksClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/virtualNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualNetwork `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c VirtualNetworksClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, VirtualNetworkOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualNetworksClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate VirtualNetworkOperationPredicate) (result ListCompleteResult, err error) { + items := make([]VirtualNetwork, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/method_listall.go b/resource-manager/network/2024-07-01/virtualnetworks/method_listall.go new file mode 100644 index 00000000000..e91f96c1cf3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/method_listall.go @@ -0,0 +1,106 @@ +package virtualnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualNetwork +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualNetwork +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c VirtualNetworksClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/virtualNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualNetwork `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c VirtualNetworksClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, VirtualNetworkOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualNetworksClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate VirtualNetworkOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]VirtualNetwork, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/method_resourcenavigationlinkslist.go b/resource-manager/network/2024-07-01/virtualnetworks/method_resourcenavigationlinkslist.go new file mode 100644 index 00000000000..16f353bcd4e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/method_resourcenavigationlinkslist.go @@ -0,0 +1,106 @@ +package virtualnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinksListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceNavigationLink +} + +type ResourceNavigationLinksListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceNavigationLink +} + +type ResourceNavigationLinksListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ResourceNavigationLinksListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ResourceNavigationLinksList ... +func (c VirtualNetworksClient) ResourceNavigationLinksList(ctx context.Context, id commonids.SubnetId) (result ResourceNavigationLinksListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ResourceNavigationLinksListCustomPager{}, + Path: fmt.Sprintf("%s/resourceNavigationLinks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceNavigationLink `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ResourceNavigationLinksListComplete retrieves all the results into a single object +func (c VirtualNetworksClient) ResourceNavigationLinksListComplete(ctx context.Context, id commonids.SubnetId) (ResourceNavigationLinksListCompleteResult, error) { + return c.ResourceNavigationLinksListCompleteMatchingPredicate(ctx, id, ResourceNavigationLinkOperationPredicate{}) +} + +// ResourceNavigationLinksListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualNetworksClient) ResourceNavigationLinksListCompleteMatchingPredicate(ctx context.Context, id commonids.SubnetId, predicate ResourceNavigationLinkOperationPredicate) (result ResourceNavigationLinksListCompleteResult, err error) { + items := make([]ResourceNavigationLink, 0) + + resp, err := c.ResourceNavigationLinksList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ResourceNavigationLinksListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/method_serviceassociationlinkslist.go b/resource-manager/network/2024-07-01/virtualnetworks/method_serviceassociationlinkslist.go new file mode 100644 index 00000000000..c246c98a15b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/method_serviceassociationlinkslist.go @@ -0,0 +1,106 @@ +package virtualnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinksListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ServiceAssociationLink +} + +type ServiceAssociationLinksListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ServiceAssociationLink +} + +type ServiceAssociationLinksListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ServiceAssociationLinksListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ServiceAssociationLinksList ... +func (c VirtualNetworksClient) ServiceAssociationLinksList(ctx context.Context, id commonids.SubnetId) (result ServiceAssociationLinksListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ServiceAssociationLinksListCustomPager{}, + Path: fmt.Sprintf("%s/serviceAssociationLinks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ServiceAssociationLink `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ServiceAssociationLinksListComplete retrieves all the results into a single object +func (c VirtualNetworksClient) ServiceAssociationLinksListComplete(ctx context.Context, id commonids.SubnetId) (ServiceAssociationLinksListCompleteResult, error) { + return c.ServiceAssociationLinksListCompleteMatchingPredicate(ctx, id, ServiceAssociationLinkOperationPredicate{}) +} + +// ServiceAssociationLinksListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualNetworksClient) ServiceAssociationLinksListCompleteMatchingPredicate(ctx context.Context, id commonids.SubnetId, predicate ServiceAssociationLinkOperationPredicate) (result ServiceAssociationLinksListCompleteResult, err error) { + items := make([]ServiceAssociationLink, 0) + + resp, err := c.ServiceAssociationLinksList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ServiceAssociationLinksListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/method_subnetspreparenetworkpolicies.go b/resource-manager/network/2024-07-01/virtualnetworks/method_subnetspreparenetworkpolicies.go new file mode 100644 index 00000000000..b42b121f904 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/method_subnetspreparenetworkpolicies.go @@ -0,0 +1,75 @@ +package virtualnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetsPrepareNetworkPoliciesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SubnetsPrepareNetworkPolicies ... +func (c VirtualNetworksClient) SubnetsPrepareNetworkPolicies(ctx context.Context, id commonids.SubnetId, input PrepareNetworkPoliciesRequest) (result SubnetsPrepareNetworkPoliciesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/prepareNetworkPolicies", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SubnetsPrepareNetworkPoliciesThenPoll performs SubnetsPrepareNetworkPolicies then polls until it's completed +func (c VirtualNetworksClient) SubnetsPrepareNetworkPoliciesThenPoll(ctx context.Context, id commonids.SubnetId, input PrepareNetworkPoliciesRequest) error { + result, err := c.SubnetsPrepareNetworkPolicies(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SubnetsPrepareNetworkPolicies: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SubnetsPrepareNetworkPolicies: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/method_subnetsunpreparenetworkpolicies.go b/resource-manager/network/2024-07-01/virtualnetworks/method_subnetsunpreparenetworkpolicies.go new file mode 100644 index 00000000000..69a0e33a2c8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/method_subnetsunpreparenetworkpolicies.go @@ -0,0 +1,75 @@ +package virtualnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetsUnprepareNetworkPoliciesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SubnetsUnprepareNetworkPolicies ... +func (c VirtualNetworksClient) SubnetsUnprepareNetworkPolicies(ctx context.Context, id commonids.SubnetId, input UnprepareNetworkPoliciesRequest) (result SubnetsUnprepareNetworkPoliciesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/unprepareNetworkPolicies", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SubnetsUnprepareNetworkPoliciesThenPoll performs SubnetsUnprepareNetworkPolicies then polls until it's completed +func (c VirtualNetworksClient) SubnetsUnprepareNetworkPoliciesThenPoll(ctx context.Context, id commonids.SubnetId, input UnprepareNetworkPoliciesRequest) error { + result, err := c.SubnetsUnprepareNetworkPolicies(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SubnetsUnprepareNetworkPolicies: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SubnetsUnprepareNetworkPolicies: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/method_updatetags.go b/resource-manager/network/2024-07-01/virtualnetworks/method_updatetags.go new file mode 100644 index 00000000000..3e63f83e2a6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/method_updatetags.go @@ -0,0 +1,58 @@ +package virtualnetworks + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetwork +} + +// UpdateTags ... +func (c VirtualNetworksClient) UpdateTags(ctx context.Context, id commonids.VirtualNetworkId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/method_virtualnetworkscheckipaddressavailability.go b/resource-manager/network/2024-07-01/virtualnetworks/method_virtualnetworkscheckipaddressavailability.go new file mode 100644 index 00000000000..bcd41a4d551 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/method_virtualnetworkscheckipaddressavailability.go @@ -0,0 +1,84 @@ +package virtualnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworksCheckIPAddressAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *IPAddressAvailabilityResult +} + +type VirtualNetworksCheckIPAddressAvailabilityOperationOptions struct { + IPAddress *string +} + +func DefaultVirtualNetworksCheckIPAddressAvailabilityOperationOptions() VirtualNetworksCheckIPAddressAvailabilityOperationOptions { + return VirtualNetworksCheckIPAddressAvailabilityOperationOptions{} +} + +func (o VirtualNetworksCheckIPAddressAvailabilityOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o VirtualNetworksCheckIPAddressAvailabilityOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o VirtualNetworksCheckIPAddressAvailabilityOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IPAddress != nil { + out.Append("ipAddress", fmt.Sprintf("%v", *o.IPAddress)) + } + return &out +} + +// VirtualNetworksCheckIPAddressAvailability ... +func (c VirtualNetworksClient) VirtualNetworksCheckIPAddressAvailability(ctx context.Context, id commonids.VirtualNetworkId, options VirtualNetworksCheckIPAddressAvailabilityOperationOptions) (result VirtualNetworksCheckIPAddressAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/checkIPAddressAvailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model IPAddressAvailabilityResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/method_virtualnetworkslistddosprotectionstatus.go b/resource-manager/network/2024-07-01/virtualnetworks/method_virtualnetworkslistddosprotectionstatus.go new file mode 100644 index 00000000000..cfc2cb53d45 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/method_virtualnetworkslistddosprotectionstatus.go @@ -0,0 +1,123 @@ +package virtualnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworksListDdosProtectionStatusOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]PublicIPDdosProtectionStatusResult +} + +type VirtualNetworksListDdosProtectionStatusCompleteResult struct { + LatestHttpResponse *http.Response + Items []PublicIPDdosProtectionStatusResult +} + +type VirtualNetworksListDdosProtectionStatusOperationOptions struct { + SkipToken *string + Top *int64 +} + +func DefaultVirtualNetworksListDdosProtectionStatusOperationOptions() VirtualNetworksListDdosProtectionStatusOperationOptions { + return VirtualNetworksListDdosProtectionStatusOperationOptions{} +} + +func (o VirtualNetworksListDdosProtectionStatusOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o VirtualNetworksListDdosProtectionStatusOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o VirtualNetworksListDdosProtectionStatusOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SkipToken != nil { + out.Append("skipToken", fmt.Sprintf("%v", *o.SkipToken)) + } + if o.Top != nil { + out.Append("top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type VirtualNetworksListDdosProtectionStatusCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VirtualNetworksListDdosProtectionStatusCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VirtualNetworksListDdosProtectionStatus ... +func (c VirtualNetworksClient) VirtualNetworksListDdosProtectionStatus(ctx context.Context, id commonids.VirtualNetworkId, options VirtualNetworksListDdosProtectionStatusOperationOptions) (result VirtualNetworksListDdosProtectionStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Pager: &VirtualNetworksListDdosProtectionStatusCustomPager{}, + Path: fmt.Sprintf("%s/ddosProtectionStatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VirtualNetworksListDdosProtectionStatusThenPoll performs VirtualNetworksListDdosProtectionStatus then polls until it's completed +func (c VirtualNetworksClient) VirtualNetworksListDdosProtectionStatusThenPoll(ctx context.Context, id commonids.VirtualNetworkId, options VirtualNetworksListDdosProtectionStatusOperationOptions) error { + result, err := c.VirtualNetworksListDdosProtectionStatus(ctx, id, options) + if err != nil { + return fmt.Errorf("performing VirtualNetworksListDdosProtectionStatus: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualNetworksListDdosProtectionStatus: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/method_virtualnetworkslistusage.go b/resource-manager/network/2024-07-01/virtualnetworks/method_virtualnetworkslistusage.go new file mode 100644 index 00000000000..cfc1a239a93 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/method_virtualnetworkslistusage.go @@ -0,0 +1,106 @@ +package virtualnetworks + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworksListUsageOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualNetworkUsage +} + +type VirtualNetworksListUsageCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualNetworkUsage +} + +type VirtualNetworksListUsageCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VirtualNetworksListUsageCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VirtualNetworksListUsage ... +func (c VirtualNetworksClient) VirtualNetworksListUsage(ctx context.Context, id commonids.VirtualNetworkId) (result VirtualNetworksListUsageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VirtualNetworksListUsageCustomPager{}, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualNetworkUsage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VirtualNetworksListUsageComplete retrieves all the results into a single object +func (c VirtualNetworksClient) VirtualNetworksListUsageComplete(ctx context.Context, id commonids.VirtualNetworkId) (VirtualNetworksListUsageCompleteResult, error) { + return c.VirtualNetworksListUsageCompleteMatchingPredicate(ctx, id, VirtualNetworkUsageOperationPredicate{}) +} + +// VirtualNetworksListUsageCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualNetworksClient) VirtualNetworksListUsageCompleteMatchingPredicate(ctx context.Context, id commonids.VirtualNetworkId, predicate VirtualNetworkUsageOperationPredicate) (result VirtualNetworksListUsageCompleteResult, err error) { + items := make([]VirtualNetworkUsage, 0) + + resp, err := c.VirtualNetworksListUsage(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VirtualNetworksListUsageCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_addressspace.go b/resource-manager/network/2024-07-01/virtualnetworks/model_addressspace.go new file mode 100644 index 00000000000..bec158f0cdb --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_addressspace.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressSpace struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/virtualnetworks/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..3f9607979a8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/virtualnetworks/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..6f399a7bf5d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..953789d1f3e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworks/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..3da3cb7d9c8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..d9d39242c2b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/virtualnetworks/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..8069aeaaf35 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..29a50229369 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_backendaddresspool.go b/resource-manager/network/2024-07-01/virtualnetworks/model_backendaddresspool.go new file mode 100644 index 00000000000..dca54b5ff44 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..b5357aa1b58 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..4608979dcd2 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_ddossettings.go b/resource-manager/network/2024-07-01/virtualnetworks/model_ddossettings.go new file mode 100644 index 00000000000..1a0ce5cf3aa --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_ddossettings.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_delegation.go b/resource-manager/network/2024-07-01/virtualnetworks/model_delegation.go new file mode 100644 index 00000000000..a8d0d243017 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_delegation.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_dhcpoptions.go b/resource-manager/network/2024-07-01/virtualnetworks/model_dhcpoptions.go new file mode 100644 index 00000000000..2e389bf9503 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_dhcpoptions.go @@ -0,0 +1,8 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DhcpOptions struct { + DnsServers *[]string `json:"dnsServers,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_flowlog.go b/resource-manager/network/2024-07-01/virtualnetworks/model_flowlog.go new file mode 100644 index 00000000000..99a08c9552f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_flowlog.go @@ -0,0 +1,19 @@ +package virtualnetworks + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/virtualnetworks/model_flowlogformatparameters.go new file mode 100644 index 00000000000..62b8c967d59 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..85dd6159153 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworks/model_frontendipconfiguration.go new file mode 100644 index 00000000000..4b7f7549a8a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package virtualnetworks + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..7f51afc745f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/virtualnetworks/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..ef3318f49d4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_inboundnatrule.go b/resource-manager/network/2024-07-01/virtualnetworks/model_inboundnatrule.go new file mode 100644 index 00000000000..20f0e56c966 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..8ca3d3cee59 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_ipaddressavailabilityresult.go b/resource-manager/network/2024-07-01/virtualnetworks/model_ipaddressavailabilityresult.go new file mode 100644 index 00000000000..2db5fbd90fa --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_ipaddressavailabilityresult.go @@ -0,0 +1,10 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAddressAvailabilityResult struct { + Available *bool `json:"available,omitempty"` + AvailableIPAddresses *[]string `json:"availableIPAddresses,omitempty"` + IsPlatformReserved *bool `json:"isPlatformReserved,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/virtualnetworks/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..46cd8513eb5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/virtualnetworks/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..5fcdce61fa3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_ipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworks/model_ipconfiguration.go new file mode 100644 index 00000000000..7fc81013c87 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/virtualnetworks/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..246a7d2784a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..1c15860eaa4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..5f7e978b372 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_iptag.go b/resource-manager/network/2024-07-01/virtualnetworks/model_iptag.go new file mode 100644 index 00000000000..5f312015c16 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_iptag.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/virtualnetworks/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..f84e6394098 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..5b16669363a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_natgateway.go b/resource-manager/network/2024-07-01/virtualnetworks/model_natgateway.go new file mode 100644 index 00000000000..e2a2c9ea1aa --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_natgateway.go @@ -0,0 +1,20 @@ +package virtualnetworks + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..7e3b277b8ff --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_natgatewaysku.go b/resource-manager/network/2024-07-01/virtualnetworks/model_natgatewaysku.go new file mode 100644 index 00000000000..3375ec20625 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_natruleportmapping.go b/resource-manager/network/2024-07-01/virtualnetworks/model_natruleportmapping.go new file mode 100644 index 00000000000..c1f6eb9d264 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_networkintentpolicy.go b/resource-manager/network/2024-07-01/virtualnetworks/model_networkintentpolicy.go new file mode 100644 index 00000000000..565f4c702ee --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_networkintentpolicy.go @@ -0,0 +1,13 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkIntentPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_networkintentpolicyconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworks/model_networkintentpolicyconfiguration.go new file mode 100644 index 00000000000..3f3080bf421 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_networkintentpolicyconfiguration.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkIntentPolicyConfiguration struct { + NetworkIntentPolicyName *string `json:"networkIntentPolicyName,omitempty"` + SourceNetworkIntentPolicy *NetworkIntentPolicy `json:"sourceNetworkIntentPolicy,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterface.go b/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterface.go new file mode 100644 index 00000000000..51266c314db --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterface.go @@ -0,0 +1,19 @@ +package virtualnetworks + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..35b796d58ea --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..e4fe127f68f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..0cf1411b04e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..f8d38101396 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..baa2e672f8a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..7ee2c196852 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..f37548acc09 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/virtualnetworks/model_networksecuritygroup.go new file mode 100644 index 00000000000..c6ffd2de200 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..bdaff37d6ec --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_preparenetworkpoliciesrequest.go b/resource-manager/network/2024-07-01/virtualnetworks/model_preparenetworkpoliciesrequest.go new file mode 100644 index 00000000000..af5d6a6061c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_preparenetworkpoliciesrequest.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrepareNetworkPoliciesRequest struct { + NetworkIntentPolicyConfigurations *[]NetworkIntentPolicyConfiguration `json:"networkIntentPolicyConfigurations,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpoint.go b/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpoint.go new file mode 100644 index 00000000000..a21e2003c7b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpoint.go @@ -0,0 +1,19 @@ +package virtualnetworks + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpointconnection.go new file mode 100644 index 00000000000..03c0943acbe --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..badbc227dee --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..b8c8c0e51e2 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..0e1ea69495c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpointproperties.go new file mode 100644 index 00000000000..c204c6f06f5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkservice.go b/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkservice.go new file mode 100644 index 00000000000..ea60905675d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package virtualnetworks + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..45640ebd97e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..ece1141c4d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..498d4f92f9a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..b637ed217b5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..7c3080b30c1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..76256f1d416 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_publicipaddress.go b/resource-manager/network/2024-07-01/virtualnetworks/model_publicipaddress.go new file mode 100644 index 00000000000..5eef47c77e3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_publicipaddress.go @@ -0,0 +1,22 @@ +package virtualnetworks + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/virtualnetworks/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..1e10d9bb32a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..f38386b9fd0 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/virtualnetworks/model_publicipaddresssku.go new file mode 100644 index 00000000000..f080c20b33e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_publicipddosprotectionstatusresult.go b/resource-manager/network/2024-07-01/virtualnetworks/model_publicipddosprotectionstatusresult.go new file mode 100644 index 00000000000..ca0f8cc894f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_publicipddosprotectionstatusresult.go @@ -0,0 +1,11 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPDdosProtectionStatusResult struct { + DdosProtectionPlanId *string `json:"ddosProtectionPlanId,omitempty"` + IsWorkloadProtected *IsWorkloadProtected `json:"isWorkloadProtected,omitempty"` + PublicIPAddress *string `json:"publicIpAddress,omitempty"` + PublicIPAddressId *string `json:"publicIpAddressId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/virtualnetworks/model_resourcenavigationlink.go new file mode 100644 index 00000000000..e26d27c7784 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..5c0bb30457e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_resourceset.go b/resource-manager/network/2024-07-01/virtualnetworks/model_resourceset.go new file mode 100644 index 00000000000..3f176c096e6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_resourceset.go @@ -0,0 +1,8 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/virtualnetworks/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..b8a74239a26 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_route.go b/resource-manager/network/2024-07-01/virtualnetworks/model_route.go new file mode 100644 index 00000000000..d76eb9ceeec --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_route.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_routepropertiesformat.go new file mode 100644 index 00000000000..e52a5de8ca6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_routetable.go b/resource-manager/network/2024-07-01/virtualnetworks/model_routetable.go new file mode 100644 index 00000000000..2e233c020e3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_routetable.go @@ -0,0 +1,14 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..69015d57403 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_securityrule.go b/resource-manager/network/2024-07-01/virtualnetworks/model_securityrule.go new file mode 100644 index 00000000000..f7ed0f51115 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_securityrule.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..af160e60e64 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/virtualnetworks/model_serviceassociationlink.go new file mode 100644 index 00000000000..77039ca3b73 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..d6ef1f15de1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..82eb0f31d43 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/virtualnetworks/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..d50c20ce576 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/virtualnetworks/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..4d2ebe5ac46 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..b221dd2c319 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..00a9c1e5662 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..8c3d42e8afc --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_subnet.go b/resource-manager/network/2024-07-01/virtualnetworks/model_subnet.go new file mode 100644 index 00000000000..7b3d4ff10c8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_subnet.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..7f143606e95 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_subresource.go b/resource-manager/network/2024-07-01/virtualnetworks/model_subresource.go new file mode 100644 index 00000000000..ecd84dace18 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_subresource.go @@ -0,0 +1,8 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_tagsobject.go b/resource-manager/network/2024-07-01/virtualnetworks/model_tagsobject.go new file mode 100644 index 00000000000..9ac4400ec75 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_tagsobject.go @@ -0,0 +1,8 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/virtualnetworks/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..ce47549e2b9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/virtualnetworks/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..26812782cc8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_unpreparenetworkpoliciesrequest.go b/resource-manager/network/2024-07-01/virtualnetworks/model_unpreparenetworkpoliciesrequest.go new file mode 100644 index 00000000000..84b1fedbc2b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_unpreparenetworkpoliciesrequest.go @@ -0,0 +1,8 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnprepareNetworkPoliciesRequest struct { + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetwork.go b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetwork.go new file mode 100644 index 00000000000..01f2a07994e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetwork.go @@ -0,0 +1,19 @@ +package virtualnetworks + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetwork struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkbgpcommunities.go b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkbgpcommunities.go new file mode 100644 index 00000000000..ecb655fd234 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkbgpcommunities.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkBgpCommunities struct { + RegionalCommunity *string `json:"regionalCommunity,omitempty"` + VirtualNetworkCommunity string `json:"virtualNetworkCommunity"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkencryption.go b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkencryption.go new file mode 100644 index 00000000000..a0d8e13fe3a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkencryption.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkEncryption struct { + Enabled bool `json:"enabled"` + Enforcement *VirtualNetworkEncryptionEnforcement `json:"enforcement,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkpeering.go b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkpeering.go new file mode 100644 index 00000000000..85b7fe9183a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkpeering.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkPeering struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkPeeringPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkpeeringpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkpeeringpropertiesformat.go new file mode 100644 index 00000000000..41ebdc1a88a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkpeeringpropertiesformat.go @@ -0,0 +1,27 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkPeeringPropertiesFormat struct { + AllowForwardedTraffic *bool `json:"allowForwardedTraffic,omitempty"` + AllowGatewayTransit *bool `json:"allowGatewayTransit,omitempty"` + AllowVirtualNetworkAccess *bool `json:"allowVirtualNetworkAccess,omitempty"` + DoNotVerifyRemoteGateways *bool `json:"doNotVerifyRemoteGateways,omitempty"` + EnableOnlyIPv6Peering *bool `json:"enableOnlyIPv6Peering,omitempty"` + LocalAddressSpace *AddressSpace `json:"localAddressSpace,omitempty"` + LocalSubnetNames *[]string `json:"localSubnetNames,omitempty"` + LocalVirtualNetworkAddressSpace *AddressSpace `json:"localVirtualNetworkAddressSpace,omitempty"` + PeerCompleteVnets *bool `json:"peerCompleteVnets,omitempty"` + PeeringState *VirtualNetworkPeeringState `json:"peeringState,omitempty"` + PeeringSyncLevel *VirtualNetworkPeeringLevel `json:"peeringSyncLevel,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RemoteAddressSpace *AddressSpace `json:"remoteAddressSpace,omitempty"` + RemoteBgpCommunities *VirtualNetworkBgpCommunities `json:"remoteBgpCommunities,omitempty"` + RemoteSubnetNames *[]string `json:"remoteSubnetNames,omitempty"` + RemoteVirtualNetwork *SubResource `json:"remoteVirtualNetwork,omitempty"` + RemoteVirtualNetworkAddressSpace *AddressSpace `json:"remoteVirtualNetworkAddressSpace,omitempty"` + RemoteVirtualNetworkEncryption *VirtualNetworkEncryption `json:"remoteVirtualNetworkEncryption,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + UseRemoteGateways *bool `json:"useRemoteGateways,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkpropertiesformat.go new file mode 100644 index 00000000000..2aee1aad0bc --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkpropertiesformat.go @@ -0,0 +1,23 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkPropertiesFormat struct { + AddressSpace *AddressSpace `json:"addressSpace,omitempty"` + BgpCommunities *VirtualNetworkBgpCommunities `json:"bgpCommunities,omitempty"` + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + DefaultPublicNatGateway *SubResource `json:"defaultPublicNatGateway,omitempty"` + DhcpOptions *DhcpOptions `json:"dhcpOptions,omitempty"` + EnableDdosProtection *bool `json:"enableDdosProtection,omitempty"` + EnableVMProtection *bool `json:"enableVmProtection,omitempty"` + Encryption *VirtualNetworkEncryption `json:"encryption,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlowTimeoutInMinutes *int64 `json:"flowTimeoutInMinutes,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + PrivateEndpointVNetPolicies *PrivateEndpointVNetPolicies `json:"privateEndpointVNetPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` + VirtualNetworkPeerings *[]VirtualNetworkPeering `json:"virtualNetworkPeerings,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworktap.go new file mode 100644 index 00000000000..d1b3faf4100 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..4c2bb1fad6c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkusage.go b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkusage.go new file mode 100644 index 00000000000..470dd6b34f8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkusage.go @@ -0,0 +1,12 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkUsage struct { + CurrentValue *float64 `json:"currentValue,omitempty"` + Id *string `json:"id,omitempty"` + Limit *float64 `json:"limit,omitempty"` + Name *VirtualNetworkUsageName `json:"name,omitempty"` + Unit *string `json:"unit,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkusagename.go b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkusagename.go new file mode 100644 index 00000000000..f3156ce6be8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/model_virtualnetworkusagename.go @@ -0,0 +1,9 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkUsageName struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/predicates.go b/resource-manager/network/2024-07-01/virtualnetworks/predicates.go new file mode 100644 index 00000000000..ae976386154 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/predicates.go @@ -0,0 +1,144 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPDdosProtectionStatusResultOperationPredicate struct { + DdosProtectionPlanId *string + PublicIPAddress *string + PublicIPAddressId *string +} + +func (p PublicIPDdosProtectionStatusResultOperationPredicate) Matches(input PublicIPDdosProtectionStatusResult) bool { + + if p.DdosProtectionPlanId != nil && (input.DdosProtectionPlanId == nil || *p.DdosProtectionPlanId != *input.DdosProtectionPlanId) { + return false + } + + if p.PublicIPAddress != nil && (input.PublicIPAddress == nil || *p.PublicIPAddress != *input.PublicIPAddress) { + return false + } + + if p.PublicIPAddressId != nil && (input.PublicIPAddressId == nil || *p.PublicIPAddressId != *input.PublicIPAddressId) { + return false + } + + return true +} + +type ResourceNavigationLinkOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p ResourceNavigationLinkOperationPredicate) Matches(input ResourceNavigationLink) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type ServiceAssociationLinkOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p ServiceAssociationLinkOperationPredicate) Matches(input ServiceAssociationLink) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type VirtualNetworkOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p VirtualNetworkOperationPredicate) Matches(input VirtualNetwork) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type VirtualNetworkUsageOperationPredicate struct { + CurrentValue *float64 + Id *string + Limit *float64 + Unit *string +} + +func (p VirtualNetworkUsageOperationPredicate) Matches(input VirtualNetworkUsage) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/virtualnetworks/version.go b/resource-manager/network/2024-07-01/virtualnetworks/version.go new file mode 100644 index 00000000000..902b6524de1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworks/version.go @@ -0,0 +1,10 @@ +package virtualnetworks + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/virtualnetworks/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/README.md b/resource-manager/network/2024-07-01/virtualnetworktap/README.md new file mode 100644 index 00000000000..32904620b73 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworktap` Documentation + +The `virtualnetworktap` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworktap" +``` + + +### Client Initialization + +```go +client := virtualnetworktap.NewVirtualNetworkTapClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VirtualNetworkTapClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualnetworktap.NewVirtualNetworkTapID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkTapName") + +payload := virtualnetworktap.VirtualNetworkTap{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkTapClient.Delete` + +```go +ctx := context.TODO() +id := virtualnetworktap.NewVirtualNetworkTapID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkTapName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualNetworkTapClient.Get` + +```go +ctx := context.TODO() +id := virtualnetworktap.NewVirtualNetworkTapID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkTapName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualNetworkTapClient.UpdateTags` + +```go +ctx := context.TODO() +id := virtualnetworktap.NewVirtualNetworkTapID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkTapName") + +payload := virtualnetworktap.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/client.go b/resource-manager/network/2024-07-01/virtualnetworktap/client.go new file mode 100644 index 00000000000..71e5a9092ba --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/client.go @@ -0,0 +1,26 @@ +package virtualnetworktap + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapClient struct { + Client *resourcemanager.Client +} + +func NewVirtualNetworkTapClientWithBaseURI(sdkApi sdkEnv.Api) (*VirtualNetworkTapClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "virtualnetworktap", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VirtualNetworkTapClient: %+v", err) + } + + return &VirtualNetworkTapClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/constants.go b/resource-manager/network/2024-07-01/virtualnetworktap/constants.go new file mode 100644 index 00000000000..fa360c57b91 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/constants.go @@ -0,0 +1,1204 @@ +package virtualnetworktap + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/id_virtualnetworktap.go b/resource-manager/network/2024-07-01/virtualnetworktap/id_virtualnetworktap.go new file mode 100644 index 00000000000..48bd4716023 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/id_virtualnetworktap.go @@ -0,0 +1,130 @@ +package virtualnetworktap + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualNetworkTapId{}) +} + +var _ resourceids.ResourceId = &VirtualNetworkTapId{} + +// VirtualNetworkTapId is a struct representing the Resource ID for a Virtual Network Tap +type VirtualNetworkTapId struct { + SubscriptionId string + ResourceGroupName string + VirtualNetworkTapName string +} + +// NewVirtualNetworkTapID returns a new VirtualNetworkTapId struct +func NewVirtualNetworkTapID(subscriptionId string, resourceGroupName string, virtualNetworkTapName string) VirtualNetworkTapId { + return VirtualNetworkTapId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualNetworkTapName: virtualNetworkTapName, + } +} + +// ParseVirtualNetworkTapID parses 'input' into a VirtualNetworkTapId +func ParseVirtualNetworkTapID(input string) (*VirtualNetworkTapId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkTapId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkTapId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualNetworkTapIDInsensitively parses 'input' case-insensitively into a VirtualNetworkTapId +// note: this method should only be used for API response data and not user input +func ParseVirtualNetworkTapIDInsensitively(input string) (*VirtualNetworkTapId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkTapId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkTapId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualNetworkTapId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VirtualNetworkTapName, ok = input.Parsed["virtualNetworkTapName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkTapName", input) + } + + return nil +} + +// ValidateVirtualNetworkTapID checks that 'input' can be parsed as a Virtual Network Tap ID +func ValidateVirtualNetworkTapID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVirtualNetworkTapID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Network Tap ID +func (id VirtualNetworkTapId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualNetworkTaps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualNetworkTapName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Network Tap ID +func (id VirtualNetworkTapId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVirtualNetworkTaps", "virtualNetworkTaps", "virtualNetworkTaps"), + resourceids.UserSpecifiedSegment("virtualNetworkTapName", "virtualNetworkTapName"), + } +} + +// String returns a human-readable description of this Virtual Network Tap ID +func (id VirtualNetworkTapId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Network Tap Name: %q", id.VirtualNetworkTapName), + } + return fmt.Sprintf("Virtual Network Tap (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/id_virtualnetworktap_test.go b/resource-manager/network/2024-07-01/virtualnetworktap/id_virtualnetworktap_test.go new file mode 100644 index 00000000000..614dfaaf5fd --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/id_virtualnetworktap_test.go @@ -0,0 +1,282 @@ +package virtualnetworktap + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualNetworkTapId{} + +func TestNewVirtualNetworkTapID(t *testing.T) { + id := NewVirtualNetworkTapID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkTapName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VirtualNetworkTapName != "virtualNetworkTapName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkTapName'", id.VirtualNetworkTapName, "virtualNetworkTapName") + } +} + +func TestFormatVirtualNetworkTapID(t *testing.T) { + actual := NewVirtualNetworkTapID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualNetworkTapName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkTaps/virtualNetworkTapName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualNetworkTapID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkTapId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkTaps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkTaps/virtualNetworkTapName", + Expected: &VirtualNetworkTapId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualNetworkTapName: "virtualNetworkTapName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkTaps/virtualNetworkTapName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkTapID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualNetworkTapName != v.Expected.VirtualNetworkTapName { + t.Fatalf("Expected %q but got %q for VirtualNetworkTapName", v.Expected.VirtualNetworkTapName, actual.VirtualNetworkTapName) + } + + } +} + +func TestParseVirtualNetworkTapIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkTapId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkTaps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlNeTwOrKtApS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkTaps/virtualNetworkTapName", + Expected: &VirtualNetworkTapId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualNetworkTapName: "virtualNetworkTapName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualNetworkTaps/virtualNetworkTapName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlNeTwOrKtApS/vIrTuAlNeTwOrKtApNaMe", + Expected: &VirtualNetworkTapId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualNetworkTapName: "vIrTuAlNeTwOrKtApNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlNeTwOrKtApS/vIrTuAlNeTwOrKtApNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkTapIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualNetworkTapName != v.Expected.VirtualNetworkTapName { + t.Fatalf("Expected %q but got %q for VirtualNetworkTapName", v.Expected.VirtualNetworkTapName, actual.VirtualNetworkTapName) + } + + } +} + +func TestSegmentsForVirtualNetworkTapId(t *testing.T) { + segments := VirtualNetworkTapId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualNetworkTapId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/method_createorupdate.go b/resource-manager/network/2024-07-01/virtualnetworktap/method_createorupdate.go new file mode 100644 index 00000000000..9e0265a1971 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/method_createorupdate.go @@ -0,0 +1,75 @@ +package virtualnetworktap + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetworkTap +} + +// CreateOrUpdate ... +func (c VirtualNetworkTapClient) CreateOrUpdate(ctx context.Context, id VirtualNetworkTapId, input VirtualNetworkTap) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c VirtualNetworkTapClient) CreateOrUpdateThenPoll(ctx context.Context, id VirtualNetworkTapId, input VirtualNetworkTap) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/method_delete.go b/resource-manager/network/2024-07-01/virtualnetworktap/method_delete.go new file mode 100644 index 00000000000..93b4ec0c489 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/method_delete.go @@ -0,0 +1,71 @@ +package virtualnetworktap + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c VirtualNetworkTapClient) Delete(ctx context.Context, id VirtualNetworkTapId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c VirtualNetworkTapClient) DeleteThenPoll(ctx context.Context, id VirtualNetworkTapId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/method_get.go b/resource-manager/network/2024-07-01/virtualnetworktap/method_get.go new file mode 100644 index 00000000000..cbeab75581a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/method_get.go @@ -0,0 +1,53 @@ +package virtualnetworktap + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetworkTap +} + +// Get ... +func (c VirtualNetworkTapClient) Get(ctx context.Context, id VirtualNetworkTapId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualNetworkTap + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/method_updatetags.go b/resource-manager/network/2024-07-01/virtualnetworktap/method_updatetags.go new file mode 100644 index 00000000000..3d2dd536791 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/method_updatetags.go @@ -0,0 +1,57 @@ +package virtualnetworktap + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualNetworkTap +} + +// UpdateTags ... +func (c VirtualNetworkTapClient) UpdateTags(ctx context.Context, id VirtualNetworkTapId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualNetworkTap + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..db62a91aeb1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..a220744195a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..f1a5f708c1c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..e0dd6f54986 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..05e2cf6e7ff --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..89fac6f865a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..dd34d207344 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_backendaddresspool.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_backendaddresspool.go new file mode 100644 index 00000000000..22fa8953303 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..6ac563af429 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..d263c1b8649 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_ddossettings.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_ddossettings.go new file mode 100644 index 00000000000..934851a560f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_ddossettings.go @@ -0,0 +1,9 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_delegation.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_delegation.go new file mode 100644 index 00000000000..b98041c6409 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_delegation.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_flowlog.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_flowlog.go new file mode 100644 index 00000000000..d3c755b3dbf --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_flowlog.go @@ -0,0 +1,19 @@ +package virtualnetworktap + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_flowlogformatparameters.go new file mode 100644 index 00000000000..05c5660bcab --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..5fe09758a9c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_frontendipconfiguration.go new file mode 100644 index 00000000000..8e718fbb787 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package virtualnetworktap + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..df238cbcfd3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..3301ab1a1c7 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_inboundnatrule.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_inboundnatrule.go new file mode 100644 index 00000000000..7c4fefd00fe --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..9562bb00429 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..d87a17332bf --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..912009e7aec --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_ipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_ipconfiguration.go new file mode 100644 index 00000000000..072921c15aa --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..319c9ec5ee9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..adf0a28fb73 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..14c8a64a2a2 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_iptag.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_iptag.go new file mode 100644 index 00000000000..85d10556d1c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_iptag.go @@ -0,0 +1,9 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..bb0a0c328c1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..b16ba8335ae --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_natgateway.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_natgateway.go new file mode 100644 index 00000000000..ff0008c8a9e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_natgateway.go @@ -0,0 +1,20 @@ +package virtualnetworktap + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..ef67c06bb0f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_natgatewaysku.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_natgatewaysku.go new file mode 100644 index 00000000000..efd87c92e07 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_natruleportmapping.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_natruleportmapping.go new file mode 100644 index 00000000000..9c675767782 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterface.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterface.go new file mode 100644 index 00000000000..90bd182032d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterface.go @@ -0,0 +1,19 @@ +package virtualnetworktap + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..8f7f5c9ab69 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..420ea20f4d2 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..e2d0d046dd7 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..133846da8a3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..fbf0ecc2cc4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..1514177f60e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..4d5181920b1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_networksecuritygroup.go new file mode 100644 index 00000000000..f1f880186f1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..c0a2565b3a0 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpoint.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpoint.go new file mode 100644 index 00000000000..18177d11a3e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpoint.go @@ -0,0 +1,19 @@ +package virtualnetworktap + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpointconnection.go new file mode 100644 index 00000000000..3a5764483c9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..f6119badaa5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..35ffb6cda11 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..8e362a6d1b5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpointproperties.go new file mode 100644 index 00000000000..8d42714c80d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkservice.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkservice.go new file mode 100644 index 00000000000..42d87ebbbcb --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package virtualnetworktap + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..6218ca9e0c5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..bb689f2425d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..4510ba8bea7 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..7f7ebc0d7f8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..9e874822a6b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..47cc3c1264a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_publicipaddress.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_publicipaddress.go new file mode 100644 index 00000000000..5059f6b2c6b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_publicipaddress.go @@ -0,0 +1,22 @@ +package virtualnetworktap + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..5e531cfaa59 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..b1b74de6b82 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_publicipaddresssku.go new file mode 100644 index 00000000000..c719ed93844 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_resourcenavigationlink.go new file mode 100644 index 00000000000..e1834b720d7 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..5100c40bc8d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_resourceset.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_resourceset.go new file mode 100644 index 00000000000..fa8408e3374 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_resourceset.go @@ -0,0 +1,8 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..402a95f81e1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_route.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_route.go new file mode 100644 index 00000000000..5eb14c76d8d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_route.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_routepropertiesformat.go new file mode 100644 index 00000000000..1e404b86207 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_routetable.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_routetable.go new file mode 100644 index 00000000000..c5bfa2aacc9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_routetable.go @@ -0,0 +1,14 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..788b58851db --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_securityrule.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_securityrule.go new file mode 100644 index 00000000000..42a4c62093e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_securityrule.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..8b92ef45964 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceassociationlink.go new file mode 100644 index 00000000000..806ced6b5e5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..9a18079edd6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..347761b277f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..6ca8e2d4a35 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..05ee77e2b81 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..537a3df890d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..f2645082640 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..13911877fe3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_subnet.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_subnet.go new file mode 100644 index 00000000000..e7d6771812b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_subnet.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..4270e2d27f2 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_subresource.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_subresource.go new file mode 100644 index 00000000000..da7e12e526b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_subresource.go @@ -0,0 +1,8 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_tagsobject.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_tagsobject.go new file mode 100644 index 00000000000..1c98be14a33 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_tagsobject.go @@ -0,0 +1,8 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..89aa415edbb --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..701cc7ae154 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_virtualnetworktap.go new file mode 100644 index 00000000000..209659855b5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktap/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..5c2f9db5892 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktap/version.go b/resource-manager/network/2024-07-01/virtualnetworktap/version.go new file mode 100644 index 00000000000..e10746a1da0 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktap/version.go @@ -0,0 +1,10 @@ +package virtualnetworktap + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/virtualnetworktap/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/README.md b/resource-manager/network/2024-07-01/virtualnetworktaps/README.md new file mode 100644 index 00000000000..ef648cc56da --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/README.md @@ -0,0 +1,55 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworktaps` Documentation + +The `virtualnetworktaps` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualnetworktaps" +``` + + +### Client Initialization + +```go +client := virtualnetworktaps.NewVirtualNetworkTapsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VirtualNetworkTapsClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualNetworkTapsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/client.go b/resource-manager/network/2024-07-01/virtualnetworktaps/client.go new file mode 100644 index 00000000000..072baab9143 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/client.go @@ -0,0 +1,26 @@ +package virtualnetworktaps + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapsClient struct { + Client *resourcemanager.Client +} + +func NewVirtualNetworkTapsClientWithBaseURI(sdkApi sdkEnv.Api) (*VirtualNetworkTapsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "virtualnetworktaps", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VirtualNetworkTapsClient: %+v", err) + } + + return &VirtualNetworkTapsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/constants.go b/resource-manager/network/2024-07-01/virtualnetworktaps/constants.go new file mode 100644 index 00000000000..22def5683b0 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/constants.go @@ -0,0 +1,1204 @@ +package virtualnetworktaps + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/method_listall.go b/resource-manager/network/2024-07-01/virtualnetworktaps/method_listall.go new file mode 100644 index 00000000000..c73f4d2a3eb --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/method_listall.go @@ -0,0 +1,106 @@ +package virtualnetworktaps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualNetworkTap +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualNetworkTap +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c VirtualNetworkTapsClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/virtualNetworkTaps", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualNetworkTap `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c VirtualNetworkTapsClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, VirtualNetworkTapOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualNetworkTapsClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate VirtualNetworkTapOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]VirtualNetworkTap, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/method_listbyresourcegroup.go b/resource-manager/network/2024-07-01/virtualnetworktaps/method_listbyresourcegroup.go new file mode 100644 index 00000000000..91d504091c5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package virtualnetworktaps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualNetworkTap +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualNetworkTap +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c VirtualNetworkTapsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/virtualNetworkTaps", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualNetworkTap `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c VirtualNetworkTapsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, VirtualNetworkTapOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualNetworkTapsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate VirtualNetworkTapOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]VirtualNetworkTap, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..b76026be6bc --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..b8bc620ea71 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..f6179e4f0e3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..9e995dbb56d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..0c3c2c531f3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..1c38043ef88 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..9102a6b9188 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_backendaddresspool.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_backendaddresspool.go new file mode 100644 index 00000000000..2c478d85562 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..9afb32298d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..36b2063994a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_ddossettings.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_ddossettings.go new file mode 100644 index 00000000000..cbd6745cb8e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_ddossettings.go @@ -0,0 +1,9 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_delegation.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_delegation.go new file mode 100644 index 00000000000..018e0605aee --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_delegation.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_flowlog.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_flowlog.go new file mode 100644 index 00000000000..0247c576115 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_flowlog.go @@ -0,0 +1,19 @@ +package virtualnetworktaps + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_flowlogformatparameters.go new file mode 100644 index 00000000000..3dc25c465d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..9393798b4c1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_frontendipconfiguration.go new file mode 100644 index 00000000000..35e28c95460 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package virtualnetworktaps + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..c6949a4745a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..a2e82dba72b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_inboundnatrule.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_inboundnatrule.go new file mode 100644 index 00000000000..f84bd93f6c7 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..8200337ef35 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..58e72a82b5b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..473b7fe72dc --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipconfiguration.go new file mode 100644 index 00000000000..fcd9033c4a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..2e7b5cfe5eb --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..1d5ab92dcd5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..4a486230c36 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_iptag.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_iptag.go new file mode 100644 index 00000000000..c4127e59d60 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_iptag.go @@ -0,0 +1,9 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..7a8c5cb8b73 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..d3193da6576 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_natgateway.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_natgateway.go new file mode 100644 index 00000000000..b2e289b8923 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_natgateway.go @@ -0,0 +1,20 @@ +package virtualnetworktaps + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..ff77484ba7f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_natgatewaysku.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_natgatewaysku.go new file mode 100644 index 00000000000..cab72fef58e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_natruleportmapping.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_natruleportmapping.go new file mode 100644 index 00000000000..2426f4e9182 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterface.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterface.go new file mode 100644 index 00000000000..0959f2effbd --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterface.go @@ -0,0 +1,19 @@ +package virtualnetworktaps + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..63a0e5410a5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..3295f16b481 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..7659a03380a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..758acc402d6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..c7a26035a57 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..3d883d5678c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..dd9ef377372 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networksecuritygroup.go new file mode 100644 index 00000000000..d3ce4b39ea6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..57de91eafd3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpoint.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpoint.go new file mode 100644 index 00000000000..b58c024b508 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpoint.go @@ -0,0 +1,19 @@ +package virtualnetworktaps + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpointconnection.go new file mode 100644 index 00000000000..3d314882781 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..d6ea54d1367 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..40468e7e3ae --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..46faf7b053b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpointproperties.go new file mode 100644 index 00000000000..44ca9629906 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkservice.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkservice.go new file mode 100644 index 00000000000..8df5b6ca8e9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package virtualnetworktaps + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..3d9511e926a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..149dad152de --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..5ae16683918 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..830a49d4825 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..b3b914d17a6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..98109112303 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_publicipaddress.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_publicipaddress.go new file mode 100644 index 00000000000..a63d498e9b2 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_publicipaddress.go @@ -0,0 +1,22 @@ +package virtualnetworktaps + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..a22c5ccb482 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..f3a6e76f01e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_publicipaddresssku.go new file mode 100644 index 00000000000..b6d56cb8fcd --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_resourcenavigationlink.go new file mode 100644 index 00000000000..b362ba5a95b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..83b81bd5755 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_resourceset.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_resourceset.go new file mode 100644 index 00000000000..7e28952a0a0 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_resourceset.go @@ -0,0 +1,8 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..9a09f483b36 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_route.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_route.go new file mode 100644 index 00000000000..fe09505f366 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_route.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_routepropertiesformat.go new file mode 100644 index 00000000000..3d3840b7cfb --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_routetable.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_routetable.go new file mode 100644 index 00000000000..dc456ac5330 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_routetable.go @@ -0,0 +1,14 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..29d5488b413 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_securityrule.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_securityrule.go new file mode 100644 index 00000000000..2b52f93106a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_securityrule.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..549b4d495a6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceassociationlink.go new file mode 100644 index 00000000000..eff71aa8797 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..72fe6efec6b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..d130c80bc92 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..b164c8a3ad8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..a715beb370f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..6283b834876 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..e39a39b0dc9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..bf27483e5ab --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_subnet.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_subnet.go new file mode 100644 index 00000000000..586828d80aa --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_subnet.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..afb81459e43 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_subresource.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_subresource.go new file mode 100644 index 00000000000..64ad7a5e2b6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_subresource.go @@ -0,0 +1,8 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..5d2043fba12 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..a673cd2c104 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_virtualnetworktap.go new file mode 100644 index 00000000000..d5bf88cf9cb --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/virtualnetworktaps/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..e75a60ff515 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/predicates.go b/resource-manager/network/2024-07-01/virtualnetworktaps/predicates.go new file mode 100644 index 00000000000..0b7fb5985f4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/predicates.go @@ -0,0 +1,37 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p VirtualNetworkTapOperationPredicate) Matches(input VirtualNetworkTap) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/virtualnetworktaps/version.go b/resource-manager/network/2024-07-01/virtualnetworktaps/version.go new file mode 100644 index 00000000000..0a92ebb68f2 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualnetworktaps/version.go @@ -0,0 +1,10 @@ +package virtualnetworktaps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/virtualnetworktaps/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/virtualrouterpeerings/README.md b/resource-manager/network/2024-07-01/virtualrouterpeerings/README.md new file mode 100644 index 00000000000..566661a2e1f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouterpeerings/README.md @@ -0,0 +1,83 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualrouterpeerings` Documentation + +The `virtualrouterpeerings` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualrouterpeerings" +``` + + +### Client Initialization + +```go +client := virtualrouterpeerings.NewVirtualRouterPeeringsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VirtualRouterPeeringsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewVirtualRouterPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualRouterName", "peeringName") + +payload := virtualrouterpeerings.VirtualRouterPeering{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualRouterPeeringsClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewVirtualRouterPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualRouterName", "peeringName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualRouterPeeringsClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewVirtualRouterPeeringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualRouterName", "peeringName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualRouterPeeringsClient.List` + +```go +ctx := context.TODO() +id := virtualrouterpeerings.NewVirtualRouterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualRouterName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/virtualrouterpeerings/client.go b/resource-manager/network/2024-07-01/virtualrouterpeerings/client.go new file mode 100644 index 00000000000..b8bf140b1c1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouterpeerings/client.go @@ -0,0 +1,26 @@ +package virtualrouterpeerings + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualRouterPeeringsClient struct { + Client *resourcemanager.Client +} + +func NewVirtualRouterPeeringsClientWithBaseURI(sdkApi sdkEnv.Api) (*VirtualRouterPeeringsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "virtualrouterpeerings", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VirtualRouterPeeringsClient: %+v", err) + } + + return &VirtualRouterPeeringsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/virtualrouterpeerings/constants.go b/resource-manager/network/2024-07-01/virtualrouterpeerings/constants.go new file mode 100644 index 00000000000..464d2b779c9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouterpeerings/constants.go @@ -0,0 +1,57 @@ +package virtualrouterpeerings + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/virtualrouterpeerings/id_virtualrouter.go b/resource-manager/network/2024-07-01/virtualrouterpeerings/id_virtualrouter.go new file mode 100644 index 00000000000..055c6f72b1c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouterpeerings/id_virtualrouter.go @@ -0,0 +1,130 @@ +package virtualrouterpeerings + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualRouterId{}) +} + +var _ resourceids.ResourceId = &VirtualRouterId{} + +// VirtualRouterId is a struct representing the Resource ID for a Virtual Router +type VirtualRouterId struct { + SubscriptionId string + ResourceGroupName string + VirtualRouterName string +} + +// NewVirtualRouterID returns a new VirtualRouterId struct +func NewVirtualRouterID(subscriptionId string, resourceGroupName string, virtualRouterName string) VirtualRouterId { + return VirtualRouterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualRouterName: virtualRouterName, + } +} + +// ParseVirtualRouterID parses 'input' into a VirtualRouterId +func ParseVirtualRouterID(input string) (*VirtualRouterId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualRouterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualRouterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualRouterIDInsensitively parses 'input' case-insensitively into a VirtualRouterId +// note: this method should only be used for API response data and not user input +func ParseVirtualRouterIDInsensitively(input string) (*VirtualRouterId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualRouterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualRouterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualRouterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VirtualRouterName, ok = input.Parsed["virtualRouterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualRouterName", input) + } + + return nil +} + +// ValidateVirtualRouterID checks that 'input' can be parsed as a Virtual Router ID +func ValidateVirtualRouterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVirtualRouterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Router ID +func (id VirtualRouterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualRouters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualRouterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Router ID +func (id VirtualRouterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVirtualRouters", "virtualRouters", "virtualRouters"), + resourceids.UserSpecifiedSegment("virtualRouterName", "virtualRouterName"), + } +} + +// String returns a human-readable description of this Virtual Router ID +func (id VirtualRouterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Router Name: %q", id.VirtualRouterName), + } + return fmt.Sprintf("Virtual Router (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualrouterpeerings/id_virtualrouter_test.go b/resource-manager/network/2024-07-01/virtualrouterpeerings/id_virtualrouter_test.go new file mode 100644 index 00000000000..36e21acd08a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouterpeerings/id_virtualrouter_test.go @@ -0,0 +1,282 @@ +package virtualrouterpeerings + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualRouterId{} + +func TestNewVirtualRouterID(t *testing.T) { + id := NewVirtualRouterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualRouterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VirtualRouterName != "virtualRouterName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualRouterName'", id.VirtualRouterName, "virtualRouterName") + } +} + +func TestFormatVirtualRouterID(t *testing.T) { + actual := NewVirtualRouterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualRouterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualRouters/virtualRouterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualRouterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualRouterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualRouters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualRouters/virtualRouterName", + Expected: &VirtualRouterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualRouterName: "virtualRouterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualRouters/virtualRouterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualRouterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualRouterName != v.Expected.VirtualRouterName { + t.Fatalf("Expected %q but got %q for VirtualRouterName", v.Expected.VirtualRouterName, actual.VirtualRouterName) + } + + } +} + +func TestParseVirtualRouterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualRouterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualRouters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlRoUtErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualRouters/virtualRouterName", + Expected: &VirtualRouterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualRouterName: "virtualRouterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualRouters/virtualRouterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlRoUtErS/vIrTuAlRoUtErNaMe", + Expected: &VirtualRouterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualRouterName: "vIrTuAlRoUtErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlRoUtErS/vIrTuAlRoUtErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualRouterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualRouterName != v.Expected.VirtualRouterName { + t.Fatalf("Expected %q but got %q for VirtualRouterName", v.Expected.VirtualRouterName, actual.VirtualRouterName) + } + + } +} + +func TestSegmentsForVirtualRouterId(t *testing.T) { + segments := VirtualRouterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualRouterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualrouterpeerings/method_createorupdate.go b/resource-manager/network/2024-07-01/virtualrouterpeerings/method_createorupdate.go new file mode 100644 index 00000000000..c3c6be8f2f4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouterpeerings/method_createorupdate.go @@ -0,0 +1,76 @@ +package virtualrouterpeerings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualRouterPeering +} + +// CreateOrUpdate ... +func (c VirtualRouterPeeringsClient) CreateOrUpdate(ctx context.Context, id commonids.VirtualRouterPeeringId, input VirtualRouterPeering) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c VirtualRouterPeeringsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.VirtualRouterPeeringId, input VirtualRouterPeering) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualrouterpeerings/method_delete.go b/resource-manager/network/2024-07-01/virtualrouterpeerings/method_delete.go new file mode 100644 index 00000000000..0f1d37addbb --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouterpeerings/method_delete.go @@ -0,0 +1,72 @@ +package virtualrouterpeerings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c VirtualRouterPeeringsClient) Delete(ctx context.Context, id commonids.VirtualRouterPeeringId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c VirtualRouterPeeringsClient) DeleteThenPoll(ctx context.Context, id commonids.VirtualRouterPeeringId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualrouterpeerings/method_get.go b/resource-manager/network/2024-07-01/virtualrouterpeerings/method_get.go new file mode 100644 index 00000000000..8b9d7a1569d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouterpeerings/method_get.go @@ -0,0 +1,54 @@ +package virtualrouterpeerings + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualRouterPeering +} + +// Get ... +func (c VirtualRouterPeeringsClient) Get(ctx context.Context, id commonids.VirtualRouterPeeringId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualRouterPeering + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualrouterpeerings/method_list.go b/resource-manager/network/2024-07-01/virtualrouterpeerings/method_list.go new file mode 100644 index 00000000000..276300c6796 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouterpeerings/method_list.go @@ -0,0 +1,105 @@ +package virtualrouterpeerings + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualRouterPeering +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualRouterPeering +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c VirtualRouterPeeringsClient) List(ctx context.Context, id VirtualRouterId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/peerings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualRouterPeering `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c VirtualRouterPeeringsClient) ListComplete(ctx context.Context, id VirtualRouterId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, VirtualRouterPeeringOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualRouterPeeringsClient) ListCompleteMatchingPredicate(ctx context.Context, id VirtualRouterId, predicate VirtualRouterPeeringOperationPredicate) (result ListCompleteResult, err error) { + items := make([]VirtualRouterPeering, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualrouterpeerings/model_virtualrouterpeering.go b/resource-manager/network/2024-07-01/virtualrouterpeerings/model_virtualrouterpeering.go new file mode 100644 index 00000000000..148137d1d12 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouterpeerings/model_virtualrouterpeering.go @@ -0,0 +1,12 @@ +package virtualrouterpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualRouterPeering struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualRouterPeeringProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualrouterpeerings/model_virtualrouterpeeringproperties.go b/resource-manager/network/2024-07-01/virtualrouterpeerings/model_virtualrouterpeeringproperties.go new file mode 100644 index 00000000000..c205251cdff --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouterpeerings/model_virtualrouterpeeringproperties.go @@ -0,0 +1,10 @@ +package virtualrouterpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualRouterPeeringProperties struct { + PeerAsn *int64 `json:"peerAsn,omitempty"` + PeerIP *string `json:"peerIp,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualrouterpeerings/predicates.go b/resource-manager/network/2024-07-01/virtualrouterpeerings/predicates.go new file mode 100644 index 00000000000..1e181881675 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouterpeerings/predicates.go @@ -0,0 +1,32 @@ +package virtualrouterpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualRouterPeeringOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p VirtualRouterPeeringOperationPredicate) Matches(input VirtualRouterPeering) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/virtualrouterpeerings/version.go b/resource-manager/network/2024-07-01/virtualrouterpeerings/version.go new file mode 100644 index 00000000000..5890c42cff4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouterpeerings/version.go @@ -0,0 +1,10 @@ +package virtualrouterpeerings + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/virtualrouterpeerings/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/virtualrouters/README.md b/resource-manager/network/2024-07-01/virtualrouters/README.md new file mode 100644 index 00000000000..24545b4de31 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouters/README.md @@ -0,0 +1,100 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualrouters` Documentation + +The `virtualrouters` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualrouters" +``` + + +### Client Initialization + +```go +client := virtualrouters.NewVirtualRoutersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VirtualRoutersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualrouters.NewVirtualRouterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualRouterName") + +payload := virtualrouters.VirtualRouter{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualRoutersClient.Delete` + +```go +ctx := context.TODO() +id := virtualrouters.NewVirtualRouterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualRouterName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualRoutersClient.Get` + +```go +ctx := context.TODO() +id := virtualrouters.NewVirtualRouterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualRouterName") + +read, err := client.Get(ctx, id, virtualrouters.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualRoutersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualRoutersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/virtualrouters/client.go b/resource-manager/network/2024-07-01/virtualrouters/client.go new file mode 100644 index 00000000000..ca9adf26c79 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouters/client.go @@ -0,0 +1,26 @@ +package virtualrouters + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualRoutersClient struct { + Client *resourcemanager.Client +} + +func NewVirtualRoutersClientWithBaseURI(sdkApi sdkEnv.Api) (*VirtualRoutersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "virtualrouters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VirtualRoutersClient: %+v", err) + } + + return &VirtualRoutersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/virtualrouters/constants.go b/resource-manager/network/2024-07-01/virtualrouters/constants.go new file mode 100644 index 00000000000..1a43afab5dd --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouters/constants.go @@ -0,0 +1,57 @@ +package virtualrouters + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/virtualrouters/id_virtualrouter.go b/resource-manager/network/2024-07-01/virtualrouters/id_virtualrouter.go new file mode 100644 index 00000000000..ca7d65615d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouters/id_virtualrouter.go @@ -0,0 +1,130 @@ +package virtualrouters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualRouterId{}) +} + +var _ resourceids.ResourceId = &VirtualRouterId{} + +// VirtualRouterId is a struct representing the Resource ID for a Virtual Router +type VirtualRouterId struct { + SubscriptionId string + ResourceGroupName string + VirtualRouterName string +} + +// NewVirtualRouterID returns a new VirtualRouterId struct +func NewVirtualRouterID(subscriptionId string, resourceGroupName string, virtualRouterName string) VirtualRouterId { + return VirtualRouterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualRouterName: virtualRouterName, + } +} + +// ParseVirtualRouterID parses 'input' into a VirtualRouterId +func ParseVirtualRouterID(input string) (*VirtualRouterId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualRouterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualRouterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualRouterIDInsensitively parses 'input' case-insensitively into a VirtualRouterId +// note: this method should only be used for API response data and not user input +func ParseVirtualRouterIDInsensitively(input string) (*VirtualRouterId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualRouterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualRouterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualRouterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VirtualRouterName, ok = input.Parsed["virtualRouterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualRouterName", input) + } + + return nil +} + +// ValidateVirtualRouterID checks that 'input' can be parsed as a Virtual Router ID +func ValidateVirtualRouterID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVirtualRouterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Router ID +func (id VirtualRouterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualRouters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualRouterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Router ID +func (id VirtualRouterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVirtualRouters", "virtualRouters", "virtualRouters"), + resourceids.UserSpecifiedSegment("virtualRouterName", "virtualRouterName"), + } +} + +// String returns a human-readable description of this Virtual Router ID +func (id VirtualRouterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Router Name: %q", id.VirtualRouterName), + } + return fmt.Sprintf("Virtual Router (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualrouters/id_virtualrouter_test.go b/resource-manager/network/2024-07-01/virtualrouters/id_virtualrouter_test.go new file mode 100644 index 00000000000..0ae9704ca6e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouters/id_virtualrouter_test.go @@ -0,0 +1,282 @@ +package virtualrouters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualRouterId{} + +func TestNewVirtualRouterID(t *testing.T) { + id := NewVirtualRouterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualRouterName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VirtualRouterName != "virtualRouterName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualRouterName'", id.VirtualRouterName, "virtualRouterName") + } +} + +func TestFormatVirtualRouterID(t *testing.T) { + actual := NewVirtualRouterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualRouterName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualRouters/virtualRouterName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualRouterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualRouterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualRouters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualRouters/virtualRouterName", + Expected: &VirtualRouterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualRouterName: "virtualRouterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualRouters/virtualRouterName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualRouterID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualRouterName != v.Expected.VirtualRouterName { + t.Fatalf("Expected %q but got %q for VirtualRouterName", v.Expected.VirtualRouterName, actual.VirtualRouterName) + } + + } +} + +func TestParseVirtualRouterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualRouterId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualRouters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlRoUtErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualRouters/virtualRouterName", + Expected: &VirtualRouterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualRouterName: "virtualRouterName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualRouters/virtualRouterName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlRoUtErS/vIrTuAlRoUtErNaMe", + Expected: &VirtualRouterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualRouterName: "vIrTuAlRoUtErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlRoUtErS/vIrTuAlRoUtErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualRouterIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualRouterName != v.Expected.VirtualRouterName { + t.Fatalf("Expected %q but got %q for VirtualRouterName", v.Expected.VirtualRouterName, actual.VirtualRouterName) + } + + } +} + +func TestSegmentsForVirtualRouterId(t *testing.T) { + segments := VirtualRouterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualRouterId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualrouters/method_createorupdate.go b/resource-manager/network/2024-07-01/virtualrouters/method_createorupdate.go new file mode 100644 index 00000000000..a9d77afc1e5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouters/method_createorupdate.go @@ -0,0 +1,75 @@ +package virtualrouters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualRouter +} + +// CreateOrUpdate ... +func (c VirtualRoutersClient) CreateOrUpdate(ctx context.Context, id VirtualRouterId, input VirtualRouter) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c VirtualRoutersClient) CreateOrUpdateThenPoll(ctx context.Context, id VirtualRouterId, input VirtualRouter) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualrouters/method_delete.go b/resource-manager/network/2024-07-01/virtualrouters/method_delete.go new file mode 100644 index 00000000000..7dcaaf847d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouters/method_delete.go @@ -0,0 +1,71 @@ +package virtualrouters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c VirtualRoutersClient) Delete(ctx context.Context, id VirtualRouterId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c VirtualRoutersClient) DeleteThenPoll(ctx context.Context, id VirtualRouterId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualrouters/method_get.go b/resource-manager/network/2024-07-01/virtualrouters/method_get.go new file mode 100644 index 00000000000..4eaa68180fa --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouters/method_get.go @@ -0,0 +1,83 @@ +package virtualrouters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualRouter +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c VirtualRoutersClient) Get(ctx context.Context, id VirtualRouterId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualRouter + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualrouters/method_list.go b/resource-manager/network/2024-07-01/virtualrouters/method_list.go new file mode 100644 index 00000000000..414434d4b95 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouters/method_list.go @@ -0,0 +1,106 @@ +package virtualrouters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualRouter +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualRouter +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c VirtualRoutersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/virtualRouters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualRouter `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c VirtualRoutersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, VirtualRouterOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualRoutersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate VirtualRouterOperationPredicate) (result ListCompleteResult, err error) { + items := make([]VirtualRouter, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualrouters/method_listbyresourcegroup.go b/resource-manager/network/2024-07-01/virtualrouters/method_listbyresourcegroup.go new file mode 100644 index 00000000000..b34c6e266b7 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouters/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package virtualrouters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualRouter +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualRouter +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c VirtualRoutersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/virtualRouters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualRouter `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c VirtualRoutersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, VirtualRouterOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualRoutersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate VirtualRouterOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]VirtualRouter, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualrouters/model_subresource.go b/resource-manager/network/2024-07-01/virtualrouters/model_subresource.go new file mode 100644 index 00000000000..f9c28cc090f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouters/model_subresource.go @@ -0,0 +1,8 @@ +package virtualrouters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualrouters/model_virtualrouter.go b/resource-manager/network/2024-07-01/virtualrouters/model_virtualrouter.go new file mode 100644 index 00000000000..ac50af509f1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouters/model_virtualrouter.go @@ -0,0 +1,14 @@ +package virtualrouters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualRouter struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualRouterPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualrouters/model_virtualrouterpropertiesformat.go b/resource-manager/network/2024-07-01/virtualrouters/model_virtualrouterpropertiesformat.go new file mode 100644 index 00000000000..24601ff2eb4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouters/model_virtualrouterpropertiesformat.go @@ -0,0 +1,13 @@ +package virtualrouters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualRouterPropertiesFormat struct { + HostedGateway *SubResource `json:"hostedGateway,omitempty"` + HostedSubnet *SubResource `json:"hostedSubnet,omitempty"` + Peerings *[]SubResource `json:"peerings,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualRouterAsn *int64 `json:"virtualRouterAsn,omitempty"` + VirtualRouterIPs *[]string `json:"virtualRouterIps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualrouters/predicates.go b/resource-manager/network/2024-07-01/virtualrouters/predicates.go new file mode 100644 index 00000000000..676ee423641 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouters/predicates.go @@ -0,0 +1,37 @@ +package virtualrouters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualRouterOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p VirtualRouterOperationPredicate) Matches(input VirtualRouter) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/virtualrouters/version.go b/resource-manager/network/2024-07-01/virtualrouters/version.go new file mode 100644 index 00000000000..5c2a3bd41d7 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualrouters/version.go @@ -0,0 +1,10 @@ +package virtualrouters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/virtualrouters/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/virtualwans/README.md b/resource-manager/network/2024-07-01/virtualwans/README.md new file mode 100644 index 00000000000..d22400cc9ef --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/README.md @@ -0,0 +1,1534 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualwans` Documentation + +The `virtualwans` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/virtualwans" +``` + + +### Client Initialization + +```go +client := virtualwans.NewVirtualWANsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VirtualWANsClient.ConfigurationPolicyGroupsCreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualwans.NewConfigurationPolicyGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnServerConfigurationName", "configurationPolicyGroupName") + +payload := virtualwans.VpnServerConfigurationPolicyGroup{ + // ... +} + + +if err := client.ConfigurationPolicyGroupsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.ConfigurationPolicyGroupsDelete` + +```go +ctx := context.TODO() +id := virtualwans.NewConfigurationPolicyGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnServerConfigurationName", "configurationPolicyGroupName") + +if err := client.ConfigurationPolicyGroupsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.ConfigurationPolicyGroupsGet` + +```go +ctx := context.TODO() +id := virtualwans.NewConfigurationPolicyGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnServerConfigurationName", "configurationPolicyGroupName") + +read, err := client.ConfigurationPolicyGroupsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.ConfigurationPolicyGroupsListByVpnServerConfiguration` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnServerConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnServerConfigurationName") + +// alternatively `client.ConfigurationPolicyGroupsListByVpnServerConfiguration(ctx, id)` can be used to do batched pagination +items, err := client.ConfigurationPolicyGroupsListByVpnServerConfigurationComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.Generatevirtualwanvpnserverconfigurationvpnprofile` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualWANID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualWanName") + +payload := virtualwans.VirtualWanVpnProfileParameters{ + // ... +} + + +if err := client.GeneratevirtualwanvpnserverconfigurationvpnprofileThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.HubRouteTablesCreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualwans.NewHubRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "hubRouteTableName") + +payload := virtualwans.HubRouteTable{ + // ... +} + + +if err := client.HubRouteTablesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.HubRouteTablesDelete` + +```go +ctx := context.TODO() +id := virtualwans.NewHubRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "hubRouteTableName") + +if err := client.HubRouteTablesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.HubRouteTablesGet` + +```go +ctx := context.TODO() +id := virtualwans.NewHubRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "hubRouteTableName") + +read, err := client.HubRouteTablesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.HubRouteTablesList` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName") + +// alternatively `client.HubRouteTablesList(ctx, id)` can be used to do batched pagination +items, err := client.HubRouteTablesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.HubVirtualNetworkConnectionsCreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualwans.NewHubVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "hubVirtualNetworkConnectionName") + +payload := virtualwans.HubVirtualNetworkConnection{ + // ... +} + + +if err := client.HubVirtualNetworkConnectionsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.HubVirtualNetworkConnectionsDelete` + +```go +ctx := context.TODO() +id := virtualwans.NewHubVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "hubVirtualNetworkConnectionName") + +if err := client.HubVirtualNetworkConnectionsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.HubVirtualNetworkConnectionsGet` + +```go +ctx := context.TODO() +id := virtualwans.NewHubVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "hubVirtualNetworkConnectionName") + +read, err := client.HubVirtualNetworkConnectionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.HubVirtualNetworkConnectionsList` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName") + +// alternatively `client.HubVirtualNetworkConnectionsList(ctx, id)` can be used to do batched pagination +items, err := client.HubVirtualNetworkConnectionsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.NatRulesCreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualwans.NewNatRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "natRuleName") + +payload := virtualwans.VpnGatewayNatRule{ + // ... +} + + +if err := client.NatRulesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.NatRulesDelete` + +```go +ctx := context.TODO() +id := virtualwans.NewNatRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "natRuleName") + +if err := client.NatRulesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.NatRulesGet` + +```go +ctx := context.TODO() +id := virtualwans.NewNatRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "natRuleName") + +read, err := client.NatRulesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.NatRulesListByVpnGateway` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName") + +// alternatively `client.NatRulesListByVpnGateway(ctx, id)` can be used to do batched pagination +items, err := client.NatRulesListByVpnGatewayComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.NetworkVirtualApplianceConnectionsCreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualwans.NewNetworkVirtualApplianceConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName", "networkVirtualApplianceConnectionName") + +payload := virtualwans.NetworkVirtualApplianceConnection{ + // ... +} + + +if err := client.NetworkVirtualApplianceConnectionsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.NetworkVirtualApplianceConnectionsDelete` + +```go +ctx := context.TODO() +id := virtualwans.NewNetworkVirtualApplianceConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName", "networkVirtualApplianceConnectionName") + +if err := client.NetworkVirtualApplianceConnectionsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.NetworkVirtualApplianceConnectionsGet` + +```go +ctx := context.TODO() +id := virtualwans.NewNetworkVirtualApplianceConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName", "networkVirtualApplianceConnectionName") + +read, err := client.NetworkVirtualApplianceConnectionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.NetworkVirtualApplianceConnectionsList` + +```go +ctx := context.TODO() +id := virtualwans.NewNetworkVirtualApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName") + +// alternatively `client.NetworkVirtualApplianceConnectionsList(ctx, id)` can be used to do batched pagination +items, err := client.NetworkVirtualApplianceConnectionsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.P2sVpnGatewaysCreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewVirtualWANP2SVPNGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "p2sVpnGatewayName") + +payload := virtualwans.P2SVpnGateway{ + // ... +} + + +if err := client.P2sVpnGatewaysCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.P2sVpnGatewaysDelete` + +```go +ctx := context.TODO() +id := commonids.NewVirtualWANP2SVPNGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "p2sVpnGatewayName") + +if err := client.P2sVpnGatewaysDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.P2sVpnGatewaysGet` + +```go +ctx := context.TODO() +id := commonids.NewVirtualWANP2SVPNGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "p2sVpnGatewayName") + +read, err := client.P2sVpnGatewaysGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.P2sVpnGatewaysList` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.P2sVpnGatewaysList(ctx, id)` can be used to do batched pagination +items, err := client.P2sVpnGatewaysListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.P2sVpnGatewaysListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.P2sVpnGatewaysListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.P2sVpnGatewaysListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.RouteMapsCreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualwans.NewRouteMapID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "routeMapName") + +payload := virtualwans.RouteMap{ + // ... +} + + +if err := client.RouteMapsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.RouteMapsDelete` + +```go +ctx := context.TODO() +id := virtualwans.NewRouteMapID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "routeMapName") + +if err := client.RouteMapsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.RouteMapsGet` + +```go +ctx := context.TODO() +id := virtualwans.NewRouteMapID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "routeMapName") + +read, err := client.RouteMapsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.RouteMapsList` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName") + +// alternatively `client.RouteMapsList(ctx, id)` can be used to do batched pagination +items, err := client.RouteMapsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.RoutingIntentCreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualwans.NewRoutingIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "routingIntentName") + +payload := virtualwans.RoutingIntent{ + // ... +} + + +if err := client.RoutingIntentCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.RoutingIntentDelete` + +```go +ctx := context.TODO() +id := virtualwans.NewRoutingIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "routingIntentName") + +if err := client.RoutingIntentDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.RoutingIntentGet` + +```go +ctx := context.TODO() +id := virtualwans.NewRoutingIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "routingIntentName") + +read, err := client.RoutingIntentGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.RoutingIntentList` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName") + +// alternatively `client.RoutingIntentList(ctx, id)` can be used to do batched pagination +items, err := client.RoutingIntentListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.SupportedSecurityProviders` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualWANID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualWanName") + +read, err := client.SupportedSecurityProviders(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.UpdateTags` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualWANID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualWanName") + +payload := virtualwans.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubBgpConnectionCreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewVirtualHubBGPConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "bgpConnectionName") + +payload := virtualwans.BgpConnection{ + // ... +} + + +if err := client.VirtualHubBgpConnectionCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubBgpConnectionDelete` + +```go +ctx := context.TODO() +id := commonids.NewVirtualHubBGPConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "bgpConnectionName") + +if err := client.VirtualHubBgpConnectionDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubBgpConnectionGet` + +```go +ctx := context.TODO() +id := commonids.NewVirtualHubBGPConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "bgpConnectionName") + +read, err := client.VirtualHubBgpConnectionGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubBgpConnectionsList` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName") + +// alternatively `client.VirtualHubBgpConnectionsList(ctx, id)` can be used to do batched pagination +items, err := client.VirtualHubBgpConnectionsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubBgpConnectionsListAdvertisedRoutes` + +```go +ctx := context.TODO() +id := commonids.NewVirtualHubBGPConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "bgpConnectionName") + +if err := client.VirtualHubBgpConnectionsListAdvertisedRoutesThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubBgpConnectionsListLearnedRoutes` + +```go +ctx := context.TODO() +id := commonids.NewVirtualHubBGPConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "bgpConnectionName") + +if err := client.VirtualHubBgpConnectionsListLearnedRoutesThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubIPConfigurationCreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewVirtualHubIPConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "ipConfigurationName") + +payload := virtualwans.HubIPConfiguration{ + // ... +} + + +if err := client.VirtualHubIPConfigurationCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubIPConfigurationDelete` + +```go +ctx := context.TODO() +id := commonids.NewVirtualHubIPConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "ipConfigurationName") + +if err := client.VirtualHubIPConfigurationDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubIPConfigurationGet` + +```go +ctx := context.TODO() +id := commonids.NewVirtualHubIPConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "ipConfigurationName") + +read, err := client.VirtualHubIPConfigurationGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubIPConfigurationList` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName") + +// alternatively `client.VirtualHubIPConfigurationList(ctx, id)` can be used to do batched pagination +items, err := client.VirtualHubIPConfigurationListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubRouteTableV2sCreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualHubRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "routeTableName") + +payload := virtualwans.VirtualHubRouteTableV2{ + // ... +} + + +if err := client.VirtualHubRouteTableV2sCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubRouteTableV2sDelete` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualHubRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "routeTableName") + +if err := client.VirtualHubRouteTableV2sDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubRouteTableV2sGet` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualHubRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "routeTableName") + +read, err := client.VirtualHubRouteTableV2sGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubRouteTableV2sList` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName") + +// alternatively `client.VirtualHubRouteTableV2sList(ctx, id)` can be used to do batched pagination +items, err := client.VirtualHubRouteTableV2sListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubsCreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName") + +payload := virtualwans.VirtualHub{ + // ... +} + + +if err := client.VirtualHubsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubsDelete` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName") + +if err := client.VirtualHubsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubsGet` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName") + +read, err := client.VirtualHubsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubsGetEffectiveVirtualHubRoutes` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName") + +payload := virtualwans.EffectiveRoutesParameters{ + // ... +} + + +if err := client.VirtualHubsGetEffectiveVirtualHubRoutesThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubsGetInboundRoutes` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName") + +payload := virtualwans.GetInboundRoutesParameters{ + // ... +} + + +if err := client.VirtualHubsGetInboundRoutesThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubsGetOutboundRoutes` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName") + +payload := virtualwans.GetOutboundRoutesParameters{ + // ... +} + + +if err := client.VirtualHubsGetOutboundRoutesThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubsList` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.VirtualHubsList(ctx, id)` can be used to do batched pagination +items, err := client.VirtualHubsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubsListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.VirtualHubsListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.VirtualHubsListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualHubsUpdateTags` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName") + +payload := virtualwans.TagsObject{ + // ... +} + + +read, err := client.VirtualHubsUpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualWansCreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualWANID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualWanName") + +payload := virtualwans.VirtualWAN{ + // ... +} + + +if err := client.VirtualWansCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualWansDelete` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualWANID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualWanName") + +if err := client.VirtualWansDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualWansGet` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualWANID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualWanName") + +read, err := client.VirtualWansGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualWansList` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.VirtualWansList(ctx, id)` can be used to do batched pagination +items, err := client.VirtualWansListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.VirtualWansListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.VirtualWansListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.VirtualWansListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.VpnConnectionsCreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewVPNConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "vpnConnectionName") + +payload := virtualwans.VpnConnection{ + // ... +} + + +if err := client.VpnConnectionsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VpnConnectionsDelete` + +```go +ctx := context.TODO() +id := commonids.NewVPNConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "vpnConnectionName") + +if err := client.VpnConnectionsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VpnConnectionsGet` + +```go +ctx := context.TODO() +id := commonids.NewVPNConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "vpnConnectionName") + +read, err := client.VpnConnectionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.VpnConnectionsListByVpnGateway` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName") + +// alternatively `client.VpnConnectionsListByVpnGateway(ctx, id)` can be used to do batched pagination +items, err := client.VpnConnectionsListByVpnGatewayComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.VpnConnectionsStartPacketCapture` + +```go +ctx := context.TODO() +id := commonids.NewVPNConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "vpnConnectionName") + +payload := virtualwans.VpnConnectionPacketCaptureStartParameters{ + // ... +} + + +if err := client.VpnConnectionsStartPacketCaptureThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VpnConnectionsStopPacketCapture` + +```go +ctx := context.TODO() +id := commonids.NewVPNConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "vpnConnectionName") + +payload := virtualwans.VpnConnectionPacketCaptureStopParameters{ + // ... +} + + +if err := client.VpnConnectionsStopPacketCaptureThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VpnGatewaysCreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName") + +payload := virtualwans.VpnGateway{ + // ... +} + + +if err := client.VpnGatewaysCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VpnGatewaysDelete` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName") + +if err := client.VpnGatewaysDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VpnGatewaysGet` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName") + +read, err := client.VpnGatewaysGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.VpnGatewaysList` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.VpnGatewaysList(ctx, id)` can be used to do batched pagination +items, err := client.VpnGatewaysListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.VpnGatewaysListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.VpnGatewaysListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.VpnGatewaysListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.VpnLinkConnectionsGetAllSharedKeys` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnLinkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "vpnConnectionName", "vpnLinkConnectionName") + +// alternatively `client.VpnLinkConnectionsGetAllSharedKeys(ctx, id)` can be used to do batched pagination +items, err := client.VpnLinkConnectionsGetAllSharedKeysComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.VpnLinkConnectionsGetDefaultSharedKey` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnLinkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "vpnConnectionName", "vpnLinkConnectionName") + +read, err := client.VpnLinkConnectionsGetDefaultSharedKey(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.VpnLinkConnectionsGetIkeSas` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnLinkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "vpnConnectionName", "vpnLinkConnectionName") + +if err := client.VpnLinkConnectionsGetIkeSasThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VpnLinkConnectionsListByVpnConnection` + +```go +ctx := context.TODO() +id := commonids.NewVPNConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "vpnConnectionName") + +// alternatively `client.VpnLinkConnectionsListByVpnConnection(ctx, id)` can be used to do batched pagination +items, err := client.VpnLinkConnectionsListByVpnConnectionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.VpnLinkConnectionsListDefaultSharedKey` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnLinkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "vpnConnectionName", "vpnLinkConnectionName") + +read, err := client.VpnLinkConnectionsListDefaultSharedKey(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.VpnLinkConnectionsSetOrInitDefaultSharedKey` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnLinkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "vpnConnectionName", "vpnLinkConnectionName") + +payload := virtualwans.ConnectionSharedKeyResult{ + // ... +} + + +if err := client.VpnLinkConnectionsSetOrInitDefaultSharedKeyThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VpnServerConfigurationsAssociatedWithVirtualWanList` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualWANID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualWanName") + +if err := client.VpnServerConfigurationsAssociatedWithVirtualWanListThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VpnServerConfigurationsCreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnServerConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnServerConfigurationName") + +payload := virtualwans.VpnServerConfiguration{ + // ... +} + + +if err := client.VpnServerConfigurationsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VpnServerConfigurationsDelete` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnServerConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnServerConfigurationName") + +if err := client.VpnServerConfigurationsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VpnServerConfigurationsGet` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnServerConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnServerConfigurationName") + +read, err := client.VpnServerConfigurationsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.VpnServerConfigurationsList` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.VpnServerConfigurationsList(ctx, id)` can be used to do batched pagination +items, err := client.VpnServerConfigurationsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.VpnServerConfigurationsListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.VpnServerConfigurationsListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.VpnServerConfigurationsListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.VpnSiteLinkConnectionsGet` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnLinkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "vpnConnectionName", "vpnLinkConnectionName") + +read, err := client.VpnSiteLinkConnectionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.VpnSiteLinksGet` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnSiteLinkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnSiteName", "vpnSiteLinkName") + +read, err := client.VpnSiteLinksGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.VpnSiteLinksListByVpnSite` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnSiteName") + +// alternatively `client.VpnSiteLinksListByVpnSite(ctx, id)` can be used to do batched pagination +items, err := client.VpnSiteLinksListByVpnSiteComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.VpnSitesConfigurationDownload` + +```go +ctx := context.TODO() +id := virtualwans.NewVirtualWANID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualWanName") + +payload := virtualwans.GetVpnSitesConfigurationRequest{ + // ... +} + + +if err := client.VpnSitesConfigurationDownloadThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VpnSitesCreateOrUpdate` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnSiteName") + +payload := virtualwans.VpnSite{ + // ... +} + + +if err := client.VpnSitesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VpnSitesDelete` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnSiteName") + +if err := client.VpnSitesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `VirtualWANsClient.VpnSitesGet` + +```go +ctx := context.TODO() +id := virtualwans.NewVpnSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnSiteName") + +read, err := client.VpnSitesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VirtualWANsClient.VpnSitesList` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.VpnSitesList(ctx, id)` can be used to do batched pagination +items, err := client.VpnSitesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VirtualWANsClient.VpnSitesListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.VpnSitesListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.VpnSitesListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/virtualwans/client.go b/resource-manager/network/2024-07-01/virtualwans/client.go new file mode 100644 index 00000000000..0d727643072 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/client.go @@ -0,0 +1,26 @@ +package virtualwans + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualWANsClient struct { + Client *resourcemanager.Client +} + +func NewVirtualWANsClientWithBaseURI(sdkApi sdkEnv.Api) (*VirtualWANsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "virtualwans", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VirtualWANsClient: %+v", err) + } + + return &VirtualWANsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/constants.go b/resource-manager/network/2024-07-01/virtualwans/constants.go new file mode 100644 index 00000000000..26a1e6db68a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/constants.go @@ -0,0 +1,2388 @@ +package virtualwans + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthenticationMethod string + +const ( + AuthenticationMethodEAPMSCHAPvTwo AuthenticationMethod = "EAPMSCHAPv2" + AuthenticationMethodEAPTLS AuthenticationMethod = "EAPTLS" +) + +func PossibleValuesForAuthenticationMethod() []string { + return []string{ + string(AuthenticationMethodEAPMSCHAPvTwo), + string(AuthenticationMethodEAPTLS), + } +} + +func (s *AuthenticationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationMethod(input string) (*AuthenticationMethod, error) { + vals := map[string]AuthenticationMethod{ + "eapmschapv2": AuthenticationMethodEAPMSCHAPvTwo, + "eaptls": AuthenticationMethodEAPTLS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationMethod(input) + return &out, nil +} + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type DhGroup string + +const ( + DhGroupDHGroupOne DhGroup = "DHGroup1" + DhGroupDHGroupOneFour DhGroup = "DHGroup14" + DhGroupDHGroupTwo DhGroup = "DHGroup2" + DhGroupDHGroupTwoFour DhGroup = "DHGroup24" + DhGroupDHGroupTwoZeroFourEight DhGroup = "DHGroup2048" + DhGroupECPThreeEightFour DhGroup = "ECP384" + DhGroupECPTwoFiveSix DhGroup = "ECP256" + DhGroupNone DhGroup = "None" +) + +func PossibleValuesForDhGroup() []string { + return []string{ + string(DhGroupDHGroupOne), + string(DhGroupDHGroupOneFour), + string(DhGroupDHGroupTwo), + string(DhGroupDHGroupTwoFour), + string(DhGroupDHGroupTwoZeroFourEight), + string(DhGroupECPThreeEightFour), + string(DhGroupECPTwoFiveSix), + string(DhGroupNone), + } +} + +func (s *DhGroup) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDhGroup(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDhGroup(input string) (*DhGroup, error) { + vals := map[string]DhGroup{ + "dhgroup1": DhGroupDHGroupOne, + "dhgroup14": DhGroupDHGroupOneFour, + "dhgroup2": DhGroupDHGroupTwo, + "dhgroup24": DhGroupDHGroupTwoFour, + "dhgroup2048": DhGroupDHGroupTwoZeroFourEight, + "ecp384": DhGroupECPThreeEightFour, + "ecp256": DhGroupECPTwoFiveSix, + "none": DhGroupNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DhGroup(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type HubBgpConnectionStatus string + +const ( + HubBgpConnectionStatusConnected HubBgpConnectionStatus = "Connected" + HubBgpConnectionStatusConnecting HubBgpConnectionStatus = "Connecting" + HubBgpConnectionStatusNotConnected HubBgpConnectionStatus = "NotConnected" + HubBgpConnectionStatusUnknown HubBgpConnectionStatus = "Unknown" +) + +func PossibleValuesForHubBgpConnectionStatus() []string { + return []string{ + string(HubBgpConnectionStatusConnected), + string(HubBgpConnectionStatusConnecting), + string(HubBgpConnectionStatusNotConnected), + string(HubBgpConnectionStatusUnknown), + } +} + +func (s *HubBgpConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHubBgpConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHubBgpConnectionStatus(input string) (*HubBgpConnectionStatus, error) { + vals := map[string]HubBgpConnectionStatus{ + "connected": HubBgpConnectionStatusConnected, + "connecting": HubBgpConnectionStatusConnecting, + "notconnected": HubBgpConnectionStatusNotConnected, + "unknown": HubBgpConnectionStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HubBgpConnectionStatus(input) + return &out, nil +} + +type HubRoutingPreference string + +const ( + HubRoutingPreferenceASPath HubRoutingPreference = "ASPath" + HubRoutingPreferenceExpressRoute HubRoutingPreference = "ExpressRoute" + HubRoutingPreferenceVpnGateway HubRoutingPreference = "VpnGateway" +) + +func PossibleValuesForHubRoutingPreference() []string { + return []string{ + string(HubRoutingPreferenceASPath), + string(HubRoutingPreferenceExpressRoute), + string(HubRoutingPreferenceVpnGateway), + } +} + +func (s *HubRoutingPreference) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHubRoutingPreference(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHubRoutingPreference(input string) (*HubRoutingPreference, error) { + vals := map[string]HubRoutingPreference{ + "aspath": HubRoutingPreferenceASPath, + "expressroute": HubRoutingPreferenceExpressRoute, + "vpngateway": HubRoutingPreferenceVpnGateway, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HubRoutingPreference(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type IPsecEncryption string + +const ( + IPsecEncryptionAESOneNineTwo IPsecEncryption = "AES192" + IPsecEncryptionAESOneTwoEight IPsecEncryption = "AES128" + IPsecEncryptionAESTwoFiveSix IPsecEncryption = "AES256" + IPsecEncryptionDES IPsecEncryption = "DES" + IPsecEncryptionDESThree IPsecEncryption = "DES3" + IPsecEncryptionGCMAESOneNineTwo IPsecEncryption = "GCMAES192" + IPsecEncryptionGCMAESOneTwoEight IPsecEncryption = "GCMAES128" + IPsecEncryptionGCMAESTwoFiveSix IPsecEncryption = "GCMAES256" + IPsecEncryptionNone IPsecEncryption = "None" +) + +func PossibleValuesForIPsecEncryption() []string { + return []string{ + string(IPsecEncryptionAESOneNineTwo), + string(IPsecEncryptionAESOneTwoEight), + string(IPsecEncryptionAESTwoFiveSix), + string(IPsecEncryptionDES), + string(IPsecEncryptionDESThree), + string(IPsecEncryptionGCMAESOneNineTwo), + string(IPsecEncryptionGCMAESOneTwoEight), + string(IPsecEncryptionGCMAESTwoFiveSix), + string(IPsecEncryptionNone), + } +} + +func (s *IPsecEncryption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPsecEncryption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPsecEncryption(input string) (*IPsecEncryption, error) { + vals := map[string]IPsecEncryption{ + "aes192": IPsecEncryptionAESOneNineTwo, + "aes128": IPsecEncryptionAESOneTwoEight, + "aes256": IPsecEncryptionAESTwoFiveSix, + "des": IPsecEncryptionDES, + "des3": IPsecEncryptionDESThree, + "gcmaes192": IPsecEncryptionGCMAESOneNineTwo, + "gcmaes128": IPsecEncryptionGCMAESOneTwoEight, + "gcmaes256": IPsecEncryptionGCMAESTwoFiveSix, + "none": IPsecEncryptionNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPsecEncryption(input) + return &out, nil +} + +type IPsecIntegrity string + +const ( + IPsecIntegrityGCMAESOneNineTwo IPsecIntegrity = "GCMAES192" + IPsecIntegrityGCMAESOneTwoEight IPsecIntegrity = "GCMAES128" + IPsecIntegrityGCMAESTwoFiveSix IPsecIntegrity = "GCMAES256" + IPsecIntegrityMDFive IPsecIntegrity = "MD5" + IPsecIntegritySHAOne IPsecIntegrity = "SHA1" + IPsecIntegritySHATwoFiveSix IPsecIntegrity = "SHA256" +) + +func PossibleValuesForIPsecIntegrity() []string { + return []string{ + string(IPsecIntegrityGCMAESOneNineTwo), + string(IPsecIntegrityGCMAESOneTwoEight), + string(IPsecIntegrityGCMAESTwoFiveSix), + string(IPsecIntegrityMDFive), + string(IPsecIntegritySHAOne), + string(IPsecIntegritySHATwoFiveSix), + } +} + +func (s *IPsecIntegrity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPsecIntegrity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPsecIntegrity(input string) (*IPsecIntegrity, error) { + vals := map[string]IPsecIntegrity{ + "gcmaes192": IPsecIntegrityGCMAESOneNineTwo, + "gcmaes128": IPsecIntegrityGCMAESOneTwoEight, + "gcmaes256": IPsecIntegrityGCMAESTwoFiveSix, + "md5": IPsecIntegrityMDFive, + "sha1": IPsecIntegritySHAOne, + "sha256": IPsecIntegritySHATwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPsecIntegrity(input) + return &out, nil +} + +type IkeEncryption string + +const ( + IkeEncryptionAESOneNineTwo IkeEncryption = "AES192" + IkeEncryptionAESOneTwoEight IkeEncryption = "AES128" + IkeEncryptionAESTwoFiveSix IkeEncryption = "AES256" + IkeEncryptionDES IkeEncryption = "DES" + IkeEncryptionDESThree IkeEncryption = "DES3" + IkeEncryptionGCMAESOneTwoEight IkeEncryption = "GCMAES128" + IkeEncryptionGCMAESTwoFiveSix IkeEncryption = "GCMAES256" +) + +func PossibleValuesForIkeEncryption() []string { + return []string{ + string(IkeEncryptionAESOneNineTwo), + string(IkeEncryptionAESOneTwoEight), + string(IkeEncryptionAESTwoFiveSix), + string(IkeEncryptionDES), + string(IkeEncryptionDESThree), + string(IkeEncryptionGCMAESOneTwoEight), + string(IkeEncryptionGCMAESTwoFiveSix), + } +} + +func (s *IkeEncryption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIkeEncryption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIkeEncryption(input string) (*IkeEncryption, error) { + vals := map[string]IkeEncryption{ + "aes192": IkeEncryptionAESOneNineTwo, + "aes128": IkeEncryptionAESOneTwoEight, + "aes256": IkeEncryptionAESTwoFiveSix, + "des": IkeEncryptionDES, + "des3": IkeEncryptionDESThree, + "gcmaes128": IkeEncryptionGCMAESOneTwoEight, + "gcmaes256": IkeEncryptionGCMAESTwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IkeEncryption(input) + return &out, nil +} + +type IkeIntegrity string + +const ( + IkeIntegrityGCMAESOneTwoEight IkeIntegrity = "GCMAES128" + IkeIntegrityGCMAESTwoFiveSix IkeIntegrity = "GCMAES256" + IkeIntegrityMDFive IkeIntegrity = "MD5" + IkeIntegritySHAOne IkeIntegrity = "SHA1" + IkeIntegritySHAThreeEightFour IkeIntegrity = "SHA384" + IkeIntegritySHATwoFiveSix IkeIntegrity = "SHA256" +) + +func PossibleValuesForIkeIntegrity() []string { + return []string{ + string(IkeIntegrityGCMAESOneTwoEight), + string(IkeIntegrityGCMAESTwoFiveSix), + string(IkeIntegrityMDFive), + string(IkeIntegritySHAOne), + string(IkeIntegritySHAThreeEightFour), + string(IkeIntegritySHATwoFiveSix), + } +} + +func (s *IkeIntegrity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIkeIntegrity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIkeIntegrity(input string) (*IkeIntegrity, error) { + vals := map[string]IkeIntegrity{ + "gcmaes128": IkeIntegrityGCMAESOneTwoEight, + "gcmaes256": IkeIntegrityGCMAESTwoFiveSix, + "md5": IkeIntegrityMDFive, + "sha1": IkeIntegritySHAOne, + "sha384": IkeIntegritySHAThreeEightFour, + "sha256": IkeIntegritySHATwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IkeIntegrity(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type NextStep string + +const ( + NextStepContinue NextStep = "Continue" + NextStepTerminate NextStep = "Terminate" + NextStepUnknown NextStep = "Unknown" +) + +func PossibleValuesForNextStep() []string { + return []string{ + string(NextStepContinue), + string(NextStepTerminate), + string(NextStepUnknown), + } +} + +func (s *NextStep) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNextStep(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNextStep(input string) (*NextStep, error) { + vals := map[string]NextStep{ + "continue": NextStepContinue, + "terminate": NextStepTerminate, + "unknown": NextStepUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NextStep(input) + return &out, nil +} + +type OfficeTrafficCategory string + +const ( + OfficeTrafficCategoryAll OfficeTrafficCategory = "All" + OfficeTrafficCategoryNone OfficeTrafficCategory = "None" + OfficeTrafficCategoryOptimize OfficeTrafficCategory = "Optimize" + OfficeTrafficCategoryOptimizeAndAllow OfficeTrafficCategory = "OptimizeAndAllow" +) + +func PossibleValuesForOfficeTrafficCategory() []string { + return []string{ + string(OfficeTrafficCategoryAll), + string(OfficeTrafficCategoryNone), + string(OfficeTrafficCategoryOptimize), + string(OfficeTrafficCategoryOptimizeAndAllow), + } +} + +func (s *OfficeTrafficCategory) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOfficeTrafficCategory(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOfficeTrafficCategory(input string) (*OfficeTrafficCategory, error) { + vals := map[string]OfficeTrafficCategory{ + "all": OfficeTrafficCategoryAll, + "none": OfficeTrafficCategoryNone, + "optimize": OfficeTrafficCategoryOptimize, + "optimizeandallow": OfficeTrafficCategoryOptimizeAndAllow, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OfficeTrafficCategory(input) + return &out, nil +} + +type PfsGroup string + +const ( + PfsGroupECPThreeEightFour PfsGroup = "ECP384" + PfsGroupECPTwoFiveSix PfsGroup = "ECP256" + PfsGroupNone PfsGroup = "None" + PfsGroupPFSMM PfsGroup = "PFSMM" + PfsGroupPFSOne PfsGroup = "PFS1" + PfsGroupPFSOneFour PfsGroup = "PFS14" + PfsGroupPFSTwo PfsGroup = "PFS2" + PfsGroupPFSTwoFour PfsGroup = "PFS24" + PfsGroupPFSTwoZeroFourEight PfsGroup = "PFS2048" +) + +func PossibleValuesForPfsGroup() []string { + return []string{ + string(PfsGroupECPThreeEightFour), + string(PfsGroupECPTwoFiveSix), + string(PfsGroupNone), + string(PfsGroupPFSMM), + string(PfsGroupPFSOne), + string(PfsGroupPFSOneFour), + string(PfsGroupPFSTwo), + string(PfsGroupPFSTwoFour), + string(PfsGroupPFSTwoZeroFourEight), + } +} + +func (s *PfsGroup) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePfsGroup(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePfsGroup(input string) (*PfsGroup, error) { + vals := map[string]PfsGroup{ + "ecp384": PfsGroupECPThreeEightFour, + "ecp256": PfsGroupECPTwoFiveSix, + "none": PfsGroupNone, + "pfsmm": PfsGroupPFSMM, + "pfs1": PfsGroupPFSOne, + "pfs14": PfsGroupPFSOneFour, + "pfs2": PfsGroupPFSTwo, + "pfs24": PfsGroupPFSTwoFour, + "pfs2048": PfsGroupPFSTwoZeroFourEight, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PfsGroup(input) + return &out, nil +} + +type PreferredRoutingGateway string + +const ( + PreferredRoutingGatewayExpressRoute PreferredRoutingGateway = "ExpressRoute" + PreferredRoutingGatewayNone PreferredRoutingGateway = "None" + PreferredRoutingGatewayVpnGateway PreferredRoutingGateway = "VpnGateway" +) + +func PossibleValuesForPreferredRoutingGateway() []string { + return []string{ + string(PreferredRoutingGatewayExpressRoute), + string(PreferredRoutingGatewayNone), + string(PreferredRoutingGatewayVpnGateway), + } +} + +func (s *PreferredRoutingGateway) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePreferredRoutingGateway(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePreferredRoutingGateway(input string) (*PreferredRoutingGateway, error) { + vals := map[string]PreferredRoutingGateway{ + "expressroute": PreferredRoutingGatewayExpressRoute, + "none": PreferredRoutingGatewayNone, + "vpngateway": PreferredRoutingGatewayVpnGateway, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PreferredRoutingGateway(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteMapActionType string + +const ( + RouteMapActionTypeAdd RouteMapActionType = "Add" + RouteMapActionTypeDrop RouteMapActionType = "Drop" + RouteMapActionTypeRemove RouteMapActionType = "Remove" + RouteMapActionTypeReplace RouteMapActionType = "Replace" + RouteMapActionTypeUnknown RouteMapActionType = "Unknown" +) + +func PossibleValuesForRouteMapActionType() []string { + return []string{ + string(RouteMapActionTypeAdd), + string(RouteMapActionTypeDrop), + string(RouteMapActionTypeRemove), + string(RouteMapActionTypeReplace), + string(RouteMapActionTypeUnknown), + } +} + +func (s *RouteMapActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteMapActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteMapActionType(input string) (*RouteMapActionType, error) { + vals := map[string]RouteMapActionType{ + "add": RouteMapActionTypeAdd, + "drop": RouteMapActionTypeDrop, + "remove": RouteMapActionTypeRemove, + "replace": RouteMapActionTypeReplace, + "unknown": RouteMapActionTypeUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteMapActionType(input) + return &out, nil +} + +type RouteMapMatchCondition string + +const ( + RouteMapMatchConditionContains RouteMapMatchCondition = "Contains" + RouteMapMatchConditionEquals RouteMapMatchCondition = "Equals" + RouteMapMatchConditionNotContains RouteMapMatchCondition = "NotContains" + RouteMapMatchConditionNotEquals RouteMapMatchCondition = "NotEquals" + RouteMapMatchConditionUnknown RouteMapMatchCondition = "Unknown" +) + +func PossibleValuesForRouteMapMatchCondition() []string { + return []string{ + string(RouteMapMatchConditionContains), + string(RouteMapMatchConditionEquals), + string(RouteMapMatchConditionNotContains), + string(RouteMapMatchConditionNotEquals), + string(RouteMapMatchConditionUnknown), + } +} + +func (s *RouteMapMatchCondition) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteMapMatchCondition(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteMapMatchCondition(input string) (*RouteMapMatchCondition, error) { + vals := map[string]RouteMapMatchCondition{ + "contains": RouteMapMatchConditionContains, + "equals": RouteMapMatchConditionEquals, + "notcontains": RouteMapMatchConditionNotContains, + "notequals": RouteMapMatchConditionNotEquals, + "unknown": RouteMapMatchConditionUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteMapMatchCondition(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type RoutingState string + +const ( + RoutingStateFailed RoutingState = "Failed" + RoutingStateNone RoutingState = "None" + RoutingStateProvisioned RoutingState = "Provisioned" + RoutingStateProvisioning RoutingState = "Provisioning" +) + +func PossibleValuesForRoutingState() []string { + return []string{ + string(RoutingStateFailed), + string(RoutingStateNone), + string(RoutingStateProvisioned), + string(RoutingStateProvisioning), + } +} + +func (s *RoutingState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRoutingState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRoutingState(input string) (*RoutingState, error) { + vals := map[string]RoutingState{ + "failed": RoutingStateFailed, + "none": RoutingStateNone, + "provisioned": RoutingStateProvisioned, + "provisioning": RoutingStateProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RoutingState(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkGatewayConnectionProtocol string + +const ( + VirtualNetworkGatewayConnectionProtocolIKEvOne VirtualNetworkGatewayConnectionProtocol = "IKEv1" + VirtualNetworkGatewayConnectionProtocolIKEvTwo VirtualNetworkGatewayConnectionProtocol = "IKEv2" +) + +func PossibleValuesForVirtualNetworkGatewayConnectionProtocol() []string { + return []string{ + string(VirtualNetworkGatewayConnectionProtocolIKEvOne), + string(VirtualNetworkGatewayConnectionProtocolIKEvTwo), + } +} + +func (s *VirtualNetworkGatewayConnectionProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewayConnectionProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewayConnectionProtocol(input string) (*VirtualNetworkGatewayConnectionProtocol, error) { + vals := map[string]VirtualNetworkGatewayConnectionProtocol{ + "ikev1": VirtualNetworkGatewayConnectionProtocolIKEvOne, + "ikev2": VirtualNetworkGatewayConnectionProtocolIKEvTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewayConnectionProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} + +type VirtualWanSecurityProviderType string + +const ( + VirtualWanSecurityProviderTypeExternal VirtualWanSecurityProviderType = "External" + VirtualWanSecurityProviderTypeNative VirtualWanSecurityProviderType = "Native" +) + +func PossibleValuesForVirtualWanSecurityProviderType() []string { + return []string{ + string(VirtualWanSecurityProviderTypeExternal), + string(VirtualWanSecurityProviderTypeNative), + } +} + +func (s *VirtualWanSecurityProviderType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualWanSecurityProviderType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualWanSecurityProviderType(input string) (*VirtualWanSecurityProviderType, error) { + vals := map[string]VirtualWanSecurityProviderType{ + "external": VirtualWanSecurityProviderTypeExternal, + "native": VirtualWanSecurityProviderTypeNative, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualWanSecurityProviderType(input) + return &out, nil +} + +type VnetLocalRouteOverrideCriteria string + +const ( + VnetLocalRouteOverrideCriteriaContains VnetLocalRouteOverrideCriteria = "Contains" + VnetLocalRouteOverrideCriteriaEqual VnetLocalRouteOverrideCriteria = "Equal" +) + +func PossibleValuesForVnetLocalRouteOverrideCriteria() []string { + return []string{ + string(VnetLocalRouteOverrideCriteriaContains), + string(VnetLocalRouteOverrideCriteriaEqual), + } +} + +func (s *VnetLocalRouteOverrideCriteria) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVnetLocalRouteOverrideCriteria(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVnetLocalRouteOverrideCriteria(input string) (*VnetLocalRouteOverrideCriteria, error) { + vals := map[string]VnetLocalRouteOverrideCriteria{ + "contains": VnetLocalRouteOverrideCriteriaContains, + "equal": VnetLocalRouteOverrideCriteriaEqual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VnetLocalRouteOverrideCriteria(input) + return &out, nil +} + +type VpnAuthenticationType string + +const ( + VpnAuthenticationTypeAAD VpnAuthenticationType = "AAD" + VpnAuthenticationTypeCertificate VpnAuthenticationType = "Certificate" + VpnAuthenticationTypeRadius VpnAuthenticationType = "Radius" +) + +func PossibleValuesForVpnAuthenticationType() []string { + return []string{ + string(VpnAuthenticationTypeAAD), + string(VpnAuthenticationTypeCertificate), + string(VpnAuthenticationTypeRadius), + } +} + +func (s *VpnAuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnAuthenticationType(input string) (*VpnAuthenticationType, error) { + vals := map[string]VpnAuthenticationType{ + "aad": VpnAuthenticationTypeAAD, + "certificate": VpnAuthenticationTypeCertificate, + "radius": VpnAuthenticationTypeRadius, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnAuthenticationType(input) + return &out, nil +} + +type VpnConnectionStatus string + +const ( + VpnConnectionStatusConnected VpnConnectionStatus = "Connected" + VpnConnectionStatusConnecting VpnConnectionStatus = "Connecting" + VpnConnectionStatusNotConnected VpnConnectionStatus = "NotConnected" + VpnConnectionStatusUnknown VpnConnectionStatus = "Unknown" +) + +func PossibleValuesForVpnConnectionStatus() []string { + return []string{ + string(VpnConnectionStatusConnected), + string(VpnConnectionStatusConnecting), + string(VpnConnectionStatusNotConnected), + string(VpnConnectionStatusUnknown), + } +} + +func (s *VpnConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnConnectionStatus(input string) (*VpnConnectionStatus, error) { + vals := map[string]VpnConnectionStatus{ + "connected": VpnConnectionStatusConnected, + "connecting": VpnConnectionStatusConnecting, + "notconnected": VpnConnectionStatusNotConnected, + "unknown": VpnConnectionStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnConnectionStatus(input) + return &out, nil +} + +type VpnGatewayTunnelingProtocol string + +const ( + VpnGatewayTunnelingProtocolIkeVTwo VpnGatewayTunnelingProtocol = "IkeV2" + VpnGatewayTunnelingProtocolOpenVPN VpnGatewayTunnelingProtocol = "OpenVPN" +) + +func PossibleValuesForVpnGatewayTunnelingProtocol() []string { + return []string{ + string(VpnGatewayTunnelingProtocolIkeVTwo), + string(VpnGatewayTunnelingProtocolOpenVPN), + } +} + +func (s *VpnGatewayTunnelingProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnGatewayTunnelingProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnGatewayTunnelingProtocol(input string) (*VpnGatewayTunnelingProtocol, error) { + vals := map[string]VpnGatewayTunnelingProtocol{ + "ikev2": VpnGatewayTunnelingProtocolIkeVTwo, + "openvpn": VpnGatewayTunnelingProtocolOpenVPN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnGatewayTunnelingProtocol(input) + return &out, nil +} + +type VpnLinkConnectionMode string + +const ( + VpnLinkConnectionModeDefault VpnLinkConnectionMode = "Default" + VpnLinkConnectionModeInitiatorOnly VpnLinkConnectionMode = "InitiatorOnly" + VpnLinkConnectionModeResponderOnly VpnLinkConnectionMode = "ResponderOnly" +) + +func PossibleValuesForVpnLinkConnectionMode() []string { + return []string{ + string(VpnLinkConnectionModeDefault), + string(VpnLinkConnectionModeInitiatorOnly), + string(VpnLinkConnectionModeResponderOnly), + } +} + +func (s *VpnLinkConnectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnLinkConnectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnLinkConnectionMode(input string) (*VpnLinkConnectionMode, error) { + vals := map[string]VpnLinkConnectionMode{ + "default": VpnLinkConnectionModeDefault, + "initiatoronly": VpnLinkConnectionModeInitiatorOnly, + "responderonly": VpnLinkConnectionModeResponderOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnLinkConnectionMode(input) + return &out, nil +} + +type VpnNatRuleMode string + +const ( + VpnNatRuleModeEgressSnat VpnNatRuleMode = "EgressSnat" + VpnNatRuleModeIngressSnat VpnNatRuleMode = "IngressSnat" +) + +func PossibleValuesForVpnNatRuleMode() []string { + return []string{ + string(VpnNatRuleModeEgressSnat), + string(VpnNatRuleModeIngressSnat), + } +} + +func (s *VpnNatRuleMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnNatRuleMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnNatRuleMode(input string) (*VpnNatRuleMode, error) { + vals := map[string]VpnNatRuleMode{ + "egresssnat": VpnNatRuleModeEgressSnat, + "ingresssnat": VpnNatRuleModeIngressSnat, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnNatRuleMode(input) + return &out, nil +} + +type VpnNatRuleType string + +const ( + VpnNatRuleTypeDynamic VpnNatRuleType = "Dynamic" + VpnNatRuleTypeStatic VpnNatRuleType = "Static" +) + +func PossibleValuesForVpnNatRuleType() []string { + return []string{ + string(VpnNatRuleTypeDynamic), + string(VpnNatRuleTypeStatic), + } +} + +func (s *VpnNatRuleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnNatRuleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnNatRuleType(input string) (*VpnNatRuleType, error) { + vals := map[string]VpnNatRuleType{ + "dynamic": VpnNatRuleTypeDynamic, + "static": VpnNatRuleTypeStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnNatRuleType(input) + return &out, nil +} + +type VpnPolicyMemberAttributeType string + +const ( + VpnPolicyMemberAttributeTypeAADGroupId VpnPolicyMemberAttributeType = "AADGroupId" + VpnPolicyMemberAttributeTypeCertificateGroupId VpnPolicyMemberAttributeType = "CertificateGroupId" + VpnPolicyMemberAttributeTypeRadiusAzureGroupId VpnPolicyMemberAttributeType = "RadiusAzureGroupId" +) + +func PossibleValuesForVpnPolicyMemberAttributeType() []string { + return []string{ + string(VpnPolicyMemberAttributeTypeAADGroupId), + string(VpnPolicyMemberAttributeTypeCertificateGroupId), + string(VpnPolicyMemberAttributeTypeRadiusAzureGroupId), + } +} + +func (s *VpnPolicyMemberAttributeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnPolicyMemberAttributeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnPolicyMemberAttributeType(input string) (*VpnPolicyMemberAttributeType, error) { + vals := map[string]VpnPolicyMemberAttributeType{ + "aadgroupid": VpnPolicyMemberAttributeTypeAADGroupId, + "certificategroupid": VpnPolicyMemberAttributeTypeCertificateGroupId, + "radiusazuregroupid": VpnPolicyMemberAttributeTypeRadiusAzureGroupId, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnPolicyMemberAttributeType(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_configurationpolicygroup.go b/resource-manager/network/2024-07-01/virtualwans/id_configurationpolicygroup.go new file mode 100644 index 00000000000..058775a50d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_configurationpolicygroup.go @@ -0,0 +1,139 @@ +package virtualwans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConfigurationPolicyGroupId{}) +} + +var _ resourceids.ResourceId = &ConfigurationPolicyGroupId{} + +// ConfigurationPolicyGroupId is a struct representing the Resource ID for a Configuration Policy Group +type ConfigurationPolicyGroupId struct { + SubscriptionId string + ResourceGroupName string + VpnServerConfigurationName string + ConfigurationPolicyGroupName string +} + +// NewConfigurationPolicyGroupID returns a new ConfigurationPolicyGroupId struct +func NewConfigurationPolicyGroupID(subscriptionId string, resourceGroupName string, vpnServerConfigurationName string, configurationPolicyGroupName string) ConfigurationPolicyGroupId { + return ConfigurationPolicyGroupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VpnServerConfigurationName: vpnServerConfigurationName, + ConfigurationPolicyGroupName: configurationPolicyGroupName, + } +} + +// ParseConfigurationPolicyGroupID parses 'input' into a ConfigurationPolicyGroupId +func ParseConfigurationPolicyGroupID(input string) (*ConfigurationPolicyGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigurationPolicyGroupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigurationPolicyGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConfigurationPolicyGroupIDInsensitively parses 'input' case-insensitively into a ConfigurationPolicyGroupId +// note: this method should only be used for API response data and not user input +func ParseConfigurationPolicyGroupIDInsensitively(input string) (*ConfigurationPolicyGroupId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigurationPolicyGroupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigurationPolicyGroupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConfigurationPolicyGroupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VpnServerConfigurationName, ok = input.Parsed["vpnServerConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vpnServerConfigurationName", input) + } + + if id.ConfigurationPolicyGroupName, ok = input.Parsed["configurationPolicyGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "configurationPolicyGroupName", input) + } + + return nil +} + +// ValidateConfigurationPolicyGroupID checks that 'input' can be parsed as a Configuration Policy Group ID +func ValidateConfigurationPolicyGroupID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseConfigurationPolicyGroupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Configuration Policy Group ID +func (id ConfigurationPolicyGroupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/vpnServerConfigurations/%s/configurationPolicyGroups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VpnServerConfigurationName, id.ConfigurationPolicyGroupName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Configuration Policy Group ID +func (id ConfigurationPolicyGroupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVpnServerConfigurations", "vpnServerConfigurations", "vpnServerConfigurations"), + resourceids.UserSpecifiedSegment("vpnServerConfigurationName", "vpnServerConfigurationName"), + resourceids.StaticSegment("staticConfigurationPolicyGroups", "configurationPolicyGroups", "configurationPolicyGroups"), + resourceids.UserSpecifiedSegment("configurationPolicyGroupName", "configurationPolicyGroupName"), + } +} + +// String returns a human-readable description of this Configuration Policy Group ID +func (id ConfigurationPolicyGroupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vpn Server Configuration Name: %q", id.VpnServerConfigurationName), + fmt.Sprintf("Configuration Policy Group Name: %q", id.ConfigurationPolicyGroupName), + } + return fmt.Sprintf("Configuration Policy Group (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_configurationpolicygroup_test.go b/resource-manager/network/2024-07-01/virtualwans/id_configurationpolicygroup_test.go new file mode 100644 index 00000000000..5650390d291 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_configurationpolicygroup_test.go @@ -0,0 +1,327 @@ +package virtualwans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ConfigurationPolicyGroupId{} + +func TestNewConfigurationPolicyGroupID(t *testing.T) { + id := NewConfigurationPolicyGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnServerConfigurationName", "configurationPolicyGroupName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VpnServerConfigurationName != "vpnServerConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'VpnServerConfigurationName'", id.VpnServerConfigurationName, "vpnServerConfigurationName") + } + + if id.ConfigurationPolicyGroupName != "configurationPolicyGroupName" { + t.Fatalf("Expected %q but got %q for Segment 'ConfigurationPolicyGroupName'", id.ConfigurationPolicyGroupName, "configurationPolicyGroupName") + } +} + +func TestFormatConfigurationPolicyGroupID(t *testing.T) { + actual := NewConfigurationPolicyGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnServerConfigurationName", "configurationPolicyGroupName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName/configurationPolicyGroups/configurationPolicyGroupName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConfigurationPolicyGroupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigurationPolicyGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName/configurationPolicyGroups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName/configurationPolicyGroups/configurationPolicyGroupName", + Expected: &ConfigurationPolicyGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnServerConfigurationName: "vpnServerConfigurationName", + ConfigurationPolicyGroupName: "configurationPolicyGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName/configurationPolicyGroups/configurationPolicyGroupName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigurationPolicyGroupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnServerConfigurationName != v.Expected.VpnServerConfigurationName { + t.Fatalf("Expected %q but got %q for VpnServerConfigurationName", v.Expected.VpnServerConfigurationName, actual.VpnServerConfigurationName) + } + + if actual.ConfigurationPolicyGroupName != v.Expected.ConfigurationPolicyGroupName { + t.Fatalf("Expected %q but got %q for ConfigurationPolicyGroupName", v.Expected.ConfigurationPolicyGroupName, actual.ConfigurationPolicyGroupName) + } + + } +} + +func TestParseConfigurationPolicyGroupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigurationPolicyGroupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSeRvErCoNfIgUrAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSeRvErCoNfIgUrAtIoNs/vPnSeRvErCoNfIgUrAtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName/configurationPolicyGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSeRvErCoNfIgUrAtIoNs/vPnSeRvErCoNfIgUrAtIoNnAmE/cOnFiGuRaTiOnPoLiCyGrOuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName/configurationPolicyGroups/configurationPolicyGroupName", + Expected: &ConfigurationPolicyGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnServerConfigurationName: "vpnServerConfigurationName", + ConfigurationPolicyGroupName: "configurationPolicyGroupName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName/configurationPolicyGroups/configurationPolicyGroupName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSeRvErCoNfIgUrAtIoNs/vPnSeRvErCoNfIgUrAtIoNnAmE/cOnFiGuRaTiOnPoLiCyGrOuPs/cOnFiGuRaTiOnPoLiCyGrOuPnAmE", + Expected: &ConfigurationPolicyGroupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VpnServerConfigurationName: "vPnSeRvErCoNfIgUrAtIoNnAmE", + ConfigurationPolicyGroupName: "cOnFiGuRaTiOnPoLiCyGrOuPnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSeRvErCoNfIgUrAtIoNs/vPnSeRvErCoNfIgUrAtIoNnAmE/cOnFiGuRaTiOnPoLiCyGrOuPs/cOnFiGuRaTiOnPoLiCyGrOuPnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigurationPolicyGroupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnServerConfigurationName != v.Expected.VpnServerConfigurationName { + t.Fatalf("Expected %q but got %q for VpnServerConfigurationName", v.Expected.VpnServerConfigurationName, actual.VpnServerConfigurationName) + } + + if actual.ConfigurationPolicyGroupName != v.Expected.ConfigurationPolicyGroupName { + t.Fatalf("Expected %q but got %q for ConfigurationPolicyGroupName", v.Expected.ConfigurationPolicyGroupName, actual.ConfigurationPolicyGroupName) + } + + } +} + +func TestSegmentsForConfigurationPolicyGroupId(t *testing.T) { + segments := ConfigurationPolicyGroupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConfigurationPolicyGroupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_hubroutetable.go b/resource-manager/network/2024-07-01/virtualwans/id_hubroutetable.go new file mode 100644 index 00000000000..12d932e8523 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_hubroutetable.go @@ -0,0 +1,139 @@ +package virtualwans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HubRouteTableId{}) +} + +var _ resourceids.ResourceId = &HubRouteTableId{} + +// HubRouteTableId is a struct representing the Resource ID for a Hub Route Table +type HubRouteTableId struct { + SubscriptionId string + ResourceGroupName string + VirtualHubName string + HubRouteTableName string +} + +// NewHubRouteTableID returns a new HubRouteTableId struct +func NewHubRouteTableID(subscriptionId string, resourceGroupName string, virtualHubName string, hubRouteTableName string) HubRouteTableId { + return HubRouteTableId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualHubName: virtualHubName, + HubRouteTableName: hubRouteTableName, + } +} + +// ParseHubRouteTableID parses 'input' into a HubRouteTableId +func ParseHubRouteTableID(input string) (*HubRouteTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&HubRouteTableId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HubRouteTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHubRouteTableIDInsensitively parses 'input' case-insensitively into a HubRouteTableId +// note: this method should only be used for API response data and not user input +func ParseHubRouteTableIDInsensitively(input string) (*HubRouteTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&HubRouteTableId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HubRouteTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HubRouteTableId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VirtualHubName, ok = input.Parsed["virtualHubName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualHubName", input) + } + + if id.HubRouteTableName, ok = input.Parsed["hubRouteTableName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hubRouteTableName", input) + } + + return nil +} + +// ValidateHubRouteTableID checks that 'input' can be parsed as a Hub Route Table ID +func ValidateHubRouteTableID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHubRouteTableID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hub Route Table ID +func (id HubRouteTableId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualHubs/%s/hubRouteTables/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualHubName, id.HubRouteTableName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hub Route Table ID +func (id HubRouteTableId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVirtualHubs", "virtualHubs", "virtualHubs"), + resourceids.UserSpecifiedSegment("virtualHubName", "virtualHubName"), + resourceids.StaticSegment("staticHubRouteTables", "hubRouteTables", "hubRouteTables"), + resourceids.UserSpecifiedSegment("hubRouteTableName", "hubRouteTableName"), + } +} + +// String returns a human-readable description of this Hub Route Table ID +func (id HubRouteTableId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Hub Name: %q", id.VirtualHubName), + fmt.Sprintf("Hub Route Table Name: %q", id.HubRouteTableName), + } + return fmt.Sprintf("Hub Route Table (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_hubroutetable_test.go b/resource-manager/network/2024-07-01/virtualwans/id_hubroutetable_test.go new file mode 100644 index 00000000000..68d653182ed --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_hubroutetable_test.go @@ -0,0 +1,327 @@ +package virtualwans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HubRouteTableId{} + +func TestNewHubRouteTableID(t *testing.T) { + id := NewHubRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "hubRouteTableName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VirtualHubName != "virtualHubName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualHubName'", id.VirtualHubName, "virtualHubName") + } + + if id.HubRouteTableName != "hubRouteTableName" { + t.Fatalf("Expected %q but got %q for Segment 'HubRouteTableName'", id.HubRouteTableName, "hubRouteTableName") + } +} + +func TestFormatHubRouteTableID(t *testing.T) { + actual := NewHubRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "hubRouteTableName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/hubRouteTables/hubRouteTableName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHubRouteTableID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HubRouteTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/hubRouteTables", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/hubRouteTables/hubRouteTableName", + Expected: &HubRouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualHubName: "virtualHubName", + HubRouteTableName: "hubRouteTableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/hubRouteTables/hubRouteTableName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHubRouteTableID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualHubName != v.Expected.VirtualHubName { + t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) + } + + if actual.HubRouteTableName != v.Expected.HubRouteTableName { + t.Fatalf("Expected %q but got %q for HubRouteTableName", v.Expected.HubRouteTableName, actual.HubRouteTableName) + } + + } +} + +func TestParseHubRouteTableIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HubRouteTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/hubRouteTables", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE/hUbRoUtEtAbLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/hubRouteTables/hubRouteTableName", + Expected: &HubRouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualHubName: "virtualHubName", + HubRouteTableName: "hubRouteTableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/hubRouteTables/hubRouteTableName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE/hUbRoUtEtAbLeS/hUbRoUtEtAbLeNaMe", + Expected: &HubRouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualHubName: "vIrTuAlHuBnAmE", + HubRouteTableName: "hUbRoUtEtAbLeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE/hUbRoUtEtAbLeS/hUbRoUtEtAbLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHubRouteTableIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualHubName != v.Expected.VirtualHubName { + t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) + } + + if actual.HubRouteTableName != v.Expected.HubRouteTableName { + t.Fatalf("Expected %q but got %q for HubRouteTableName", v.Expected.HubRouteTableName, actual.HubRouteTableName) + } + + } +} + +func TestSegmentsForHubRouteTableId(t *testing.T) { + segments := HubRouteTableId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HubRouteTableId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_hubvirtualnetworkconnection.go b/resource-manager/network/2024-07-01/virtualwans/id_hubvirtualnetworkconnection.go new file mode 100644 index 00000000000..17eee4937eb --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_hubvirtualnetworkconnection.go @@ -0,0 +1,139 @@ +package virtualwans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HubVirtualNetworkConnectionId{}) +} + +var _ resourceids.ResourceId = &HubVirtualNetworkConnectionId{} + +// HubVirtualNetworkConnectionId is a struct representing the Resource ID for a Hub Virtual Network Connection +type HubVirtualNetworkConnectionId struct { + SubscriptionId string + ResourceGroupName string + VirtualHubName string + HubVirtualNetworkConnectionName string +} + +// NewHubVirtualNetworkConnectionID returns a new HubVirtualNetworkConnectionId struct +func NewHubVirtualNetworkConnectionID(subscriptionId string, resourceGroupName string, virtualHubName string, hubVirtualNetworkConnectionName string) HubVirtualNetworkConnectionId { + return HubVirtualNetworkConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualHubName: virtualHubName, + HubVirtualNetworkConnectionName: hubVirtualNetworkConnectionName, + } +} + +// ParseHubVirtualNetworkConnectionID parses 'input' into a HubVirtualNetworkConnectionId +func ParseHubVirtualNetworkConnectionID(input string) (*HubVirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&HubVirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HubVirtualNetworkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHubVirtualNetworkConnectionIDInsensitively parses 'input' case-insensitively into a HubVirtualNetworkConnectionId +// note: this method should only be used for API response data and not user input +func ParseHubVirtualNetworkConnectionIDInsensitively(input string) (*HubVirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&HubVirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HubVirtualNetworkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HubVirtualNetworkConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VirtualHubName, ok = input.Parsed["virtualHubName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualHubName", input) + } + + if id.HubVirtualNetworkConnectionName, ok = input.Parsed["hubVirtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hubVirtualNetworkConnectionName", input) + } + + return nil +} + +// ValidateHubVirtualNetworkConnectionID checks that 'input' can be parsed as a Hub Virtual Network Connection ID +func ValidateHubVirtualNetworkConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHubVirtualNetworkConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hub Virtual Network Connection ID +func (id HubVirtualNetworkConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualHubs/%s/hubVirtualNetworkConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualHubName, id.HubVirtualNetworkConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hub Virtual Network Connection ID +func (id HubVirtualNetworkConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVirtualHubs", "virtualHubs", "virtualHubs"), + resourceids.UserSpecifiedSegment("virtualHubName", "virtualHubName"), + resourceids.StaticSegment("staticHubVirtualNetworkConnections", "hubVirtualNetworkConnections", "hubVirtualNetworkConnections"), + resourceids.UserSpecifiedSegment("hubVirtualNetworkConnectionName", "hubVirtualNetworkConnectionName"), + } +} + +// String returns a human-readable description of this Hub Virtual Network Connection ID +func (id HubVirtualNetworkConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Hub Name: %q", id.VirtualHubName), + fmt.Sprintf("Hub Virtual Network Connection Name: %q", id.HubVirtualNetworkConnectionName), + } + return fmt.Sprintf("Hub Virtual Network Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_hubvirtualnetworkconnection_test.go b/resource-manager/network/2024-07-01/virtualwans/id_hubvirtualnetworkconnection_test.go new file mode 100644 index 00000000000..fcfebd848f0 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_hubvirtualnetworkconnection_test.go @@ -0,0 +1,327 @@ +package virtualwans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HubVirtualNetworkConnectionId{} + +func TestNewHubVirtualNetworkConnectionID(t *testing.T) { + id := NewHubVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "hubVirtualNetworkConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VirtualHubName != "virtualHubName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualHubName'", id.VirtualHubName, "virtualHubName") + } + + if id.HubVirtualNetworkConnectionName != "hubVirtualNetworkConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'HubVirtualNetworkConnectionName'", id.HubVirtualNetworkConnectionName, "hubVirtualNetworkConnectionName") + } +} + +func TestFormatHubVirtualNetworkConnectionID(t *testing.T) { + actual := NewHubVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "hubVirtualNetworkConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/hubVirtualNetworkConnections/hubVirtualNetworkConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHubVirtualNetworkConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HubVirtualNetworkConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/hubVirtualNetworkConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/hubVirtualNetworkConnections/hubVirtualNetworkConnectionName", + Expected: &HubVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualHubName: "virtualHubName", + HubVirtualNetworkConnectionName: "hubVirtualNetworkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/hubVirtualNetworkConnections/hubVirtualNetworkConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHubVirtualNetworkConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualHubName != v.Expected.VirtualHubName { + t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) + } + + if actual.HubVirtualNetworkConnectionName != v.Expected.HubVirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for HubVirtualNetworkConnectionName", v.Expected.HubVirtualNetworkConnectionName, actual.HubVirtualNetworkConnectionName) + } + + } +} + +func TestParseHubVirtualNetworkConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HubVirtualNetworkConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/hubVirtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE/hUbViRtUaLnEtWoRkCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/hubVirtualNetworkConnections/hubVirtualNetworkConnectionName", + Expected: &HubVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualHubName: "virtualHubName", + HubVirtualNetworkConnectionName: "hubVirtualNetworkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/hubVirtualNetworkConnections/hubVirtualNetworkConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE/hUbViRtUaLnEtWoRkCoNnEcTiOnS/hUbViRtUaLnEtWoRkCoNnEcTiOnNaMe", + Expected: &HubVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualHubName: "vIrTuAlHuBnAmE", + HubVirtualNetworkConnectionName: "hUbViRtUaLnEtWoRkCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE/hUbViRtUaLnEtWoRkCoNnEcTiOnS/hUbViRtUaLnEtWoRkCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHubVirtualNetworkConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualHubName != v.Expected.VirtualHubName { + t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) + } + + if actual.HubVirtualNetworkConnectionName != v.Expected.HubVirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for HubVirtualNetworkConnectionName", v.Expected.HubVirtualNetworkConnectionName, actual.HubVirtualNetworkConnectionName) + } + + } +} + +func TestSegmentsForHubVirtualNetworkConnectionId(t *testing.T) { + segments := HubVirtualNetworkConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HubVirtualNetworkConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_natrule.go b/resource-manager/network/2024-07-01/virtualwans/id_natrule.go new file mode 100644 index 00000000000..ab096bb8e61 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_natrule.go @@ -0,0 +1,139 @@ +package virtualwans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NatRuleId{}) +} + +var _ resourceids.ResourceId = &NatRuleId{} + +// NatRuleId is a struct representing the Resource ID for a Nat Rule +type NatRuleId struct { + SubscriptionId string + ResourceGroupName string + VpnGatewayName string + NatRuleName string +} + +// NewNatRuleID returns a new NatRuleId struct +func NewNatRuleID(subscriptionId string, resourceGroupName string, vpnGatewayName string, natRuleName string) NatRuleId { + return NatRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VpnGatewayName: vpnGatewayName, + NatRuleName: natRuleName, + } +} + +// ParseNatRuleID parses 'input' into a NatRuleId +func ParseNatRuleID(input string) (*NatRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&NatRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NatRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNatRuleIDInsensitively parses 'input' case-insensitively into a NatRuleId +// note: this method should only be used for API response data and not user input +func ParseNatRuleIDInsensitively(input string) (*NatRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&NatRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NatRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NatRuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VpnGatewayName, ok = input.Parsed["vpnGatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vpnGatewayName", input) + } + + if id.NatRuleName, ok = input.Parsed["natRuleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "natRuleName", input) + } + + return nil +} + +// ValidateNatRuleID checks that 'input' can be parsed as a Nat Rule ID +func ValidateNatRuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNatRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Nat Rule ID +func (id NatRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/vpnGateways/%s/natRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VpnGatewayName, id.NatRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Nat Rule ID +func (id NatRuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVpnGateways", "vpnGateways", "vpnGateways"), + resourceids.UserSpecifiedSegment("vpnGatewayName", "vpnGatewayName"), + resourceids.StaticSegment("staticNatRules", "natRules", "natRules"), + resourceids.UserSpecifiedSegment("natRuleName", "natRuleName"), + } +} + +// String returns a human-readable description of this Nat Rule ID +func (id NatRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vpn Gateway Name: %q", id.VpnGatewayName), + fmt.Sprintf("Nat Rule Name: %q", id.NatRuleName), + } + return fmt.Sprintf("Nat Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_natrule_test.go b/resource-manager/network/2024-07-01/virtualwans/id_natrule_test.go new file mode 100644 index 00000000000..0b0048431d8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_natrule_test.go @@ -0,0 +1,327 @@ +package virtualwans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NatRuleId{} + +func TestNewNatRuleID(t *testing.T) { + id := NewNatRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "natRuleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VpnGatewayName != "vpnGatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'VpnGatewayName'", id.VpnGatewayName, "vpnGatewayName") + } + + if id.NatRuleName != "natRuleName" { + t.Fatalf("Expected %q but got %q for Segment 'NatRuleName'", id.NatRuleName, "natRuleName") + } +} + +func TestFormatNatRuleID(t *testing.T) { + actual := NewNatRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "natRuleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/natRules/natRuleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNatRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NatRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/natRules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/natRules/natRuleName", + Expected: &NatRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnGatewayName: "vpnGatewayName", + NatRuleName: "natRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/natRules/natRuleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNatRuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnGatewayName != v.Expected.VpnGatewayName { + t.Fatalf("Expected %q but got %q for VpnGatewayName", v.Expected.VpnGatewayName, actual.VpnGatewayName) + } + + if actual.NatRuleName != v.Expected.NatRuleName { + t.Fatalf("Expected %q but got %q for NatRuleName", v.Expected.NatRuleName, actual.NatRuleName) + } + + } +} + +func TestParseNatRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NatRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/natRules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE/nAtRuLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/natRules/natRuleName", + Expected: &NatRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnGatewayName: "vpnGatewayName", + NatRuleName: "natRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/natRules/natRuleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE/nAtRuLeS/nAtRuLeNaMe", + Expected: &NatRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VpnGatewayName: "vPnGaTeWaYnAmE", + NatRuleName: "nAtRuLeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE/nAtRuLeS/nAtRuLeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNatRuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnGatewayName != v.Expected.VpnGatewayName { + t.Fatalf("Expected %q but got %q for VpnGatewayName", v.Expected.VpnGatewayName, actual.VpnGatewayName) + } + + if actual.NatRuleName != v.Expected.NatRuleName { + t.Fatalf("Expected %q but got %q for NatRuleName", v.Expected.NatRuleName, actual.NatRuleName) + } + + } +} + +func TestSegmentsForNatRuleId(t *testing.T) { + segments := NatRuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NatRuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_networkvirtualappliance.go b/resource-manager/network/2024-07-01/virtualwans/id_networkvirtualappliance.go new file mode 100644 index 00000000000..3b7e0a17a90 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_networkvirtualappliance.go @@ -0,0 +1,130 @@ +package virtualwans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkVirtualApplianceId{}) +} + +var _ resourceids.ResourceId = &NetworkVirtualApplianceId{} + +// NetworkVirtualApplianceId is a struct representing the Resource ID for a Network Virtual Appliance +type NetworkVirtualApplianceId struct { + SubscriptionId string + ResourceGroupName string + NetworkVirtualApplianceName string +} + +// NewNetworkVirtualApplianceID returns a new NetworkVirtualApplianceId struct +func NewNetworkVirtualApplianceID(subscriptionId string, resourceGroupName string, networkVirtualApplianceName string) NetworkVirtualApplianceId { + return NetworkVirtualApplianceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkVirtualApplianceName: networkVirtualApplianceName, + } +} + +// ParseNetworkVirtualApplianceID parses 'input' into a NetworkVirtualApplianceId +func ParseNetworkVirtualApplianceID(input string) (*NetworkVirtualApplianceId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkVirtualApplianceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkVirtualApplianceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkVirtualApplianceIDInsensitively parses 'input' case-insensitively into a NetworkVirtualApplianceId +// note: this method should only be used for API response data and not user input +func ParseNetworkVirtualApplianceIDInsensitively(input string) (*NetworkVirtualApplianceId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkVirtualApplianceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkVirtualApplianceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkVirtualApplianceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkVirtualApplianceName, ok = input.Parsed["networkVirtualApplianceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkVirtualApplianceName", input) + } + + return nil +} + +// ValidateNetworkVirtualApplianceID checks that 'input' can be parsed as a Network Virtual Appliance ID +func ValidateNetworkVirtualApplianceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkVirtualApplianceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Virtual Appliance ID +func (id NetworkVirtualApplianceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkVirtualAppliances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkVirtualApplianceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Virtual Appliance ID +func (id NetworkVirtualApplianceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkVirtualAppliances", "networkVirtualAppliances", "networkVirtualAppliances"), + resourceids.UserSpecifiedSegment("networkVirtualApplianceName", "networkVirtualApplianceName"), + } +} + +// String returns a human-readable description of this Network Virtual Appliance ID +func (id NetworkVirtualApplianceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Virtual Appliance Name: %q", id.NetworkVirtualApplianceName), + } + return fmt.Sprintf("Network Virtual Appliance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_networkvirtualappliance_test.go b/resource-manager/network/2024-07-01/virtualwans/id_networkvirtualappliance_test.go new file mode 100644 index 00000000000..09abffdd00f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_networkvirtualappliance_test.go @@ -0,0 +1,282 @@ +package virtualwans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkVirtualApplianceId{} + +func TestNewNetworkVirtualApplianceID(t *testing.T) { + id := NewNetworkVirtualApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkVirtualApplianceName != "networkVirtualApplianceName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkVirtualApplianceName'", id.NetworkVirtualApplianceName, "networkVirtualApplianceName") + } +} + +func TestFormatNetworkVirtualApplianceID(t *testing.T) { + actual := NewNetworkVirtualApplianceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkVirtualApplianceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkVirtualApplianceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName", + Expected: &NetworkVirtualApplianceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkVirtualApplianceName: "networkVirtualApplianceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkVirtualApplianceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkVirtualApplianceName != v.Expected.NetworkVirtualApplianceName { + t.Fatalf("Expected %q but got %q for NetworkVirtualApplianceName", v.Expected.NetworkVirtualApplianceName, actual.NetworkVirtualApplianceName) + } + + } +} + +func TestParseNetworkVirtualApplianceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkVirtualApplianceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName", + Expected: &NetworkVirtualApplianceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkVirtualApplianceName: "networkVirtualApplianceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe", + Expected: &NetworkVirtualApplianceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkVirtualApplianceName: "nEtWoRkViRtUaLaPpLiAnCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkVirtualApplianceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkVirtualApplianceName != v.Expected.NetworkVirtualApplianceName { + t.Fatalf("Expected %q but got %q for NetworkVirtualApplianceName", v.Expected.NetworkVirtualApplianceName, actual.NetworkVirtualApplianceName) + } + + } +} + +func TestSegmentsForNetworkVirtualApplianceId(t *testing.T) { + segments := NetworkVirtualApplianceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkVirtualApplianceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_networkvirtualapplianceconnection.go b/resource-manager/network/2024-07-01/virtualwans/id_networkvirtualapplianceconnection.go new file mode 100644 index 00000000000..fbbc66efaec --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_networkvirtualapplianceconnection.go @@ -0,0 +1,139 @@ +package virtualwans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkVirtualApplianceConnectionId{}) +} + +var _ resourceids.ResourceId = &NetworkVirtualApplianceConnectionId{} + +// NetworkVirtualApplianceConnectionId is a struct representing the Resource ID for a Network Virtual Appliance Connection +type NetworkVirtualApplianceConnectionId struct { + SubscriptionId string + ResourceGroupName string + NetworkVirtualApplianceName string + NetworkVirtualApplianceConnectionName string +} + +// NewNetworkVirtualApplianceConnectionID returns a new NetworkVirtualApplianceConnectionId struct +func NewNetworkVirtualApplianceConnectionID(subscriptionId string, resourceGroupName string, networkVirtualApplianceName string, networkVirtualApplianceConnectionName string) NetworkVirtualApplianceConnectionId { + return NetworkVirtualApplianceConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + NetworkVirtualApplianceName: networkVirtualApplianceName, + NetworkVirtualApplianceConnectionName: networkVirtualApplianceConnectionName, + } +} + +// ParseNetworkVirtualApplianceConnectionID parses 'input' into a NetworkVirtualApplianceConnectionId +func ParseNetworkVirtualApplianceConnectionID(input string) (*NetworkVirtualApplianceConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkVirtualApplianceConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkVirtualApplianceConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkVirtualApplianceConnectionIDInsensitively parses 'input' case-insensitively into a NetworkVirtualApplianceConnectionId +// note: this method should only be used for API response data and not user input +func ParseNetworkVirtualApplianceConnectionIDInsensitively(input string) (*NetworkVirtualApplianceConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkVirtualApplianceConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkVirtualApplianceConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkVirtualApplianceConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.NetworkVirtualApplianceName, ok = input.Parsed["networkVirtualApplianceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkVirtualApplianceName", input) + } + + if id.NetworkVirtualApplianceConnectionName, ok = input.Parsed["networkVirtualApplianceConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkVirtualApplianceConnectionName", input) + } + + return nil +} + +// ValidateNetworkVirtualApplianceConnectionID checks that 'input' can be parsed as a Network Virtual Appliance Connection ID +func ValidateNetworkVirtualApplianceConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkVirtualApplianceConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Virtual Appliance Connection ID +func (id NetworkVirtualApplianceConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/networkVirtualAppliances/%s/networkVirtualApplianceConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.NetworkVirtualApplianceName, id.NetworkVirtualApplianceConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Virtual Appliance Connection ID +func (id NetworkVirtualApplianceConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticNetworkVirtualAppliances", "networkVirtualAppliances", "networkVirtualAppliances"), + resourceids.UserSpecifiedSegment("networkVirtualApplianceName", "networkVirtualApplianceName"), + resourceids.StaticSegment("staticNetworkVirtualApplianceConnections", "networkVirtualApplianceConnections", "networkVirtualApplianceConnections"), + resourceids.UserSpecifiedSegment("networkVirtualApplianceConnectionName", "networkVirtualApplianceConnectionName"), + } +} + +// String returns a human-readable description of this Network Virtual Appliance Connection ID +func (id NetworkVirtualApplianceConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Network Virtual Appliance Name: %q", id.NetworkVirtualApplianceName), + fmt.Sprintf("Network Virtual Appliance Connection Name: %q", id.NetworkVirtualApplianceConnectionName), + } + return fmt.Sprintf("Network Virtual Appliance Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_networkvirtualapplianceconnection_test.go b/resource-manager/network/2024-07-01/virtualwans/id_networkvirtualapplianceconnection_test.go new file mode 100644 index 00000000000..e467eaa75a2 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_networkvirtualapplianceconnection_test.go @@ -0,0 +1,327 @@ +package virtualwans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkVirtualApplianceConnectionId{} + +func TestNewNetworkVirtualApplianceConnectionID(t *testing.T) { + id := NewNetworkVirtualApplianceConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName", "networkVirtualApplianceConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.NetworkVirtualApplianceName != "networkVirtualApplianceName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkVirtualApplianceName'", id.NetworkVirtualApplianceName, "networkVirtualApplianceName") + } + + if id.NetworkVirtualApplianceConnectionName != "networkVirtualApplianceConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkVirtualApplianceConnectionName'", id.NetworkVirtualApplianceConnectionName, "networkVirtualApplianceConnectionName") + } +} + +func TestFormatNetworkVirtualApplianceConnectionID(t *testing.T) { + actual := NewNetworkVirtualApplianceConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "networkVirtualApplianceName", "networkVirtualApplianceConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/networkVirtualApplianceConnections/networkVirtualApplianceConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkVirtualApplianceConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkVirtualApplianceConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/networkVirtualApplianceConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/networkVirtualApplianceConnections/networkVirtualApplianceConnectionName", + Expected: &NetworkVirtualApplianceConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkVirtualApplianceName: "networkVirtualApplianceName", + NetworkVirtualApplianceConnectionName: "networkVirtualApplianceConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/networkVirtualApplianceConnections/networkVirtualApplianceConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkVirtualApplianceConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkVirtualApplianceName != v.Expected.NetworkVirtualApplianceName { + t.Fatalf("Expected %q but got %q for NetworkVirtualApplianceName", v.Expected.NetworkVirtualApplianceName, actual.NetworkVirtualApplianceName) + } + + if actual.NetworkVirtualApplianceConnectionName != v.Expected.NetworkVirtualApplianceConnectionName { + t.Fatalf("Expected %q but got %q for NetworkVirtualApplianceConnectionName", v.Expected.NetworkVirtualApplianceConnectionName, actual.NetworkVirtualApplianceConnectionName) + } + + } +} + +func TestParseNetworkVirtualApplianceConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkVirtualApplianceConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/networkVirtualApplianceConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe/nEtWoRkViRtUaLaPpLiAnCeCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/networkVirtualApplianceConnections/networkVirtualApplianceConnectionName", + Expected: &NetworkVirtualApplianceConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + NetworkVirtualApplianceName: "networkVirtualApplianceName", + NetworkVirtualApplianceConnectionName: "networkVirtualApplianceConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/networkVirtualAppliances/networkVirtualApplianceName/networkVirtualApplianceConnections/networkVirtualApplianceConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe/nEtWoRkViRtUaLaPpLiAnCeCoNnEcTiOnS/nEtWoRkViRtUaLaPpLiAnCeCoNnEcTiOnNaMe", + Expected: &NetworkVirtualApplianceConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + NetworkVirtualApplianceName: "nEtWoRkViRtUaLaPpLiAnCeNaMe", + NetworkVirtualApplianceConnectionName: "nEtWoRkViRtUaLaPpLiAnCeCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/nEtWoRkViRtUaLaPpLiAnCeS/nEtWoRkViRtUaLaPpLiAnCeNaMe/nEtWoRkViRtUaLaPpLiAnCeCoNnEcTiOnS/nEtWoRkViRtUaLaPpLiAnCeCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkVirtualApplianceConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.NetworkVirtualApplianceName != v.Expected.NetworkVirtualApplianceName { + t.Fatalf("Expected %q but got %q for NetworkVirtualApplianceName", v.Expected.NetworkVirtualApplianceName, actual.NetworkVirtualApplianceName) + } + + if actual.NetworkVirtualApplianceConnectionName != v.Expected.NetworkVirtualApplianceConnectionName { + t.Fatalf("Expected %q but got %q for NetworkVirtualApplianceConnectionName", v.Expected.NetworkVirtualApplianceConnectionName, actual.NetworkVirtualApplianceConnectionName) + } + + } +} + +func TestSegmentsForNetworkVirtualApplianceConnectionId(t *testing.T) { + segments := NetworkVirtualApplianceConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkVirtualApplianceConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_routemap.go b/resource-manager/network/2024-07-01/virtualwans/id_routemap.go new file mode 100644 index 00000000000..cf9525f1046 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_routemap.go @@ -0,0 +1,139 @@ +package virtualwans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RouteMapId{}) +} + +var _ resourceids.ResourceId = &RouteMapId{} + +// RouteMapId is a struct representing the Resource ID for a Route Map +type RouteMapId struct { + SubscriptionId string + ResourceGroupName string + VirtualHubName string + RouteMapName string +} + +// NewRouteMapID returns a new RouteMapId struct +func NewRouteMapID(subscriptionId string, resourceGroupName string, virtualHubName string, routeMapName string) RouteMapId { + return RouteMapId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualHubName: virtualHubName, + RouteMapName: routeMapName, + } +} + +// ParseRouteMapID parses 'input' into a RouteMapId +func ParseRouteMapID(input string) (*RouteMapId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteMapId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteMapId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRouteMapIDInsensitively parses 'input' case-insensitively into a RouteMapId +// note: this method should only be used for API response data and not user input +func ParseRouteMapIDInsensitively(input string) (*RouteMapId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteMapId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteMapId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RouteMapId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VirtualHubName, ok = input.Parsed["virtualHubName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualHubName", input) + } + + if id.RouteMapName, ok = input.Parsed["routeMapName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeMapName", input) + } + + return nil +} + +// ValidateRouteMapID checks that 'input' can be parsed as a Route Map ID +func ValidateRouteMapID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRouteMapID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Route Map ID +func (id RouteMapId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualHubs/%s/routeMaps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualHubName, id.RouteMapName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Route Map ID +func (id RouteMapId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVirtualHubs", "virtualHubs", "virtualHubs"), + resourceids.UserSpecifiedSegment("virtualHubName", "virtualHubName"), + resourceids.StaticSegment("staticRouteMaps", "routeMaps", "routeMaps"), + resourceids.UserSpecifiedSegment("routeMapName", "routeMapName"), + } +} + +// String returns a human-readable description of this Route Map ID +func (id RouteMapId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Hub Name: %q", id.VirtualHubName), + fmt.Sprintf("Route Map Name: %q", id.RouteMapName), + } + return fmt.Sprintf("Route Map (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_routemap_test.go b/resource-manager/network/2024-07-01/virtualwans/id_routemap_test.go new file mode 100644 index 00000000000..82a9a70b579 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_routemap_test.go @@ -0,0 +1,327 @@ +package virtualwans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RouteMapId{} + +func TestNewRouteMapID(t *testing.T) { + id := NewRouteMapID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "routeMapName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VirtualHubName != "virtualHubName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualHubName'", id.VirtualHubName, "virtualHubName") + } + + if id.RouteMapName != "routeMapName" { + t.Fatalf("Expected %q but got %q for Segment 'RouteMapName'", id.RouteMapName, "routeMapName") + } +} + +func TestFormatRouteMapID(t *testing.T) { + actual := NewRouteMapID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "routeMapName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routeMaps/routeMapName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRouteMapID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteMapId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routeMaps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routeMaps/routeMapName", + Expected: &RouteMapId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualHubName: "virtualHubName", + RouteMapName: "routeMapName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routeMaps/routeMapName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteMapID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualHubName != v.Expected.VirtualHubName { + t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) + } + + if actual.RouteMapName != v.Expected.RouteMapName { + t.Fatalf("Expected %q but got %q for RouteMapName", v.Expected.RouteMapName, actual.RouteMapName) + } + + } +} + +func TestParseRouteMapIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteMapId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routeMaps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE/rOuTeMaPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routeMaps/routeMapName", + Expected: &RouteMapId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualHubName: "virtualHubName", + RouteMapName: "routeMapName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routeMaps/routeMapName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE/rOuTeMaPs/rOuTeMaPnAmE", + Expected: &RouteMapId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualHubName: "vIrTuAlHuBnAmE", + RouteMapName: "rOuTeMaPnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE/rOuTeMaPs/rOuTeMaPnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteMapIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualHubName != v.Expected.VirtualHubName { + t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) + } + + if actual.RouteMapName != v.Expected.RouteMapName { + t.Fatalf("Expected %q but got %q for RouteMapName", v.Expected.RouteMapName, actual.RouteMapName) + } + + } +} + +func TestSegmentsForRouteMapId(t *testing.T) { + segments := RouteMapId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RouteMapId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_routingintent.go b/resource-manager/network/2024-07-01/virtualwans/id_routingintent.go new file mode 100644 index 00000000000..cb05e57eb4c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_routingintent.go @@ -0,0 +1,139 @@ +package virtualwans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RoutingIntentId{}) +} + +var _ resourceids.ResourceId = &RoutingIntentId{} + +// RoutingIntentId is a struct representing the Resource ID for a Routing Intent +type RoutingIntentId struct { + SubscriptionId string + ResourceGroupName string + VirtualHubName string + RoutingIntentName string +} + +// NewRoutingIntentID returns a new RoutingIntentId struct +func NewRoutingIntentID(subscriptionId string, resourceGroupName string, virtualHubName string, routingIntentName string) RoutingIntentId { + return RoutingIntentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualHubName: virtualHubName, + RoutingIntentName: routingIntentName, + } +} + +// ParseRoutingIntentID parses 'input' into a RoutingIntentId +func ParseRoutingIntentID(input string) (*RoutingIntentId, error) { + parser := resourceids.NewParserFromResourceIdType(&RoutingIntentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RoutingIntentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRoutingIntentIDInsensitively parses 'input' case-insensitively into a RoutingIntentId +// note: this method should only be used for API response data and not user input +func ParseRoutingIntentIDInsensitively(input string) (*RoutingIntentId, error) { + parser := resourceids.NewParserFromResourceIdType(&RoutingIntentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RoutingIntentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RoutingIntentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VirtualHubName, ok = input.Parsed["virtualHubName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualHubName", input) + } + + if id.RoutingIntentName, ok = input.Parsed["routingIntentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routingIntentName", input) + } + + return nil +} + +// ValidateRoutingIntentID checks that 'input' can be parsed as a Routing Intent ID +func ValidateRoutingIntentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRoutingIntentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Routing Intent ID +func (id RoutingIntentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualHubs/%s/routingIntent/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualHubName, id.RoutingIntentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Routing Intent ID +func (id RoutingIntentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVirtualHubs", "virtualHubs", "virtualHubs"), + resourceids.UserSpecifiedSegment("virtualHubName", "virtualHubName"), + resourceids.StaticSegment("staticRoutingIntent", "routingIntent", "routingIntent"), + resourceids.UserSpecifiedSegment("routingIntentName", "routingIntentName"), + } +} + +// String returns a human-readable description of this Routing Intent ID +func (id RoutingIntentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Hub Name: %q", id.VirtualHubName), + fmt.Sprintf("Routing Intent Name: %q", id.RoutingIntentName), + } + return fmt.Sprintf("Routing Intent (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_routingintent_test.go b/resource-manager/network/2024-07-01/virtualwans/id_routingintent_test.go new file mode 100644 index 00000000000..0e05ca7ec05 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_routingintent_test.go @@ -0,0 +1,327 @@ +package virtualwans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RoutingIntentId{} + +func TestNewRoutingIntentID(t *testing.T) { + id := NewRoutingIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "routingIntentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VirtualHubName != "virtualHubName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualHubName'", id.VirtualHubName, "virtualHubName") + } + + if id.RoutingIntentName != "routingIntentName" { + t.Fatalf("Expected %q but got %q for Segment 'RoutingIntentName'", id.RoutingIntentName, "routingIntentName") + } +} + +func TestFormatRoutingIntentID(t *testing.T) { + actual := NewRoutingIntentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "routingIntentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routingIntent/routingIntentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRoutingIntentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RoutingIntentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routingIntent", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routingIntent/routingIntentName", + Expected: &RoutingIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualHubName: "virtualHubName", + RoutingIntentName: "routingIntentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routingIntent/routingIntentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRoutingIntentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualHubName != v.Expected.VirtualHubName { + t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) + } + + if actual.RoutingIntentName != v.Expected.RoutingIntentName { + t.Fatalf("Expected %q but got %q for RoutingIntentName", v.Expected.RoutingIntentName, actual.RoutingIntentName) + } + + } +} + +func TestParseRoutingIntentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RoutingIntentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routingIntent", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE/rOuTiNgInTeNt", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routingIntent/routingIntentName", + Expected: &RoutingIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualHubName: "virtualHubName", + RoutingIntentName: "routingIntentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routingIntent/routingIntentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE/rOuTiNgInTeNt/rOuTiNgInTeNtNaMe", + Expected: &RoutingIntentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualHubName: "vIrTuAlHuBnAmE", + RoutingIntentName: "rOuTiNgInTeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE/rOuTiNgInTeNt/rOuTiNgInTeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRoutingIntentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualHubName != v.Expected.VirtualHubName { + t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) + } + + if actual.RoutingIntentName != v.Expected.RoutingIntentName { + t.Fatalf("Expected %q but got %q for RoutingIntentName", v.Expected.RoutingIntentName, actual.RoutingIntentName) + } + + } +} + +func TestSegmentsForRoutingIntentId(t *testing.T) { + segments := RoutingIntentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RoutingIntentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_virtualhub.go b/resource-manager/network/2024-07-01/virtualwans/id_virtualhub.go new file mode 100644 index 00000000000..b406438486c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_virtualhub.go @@ -0,0 +1,130 @@ +package virtualwans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualHubId{}) +} + +var _ resourceids.ResourceId = &VirtualHubId{} + +// VirtualHubId is a struct representing the Resource ID for a Virtual Hub +type VirtualHubId struct { + SubscriptionId string + ResourceGroupName string + VirtualHubName string +} + +// NewVirtualHubID returns a new VirtualHubId struct +func NewVirtualHubID(subscriptionId string, resourceGroupName string, virtualHubName string) VirtualHubId { + return VirtualHubId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualHubName: virtualHubName, + } +} + +// ParseVirtualHubID parses 'input' into a VirtualHubId +func ParseVirtualHubID(input string) (*VirtualHubId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualHubId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualHubId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualHubIDInsensitively parses 'input' case-insensitively into a VirtualHubId +// note: this method should only be used for API response data and not user input +func ParseVirtualHubIDInsensitively(input string) (*VirtualHubId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualHubId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualHubId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualHubId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VirtualHubName, ok = input.Parsed["virtualHubName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualHubName", input) + } + + return nil +} + +// ValidateVirtualHubID checks that 'input' can be parsed as a Virtual Hub ID +func ValidateVirtualHubID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVirtualHubID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Hub ID +func (id VirtualHubId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualHubs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualHubName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Hub ID +func (id VirtualHubId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVirtualHubs", "virtualHubs", "virtualHubs"), + resourceids.UserSpecifiedSegment("virtualHubName", "virtualHubName"), + } +} + +// String returns a human-readable description of this Virtual Hub ID +func (id VirtualHubId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Hub Name: %q", id.VirtualHubName), + } + return fmt.Sprintf("Virtual Hub (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_virtualhub_test.go b/resource-manager/network/2024-07-01/virtualwans/id_virtualhub_test.go new file mode 100644 index 00000000000..4689c9a0153 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_virtualhub_test.go @@ -0,0 +1,282 @@ +package virtualwans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualHubId{} + +func TestNewVirtualHubID(t *testing.T) { + id := NewVirtualHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VirtualHubName != "virtualHubName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualHubName'", id.VirtualHubName, "virtualHubName") + } +} + +func TestFormatVirtualHubID(t *testing.T) { + actual := NewVirtualHubID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualHubID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualHubId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName", + Expected: &VirtualHubId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualHubName: "virtualHubName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualHubID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualHubName != v.Expected.VirtualHubName { + t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) + } + + } +} + +func TestParseVirtualHubIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualHubId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName", + Expected: &VirtualHubId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualHubName: "virtualHubName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE", + Expected: &VirtualHubId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualHubName: "vIrTuAlHuBnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualHubIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualHubName != v.Expected.VirtualHubName { + t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) + } + + } +} + +func TestSegmentsForVirtualHubId(t *testing.T) { + segments := VirtualHubId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualHubId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_virtualhubroutetable.go b/resource-manager/network/2024-07-01/virtualwans/id_virtualhubroutetable.go new file mode 100644 index 00000000000..db641540b54 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_virtualhubroutetable.go @@ -0,0 +1,139 @@ +package virtualwans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualHubRouteTableId{}) +} + +var _ resourceids.ResourceId = &VirtualHubRouteTableId{} + +// VirtualHubRouteTableId is a struct representing the Resource ID for a Virtual Hub Route Table +type VirtualHubRouteTableId struct { + SubscriptionId string + ResourceGroupName string + VirtualHubName string + RouteTableName string +} + +// NewVirtualHubRouteTableID returns a new VirtualHubRouteTableId struct +func NewVirtualHubRouteTableID(subscriptionId string, resourceGroupName string, virtualHubName string, routeTableName string) VirtualHubRouteTableId { + return VirtualHubRouteTableId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualHubName: virtualHubName, + RouteTableName: routeTableName, + } +} + +// ParseVirtualHubRouteTableID parses 'input' into a VirtualHubRouteTableId +func ParseVirtualHubRouteTableID(input string) (*VirtualHubRouteTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualHubRouteTableId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualHubRouteTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualHubRouteTableIDInsensitively parses 'input' case-insensitively into a VirtualHubRouteTableId +// note: this method should only be used for API response data and not user input +func ParseVirtualHubRouteTableIDInsensitively(input string) (*VirtualHubRouteTableId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualHubRouteTableId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualHubRouteTableId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualHubRouteTableId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VirtualHubName, ok = input.Parsed["virtualHubName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualHubName", input) + } + + if id.RouteTableName, ok = input.Parsed["routeTableName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeTableName", input) + } + + return nil +} + +// ValidateVirtualHubRouteTableID checks that 'input' can be parsed as a Virtual Hub Route Table ID +func ValidateVirtualHubRouteTableID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVirtualHubRouteTableID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Hub Route Table ID +func (id VirtualHubRouteTableId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualHubs/%s/routeTables/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualHubName, id.RouteTableName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Hub Route Table ID +func (id VirtualHubRouteTableId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVirtualHubs", "virtualHubs", "virtualHubs"), + resourceids.UserSpecifiedSegment("virtualHubName", "virtualHubName"), + resourceids.StaticSegment("staticRouteTables", "routeTables", "routeTables"), + resourceids.UserSpecifiedSegment("routeTableName", "routeTableName"), + } +} + +// String returns a human-readable description of this Virtual Hub Route Table ID +func (id VirtualHubRouteTableId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Hub Name: %q", id.VirtualHubName), + fmt.Sprintf("Route Table Name: %q", id.RouteTableName), + } + return fmt.Sprintf("Virtual Hub Route Table (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_virtualhubroutetable_test.go b/resource-manager/network/2024-07-01/virtualwans/id_virtualhubroutetable_test.go new file mode 100644 index 00000000000..04fbe6f543f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_virtualhubroutetable_test.go @@ -0,0 +1,327 @@ +package virtualwans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualHubRouteTableId{} + +func TestNewVirtualHubRouteTableID(t *testing.T) { + id := NewVirtualHubRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "routeTableName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VirtualHubName != "virtualHubName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualHubName'", id.VirtualHubName, "virtualHubName") + } + + if id.RouteTableName != "routeTableName" { + t.Fatalf("Expected %q but got %q for Segment 'RouteTableName'", id.RouteTableName, "routeTableName") + } +} + +func TestFormatVirtualHubRouteTableID(t *testing.T) { + actual := NewVirtualHubRouteTableID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualHubName", "routeTableName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routeTables/routeTableName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualHubRouteTableID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualHubRouteTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routeTables", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routeTables/routeTableName", + Expected: &VirtualHubRouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualHubName: "virtualHubName", + RouteTableName: "routeTableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routeTables/routeTableName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualHubRouteTableID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualHubName != v.Expected.VirtualHubName { + t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) + } + + if actual.RouteTableName != v.Expected.RouteTableName { + t.Fatalf("Expected %q but got %q for RouteTableName", v.Expected.RouteTableName, actual.RouteTableName) + } + + } +} + +func TestParseVirtualHubRouteTableIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualHubRouteTableId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routeTables", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE/rOuTeTaBlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routeTables/routeTableName", + Expected: &VirtualHubRouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualHubName: "virtualHubName", + RouteTableName: "routeTableName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualHubs/virtualHubName/routeTables/routeTableName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE/rOuTeTaBlEs/rOuTeTaBlEnAmE", + Expected: &VirtualHubRouteTableId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualHubName: "vIrTuAlHuBnAmE", + RouteTableName: "rOuTeTaBlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlHuBs/vIrTuAlHuBnAmE/rOuTeTaBlEs/rOuTeTaBlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualHubRouteTableIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualHubName != v.Expected.VirtualHubName { + t.Fatalf("Expected %q but got %q for VirtualHubName", v.Expected.VirtualHubName, actual.VirtualHubName) + } + + if actual.RouteTableName != v.Expected.RouteTableName { + t.Fatalf("Expected %q but got %q for RouteTableName", v.Expected.RouteTableName, actual.RouteTableName) + } + + } +} + +func TestSegmentsForVirtualHubRouteTableId(t *testing.T) { + segments := VirtualHubRouteTableId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualHubRouteTableId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_virtualwan.go b/resource-manager/network/2024-07-01/virtualwans/id_virtualwan.go new file mode 100644 index 00000000000..fa94d154c26 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_virtualwan.go @@ -0,0 +1,130 @@ +package virtualwans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualWANId{}) +} + +var _ resourceids.ResourceId = &VirtualWANId{} + +// VirtualWANId is a struct representing the Resource ID for a Virtual W A N +type VirtualWANId struct { + SubscriptionId string + ResourceGroupName string + VirtualWanName string +} + +// NewVirtualWANID returns a new VirtualWANId struct +func NewVirtualWANID(subscriptionId string, resourceGroupName string, virtualWanName string) VirtualWANId { + return VirtualWANId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualWanName: virtualWanName, + } +} + +// ParseVirtualWANID parses 'input' into a VirtualWANId +func ParseVirtualWANID(input string) (*VirtualWANId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualWANId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualWANId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualWANIDInsensitively parses 'input' case-insensitively into a VirtualWANId +// note: this method should only be used for API response data and not user input +func ParseVirtualWANIDInsensitively(input string) (*VirtualWANId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualWANId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualWANId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualWANId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VirtualWanName, ok = input.Parsed["virtualWanName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualWanName", input) + } + + return nil +} + +// ValidateVirtualWANID checks that 'input' can be parsed as a Virtual W A N ID +func ValidateVirtualWANID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVirtualWANID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual W A N ID +func (id VirtualWANId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualWans/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualWanName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual W A N ID +func (id VirtualWANId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVirtualWans", "virtualWans", "virtualWans"), + resourceids.UserSpecifiedSegment("virtualWanName", "virtualWanName"), + } +} + +// String returns a human-readable description of this Virtual W A N ID +func (id VirtualWANId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Wan Name: %q", id.VirtualWanName), + } + return fmt.Sprintf("Virtual W A N (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_virtualwan_test.go b/resource-manager/network/2024-07-01/virtualwans/id_virtualwan_test.go new file mode 100644 index 00000000000..b07670d82b4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_virtualwan_test.go @@ -0,0 +1,282 @@ +package virtualwans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualWANId{} + +func TestNewVirtualWANID(t *testing.T) { + id := NewVirtualWANID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualWanName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VirtualWanName != "virtualWanName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualWanName'", id.VirtualWanName, "virtualWanName") + } +} + +func TestFormatVirtualWANID(t *testing.T) { + actual := NewVirtualWANID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualWanName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualWans/virtualWanName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualWANID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualWANId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualWans", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualWans/virtualWanName", + Expected: &VirtualWANId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualWanName: "virtualWanName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualWans/virtualWanName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualWANID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualWanName != v.Expected.VirtualWanName { + t.Fatalf("Expected %q but got %q for VirtualWanName", v.Expected.VirtualWanName, actual.VirtualWanName) + } + + } +} + +func TestParseVirtualWANIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualWANId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualWans", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlWaNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualWans/virtualWanName", + Expected: &VirtualWANId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualWanName: "virtualWanName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/virtualWans/virtualWanName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlWaNs/vIrTuAlWaNnAmE", + Expected: &VirtualWANId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualWanName: "vIrTuAlWaNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vIrTuAlWaNs/vIrTuAlWaNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualWANIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualWanName != v.Expected.VirtualWanName { + t.Fatalf("Expected %q but got %q for VirtualWanName", v.Expected.VirtualWanName, actual.VirtualWanName) + } + + } +} + +func TestSegmentsForVirtualWANId(t *testing.T) { + segments := VirtualWANId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualWANId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_vpngateway.go b/resource-manager/network/2024-07-01/virtualwans/id_vpngateway.go new file mode 100644 index 00000000000..4aac85c0d13 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_vpngateway.go @@ -0,0 +1,130 @@ +package virtualwans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VpnGatewayId{}) +} + +var _ resourceids.ResourceId = &VpnGatewayId{} + +// VpnGatewayId is a struct representing the Resource ID for a Vpn Gateway +type VpnGatewayId struct { + SubscriptionId string + ResourceGroupName string + VpnGatewayName string +} + +// NewVpnGatewayID returns a new VpnGatewayId struct +func NewVpnGatewayID(subscriptionId string, resourceGroupName string, vpnGatewayName string) VpnGatewayId { + return VpnGatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VpnGatewayName: vpnGatewayName, + } +} + +// ParseVpnGatewayID parses 'input' into a VpnGatewayId +func ParseVpnGatewayID(input string) (*VpnGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnGatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVpnGatewayIDInsensitively parses 'input' case-insensitively into a VpnGatewayId +// note: this method should only be used for API response data and not user input +func ParseVpnGatewayIDInsensitively(input string) (*VpnGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnGatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VpnGatewayId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VpnGatewayName, ok = input.Parsed["vpnGatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vpnGatewayName", input) + } + + return nil +} + +// ValidateVpnGatewayID checks that 'input' can be parsed as a Vpn Gateway ID +func ValidateVpnGatewayID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVpnGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vpn Gateway ID +func (id VpnGatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/vpnGateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VpnGatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vpn Gateway ID +func (id VpnGatewayId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVpnGateways", "vpnGateways", "vpnGateways"), + resourceids.UserSpecifiedSegment("vpnGatewayName", "vpnGatewayName"), + } +} + +// String returns a human-readable description of this Vpn Gateway ID +func (id VpnGatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vpn Gateway Name: %q", id.VpnGatewayName), + } + return fmt.Sprintf("Vpn Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_vpngateway_test.go b/resource-manager/network/2024-07-01/virtualwans/id_vpngateway_test.go new file mode 100644 index 00000000000..c7406d1fb5a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_vpngateway_test.go @@ -0,0 +1,282 @@ +package virtualwans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VpnGatewayId{} + +func TestNewVpnGatewayID(t *testing.T) { + id := NewVpnGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VpnGatewayName != "vpnGatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'VpnGatewayName'", id.VpnGatewayName, "vpnGatewayName") + } +} + +func TestFormatVpnGatewayID(t *testing.T) { + actual := NewVpnGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVpnGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName", + Expected: &VpnGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnGatewayName: "vpnGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnGatewayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnGatewayName != v.Expected.VpnGatewayName { + t.Fatalf("Expected %q but got %q for VpnGatewayName", v.Expected.VpnGatewayName, actual.VpnGatewayName) + } + + } +} + +func TestParseVpnGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName", + Expected: &VpnGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnGatewayName: "vpnGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE", + Expected: &VpnGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VpnGatewayName: "vPnGaTeWaYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnGatewayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnGatewayName != v.Expected.VpnGatewayName { + t.Fatalf("Expected %q but got %q for VpnGatewayName", v.Expected.VpnGatewayName, actual.VpnGatewayName) + } + + } +} + +func TestSegmentsForVpnGatewayId(t *testing.T) { + segments := VpnGatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VpnGatewayId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_vpnlinkconnection.go b/resource-manager/network/2024-07-01/virtualwans/id_vpnlinkconnection.go new file mode 100644 index 00000000000..98326bfe842 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_vpnlinkconnection.go @@ -0,0 +1,148 @@ +package virtualwans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VpnLinkConnectionId{}) +} + +var _ resourceids.ResourceId = &VpnLinkConnectionId{} + +// VpnLinkConnectionId is a struct representing the Resource ID for a Vpn Link Connection +type VpnLinkConnectionId struct { + SubscriptionId string + ResourceGroupName string + VpnGatewayName string + VpnConnectionName string + VpnLinkConnectionName string +} + +// NewVpnLinkConnectionID returns a new VpnLinkConnectionId struct +func NewVpnLinkConnectionID(subscriptionId string, resourceGroupName string, vpnGatewayName string, vpnConnectionName string, vpnLinkConnectionName string) VpnLinkConnectionId { + return VpnLinkConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VpnGatewayName: vpnGatewayName, + VpnConnectionName: vpnConnectionName, + VpnLinkConnectionName: vpnLinkConnectionName, + } +} + +// ParseVpnLinkConnectionID parses 'input' into a VpnLinkConnectionId +func ParseVpnLinkConnectionID(input string) (*VpnLinkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnLinkConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnLinkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVpnLinkConnectionIDInsensitively parses 'input' case-insensitively into a VpnLinkConnectionId +// note: this method should only be used for API response data and not user input +func ParseVpnLinkConnectionIDInsensitively(input string) (*VpnLinkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnLinkConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnLinkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VpnLinkConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VpnGatewayName, ok = input.Parsed["vpnGatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vpnGatewayName", input) + } + + if id.VpnConnectionName, ok = input.Parsed["vpnConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vpnConnectionName", input) + } + + if id.VpnLinkConnectionName, ok = input.Parsed["vpnLinkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vpnLinkConnectionName", input) + } + + return nil +} + +// ValidateVpnLinkConnectionID checks that 'input' can be parsed as a Vpn Link Connection ID +func ValidateVpnLinkConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVpnLinkConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vpn Link Connection ID +func (id VpnLinkConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/vpnGateways/%s/vpnConnections/%s/vpnLinkConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VpnGatewayName, id.VpnConnectionName, id.VpnLinkConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vpn Link Connection ID +func (id VpnLinkConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVpnGateways", "vpnGateways", "vpnGateways"), + resourceids.UserSpecifiedSegment("vpnGatewayName", "vpnGatewayName"), + resourceids.StaticSegment("staticVpnConnections", "vpnConnections", "vpnConnections"), + resourceids.UserSpecifiedSegment("vpnConnectionName", "vpnConnectionName"), + resourceids.StaticSegment("staticVpnLinkConnections", "vpnLinkConnections", "vpnLinkConnections"), + resourceids.UserSpecifiedSegment("vpnLinkConnectionName", "vpnLinkConnectionName"), + } +} + +// String returns a human-readable description of this Vpn Link Connection ID +func (id VpnLinkConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vpn Gateway Name: %q", id.VpnGatewayName), + fmt.Sprintf("Vpn Connection Name: %q", id.VpnConnectionName), + fmt.Sprintf("Vpn Link Connection Name: %q", id.VpnLinkConnectionName), + } + return fmt.Sprintf("Vpn Link Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_vpnlinkconnection_test.go b/resource-manager/network/2024-07-01/virtualwans/id_vpnlinkconnection_test.go new file mode 100644 index 00000000000..98ddb202383 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_vpnlinkconnection_test.go @@ -0,0 +1,372 @@ +package virtualwans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VpnLinkConnectionId{} + +func TestNewVpnLinkConnectionID(t *testing.T) { + id := NewVpnLinkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "vpnConnectionName", "vpnLinkConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VpnGatewayName != "vpnGatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'VpnGatewayName'", id.VpnGatewayName, "vpnGatewayName") + } + + if id.VpnConnectionName != "vpnConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VpnConnectionName'", id.VpnConnectionName, "vpnConnectionName") + } + + if id.VpnLinkConnectionName != "vpnLinkConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VpnLinkConnectionName'", id.VpnLinkConnectionName, "vpnLinkConnectionName") + } +} + +func TestFormatVpnLinkConnectionID(t *testing.T) { + actual := NewVpnLinkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "vpnConnectionName", "vpnLinkConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName/vpnLinkConnections/vpnLinkConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVpnLinkConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnLinkConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName/vpnLinkConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName/vpnLinkConnections/vpnLinkConnectionName", + Expected: &VpnLinkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnGatewayName: "vpnGatewayName", + VpnConnectionName: "vpnConnectionName", + VpnLinkConnectionName: "vpnLinkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName/vpnLinkConnections/vpnLinkConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnLinkConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnGatewayName != v.Expected.VpnGatewayName { + t.Fatalf("Expected %q but got %q for VpnGatewayName", v.Expected.VpnGatewayName, actual.VpnGatewayName) + } + + if actual.VpnConnectionName != v.Expected.VpnConnectionName { + t.Fatalf("Expected %q but got %q for VpnConnectionName", v.Expected.VpnConnectionName, actual.VpnConnectionName) + } + + if actual.VpnLinkConnectionName != v.Expected.VpnLinkConnectionName { + t.Fatalf("Expected %q but got %q for VpnLinkConnectionName", v.Expected.VpnLinkConnectionName, actual.VpnLinkConnectionName) + } + + } +} + +func TestParseVpnLinkConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnLinkConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE/vPnCoNnEcTiOnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE/vPnCoNnEcTiOnS/vPnCoNnEcTiOnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName/vpnLinkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE/vPnCoNnEcTiOnS/vPnCoNnEcTiOnNaMe/vPnLiNkCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName/vpnLinkConnections/vpnLinkConnectionName", + Expected: &VpnLinkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnGatewayName: "vpnGatewayName", + VpnConnectionName: "vpnConnectionName", + VpnLinkConnectionName: "vpnLinkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName/vpnLinkConnections/vpnLinkConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE/vPnCoNnEcTiOnS/vPnCoNnEcTiOnNaMe/vPnLiNkCoNnEcTiOnS/vPnLiNkCoNnEcTiOnNaMe", + Expected: &VpnLinkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VpnGatewayName: "vPnGaTeWaYnAmE", + VpnConnectionName: "vPnCoNnEcTiOnNaMe", + VpnLinkConnectionName: "vPnLiNkCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE/vPnCoNnEcTiOnS/vPnCoNnEcTiOnNaMe/vPnLiNkCoNnEcTiOnS/vPnLiNkCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnLinkConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnGatewayName != v.Expected.VpnGatewayName { + t.Fatalf("Expected %q but got %q for VpnGatewayName", v.Expected.VpnGatewayName, actual.VpnGatewayName) + } + + if actual.VpnConnectionName != v.Expected.VpnConnectionName { + t.Fatalf("Expected %q but got %q for VpnConnectionName", v.Expected.VpnConnectionName, actual.VpnConnectionName) + } + + if actual.VpnLinkConnectionName != v.Expected.VpnLinkConnectionName { + t.Fatalf("Expected %q but got %q for VpnLinkConnectionName", v.Expected.VpnLinkConnectionName, actual.VpnLinkConnectionName) + } + + } +} + +func TestSegmentsForVpnLinkConnectionId(t *testing.T) { + segments := VpnLinkConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VpnLinkConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_vpnserverconfiguration.go b/resource-manager/network/2024-07-01/virtualwans/id_vpnserverconfiguration.go new file mode 100644 index 00000000000..641107f1430 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_vpnserverconfiguration.go @@ -0,0 +1,130 @@ +package virtualwans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VpnServerConfigurationId{}) +} + +var _ resourceids.ResourceId = &VpnServerConfigurationId{} + +// VpnServerConfigurationId is a struct representing the Resource ID for a Vpn Server Configuration +type VpnServerConfigurationId struct { + SubscriptionId string + ResourceGroupName string + VpnServerConfigurationName string +} + +// NewVpnServerConfigurationID returns a new VpnServerConfigurationId struct +func NewVpnServerConfigurationID(subscriptionId string, resourceGroupName string, vpnServerConfigurationName string) VpnServerConfigurationId { + return VpnServerConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VpnServerConfigurationName: vpnServerConfigurationName, + } +} + +// ParseVpnServerConfigurationID parses 'input' into a VpnServerConfigurationId +func ParseVpnServerConfigurationID(input string) (*VpnServerConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnServerConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnServerConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVpnServerConfigurationIDInsensitively parses 'input' case-insensitively into a VpnServerConfigurationId +// note: this method should only be used for API response data and not user input +func ParseVpnServerConfigurationIDInsensitively(input string) (*VpnServerConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnServerConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnServerConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VpnServerConfigurationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VpnServerConfigurationName, ok = input.Parsed["vpnServerConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vpnServerConfigurationName", input) + } + + return nil +} + +// ValidateVpnServerConfigurationID checks that 'input' can be parsed as a Vpn Server Configuration ID +func ValidateVpnServerConfigurationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVpnServerConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vpn Server Configuration ID +func (id VpnServerConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/vpnServerConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VpnServerConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vpn Server Configuration ID +func (id VpnServerConfigurationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVpnServerConfigurations", "vpnServerConfigurations", "vpnServerConfigurations"), + resourceids.UserSpecifiedSegment("vpnServerConfigurationName", "vpnServerConfigurationName"), + } +} + +// String returns a human-readable description of this Vpn Server Configuration ID +func (id VpnServerConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vpn Server Configuration Name: %q", id.VpnServerConfigurationName), + } + return fmt.Sprintf("Vpn Server Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_vpnserverconfiguration_test.go b/resource-manager/network/2024-07-01/virtualwans/id_vpnserverconfiguration_test.go new file mode 100644 index 00000000000..27bec6d0ee8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_vpnserverconfiguration_test.go @@ -0,0 +1,282 @@ +package virtualwans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VpnServerConfigurationId{} + +func TestNewVpnServerConfigurationID(t *testing.T) { + id := NewVpnServerConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnServerConfigurationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VpnServerConfigurationName != "vpnServerConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'VpnServerConfigurationName'", id.VpnServerConfigurationName, "vpnServerConfigurationName") + } +} + +func TestFormatVpnServerConfigurationID(t *testing.T) { + actual := NewVpnServerConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnServerConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVpnServerConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnServerConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName", + Expected: &VpnServerConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnServerConfigurationName: "vpnServerConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnServerConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnServerConfigurationName != v.Expected.VpnServerConfigurationName { + t.Fatalf("Expected %q but got %q for VpnServerConfigurationName", v.Expected.VpnServerConfigurationName, actual.VpnServerConfigurationName) + } + + } +} + +func TestParseVpnServerConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnServerConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSeRvErCoNfIgUrAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName", + Expected: &VpnServerConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnServerConfigurationName: "vpnServerConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSeRvErCoNfIgUrAtIoNs/vPnSeRvErCoNfIgUrAtIoNnAmE", + Expected: &VpnServerConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VpnServerConfigurationName: "vPnSeRvErCoNfIgUrAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSeRvErCoNfIgUrAtIoNs/vPnSeRvErCoNfIgUrAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnServerConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnServerConfigurationName != v.Expected.VpnServerConfigurationName { + t.Fatalf("Expected %q but got %q for VpnServerConfigurationName", v.Expected.VpnServerConfigurationName, actual.VpnServerConfigurationName) + } + + } +} + +func TestSegmentsForVpnServerConfigurationId(t *testing.T) { + segments := VpnServerConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VpnServerConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_vpnsite.go b/resource-manager/network/2024-07-01/virtualwans/id_vpnsite.go new file mode 100644 index 00000000000..241994cde17 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_vpnsite.go @@ -0,0 +1,130 @@ +package virtualwans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VpnSiteId{}) +} + +var _ resourceids.ResourceId = &VpnSiteId{} + +// VpnSiteId is a struct representing the Resource ID for a Vpn Site +type VpnSiteId struct { + SubscriptionId string + ResourceGroupName string + VpnSiteName string +} + +// NewVpnSiteID returns a new VpnSiteId struct +func NewVpnSiteID(subscriptionId string, resourceGroupName string, vpnSiteName string) VpnSiteId { + return VpnSiteId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VpnSiteName: vpnSiteName, + } +} + +// ParseVpnSiteID parses 'input' into a VpnSiteId +func ParseVpnSiteID(input string) (*VpnSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnSiteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVpnSiteIDInsensitively parses 'input' case-insensitively into a VpnSiteId +// note: this method should only be used for API response data and not user input +func ParseVpnSiteIDInsensitively(input string) (*VpnSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnSiteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VpnSiteId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VpnSiteName, ok = input.Parsed["vpnSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vpnSiteName", input) + } + + return nil +} + +// ValidateVpnSiteID checks that 'input' can be parsed as a Vpn Site ID +func ValidateVpnSiteID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVpnSiteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vpn Site ID +func (id VpnSiteId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/vpnSites/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VpnSiteName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vpn Site ID +func (id VpnSiteId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVpnSites", "vpnSites", "vpnSites"), + resourceids.UserSpecifiedSegment("vpnSiteName", "vpnSiteName"), + } +} + +// String returns a human-readable description of this Vpn Site ID +func (id VpnSiteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vpn Site Name: %q", id.VpnSiteName), + } + return fmt.Sprintf("Vpn Site (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_vpnsite_test.go b/resource-manager/network/2024-07-01/virtualwans/id_vpnsite_test.go new file mode 100644 index 00000000000..bb520fe9f4e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_vpnsite_test.go @@ -0,0 +1,282 @@ +package virtualwans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VpnSiteId{} + +func TestNewVpnSiteID(t *testing.T) { + id := NewVpnSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnSiteName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VpnSiteName != "vpnSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'VpnSiteName'", id.VpnSiteName, "vpnSiteName") + } +} + +func TestFormatVpnSiteID(t *testing.T) { + actual := NewVpnSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnSiteName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVpnSiteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnSiteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName", + Expected: &VpnSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnSiteName: "vpnSiteName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnSiteID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnSiteName != v.Expected.VpnSiteName { + t.Fatalf("Expected %q but got %q for VpnSiteName", v.Expected.VpnSiteName, actual.VpnSiteName) + } + + } +} + +func TestParseVpnSiteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnSiteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSiTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName", + Expected: &VpnSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnSiteName: "vpnSiteName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSiTeS/vPnSiTeNaMe", + Expected: &VpnSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VpnSiteName: "vPnSiTeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSiTeS/vPnSiTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnSiteIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnSiteName != v.Expected.VpnSiteName { + t.Fatalf("Expected %q but got %q for VpnSiteName", v.Expected.VpnSiteName, actual.VpnSiteName) + } + + } +} + +func TestSegmentsForVpnSiteId(t *testing.T) { + segments := VpnSiteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VpnSiteId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_vpnsitelink.go b/resource-manager/network/2024-07-01/virtualwans/id_vpnsitelink.go new file mode 100644 index 00000000000..fcfd5aa34ed --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_vpnsitelink.go @@ -0,0 +1,139 @@ +package virtualwans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VpnSiteLinkId{}) +} + +var _ resourceids.ResourceId = &VpnSiteLinkId{} + +// VpnSiteLinkId is a struct representing the Resource ID for a Vpn Site Link +type VpnSiteLinkId struct { + SubscriptionId string + ResourceGroupName string + VpnSiteName string + VpnSiteLinkName string +} + +// NewVpnSiteLinkID returns a new VpnSiteLinkId struct +func NewVpnSiteLinkID(subscriptionId string, resourceGroupName string, vpnSiteName string, vpnSiteLinkName string) VpnSiteLinkId { + return VpnSiteLinkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VpnSiteName: vpnSiteName, + VpnSiteLinkName: vpnSiteLinkName, + } +} + +// ParseVpnSiteLinkID parses 'input' into a VpnSiteLinkId +func ParseVpnSiteLinkID(input string) (*VpnSiteLinkId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnSiteLinkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnSiteLinkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVpnSiteLinkIDInsensitively parses 'input' case-insensitively into a VpnSiteLinkId +// note: this method should only be used for API response data and not user input +func ParseVpnSiteLinkIDInsensitively(input string) (*VpnSiteLinkId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnSiteLinkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnSiteLinkId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VpnSiteLinkId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VpnSiteName, ok = input.Parsed["vpnSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vpnSiteName", input) + } + + if id.VpnSiteLinkName, ok = input.Parsed["vpnSiteLinkName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vpnSiteLinkName", input) + } + + return nil +} + +// ValidateVpnSiteLinkID checks that 'input' can be parsed as a Vpn Site Link ID +func ValidateVpnSiteLinkID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVpnSiteLinkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vpn Site Link ID +func (id VpnSiteLinkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/vpnSites/%s/vpnSiteLinks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VpnSiteName, id.VpnSiteLinkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vpn Site Link ID +func (id VpnSiteLinkId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVpnSites", "vpnSites", "vpnSites"), + resourceids.UserSpecifiedSegment("vpnSiteName", "vpnSiteName"), + resourceids.StaticSegment("staticVpnSiteLinks", "vpnSiteLinks", "vpnSiteLinks"), + resourceids.UserSpecifiedSegment("vpnSiteLinkName", "vpnSiteLinkName"), + } +} + +// String returns a human-readable description of this Vpn Site Link ID +func (id VpnSiteLinkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vpn Site Name: %q", id.VpnSiteName), + fmt.Sprintf("Vpn Site Link Name: %q", id.VpnSiteLinkName), + } + return fmt.Sprintf("Vpn Site Link (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/virtualwans/id_vpnsitelink_test.go b/resource-manager/network/2024-07-01/virtualwans/id_vpnsitelink_test.go new file mode 100644 index 00000000000..0b959ed7f39 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/id_vpnsitelink_test.go @@ -0,0 +1,327 @@ +package virtualwans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VpnSiteLinkId{} + +func TestNewVpnSiteLinkID(t *testing.T) { + id := NewVpnSiteLinkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnSiteName", "vpnSiteLinkName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VpnSiteName != "vpnSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'VpnSiteName'", id.VpnSiteName, "vpnSiteName") + } + + if id.VpnSiteLinkName != "vpnSiteLinkName" { + t.Fatalf("Expected %q but got %q for Segment 'VpnSiteLinkName'", id.VpnSiteLinkName, "vpnSiteLinkName") + } +} + +func TestFormatVpnSiteLinkID(t *testing.T) { + actual := NewVpnSiteLinkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnSiteName", "vpnSiteLinkName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName/vpnSiteLinks/vpnSiteLinkName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVpnSiteLinkID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnSiteLinkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName/vpnSiteLinks", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName/vpnSiteLinks/vpnSiteLinkName", + Expected: &VpnSiteLinkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnSiteName: "vpnSiteName", + VpnSiteLinkName: "vpnSiteLinkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName/vpnSiteLinks/vpnSiteLinkName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnSiteLinkID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnSiteName != v.Expected.VpnSiteName { + t.Fatalf("Expected %q but got %q for VpnSiteName", v.Expected.VpnSiteName, actual.VpnSiteName) + } + + if actual.VpnSiteLinkName != v.Expected.VpnSiteLinkName { + t.Fatalf("Expected %q but got %q for VpnSiteLinkName", v.Expected.VpnSiteLinkName, actual.VpnSiteLinkName) + } + + } +} + +func TestParseVpnSiteLinkIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnSiteLinkId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSiTeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSiTeS/vPnSiTeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName/vpnSiteLinks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSiTeS/vPnSiTeNaMe/vPnSiTeLiNkS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName/vpnSiteLinks/vpnSiteLinkName", + Expected: &VpnSiteLinkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnSiteName: "vpnSiteName", + VpnSiteLinkName: "vpnSiteLinkName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName/vpnSiteLinks/vpnSiteLinkName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSiTeS/vPnSiTeNaMe/vPnSiTeLiNkS/vPnSiTeLiNkNaMe", + Expected: &VpnSiteLinkId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VpnSiteName: "vPnSiTeNaMe", + VpnSiteLinkName: "vPnSiTeLiNkNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSiTeS/vPnSiTeNaMe/vPnSiTeLiNkS/vPnSiTeLiNkNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnSiteLinkIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnSiteName != v.Expected.VpnSiteName { + t.Fatalf("Expected %q but got %q for VpnSiteName", v.Expected.VpnSiteName, actual.VpnSiteName) + } + + if actual.VpnSiteLinkName != v.Expected.VpnSiteLinkName { + t.Fatalf("Expected %q but got %q for VpnSiteLinkName", v.Expected.VpnSiteLinkName, actual.VpnSiteLinkName) + } + + } +} + +func TestSegmentsForVpnSiteLinkId(t *testing.T) { + segments := VpnSiteLinkId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VpnSiteLinkId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_configurationpolicygroupscreateorupdate.go b/resource-manager/network/2024-07-01/virtualwans/method_configurationpolicygroupscreateorupdate.go new file mode 100644 index 00000000000..391d34a222a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_configurationpolicygroupscreateorupdate.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigurationPolicyGroupsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VpnServerConfigurationPolicyGroup +} + +// ConfigurationPolicyGroupsCreateOrUpdate ... +func (c VirtualWANsClient) ConfigurationPolicyGroupsCreateOrUpdate(ctx context.Context, id ConfigurationPolicyGroupId, input VpnServerConfigurationPolicyGroup) (result ConfigurationPolicyGroupsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ConfigurationPolicyGroupsCreateOrUpdateThenPoll performs ConfigurationPolicyGroupsCreateOrUpdate then polls until it's completed +func (c VirtualWANsClient) ConfigurationPolicyGroupsCreateOrUpdateThenPoll(ctx context.Context, id ConfigurationPolicyGroupId, input VpnServerConfigurationPolicyGroup) error { + result, err := c.ConfigurationPolicyGroupsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ConfigurationPolicyGroupsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ConfigurationPolicyGroupsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_configurationpolicygroupsdelete.go b/resource-manager/network/2024-07-01/virtualwans/method_configurationpolicygroupsdelete.go new file mode 100644 index 00000000000..faabc47e666 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_configurationpolicygroupsdelete.go @@ -0,0 +1,71 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigurationPolicyGroupsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ConfigurationPolicyGroupsDelete ... +func (c VirtualWANsClient) ConfigurationPolicyGroupsDelete(ctx context.Context, id ConfigurationPolicyGroupId) (result ConfigurationPolicyGroupsDeleteOperationResponse, 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 +} + +// ConfigurationPolicyGroupsDeleteThenPoll performs ConfigurationPolicyGroupsDelete then polls until it's completed +func (c VirtualWANsClient) ConfigurationPolicyGroupsDeleteThenPoll(ctx context.Context, id ConfigurationPolicyGroupId) error { + result, err := c.ConfigurationPolicyGroupsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing ConfigurationPolicyGroupsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ConfigurationPolicyGroupsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_configurationpolicygroupsget.go b/resource-manager/network/2024-07-01/virtualwans/method_configurationpolicygroupsget.go new file mode 100644 index 00000000000..d8feaa4f23a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_configurationpolicygroupsget.go @@ -0,0 +1,53 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigurationPolicyGroupsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VpnServerConfigurationPolicyGroup +} + +// ConfigurationPolicyGroupsGet ... +func (c VirtualWANsClient) ConfigurationPolicyGroupsGet(ctx context.Context, id ConfigurationPolicyGroupId) (result ConfigurationPolicyGroupsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VpnServerConfigurationPolicyGroup + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_configurationpolicygroupslistbyvpnserverconfiguration.go b/resource-manager/network/2024-07-01/virtualwans/method_configurationpolicygroupslistbyvpnserverconfiguration.go new file mode 100644 index 00000000000..d8055521e53 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_configurationpolicygroupslistbyvpnserverconfiguration.go @@ -0,0 +1,105 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConfigurationPolicyGroupsListByVpnServerConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VpnServerConfigurationPolicyGroup +} + +type ConfigurationPolicyGroupsListByVpnServerConfigurationCompleteResult struct { + LatestHttpResponse *http.Response + Items []VpnServerConfigurationPolicyGroup +} + +type ConfigurationPolicyGroupsListByVpnServerConfigurationCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ConfigurationPolicyGroupsListByVpnServerConfigurationCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ConfigurationPolicyGroupsListByVpnServerConfiguration ... +func (c VirtualWANsClient) ConfigurationPolicyGroupsListByVpnServerConfiguration(ctx context.Context, id VpnServerConfigurationId) (result ConfigurationPolicyGroupsListByVpnServerConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ConfigurationPolicyGroupsListByVpnServerConfigurationCustomPager{}, + Path: fmt.Sprintf("%s/configurationPolicyGroups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VpnServerConfigurationPolicyGroup `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ConfigurationPolicyGroupsListByVpnServerConfigurationComplete retrieves all the results into a single object +func (c VirtualWANsClient) ConfigurationPolicyGroupsListByVpnServerConfigurationComplete(ctx context.Context, id VpnServerConfigurationId) (ConfigurationPolicyGroupsListByVpnServerConfigurationCompleteResult, error) { + return c.ConfigurationPolicyGroupsListByVpnServerConfigurationCompleteMatchingPredicate(ctx, id, VpnServerConfigurationPolicyGroupOperationPredicate{}) +} + +// ConfigurationPolicyGroupsListByVpnServerConfigurationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) ConfigurationPolicyGroupsListByVpnServerConfigurationCompleteMatchingPredicate(ctx context.Context, id VpnServerConfigurationId, predicate VpnServerConfigurationPolicyGroupOperationPredicate) (result ConfigurationPolicyGroupsListByVpnServerConfigurationCompleteResult, err error) { + items := make([]VpnServerConfigurationPolicyGroup, 0) + + resp, err := c.ConfigurationPolicyGroupsListByVpnServerConfiguration(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ConfigurationPolicyGroupsListByVpnServerConfigurationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_generatevirtualwanvpnserverconfigurationvpnprofile.go b/resource-manager/network/2024-07-01/virtualwans/method_generatevirtualwanvpnserverconfigurationvpnprofile.go new file mode 100644 index 00000000000..aed56fdab18 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_generatevirtualwanvpnserverconfigurationvpnprofile.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GeneratevirtualwanvpnserverconfigurationvpnprofileOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VpnProfileResponse +} + +// Generatevirtualwanvpnserverconfigurationvpnprofile ... +func (c VirtualWANsClient) Generatevirtualwanvpnserverconfigurationvpnprofile(ctx context.Context, id VirtualWANId, input VirtualWanVpnProfileParameters) (result GeneratevirtualwanvpnserverconfigurationvpnprofileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/generateVpnProfile", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// GeneratevirtualwanvpnserverconfigurationvpnprofileThenPoll performs Generatevirtualwanvpnserverconfigurationvpnprofile then polls until it's completed +func (c VirtualWANsClient) GeneratevirtualwanvpnserverconfigurationvpnprofileThenPoll(ctx context.Context, id VirtualWANId, input VirtualWanVpnProfileParameters) error { + result, err := c.Generatevirtualwanvpnserverconfigurationvpnprofile(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Generatevirtualwanvpnserverconfigurationvpnprofile: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Generatevirtualwanvpnserverconfigurationvpnprofile: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_hubroutetablescreateorupdate.go b/resource-manager/network/2024-07-01/virtualwans/method_hubroutetablescreateorupdate.go new file mode 100644 index 00000000000..58545e66cc2 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_hubroutetablescreateorupdate.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubRouteTablesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *HubRouteTable +} + +// HubRouteTablesCreateOrUpdate ... +func (c VirtualWANsClient) HubRouteTablesCreateOrUpdate(ctx context.Context, id HubRouteTableId, input HubRouteTable) (result HubRouteTablesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// HubRouteTablesCreateOrUpdateThenPoll performs HubRouteTablesCreateOrUpdate then polls until it's completed +func (c VirtualWANsClient) HubRouteTablesCreateOrUpdateThenPoll(ctx context.Context, id HubRouteTableId, input HubRouteTable) error { + result, err := c.HubRouteTablesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing HubRouteTablesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after HubRouteTablesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_hubroutetablesdelete.go b/resource-manager/network/2024-07-01/virtualwans/method_hubroutetablesdelete.go new file mode 100644 index 00000000000..e51f251c714 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_hubroutetablesdelete.go @@ -0,0 +1,71 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubRouteTablesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// HubRouteTablesDelete ... +func (c VirtualWANsClient) HubRouteTablesDelete(ctx context.Context, id HubRouteTableId) (result HubRouteTablesDeleteOperationResponse, 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 +} + +// HubRouteTablesDeleteThenPoll performs HubRouteTablesDelete then polls until it's completed +func (c VirtualWANsClient) HubRouteTablesDeleteThenPoll(ctx context.Context, id HubRouteTableId) error { + result, err := c.HubRouteTablesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing HubRouteTablesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after HubRouteTablesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_hubroutetablesget.go b/resource-manager/network/2024-07-01/virtualwans/method_hubroutetablesget.go new file mode 100644 index 00000000000..e714731e2bf --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_hubroutetablesget.go @@ -0,0 +1,53 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubRouteTablesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HubRouteTable +} + +// HubRouteTablesGet ... +func (c VirtualWANsClient) HubRouteTablesGet(ctx context.Context, id HubRouteTableId) (result HubRouteTablesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HubRouteTable + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_hubroutetableslist.go b/resource-manager/network/2024-07-01/virtualwans/method_hubroutetableslist.go new file mode 100644 index 00000000000..d36631c9289 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_hubroutetableslist.go @@ -0,0 +1,105 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubRouteTablesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HubRouteTable +} + +type HubRouteTablesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []HubRouteTable +} + +type HubRouteTablesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *HubRouteTablesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// HubRouteTablesList ... +func (c VirtualWANsClient) HubRouteTablesList(ctx context.Context, id VirtualHubId) (result HubRouteTablesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &HubRouteTablesListCustomPager{}, + Path: fmt.Sprintf("%s/hubRouteTables", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]HubRouteTable `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// HubRouteTablesListComplete retrieves all the results into a single object +func (c VirtualWANsClient) HubRouteTablesListComplete(ctx context.Context, id VirtualHubId) (HubRouteTablesListCompleteResult, error) { + return c.HubRouteTablesListCompleteMatchingPredicate(ctx, id, HubRouteTableOperationPredicate{}) +} + +// HubRouteTablesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) HubRouteTablesListCompleteMatchingPredicate(ctx context.Context, id VirtualHubId, predicate HubRouteTableOperationPredicate) (result HubRouteTablesListCompleteResult, err error) { + items := make([]HubRouteTable, 0) + + resp, err := c.HubRouteTablesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = HubRouteTablesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_hubvirtualnetworkconnectionscreateorupdate.go b/resource-manager/network/2024-07-01/virtualwans/method_hubvirtualnetworkconnectionscreateorupdate.go new file mode 100644 index 00000000000..4353d1898c9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_hubvirtualnetworkconnectionscreateorupdate.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubVirtualNetworkConnectionsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *HubVirtualNetworkConnection +} + +// HubVirtualNetworkConnectionsCreateOrUpdate ... +func (c VirtualWANsClient) HubVirtualNetworkConnectionsCreateOrUpdate(ctx context.Context, id HubVirtualNetworkConnectionId, input HubVirtualNetworkConnection) (result HubVirtualNetworkConnectionsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// HubVirtualNetworkConnectionsCreateOrUpdateThenPoll performs HubVirtualNetworkConnectionsCreateOrUpdate then polls until it's completed +func (c VirtualWANsClient) HubVirtualNetworkConnectionsCreateOrUpdateThenPoll(ctx context.Context, id HubVirtualNetworkConnectionId, input HubVirtualNetworkConnection) error { + result, err := c.HubVirtualNetworkConnectionsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing HubVirtualNetworkConnectionsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after HubVirtualNetworkConnectionsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_hubvirtualnetworkconnectionsdelete.go b/resource-manager/network/2024-07-01/virtualwans/method_hubvirtualnetworkconnectionsdelete.go new file mode 100644 index 00000000000..d26ec8f61b8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_hubvirtualnetworkconnectionsdelete.go @@ -0,0 +1,71 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubVirtualNetworkConnectionsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// HubVirtualNetworkConnectionsDelete ... +func (c VirtualWANsClient) HubVirtualNetworkConnectionsDelete(ctx context.Context, id HubVirtualNetworkConnectionId) (result HubVirtualNetworkConnectionsDeleteOperationResponse, 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 +} + +// HubVirtualNetworkConnectionsDeleteThenPoll performs HubVirtualNetworkConnectionsDelete then polls until it's completed +func (c VirtualWANsClient) HubVirtualNetworkConnectionsDeleteThenPoll(ctx context.Context, id HubVirtualNetworkConnectionId) error { + result, err := c.HubVirtualNetworkConnectionsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing HubVirtualNetworkConnectionsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after HubVirtualNetworkConnectionsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_hubvirtualnetworkconnectionsget.go b/resource-manager/network/2024-07-01/virtualwans/method_hubvirtualnetworkconnectionsget.go new file mode 100644 index 00000000000..f08f465d3c1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_hubvirtualnetworkconnectionsget.go @@ -0,0 +1,53 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubVirtualNetworkConnectionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HubVirtualNetworkConnection +} + +// HubVirtualNetworkConnectionsGet ... +func (c VirtualWANsClient) HubVirtualNetworkConnectionsGet(ctx context.Context, id HubVirtualNetworkConnectionId) (result HubVirtualNetworkConnectionsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HubVirtualNetworkConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_hubvirtualnetworkconnectionslist.go b/resource-manager/network/2024-07-01/virtualwans/method_hubvirtualnetworkconnectionslist.go new file mode 100644 index 00000000000..9ba166e19d8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_hubvirtualnetworkconnectionslist.go @@ -0,0 +1,105 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubVirtualNetworkConnectionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HubVirtualNetworkConnection +} + +type HubVirtualNetworkConnectionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []HubVirtualNetworkConnection +} + +type HubVirtualNetworkConnectionsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *HubVirtualNetworkConnectionsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// HubVirtualNetworkConnectionsList ... +func (c VirtualWANsClient) HubVirtualNetworkConnectionsList(ctx context.Context, id VirtualHubId) (result HubVirtualNetworkConnectionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &HubVirtualNetworkConnectionsListCustomPager{}, + Path: fmt.Sprintf("%s/hubVirtualNetworkConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]HubVirtualNetworkConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// HubVirtualNetworkConnectionsListComplete retrieves all the results into a single object +func (c VirtualWANsClient) HubVirtualNetworkConnectionsListComplete(ctx context.Context, id VirtualHubId) (HubVirtualNetworkConnectionsListCompleteResult, error) { + return c.HubVirtualNetworkConnectionsListCompleteMatchingPredicate(ctx, id, HubVirtualNetworkConnectionOperationPredicate{}) +} + +// HubVirtualNetworkConnectionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) HubVirtualNetworkConnectionsListCompleteMatchingPredicate(ctx context.Context, id VirtualHubId, predicate HubVirtualNetworkConnectionOperationPredicate) (result HubVirtualNetworkConnectionsListCompleteResult, err error) { + items := make([]HubVirtualNetworkConnection, 0) + + resp, err := c.HubVirtualNetworkConnectionsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = HubVirtualNetworkConnectionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_natrulescreateorupdate.go b/resource-manager/network/2024-07-01/virtualwans/method_natrulescreateorupdate.go new file mode 100644 index 00000000000..168ea42291c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_natrulescreateorupdate.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VpnGatewayNatRule +} + +// NatRulesCreateOrUpdate ... +func (c VirtualWANsClient) NatRulesCreateOrUpdate(ctx context.Context, id NatRuleId, input VpnGatewayNatRule) (result NatRulesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// NatRulesCreateOrUpdateThenPoll performs NatRulesCreateOrUpdate then polls until it's completed +func (c VirtualWANsClient) NatRulesCreateOrUpdateThenPoll(ctx context.Context, id NatRuleId, input VpnGatewayNatRule) error { + result, err := c.NatRulesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing NatRulesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after NatRulesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_natrulesdelete.go b/resource-manager/network/2024-07-01/virtualwans/method_natrulesdelete.go new file mode 100644 index 00000000000..6908f8fa7a2 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_natrulesdelete.go @@ -0,0 +1,71 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// NatRulesDelete ... +func (c VirtualWANsClient) NatRulesDelete(ctx context.Context, id NatRuleId) (result NatRulesDeleteOperationResponse, 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 +} + +// NatRulesDeleteThenPoll performs NatRulesDelete then polls until it's completed +func (c VirtualWANsClient) NatRulesDeleteThenPoll(ctx context.Context, id NatRuleId) error { + result, err := c.NatRulesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing NatRulesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after NatRulesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_natrulesget.go b/resource-manager/network/2024-07-01/virtualwans/method_natrulesget.go new file mode 100644 index 00000000000..c81f0b6e89a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_natrulesget.go @@ -0,0 +1,53 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VpnGatewayNatRule +} + +// NatRulesGet ... +func (c VirtualWANsClient) NatRulesGet(ctx context.Context, id NatRuleId) (result NatRulesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VpnGatewayNatRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_natruleslistbyvpngateway.go b/resource-manager/network/2024-07-01/virtualwans/method_natruleslistbyvpngateway.go new file mode 100644 index 00000000000..e5393de1385 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_natruleslistbyvpngateway.go @@ -0,0 +1,105 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulesListByVpnGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VpnGatewayNatRule +} + +type NatRulesListByVpnGatewayCompleteResult struct { + LatestHttpResponse *http.Response + Items []VpnGatewayNatRule +} + +type NatRulesListByVpnGatewayCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *NatRulesListByVpnGatewayCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// NatRulesListByVpnGateway ... +func (c VirtualWANsClient) NatRulesListByVpnGateway(ctx context.Context, id VpnGatewayId) (result NatRulesListByVpnGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &NatRulesListByVpnGatewayCustomPager{}, + Path: fmt.Sprintf("%s/natRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VpnGatewayNatRule `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// NatRulesListByVpnGatewayComplete retrieves all the results into a single object +func (c VirtualWANsClient) NatRulesListByVpnGatewayComplete(ctx context.Context, id VpnGatewayId) (NatRulesListByVpnGatewayCompleteResult, error) { + return c.NatRulesListByVpnGatewayCompleteMatchingPredicate(ctx, id, VpnGatewayNatRuleOperationPredicate{}) +} + +// NatRulesListByVpnGatewayCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) NatRulesListByVpnGatewayCompleteMatchingPredicate(ctx context.Context, id VpnGatewayId, predicate VpnGatewayNatRuleOperationPredicate) (result NatRulesListByVpnGatewayCompleteResult, err error) { + items := make([]VpnGatewayNatRule, 0) + + resp, err := c.NatRulesListByVpnGateway(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = NatRulesListByVpnGatewayCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_networkvirtualapplianceconnectionscreateorupdate.go b/resource-manager/network/2024-07-01/virtualwans/method_networkvirtualapplianceconnectionscreateorupdate.go new file mode 100644 index 00000000000..1bcdfbdee15 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_networkvirtualapplianceconnectionscreateorupdate.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualApplianceConnectionsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NetworkVirtualApplianceConnection +} + +// NetworkVirtualApplianceConnectionsCreateOrUpdate ... +func (c VirtualWANsClient) NetworkVirtualApplianceConnectionsCreateOrUpdate(ctx context.Context, id NetworkVirtualApplianceConnectionId, input NetworkVirtualApplianceConnection) (result NetworkVirtualApplianceConnectionsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// NetworkVirtualApplianceConnectionsCreateOrUpdateThenPoll performs NetworkVirtualApplianceConnectionsCreateOrUpdate then polls until it's completed +func (c VirtualWANsClient) NetworkVirtualApplianceConnectionsCreateOrUpdateThenPoll(ctx context.Context, id NetworkVirtualApplianceConnectionId, input NetworkVirtualApplianceConnection) error { + result, err := c.NetworkVirtualApplianceConnectionsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing NetworkVirtualApplianceConnectionsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after NetworkVirtualApplianceConnectionsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_networkvirtualapplianceconnectionsdelete.go b/resource-manager/network/2024-07-01/virtualwans/method_networkvirtualapplianceconnectionsdelete.go new file mode 100644 index 00000000000..38492cbbb11 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_networkvirtualapplianceconnectionsdelete.go @@ -0,0 +1,71 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualApplianceConnectionsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// NetworkVirtualApplianceConnectionsDelete ... +func (c VirtualWANsClient) NetworkVirtualApplianceConnectionsDelete(ctx context.Context, id NetworkVirtualApplianceConnectionId) (result NetworkVirtualApplianceConnectionsDeleteOperationResponse, 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 +} + +// NetworkVirtualApplianceConnectionsDeleteThenPoll performs NetworkVirtualApplianceConnectionsDelete then polls until it's completed +func (c VirtualWANsClient) NetworkVirtualApplianceConnectionsDeleteThenPoll(ctx context.Context, id NetworkVirtualApplianceConnectionId) error { + result, err := c.NetworkVirtualApplianceConnectionsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing NetworkVirtualApplianceConnectionsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after NetworkVirtualApplianceConnectionsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_networkvirtualapplianceconnectionsget.go b/resource-manager/network/2024-07-01/virtualwans/method_networkvirtualapplianceconnectionsget.go new file mode 100644 index 00000000000..783b3251a6c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_networkvirtualapplianceconnectionsget.go @@ -0,0 +1,53 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualApplianceConnectionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkVirtualApplianceConnection +} + +// NetworkVirtualApplianceConnectionsGet ... +func (c VirtualWANsClient) NetworkVirtualApplianceConnectionsGet(ctx context.Context, id NetworkVirtualApplianceConnectionId) (result NetworkVirtualApplianceConnectionsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkVirtualApplianceConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_networkvirtualapplianceconnectionslist.go b/resource-manager/network/2024-07-01/virtualwans/method_networkvirtualapplianceconnectionslist.go new file mode 100644 index 00000000000..72b22855ec4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_networkvirtualapplianceconnectionslist.go @@ -0,0 +1,105 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualApplianceConnectionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkVirtualApplianceConnection +} + +type NetworkVirtualApplianceConnectionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []NetworkVirtualApplianceConnection +} + +type NetworkVirtualApplianceConnectionsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *NetworkVirtualApplianceConnectionsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// NetworkVirtualApplianceConnectionsList ... +func (c VirtualWANsClient) NetworkVirtualApplianceConnectionsList(ctx context.Context, id NetworkVirtualApplianceId) (result NetworkVirtualApplianceConnectionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &NetworkVirtualApplianceConnectionsListCustomPager{}, + Path: fmt.Sprintf("%s/networkVirtualApplianceConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NetworkVirtualApplianceConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// NetworkVirtualApplianceConnectionsListComplete retrieves all the results into a single object +func (c VirtualWANsClient) NetworkVirtualApplianceConnectionsListComplete(ctx context.Context, id NetworkVirtualApplianceId) (NetworkVirtualApplianceConnectionsListCompleteResult, error) { + return c.NetworkVirtualApplianceConnectionsListCompleteMatchingPredicate(ctx, id, NetworkVirtualApplianceConnectionOperationPredicate{}) +} + +// NetworkVirtualApplianceConnectionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) NetworkVirtualApplianceConnectionsListCompleteMatchingPredicate(ctx context.Context, id NetworkVirtualApplianceId, predicate NetworkVirtualApplianceConnectionOperationPredicate) (result NetworkVirtualApplianceConnectionsListCompleteResult, err error) { + items := make([]NetworkVirtualApplianceConnection, 0) + + resp, err := c.NetworkVirtualApplianceConnectionsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = NetworkVirtualApplianceConnectionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_p2svpngatewayscreateorupdate.go b/resource-manager/network/2024-07-01/virtualwans/method_p2svpngatewayscreateorupdate.go new file mode 100644 index 00000000000..664698b3088 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_p2svpngatewayscreateorupdate.go @@ -0,0 +1,76 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2sVpnGatewaysCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *P2SVpnGateway +} + +// P2sVpnGatewaysCreateOrUpdate ... +func (c VirtualWANsClient) P2sVpnGatewaysCreateOrUpdate(ctx context.Context, id commonids.VirtualWANP2SVPNGatewayId, input P2SVpnGateway) (result P2sVpnGatewaysCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// P2sVpnGatewaysCreateOrUpdateThenPoll performs P2sVpnGatewaysCreateOrUpdate then polls until it's completed +func (c VirtualWANsClient) P2sVpnGatewaysCreateOrUpdateThenPoll(ctx context.Context, id commonids.VirtualWANP2SVPNGatewayId, input P2SVpnGateway) error { + result, err := c.P2sVpnGatewaysCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing P2sVpnGatewaysCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after P2sVpnGatewaysCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_p2svpngatewaysdelete.go b/resource-manager/network/2024-07-01/virtualwans/method_p2svpngatewaysdelete.go new file mode 100644 index 00000000000..23ae30eaecd --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_p2svpngatewaysdelete.go @@ -0,0 +1,72 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2sVpnGatewaysDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// P2sVpnGatewaysDelete ... +func (c VirtualWANsClient) P2sVpnGatewaysDelete(ctx context.Context, id commonids.VirtualWANP2SVPNGatewayId) (result P2sVpnGatewaysDeleteOperationResponse, 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 +} + +// P2sVpnGatewaysDeleteThenPoll performs P2sVpnGatewaysDelete then polls until it's completed +func (c VirtualWANsClient) P2sVpnGatewaysDeleteThenPoll(ctx context.Context, id commonids.VirtualWANP2SVPNGatewayId) error { + result, err := c.P2sVpnGatewaysDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing P2sVpnGatewaysDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after P2sVpnGatewaysDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_p2svpngatewaysget.go b/resource-manager/network/2024-07-01/virtualwans/method_p2svpngatewaysget.go new file mode 100644 index 00000000000..ec7e18c347e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_p2svpngatewaysget.go @@ -0,0 +1,54 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2sVpnGatewaysGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *P2SVpnGateway +} + +// P2sVpnGatewaysGet ... +func (c VirtualWANsClient) P2sVpnGatewaysGet(ctx context.Context, id commonids.VirtualWANP2SVPNGatewayId) (result P2sVpnGatewaysGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model P2SVpnGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_p2svpngatewayslist.go b/resource-manager/network/2024-07-01/virtualwans/method_p2svpngatewayslist.go new file mode 100644 index 00000000000..b51053de49e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_p2svpngatewayslist.go @@ -0,0 +1,106 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2sVpnGatewaysListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]P2SVpnGateway +} + +type P2sVpnGatewaysListCompleteResult struct { + LatestHttpResponse *http.Response + Items []P2SVpnGateway +} + +type P2sVpnGatewaysListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *P2sVpnGatewaysListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// P2sVpnGatewaysList ... +func (c VirtualWANsClient) P2sVpnGatewaysList(ctx context.Context, id commonids.SubscriptionId) (result P2sVpnGatewaysListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &P2sVpnGatewaysListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/p2sVpnGateways", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]P2SVpnGateway `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// P2sVpnGatewaysListComplete retrieves all the results into a single object +func (c VirtualWANsClient) P2sVpnGatewaysListComplete(ctx context.Context, id commonids.SubscriptionId) (P2sVpnGatewaysListCompleteResult, error) { + return c.P2sVpnGatewaysListCompleteMatchingPredicate(ctx, id, P2SVpnGatewayOperationPredicate{}) +} + +// P2sVpnGatewaysListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) P2sVpnGatewaysListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate P2SVpnGatewayOperationPredicate) (result P2sVpnGatewaysListCompleteResult, err error) { + items := make([]P2SVpnGateway, 0) + + resp, err := c.P2sVpnGatewaysList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = P2sVpnGatewaysListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_p2svpngatewayslistbyresourcegroup.go b/resource-manager/network/2024-07-01/virtualwans/method_p2svpngatewayslistbyresourcegroup.go new file mode 100644 index 00000000000..1c57fc684fa --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_p2svpngatewayslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2sVpnGatewaysListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]P2SVpnGateway +} + +type P2sVpnGatewaysListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []P2SVpnGateway +} + +type P2sVpnGatewaysListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *P2sVpnGatewaysListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// P2sVpnGatewaysListByResourceGroup ... +func (c VirtualWANsClient) P2sVpnGatewaysListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result P2sVpnGatewaysListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &P2sVpnGatewaysListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/p2sVpnGateways", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]P2SVpnGateway `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// P2sVpnGatewaysListByResourceGroupComplete retrieves all the results into a single object +func (c VirtualWANsClient) P2sVpnGatewaysListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (P2sVpnGatewaysListByResourceGroupCompleteResult, error) { + return c.P2sVpnGatewaysListByResourceGroupCompleteMatchingPredicate(ctx, id, P2SVpnGatewayOperationPredicate{}) +} + +// P2sVpnGatewaysListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) P2sVpnGatewaysListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate P2SVpnGatewayOperationPredicate) (result P2sVpnGatewaysListByResourceGroupCompleteResult, err error) { + items := make([]P2SVpnGateway, 0) + + resp, err := c.P2sVpnGatewaysListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = P2sVpnGatewaysListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_routemapscreateorupdate.go b/resource-manager/network/2024-07-01/virtualwans/method_routemapscreateorupdate.go new file mode 100644 index 00000000000..ffcf789da29 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_routemapscreateorupdate.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteMapsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RouteMap +} + +// RouteMapsCreateOrUpdate ... +func (c VirtualWANsClient) RouteMapsCreateOrUpdate(ctx context.Context, id RouteMapId, input RouteMap) (result RouteMapsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RouteMapsCreateOrUpdateThenPoll performs RouteMapsCreateOrUpdate then polls until it's completed +func (c VirtualWANsClient) RouteMapsCreateOrUpdateThenPoll(ctx context.Context, id RouteMapId, input RouteMap) error { + result, err := c.RouteMapsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RouteMapsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RouteMapsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_routemapsdelete.go b/resource-manager/network/2024-07-01/virtualwans/method_routemapsdelete.go new file mode 100644 index 00000000000..f89977d5d94 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_routemapsdelete.go @@ -0,0 +1,71 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteMapsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RouteMapsDelete ... +func (c VirtualWANsClient) RouteMapsDelete(ctx context.Context, id RouteMapId) (result RouteMapsDeleteOperationResponse, 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 +} + +// RouteMapsDeleteThenPoll performs RouteMapsDelete then polls until it's completed +func (c VirtualWANsClient) RouteMapsDeleteThenPoll(ctx context.Context, id RouteMapId) error { + result, err := c.RouteMapsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RouteMapsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RouteMapsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_routemapsget.go b/resource-manager/network/2024-07-01/virtualwans/method_routemapsget.go new file mode 100644 index 00000000000..c1db2c3033a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_routemapsget.go @@ -0,0 +1,53 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteMapsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RouteMap +} + +// RouteMapsGet ... +func (c VirtualWANsClient) RouteMapsGet(ctx context.Context, id RouteMapId) (result RouteMapsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RouteMap + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_routemapslist.go b/resource-manager/network/2024-07-01/virtualwans/method_routemapslist.go new file mode 100644 index 00000000000..a9eddc11d95 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_routemapslist.go @@ -0,0 +1,105 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteMapsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RouteMap +} + +type RouteMapsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RouteMap +} + +type RouteMapsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RouteMapsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RouteMapsList ... +func (c VirtualWANsClient) RouteMapsList(ctx context.Context, id VirtualHubId) (result RouteMapsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &RouteMapsListCustomPager{}, + Path: fmt.Sprintf("%s/routeMaps", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RouteMap `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RouteMapsListComplete retrieves all the results into a single object +func (c VirtualWANsClient) RouteMapsListComplete(ctx context.Context, id VirtualHubId) (RouteMapsListCompleteResult, error) { + return c.RouteMapsListCompleteMatchingPredicate(ctx, id, RouteMapOperationPredicate{}) +} + +// RouteMapsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) RouteMapsListCompleteMatchingPredicate(ctx context.Context, id VirtualHubId, predicate RouteMapOperationPredicate) (result RouteMapsListCompleteResult, err error) { + items := make([]RouteMap, 0) + + resp, err := c.RouteMapsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = RouteMapsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_routingintentcreateorupdate.go b/resource-manager/network/2024-07-01/virtualwans/method_routingintentcreateorupdate.go new file mode 100644 index 00000000000..58de7662435 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_routingintentcreateorupdate.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingIntentCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RoutingIntent +} + +// RoutingIntentCreateOrUpdate ... +func (c VirtualWANsClient) RoutingIntentCreateOrUpdate(ctx context.Context, id RoutingIntentId, input RoutingIntent) (result RoutingIntentCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RoutingIntentCreateOrUpdateThenPoll performs RoutingIntentCreateOrUpdate then polls until it's completed +func (c VirtualWANsClient) RoutingIntentCreateOrUpdateThenPoll(ctx context.Context, id RoutingIntentId, input RoutingIntent) error { + result, err := c.RoutingIntentCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RoutingIntentCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RoutingIntentCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_routingintentdelete.go b/resource-manager/network/2024-07-01/virtualwans/method_routingintentdelete.go new file mode 100644 index 00000000000..dd481f41454 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_routingintentdelete.go @@ -0,0 +1,71 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingIntentDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RoutingIntentDelete ... +func (c VirtualWANsClient) RoutingIntentDelete(ctx context.Context, id RoutingIntentId) (result RoutingIntentDeleteOperationResponse, 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 +} + +// RoutingIntentDeleteThenPoll performs RoutingIntentDelete then polls until it's completed +func (c VirtualWANsClient) RoutingIntentDeleteThenPoll(ctx context.Context, id RoutingIntentId) error { + result, err := c.RoutingIntentDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RoutingIntentDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RoutingIntentDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_routingintentget.go b/resource-manager/network/2024-07-01/virtualwans/method_routingintentget.go new file mode 100644 index 00000000000..fea07e77795 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_routingintentget.go @@ -0,0 +1,53 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingIntentGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RoutingIntent +} + +// RoutingIntentGet ... +func (c VirtualWANsClient) RoutingIntentGet(ctx context.Context, id RoutingIntentId) (result RoutingIntentGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RoutingIntent + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_routingintentlist.go b/resource-manager/network/2024-07-01/virtualwans/method_routingintentlist.go new file mode 100644 index 00000000000..b3edd99b519 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_routingintentlist.go @@ -0,0 +1,105 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingIntentListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RoutingIntent +} + +type RoutingIntentListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RoutingIntent +} + +type RoutingIntentListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RoutingIntentListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RoutingIntentList ... +func (c VirtualWANsClient) RoutingIntentList(ctx context.Context, id VirtualHubId) (result RoutingIntentListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &RoutingIntentListCustomPager{}, + Path: fmt.Sprintf("%s/routingIntent", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RoutingIntent `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RoutingIntentListComplete retrieves all the results into a single object +func (c VirtualWANsClient) RoutingIntentListComplete(ctx context.Context, id VirtualHubId) (RoutingIntentListCompleteResult, error) { + return c.RoutingIntentListCompleteMatchingPredicate(ctx, id, RoutingIntentOperationPredicate{}) +} + +// RoutingIntentListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) RoutingIntentListCompleteMatchingPredicate(ctx context.Context, id VirtualHubId, predicate RoutingIntentOperationPredicate) (result RoutingIntentListCompleteResult, err error) { + items := make([]RoutingIntent, 0) + + resp, err := c.RoutingIntentList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = RoutingIntentListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_supportedsecurityproviders.go b/resource-manager/network/2024-07-01/virtualwans/method_supportedsecurityproviders.go new file mode 100644 index 00000000000..3351ee7549f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_supportedsecurityproviders.go @@ -0,0 +1,54 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportedSecurityProvidersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualWanSecurityProviders +} + +// SupportedSecurityProviders ... +func (c VirtualWANsClient) SupportedSecurityProviders(ctx context.Context, id VirtualWANId) (result SupportedSecurityProvidersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/supportedSecurityProviders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualWanSecurityProviders + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_updatetags.go b/resource-manager/network/2024-07-01/virtualwans/method_updatetags.go new file mode 100644 index 00000000000..42f292d4aea --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_updatetags.go @@ -0,0 +1,57 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualWAN +} + +// UpdateTags ... +func (c VirtualWANsClient) UpdateTags(ctx context.Context, id VirtualWANId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualWAN + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectioncreateorupdate.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectioncreateorupdate.go new file mode 100644 index 00000000000..3a42d5bcafd --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectioncreateorupdate.go @@ -0,0 +1,76 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubBgpConnectionCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *BgpConnection +} + +// VirtualHubBgpConnectionCreateOrUpdate ... +func (c VirtualWANsClient) VirtualHubBgpConnectionCreateOrUpdate(ctx context.Context, id commonids.VirtualHubBGPConnectionId, input BgpConnection) (result VirtualHubBgpConnectionCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VirtualHubBgpConnectionCreateOrUpdateThenPoll performs VirtualHubBgpConnectionCreateOrUpdate then polls until it's completed +func (c VirtualWANsClient) VirtualHubBgpConnectionCreateOrUpdateThenPoll(ctx context.Context, id commonids.VirtualHubBGPConnectionId, input BgpConnection) error { + result, err := c.VirtualHubBgpConnectionCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VirtualHubBgpConnectionCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualHubBgpConnectionCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectiondelete.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectiondelete.go new file mode 100644 index 00000000000..b8f353d5be6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectiondelete.go @@ -0,0 +1,72 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubBgpConnectionDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VirtualHubBgpConnectionDelete ... +func (c VirtualWANsClient) VirtualHubBgpConnectionDelete(ctx context.Context, id commonids.VirtualHubBGPConnectionId) (result VirtualHubBgpConnectionDeleteOperationResponse, 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 +} + +// VirtualHubBgpConnectionDeleteThenPoll performs VirtualHubBgpConnectionDelete then polls until it's completed +func (c VirtualWANsClient) VirtualHubBgpConnectionDeleteThenPoll(ctx context.Context, id commonids.VirtualHubBGPConnectionId) error { + result, err := c.VirtualHubBgpConnectionDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing VirtualHubBgpConnectionDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualHubBgpConnectionDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectionget.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectionget.go new file mode 100644 index 00000000000..e4d4c41773a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectionget.go @@ -0,0 +1,54 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubBgpConnectionGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BgpConnection +} + +// VirtualHubBgpConnectionGet ... +func (c VirtualWANsClient) VirtualHubBgpConnectionGet(ctx context.Context, id commonids.VirtualHubBGPConnectionId) (result VirtualHubBgpConnectionGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BgpConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectionslist.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectionslist.go new file mode 100644 index 00000000000..802bf0b65b9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectionslist.go @@ -0,0 +1,105 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubBgpConnectionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BgpConnection +} + +type VirtualHubBgpConnectionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []BgpConnection +} + +type VirtualHubBgpConnectionsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VirtualHubBgpConnectionsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VirtualHubBgpConnectionsList ... +func (c VirtualWANsClient) VirtualHubBgpConnectionsList(ctx context.Context, id VirtualHubId) (result VirtualHubBgpConnectionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VirtualHubBgpConnectionsListCustomPager{}, + Path: fmt.Sprintf("%s/bgpConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BgpConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VirtualHubBgpConnectionsListComplete retrieves all the results into a single object +func (c VirtualWANsClient) VirtualHubBgpConnectionsListComplete(ctx context.Context, id VirtualHubId) (VirtualHubBgpConnectionsListCompleteResult, error) { + return c.VirtualHubBgpConnectionsListCompleteMatchingPredicate(ctx, id, BgpConnectionOperationPredicate{}) +} + +// VirtualHubBgpConnectionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) VirtualHubBgpConnectionsListCompleteMatchingPredicate(ctx context.Context, id VirtualHubId, predicate BgpConnectionOperationPredicate) (result VirtualHubBgpConnectionsListCompleteResult, err error) { + items := make([]BgpConnection, 0) + + resp, err := c.VirtualHubBgpConnectionsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VirtualHubBgpConnectionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectionslistadvertisedroutes.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectionslistadvertisedroutes.go new file mode 100644 index 00000000000..6c0c2308e2b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectionslistadvertisedroutes.go @@ -0,0 +1,72 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubBgpConnectionsListAdvertisedRoutesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *map[string][]PeerRoute +} + +// VirtualHubBgpConnectionsListAdvertisedRoutes ... +func (c VirtualWANsClient) VirtualHubBgpConnectionsListAdvertisedRoutes(ctx context.Context, id commonids.VirtualHubBGPConnectionId) (result VirtualHubBgpConnectionsListAdvertisedRoutesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/advertisedRoutes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VirtualHubBgpConnectionsListAdvertisedRoutesThenPoll performs VirtualHubBgpConnectionsListAdvertisedRoutes then polls until it's completed +func (c VirtualWANsClient) VirtualHubBgpConnectionsListAdvertisedRoutesThenPoll(ctx context.Context, id commonids.VirtualHubBGPConnectionId) error { + result, err := c.VirtualHubBgpConnectionsListAdvertisedRoutes(ctx, id) + if err != nil { + return fmt.Errorf("performing VirtualHubBgpConnectionsListAdvertisedRoutes: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualHubBgpConnectionsListAdvertisedRoutes: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectionslistlearnedroutes.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectionslistlearnedroutes.go new file mode 100644 index 00000000000..4c6842802ef --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubbgpconnectionslistlearnedroutes.go @@ -0,0 +1,72 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubBgpConnectionsListLearnedRoutesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *map[string][]PeerRoute +} + +// VirtualHubBgpConnectionsListLearnedRoutes ... +func (c VirtualWANsClient) VirtualHubBgpConnectionsListLearnedRoutes(ctx context.Context, id commonids.VirtualHubBGPConnectionId) (result VirtualHubBgpConnectionsListLearnedRoutesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/learnedRoutes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VirtualHubBgpConnectionsListLearnedRoutesThenPoll performs VirtualHubBgpConnectionsListLearnedRoutes then polls until it's completed +func (c VirtualWANsClient) VirtualHubBgpConnectionsListLearnedRoutesThenPoll(ctx context.Context, id commonids.VirtualHubBGPConnectionId) error { + result, err := c.VirtualHubBgpConnectionsListLearnedRoutes(ctx, id) + if err != nil { + return fmt.Errorf("performing VirtualHubBgpConnectionsListLearnedRoutes: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualHubBgpConnectionsListLearnedRoutes: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubipconfigurationcreateorupdate.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubipconfigurationcreateorupdate.go new file mode 100644 index 00000000000..dfb4925ba51 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubipconfigurationcreateorupdate.go @@ -0,0 +1,76 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubIPConfigurationCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *HubIPConfiguration +} + +// VirtualHubIPConfigurationCreateOrUpdate ... +func (c VirtualWANsClient) VirtualHubIPConfigurationCreateOrUpdate(ctx context.Context, id commonids.VirtualHubIPConfigurationId, input HubIPConfiguration) (result VirtualHubIPConfigurationCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VirtualHubIPConfigurationCreateOrUpdateThenPoll performs VirtualHubIPConfigurationCreateOrUpdate then polls until it's completed +func (c VirtualWANsClient) VirtualHubIPConfigurationCreateOrUpdateThenPoll(ctx context.Context, id commonids.VirtualHubIPConfigurationId, input HubIPConfiguration) error { + result, err := c.VirtualHubIPConfigurationCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VirtualHubIPConfigurationCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualHubIPConfigurationCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubipconfigurationdelete.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubipconfigurationdelete.go new file mode 100644 index 00000000000..36341aa33f7 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubipconfigurationdelete.go @@ -0,0 +1,72 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubIPConfigurationDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VirtualHubIPConfigurationDelete ... +func (c VirtualWANsClient) VirtualHubIPConfigurationDelete(ctx context.Context, id commonids.VirtualHubIPConfigurationId) (result VirtualHubIPConfigurationDeleteOperationResponse, 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 +} + +// VirtualHubIPConfigurationDeleteThenPoll performs VirtualHubIPConfigurationDelete then polls until it's completed +func (c VirtualWANsClient) VirtualHubIPConfigurationDeleteThenPoll(ctx context.Context, id commonids.VirtualHubIPConfigurationId) error { + result, err := c.VirtualHubIPConfigurationDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing VirtualHubIPConfigurationDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualHubIPConfigurationDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubipconfigurationget.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubipconfigurationget.go new file mode 100644 index 00000000000..c4abe234784 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubipconfigurationget.go @@ -0,0 +1,54 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubIPConfigurationGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HubIPConfiguration +} + +// VirtualHubIPConfigurationGet ... +func (c VirtualWANsClient) VirtualHubIPConfigurationGet(ctx context.Context, id commonids.VirtualHubIPConfigurationId) (result VirtualHubIPConfigurationGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HubIPConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubipconfigurationlist.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubipconfigurationlist.go new file mode 100644 index 00000000000..8ae13b9fb7d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubipconfigurationlist.go @@ -0,0 +1,105 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubIPConfigurationListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HubIPConfiguration +} + +type VirtualHubIPConfigurationListCompleteResult struct { + LatestHttpResponse *http.Response + Items []HubIPConfiguration +} + +type VirtualHubIPConfigurationListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VirtualHubIPConfigurationListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VirtualHubIPConfigurationList ... +func (c VirtualWANsClient) VirtualHubIPConfigurationList(ctx context.Context, id VirtualHubId) (result VirtualHubIPConfigurationListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VirtualHubIPConfigurationListCustomPager{}, + Path: fmt.Sprintf("%s/ipConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]HubIPConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VirtualHubIPConfigurationListComplete retrieves all the results into a single object +func (c VirtualWANsClient) VirtualHubIPConfigurationListComplete(ctx context.Context, id VirtualHubId) (VirtualHubIPConfigurationListCompleteResult, error) { + return c.VirtualHubIPConfigurationListCompleteMatchingPredicate(ctx, id, HubIPConfigurationOperationPredicate{}) +} + +// VirtualHubIPConfigurationListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) VirtualHubIPConfigurationListCompleteMatchingPredicate(ctx context.Context, id VirtualHubId, predicate HubIPConfigurationOperationPredicate) (result VirtualHubIPConfigurationListCompleteResult, err error) { + items := make([]HubIPConfiguration, 0) + + resp, err := c.VirtualHubIPConfigurationList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VirtualHubIPConfigurationListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubroutetablev2screateorupdate.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubroutetablev2screateorupdate.go new file mode 100644 index 00000000000..b7e92feb6c7 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubroutetablev2screateorupdate.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubRouteTableV2sCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualHubRouteTableV2 +} + +// VirtualHubRouteTableV2sCreateOrUpdate ... +func (c VirtualWANsClient) VirtualHubRouteTableV2sCreateOrUpdate(ctx context.Context, id VirtualHubRouteTableId, input VirtualHubRouteTableV2) (result VirtualHubRouteTableV2sCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VirtualHubRouteTableV2sCreateOrUpdateThenPoll performs VirtualHubRouteTableV2sCreateOrUpdate then polls until it's completed +func (c VirtualWANsClient) VirtualHubRouteTableV2sCreateOrUpdateThenPoll(ctx context.Context, id VirtualHubRouteTableId, input VirtualHubRouteTableV2) error { + result, err := c.VirtualHubRouteTableV2sCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VirtualHubRouteTableV2sCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualHubRouteTableV2sCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubroutetablev2sdelete.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubroutetablev2sdelete.go new file mode 100644 index 00000000000..91cc7babd28 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubroutetablev2sdelete.go @@ -0,0 +1,71 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubRouteTableV2sDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VirtualHubRouteTableV2sDelete ... +func (c VirtualWANsClient) VirtualHubRouteTableV2sDelete(ctx context.Context, id VirtualHubRouteTableId) (result VirtualHubRouteTableV2sDeleteOperationResponse, 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 +} + +// VirtualHubRouteTableV2sDeleteThenPoll performs VirtualHubRouteTableV2sDelete then polls until it's completed +func (c VirtualWANsClient) VirtualHubRouteTableV2sDeleteThenPoll(ctx context.Context, id VirtualHubRouteTableId) error { + result, err := c.VirtualHubRouteTableV2sDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing VirtualHubRouteTableV2sDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualHubRouteTableV2sDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubroutetablev2sget.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubroutetablev2sget.go new file mode 100644 index 00000000000..0d274e1355a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubroutetablev2sget.go @@ -0,0 +1,53 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubRouteTableV2sGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualHubRouteTableV2 +} + +// VirtualHubRouteTableV2sGet ... +func (c VirtualWANsClient) VirtualHubRouteTableV2sGet(ctx context.Context, id VirtualHubRouteTableId) (result VirtualHubRouteTableV2sGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualHubRouteTableV2 + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubroutetablev2slist.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubroutetablev2slist.go new file mode 100644 index 00000000000..cf9c9ef61a3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubroutetablev2slist.go @@ -0,0 +1,105 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubRouteTableV2sListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualHubRouteTableV2 +} + +type VirtualHubRouteTableV2sListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualHubRouteTableV2 +} + +type VirtualHubRouteTableV2sListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VirtualHubRouteTableV2sListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VirtualHubRouteTableV2sList ... +func (c VirtualWANsClient) VirtualHubRouteTableV2sList(ctx context.Context, id VirtualHubId) (result VirtualHubRouteTableV2sListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VirtualHubRouteTableV2sListCustomPager{}, + Path: fmt.Sprintf("%s/routeTables", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualHubRouteTableV2 `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VirtualHubRouteTableV2sListComplete retrieves all the results into a single object +func (c VirtualWANsClient) VirtualHubRouteTableV2sListComplete(ctx context.Context, id VirtualHubId) (VirtualHubRouteTableV2sListCompleteResult, error) { + return c.VirtualHubRouteTableV2sListCompleteMatchingPredicate(ctx, id, VirtualHubRouteTableV2OperationPredicate{}) +} + +// VirtualHubRouteTableV2sListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) VirtualHubRouteTableV2sListCompleteMatchingPredicate(ctx context.Context, id VirtualHubId, predicate VirtualHubRouteTableV2OperationPredicate) (result VirtualHubRouteTableV2sListCompleteResult, err error) { + items := make([]VirtualHubRouteTableV2, 0) + + resp, err := c.VirtualHubRouteTableV2sList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VirtualHubRouteTableV2sListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubscreateorupdate.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubscreateorupdate.go new file mode 100644 index 00000000000..6b78901c93c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubscreateorupdate.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualHub +} + +// VirtualHubsCreateOrUpdate ... +func (c VirtualWANsClient) VirtualHubsCreateOrUpdate(ctx context.Context, id VirtualHubId, input VirtualHub) (result VirtualHubsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VirtualHubsCreateOrUpdateThenPoll performs VirtualHubsCreateOrUpdate then polls until it's completed +func (c VirtualWANsClient) VirtualHubsCreateOrUpdateThenPoll(ctx context.Context, id VirtualHubId, input VirtualHub) error { + result, err := c.VirtualHubsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VirtualHubsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualHubsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsdelete.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsdelete.go new file mode 100644 index 00000000000..70eebb0a343 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsdelete.go @@ -0,0 +1,71 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VirtualHubsDelete ... +func (c VirtualWANsClient) VirtualHubsDelete(ctx context.Context, id VirtualHubId) (result VirtualHubsDeleteOperationResponse, 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 +} + +// VirtualHubsDeleteThenPoll performs VirtualHubsDelete then polls until it's completed +func (c VirtualWANsClient) VirtualHubsDeleteThenPoll(ctx context.Context, id VirtualHubId) error { + result, err := c.VirtualHubsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing VirtualHubsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualHubsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsget.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsget.go new file mode 100644 index 00000000000..0b1bcbe8573 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsget.go @@ -0,0 +1,53 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualHub +} + +// VirtualHubsGet ... +func (c VirtualWANsClient) VirtualHubsGet(ctx context.Context, id VirtualHubId) (result VirtualHubsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualHub + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsgeteffectivevirtualhubroutes.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsgeteffectivevirtualhubroutes.go new file mode 100644 index 00000000000..1bbae403695 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsgeteffectivevirtualhubroutes.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubsGetEffectiveVirtualHubRoutesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualHubEffectiveRouteList +} + +// VirtualHubsGetEffectiveVirtualHubRoutes ... +func (c VirtualWANsClient) VirtualHubsGetEffectiveVirtualHubRoutes(ctx context.Context, id VirtualHubId, input EffectiveRoutesParameters) (result VirtualHubsGetEffectiveVirtualHubRoutesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/effectiveRoutes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VirtualHubsGetEffectiveVirtualHubRoutesThenPoll performs VirtualHubsGetEffectiveVirtualHubRoutes then polls until it's completed +func (c VirtualWANsClient) VirtualHubsGetEffectiveVirtualHubRoutesThenPoll(ctx context.Context, id VirtualHubId, input EffectiveRoutesParameters) error { + result, err := c.VirtualHubsGetEffectiveVirtualHubRoutes(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VirtualHubsGetEffectiveVirtualHubRoutes: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualHubsGetEffectiveVirtualHubRoutes: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsgetinboundroutes.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsgetinboundroutes.go new file mode 100644 index 00000000000..03114d0c238 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsgetinboundroutes.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubsGetInboundRoutesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *EffectiveRouteMapRouteList +} + +// VirtualHubsGetInboundRoutes ... +func (c VirtualWANsClient) VirtualHubsGetInboundRoutes(ctx context.Context, id VirtualHubId, input GetInboundRoutesParameters) (result VirtualHubsGetInboundRoutesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/inboundRoutes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VirtualHubsGetInboundRoutesThenPoll performs VirtualHubsGetInboundRoutes then polls until it's completed +func (c VirtualWANsClient) VirtualHubsGetInboundRoutesThenPoll(ctx context.Context, id VirtualHubId, input GetInboundRoutesParameters) error { + result, err := c.VirtualHubsGetInboundRoutes(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VirtualHubsGetInboundRoutes: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualHubsGetInboundRoutes: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsgetoutboundroutes.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsgetoutboundroutes.go new file mode 100644 index 00000000000..9a715f99613 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsgetoutboundroutes.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubsGetOutboundRoutesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *EffectiveRouteMapRouteList +} + +// VirtualHubsGetOutboundRoutes ... +func (c VirtualWANsClient) VirtualHubsGetOutboundRoutes(ctx context.Context, id VirtualHubId, input GetOutboundRoutesParameters) (result VirtualHubsGetOutboundRoutesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/outboundRoutes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VirtualHubsGetOutboundRoutesThenPoll performs VirtualHubsGetOutboundRoutes then polls until it's completed +func (c VirtualWANsClient) VirtualHubsGetOutboundRoutesThenPoll(ctx context.Context, id VirtualHubId, input GetOutboundRoutesParameters) error { + result, err := c.VirtualHubsGetOutboundRoutes(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VirtualHubsGetOutboundRoutes: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualHubsGetOutboundRoutes: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubslist.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubslist.go new file mode 100644 index 00000000000..d8fa3805233 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubslist.go @@ -0,0 +1,106 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualHub +} + +type VirtualHubsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualHub +} + +type VirtualHubsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VirtualHubsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VirtualHubsList ... +func (c VirtualWANsClient) VirtualHubsList(ctx context.Context, id commonids.SubscriptionId) (result VirtualHubsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VirtualHubsListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/virtualHubs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualHub `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VirtualHubsListComplete retrieves all the results into a single object +func (c VirtualWANsClient) VirtualHubsListComplete(ctx context.Context, id commonids.SubscriptionId) (VirtualHubsListCompleteResult, error) { + return c.VirtualHubsListCompleteMatchingPredicate(ctx, id, VirtualHubOperationPredicate{}) +} + +// VirtualHubsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) VirtualHubsListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate VirtualHubOperationPredicate) (result VirtualHubsListCompleteResult, err error) { + items := make([]VirtualHub, 0) + + resp, err := c.VirtualHubsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VirtualHubsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubslistbyresourcegroup.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubslistbyresourcegroup.go new file mode 100644 index 00000000000..9427d542093 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubsListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualHub +} + +type VirtualHubsListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualHub +} + +type VirtualHubsListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VirtualHubsListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VirtualHubsListByResourceGroup ... +func (c VirtualWANsClient) VirtualHubsListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result VirtualHubsListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VirtualHubsListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/virtualHubs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualHub `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VirtualHubsListByResourceGroupComplete retrieves all the results into a single object +func (c VirtualWANsClient) VirtualHubsListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (VirtualHubsListByResourceGroupCompleteResult, error) { + return c.VirtualHubsListByResourceGroupCompleteMatchingPredicate(ctx, id, VirtualHubOperationPredicate{}) +} + +// VirtualHubsListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) VirtualHubsListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate VirtualHubOperationPredicate) (result VirtualHubsListByResourceGroupCompleteResult, err error) { + items := make([]VirtualHub, 0) + + resp, err := c.VirtualHubsListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VirtualHubsListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsupdatetags.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsupdatetags.go new file mode 100644 index 00000000000..23f6df52743 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualhubsupdatetags.go @@ -0,0 +1,57 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubsUpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualHub +} + +// VirtualHubsUpdateTags ... +func (c VirtualWANsClient) VirtualHubsUpdateTags(ctx context.Context, id VirtualHubId, input TagsObject) (result VirtualHubsUpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualHub + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualwanscreateorupdate.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualwanscreateorupdate.go new file mode 100644 index 00000000000..310b768e4e5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualwanscreateorupdate.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualWansCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VirtualWAN +} + +// VirtualWansCreateOrUpdate ... +func (c VirtualWANsClient) VirtualWansCreateOrUpdate(ctx context.Context, id VirtualWANId, input VirtualWAN) (result VirtualWansCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VirtualWansCreateOrUpdateThenPoll performs VirtualWansCreateOrUpdate then polls until it's completed +func (c VirtualWANsClient) VirtualWansCreateOrUpdateThenPoll(ctx context.Context, id VirtualWANId, input VirtualWAN) error { + result, err := c.VirtualWansCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VirtualWansCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualWansCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualwansdelete.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualwansdelete.go new file mode 100644 index 00000000000..4ce708a8edd --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualwansdelete.go @@ -0,0 +1,71 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualWansDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VirtualWansDelete ... +func (c VirtualWANsClient) VirtualWansDelete(ctx context.Context, id VirtualWANId) (result VirtualWansDeleteOperationResponse, 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 +} + +// VirtualWansDeleteThenPoll performs VirtualWansDelete then polls until it's completed +func (c VirtualWANsClient) VirtualWansDeleteThenPoll(ctx context.Context, id VirtualWANId) error { + result, err := c.VirtualWansDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing VirtualWansDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VirtualWansDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualwansget.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualwansget.go new file mode 100644 index 00000000000..66d801a779a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualwansget.go @@ -0,0 +1,53 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualWansGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VirtualWAN +} + +// VirtualWansGet ... +func (c VirtualWANsClient) VirtualWansGet(ctx context.Context, id VirtualWANId) (result VirtualWansGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualWAN + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualwanslist.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualwanslist.go new file mode 100644 index 00000000000..8a8cb8514e3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualwanslist.go @@ -0,0 +1,106 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualWansListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualWAN +} + +type VirtualWansListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualWAN +} + +type VirtualWansListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VirtualWansListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VirtualWansList ... +func (c VirtualWANsClient) VirtualWansList(ctx context.Context, id commonids.SubscriptionId) (result VirtualWansListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VirtualWansListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/virtualWans", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualWAN `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VirtualWansListComplete retrieves all the results into a single object +func (c VirtualWANsClient) VirtualWansListComplete(ctx context.Context, id commonids.SubscriptionId) (VirtualWansListCompleteResult, error) { + return c.VirtualWansListCompleteMatchingPredicate(ctx, id, VirtualWANOperationPredicate{}) +} + +// VirtualWansListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) VirtualWansListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate VirtualWANOperationPredicate) (result VirtualWansListCompleteResult, err error) { + items := make([]VirtualWAN, 0) + + resp, err := c.VirtualWansList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VirtualWansListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_virtualwanslistbyresourcegroup.go b/resource-manager/network/2024-07-01/virtualwans/method_virtualwanslistbyresourcegroup.go new file mode 100644 index 00000000000..24b02c20232 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_virtualwanslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualWansListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VirtualWAN +} + +type VirtualWansListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []VirtualWAN +} + +type VirtualWansListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VirtualWansListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VirtualWansListByResourceGroup ... +func (c VirtualWANsClient) VirtualWansListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result VirtualWansListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VirtualWansListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/virtualWans", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VirtualWAN `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VirtualWansListByResourceGroupComplete retrieves all the results into a single object +func (c VirtualWANsClient) VirtualWansListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (VirtualWansListByResourceGroupCompleteResult, error) { + return c.VirtualWansListByResourceGroupCompleteMatchingPredicate(ctx, id, VirtualWANOperationPredicate{}) +} + +// VirtualWansListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) VirtualWansListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate VirtualWANOperationPredicate) (result VirtualWansListByResourceGroupCompleteResult, err error) { + items := make([]VirtualWAN, 0) + + resp, err := c.VirtualWansListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VirtualWansListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionscreateorupdate.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionscreateorupdate.go new file mode 100644 index 00000000000..58f8bec5b87 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionscreateorupdate.go @@ -0,0 +1,76 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnConnectionsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VpnConnection +} + +// VpnConnectionsCreateOrUpdate ... +func (c VirtualWANsClient) VpnConnectionsCreateOrUpdate(ctx context.Context, id commonids.VPNConnectionId, input VpnConnection) (result VpnConnectionsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VpnConnectionsCreateOrUpdateThenPoll performs VpnConnectionsCreateOrUpdate then polls until it's completed +func (c VirtualWANsClient) VpnConnectionsCreateOrUpdateThenPoll(ctx context.Context, id commonids.VPNConnectionId, input VpnConnection) error { + result, err := c.VpnConnectionsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VpnConnectionsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VpnConnectionsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionsdelete.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionsdelete.go new file mode 100644 index 00000000000..12193490035 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionsdelete.go @@ -0,0 +1,72 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnConnectionsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VpnConnectionsDelete ... +func (c VirtualWANsClient) VpnConnectionsDelete(ctx context.Context, id commonids.VPNConnectionId) (result VpnConnectionsDeleteOperationResponse, 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 +} + +// VpnConnectionsDeleteThenPoll performs VpnConnectionsDelete then polls until it's completed +func (c VirtualWANsClient) VpnConnectionsDeleteThenPoll(ctx context.Context, id commonids.VPNConnectionId) error { + result, err := c.VpnConnectionsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing VpnConnectionsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VpnConnectionsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionsget.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionsget.go new file mode 100644 index 00000000000..ca7d4d2a9b4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionsget.go @@ -0,0 +1,54 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnConnectionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VpnConnection +} + +// VpnConnectionsGet ... +func (c VirtualWANsClient) VpnConnectionsGet(ctx context.Context, id commonids.VPNConnectionId) (result VpnConnectionsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VpnConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionslistbyvpngateway.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionslistbyvpngateway.go new file mode 100644 index 00000000000..d1ed0d12708 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionslistbyvpngateway.go @@ -0,0 +1,105 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnConnectionsListByVpnGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VpnConnection +} + +type VpnConnectionsListByVpnGatewayCompleteResult struct { + LatestHttpResponse *http.Response + Items []VpnConnection +} + +type VpnConnectionsListByVpnGatewayCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VpnConnectionsListByVpnGatewayCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VpnConnectionsListByVpnGateway ... +func (c VirtualWANsClient) VpnConnectionsListByVpnGateway(ctx context.Context, id VpnGatewayId) (result VpnConnectionsListByVpnGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VpnConnectionsListByVpnGatewayCustomPager{}, + Path: fmt.Sprintf("%s/vpnConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VpnConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VpnConnectionsListByVpnGatewayComplete retrieves all the results into a single object +func (c VirtualWANsClient) VpnConnectionsListByVpnGatewayComplete(ctx context.Context, id VpnGatewayId) (VpnConnectionsListByVpnGatewayCompleteResult, error) { + return c.VpnConnectionsListByVpnGatewayCompleteMatchingPredicate(ctx, id, VpnConnectionOperationPredicate{}) +} + +// VpnConnectionsListByVpnGatewayCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) VpnConnectionsListByVpnGatewayCompleteMatchingPredicate(ctx context.Context, id VpnGatewayId, predicate VpnConnectionOperationPredicate) (result VpnConnectionsListByVpnGatewayCompleteResult, err error) { + items := make([]VpnConnection, 0) + + resp, err := c.VpnConnectionsListByVpnGateway(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VpnConnectionsListByVpnGatewayCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionsstartpacketcapture.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionsstartpacketcapture.go new file mode 100644 index 00000000000..98551e48f98 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionsstartpacketcapture.go @@ -0,0 +1,76 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnConnectionsStartPacketCaptureOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// VpnConnectionsStartPacketCapture ... +func (c VirtualWANsClient) VpnConnectionsStartPacketCapture(ctx context.Context, id commonids.VPNConnectionId, input VpnConnectionPacketCaptureStartParameters) (result VpnConnectionsStartPacketCaptureOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startpacketcapture", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VpnConnectionsStartPacketCaptureThenPoll performs VpnConnectionsStartPacketCapture then polls until it's completed +func (c VirtualWANsClient) VpnConnectionsStartPacketCaptureThenPoll(ctx context.Context, id commonids.VPNConnectionId, input VpnConnectionPacketCaptureStartParameters) error { + result, err := c.VpnConnectionsStartPacketCapture(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VpnConnectionsStartPacketCapture: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VpnConnectionsStartPacketCapture: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionsstoppacketcapture.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionsstoppacketcapture.go new file mode 100644 index 00000000000..b32b88c6969 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnconnectionsstoppacketcapture.go @@ -0,0 +1,76 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnConnectionsStopPacketCaptureOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// VpnConnectionsStopPacketCapture ... +func (c VirtualWANsClient) VpnConnectionsStopPacketCapture(ctx context.Context, id commonids.VPNConnectionId, input VpnConnectionPacketCaptureStopParameters) (result VpnConnectionsStopPacketCaptureOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stoppacketcapture", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VpnConnectionsStopPacketCaptureThenPoll performs VpnConnectionsStopPacketCapture then polls until it's completed +func (c VirtualWANsClient) VpnConnectionsStopPacketCaptureThenPoll(ctx context.Context, id commonids.VPNConnectionId, input VpnConnectionPacketCaptureStopParameters) error { + result, err := c.VpnConnectionsStopPacketCapture(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VpnConnectionsStopPacketCapture: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VpnConnectionsStopPacketCapture: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpngatewayscreateorupdate.go b/resource-manager/network/2024-07-01/virtualwans/method_vpngatewayscreateorupdate.go new file mode 100644 index 00000000000..2cabc7eba19 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpngatewayscreateorupdate.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGatewaysCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VpnGateway +} + +// VpnGatewaysCreateOrUpdate ... +func (c VirtualWANsClient) VpnGatewaysCreateOrUpdate(ctx context.Context, id VpnGatewayId, input VpnGateway) (result VpnGatewaysCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VpnGatewaysCreateOrUpdateThenPoll performs VpnGatewaysCreateOrUpdate then polls until it's completed +func (c VirtualWANsClient) VpnGatewaysCreateOrUpdateThenPoll(ctx context.Context, id VpnGatewayId, input VpnGateway) error { + result, err := c.VpnGatewaysCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VpnGatewaysCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VpnGatewaysCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpngatewaysdelete.go b/resource-manager/network/2024-07-01/virtualwans/method_vpngatewaysdelete.go new file mode 100644 index 00000000000..76d02ba38d5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpngatewaysdelete.go @@ -0,0 +1,71 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGatewaysDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VpnGatewaysDelete ... +func (c VirtualWANsClient) VpnGatewaysDelete(ctx context.Context, id VpnGatewayId) (result VpnGatewaysDeleteOperationResponse, 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 +} + +// VpnGatewaysDeleteThenPoll performs VpnGatewaysDelete then polls until it's completed +func (c VirtualWANsClient) VpnGatewaysDeleteThenPoll(ctx context.Context, id VpnGatewayId) error { + result, err := c.VpnGatewaysDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing VpnGatewaysDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VpnGatewaysDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpngatewaysget.go b/resource-manager/network/2024-07-01/virtualwans/method_vpngatewaysget.go new file mode 100644 index 00000000000..0793829ea75 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpngatewaysget.go @@ -0,0 +1,53 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGatewaysGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VpnGateway +} + +// VpnGatewaysGet ... +func (c VirtualWANsClient) VpnGatewaysGet(ctx context.Context, id VpnGatewayId) (result VpnGatewaysGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VpnGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpngatewayslist.go b/resource-manager/network/2024-07-01/virtualwans/method_vpngatewayslist.go new file mode 100644 index 00000000000..d5ecf5c40ee --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpngatewayslist.go @@ -0,0 +1,106 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGatewaysListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VpnGateway +} + +type VpnGatewaysListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VpnGateway +} + +type VpnGatewaysListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VpnGatewaysListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VpnGatewaysList ... +func (c VirtualWANsClient) VpnGatewaysList(ctx context.Context, id commonids.SubscriptionId) (result VpnGatewaysListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VpnGatewaysListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/vpnGateways", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VpnGateway `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VpnGatewaysListComplete retrieves all the results into a single object +func (c VirtualWANsClient) VpnGatewaysListComplete(ctx context.Context, id commonids.SubscriptionId) (VpnGatewaysListCompleteResult, error) { + return c.VpnGatewaysListCompleteMatchingPredicate(ctx, id, VpnGatewayOperationPredicate{}) +} + +// VpnGatewaysListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) VpnGatewaysListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate VpnGatewayOperationPredicate) (result VpnGatewaysListCompleteResult, err error) { + items := make([]VpnGateway, 0) + + resp, err := c.VpnGatewaysList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VpnGatewaysListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpngatewayslistbyresourcegroup.go b/resource-manager/network/2024-07-01/virtualwans/method_vpngatewayslistbyresourcegroup.go new file mode 100644 index 00000000000..e0e679927ad --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpngatewayslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGatewaysListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VpnGateway +} + +type VpnGatewaysListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []VpnGateway +} + +type VpnGatewaysListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VpnGatewaysListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VpnGatewaysListByResourceGroup ... +func (c VirtualWANsClient) VpnGatewaysListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result VpnGatewaysListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VpnGatewaysListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/vpnGateways", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VpnGateway `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VpnGatewaysListByResourceGroupComplete retrieves all the results into a single object +func (c VirtualWANsClient) VpnGatewaysListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (VpnGatewaysListByResourceGroupCompleteResult, error) { + return c.VpnGatewaysListByResourceGroupCompleteMatchingPredicate(ctx, id, VpnGatewayOperationPredicate{}) +} + +// VpnGatewaysListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) VpnGatewaysListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate VpnGatewayOperationPredicate) (result VpnGatewaysListByResourceGroupCompleteResult, err error) { + items := make([]VpnGateway, 0) + + resp, err := c.VpnGatewaysListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VpnGatewaysListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionsgetallsharedkeys.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionsgetallsharedkeys.go new file mode 100644 index 00000000000..050f49ad115 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionsgetallsharedkeys.go @@ -0,0 +1,105 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnLinkConnectionsGetAllSharedKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ConnectionSharedKeyResult +} + +type VpnLinkConnectionsGetAllSharedKeysCompleteResult struct { + LatestHttpResponse *http.Response + Items []ConnectionSharedKeyResult +} + +type VpnLinkConnectionsGetAllSharedKeysCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VpnLinkConnectionsGetAllSharedKeysCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VpnLinkConnectionsGetAllSharedKeys ... +func (c VirtualWANsClient) VpnLinkConnectionsGetAllSharedKeys(ctx context.Context, id VpnLinkConnectionId) (result VpnLinkConnectionsGetAllSharedKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VpnLinkConnectionsGetAllSharedKeysCustomPager{}, + Path: fmt.Sprintf("%s/sharedKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ConnectionSharedKeyResult `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VpnLinkConnectionsGetAllSharedKeysComplete retrieves all the results into a single object +func (c VirtualWANsClient) VpnLinkConnectionsGetAllSharedKeysComplete(ctx context.Context, id VpnLinkConnectionId) (VpnLinkConnectionsGetAllSharedKeysCompleteResult, error) { + return c.VpnLinkConnectionsGetAllSharedKeysCompleteMatchingPredicate(ctx, id, ConnectionSharedKeyResultOperationPredicate{}) +} + +// VpnLinkConnectionsGetAllSharedKeysCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) VpnLinkConnectionsGetAllSharedKeysCompleteMatchingPredicate(ctx context.Context, id VpnLinkConnectionId, predicate ConnectionSharedKeyResultOperationPredicate) (result VpnLinkConnectionsGetAllSharedKeysCompleteResult, err error) { + items := make([]ConnectionSharedKeyResult, 0) + + resp, err := c.VpnLinkConnectionsGetAllSharedKeys(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VpnLinkConnectionsGetAllSharedKeysCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionsgetdefaultsharedkey.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionsgetdefaultsharedkey.go new file mode 100644 index 00000000000..aa16f486d53 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionsgetdefaultsharedkey.go @@ -0,0 +1,54 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnLinkConnectionsGetDefaultSharedKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionSharedKeyResult +} + +// VpnLinkConnectionsGetDefaultSharedKey ... +func (c VirtualWANsClient) VpnLinkConnectionsGetDefaultSharedKey(ctx context.Context, id VpnLinkConnectionId) (result VpnLinkConnectionsGetDefaultSharedKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sharedKeys/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectionSharedKeyResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionsgetikesas.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionsgetikesas.go new file mode 100644 index 00000000000..5ecf6a6d2e7 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionsgetikesas.go @@ -0,0 +1,71 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnLinkConnectionsGetIkeSasOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// VpnLinkConnectionsGetIkeSas ... +func (c VirtualWANsClient) VpnLinkConnectionsGetIkeSas(ctx context.Context, id VpnLinkConnectionId) (result VpnLinkConnectionsGetIkeSasOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getikesas", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VpnLinkConnectionsGetIkeSasThenPoll performs VpnLinkConnectionsGetIkeSas then polls until it's completed +func (c VirtualWANsClient) VpnLinkConnectionsGetIkeSasThenPoll(ctx context.Context, id VpnLinkConnectionId) error { + result, err := c.VpnLinkConnectionsGetIkeSas(ctx, id) + if err != nil { + return fmt.Errorf("performing VpnLinkConnectionsGetIkeSas: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VpnLinkConnectionsGetIkeSas: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionslistbyvpnconnection.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionslistbyvpnconnection.go new file mode 100644 index 00000000000..28dcee0d679 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionslistbyvpnconnection.go @@ -0,0 +1,106 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnLinkConnectionsListByVpnConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VpnSiteLinkConnection +} + +type VpnLinkConnectionsListByVpnConnectionCompleteResult struct { + LatestHttpResponse *http.Response + Items []VpnSiteLinkConnection +} + +type VpnLinkConnectionsListByVpnConnectionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VpnLinkConnectionsListByVpnConnectionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VpnLinkConnectionsListByVpnConnection ... +func (c VirtualWANsClient) VpnLinkConnectionsListByVpnConnection(ctx context.Context, id commonids.VPNConnectionId) (result VpnLinkConnectionsListByVpnConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VpnLinkConnectionsListByVpnConnectionCustomPager{}, + Path: fmt.Sprintf("%s/vpnLinkConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VpnSiteLinkConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VpnLinkConnectionsListByVpnConnectionComplete retrieves all the results into a single object +func (c VirtualWANsClient) VpnLinkConnectionsListByVpnConnectionComplete(ctx context.Context, id commonids.VPNConnectionId) (VpnLinkConnectionsListByVpnConnectionCompleteResult, error) { + return c.VpnLinkConnectionsListByVpnConnectionCompleteMatchingPredicate(ctx, id, VpnSiteLinkConnectionOperationPredicate{}) +} + +// VpnLinkConnectionsListByVpnConnectionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) VpnLinkConnectionsListByVpnConnectionCompleteMatchingPredicate(ctx context.Context, id commonids.VPNConnectionId, predicate VpnSiteLinkConnectionOperationPredicate) (result VpnLinkConnectionsListByVpnConnectionCompleteResult, err error) { + items := make([]VpnSiteLinkConnection, 0) + + resp, err := c.VpnLinkConnectionsListByVpnConnection(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VpnLinkConnectionsListByVpnConnectionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionslistdefaultsharedkey.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionslistdefaultsharedkey.go new file mode 100644 index 00000000000..61d6ae83529 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionslistdefaultsharedkey.go @@ -0,0 +1,54 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnLinkConnectionsListDefaultSharedKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionSharedKeyResult +} + +// VpnLinkConnectionsListDefaultSharedKey ... +func (c VirtualWANsClient) VpnLinkConnectionsListDefaultSharedKey(ctx context.Context, id VpnLinkConnectionId) (result VpnLinkConnectionsListDefaultSharedKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sharedKeys/default/listSharedKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectionSharedKeyResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionssetorinitdefaultsharedkey.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionssetorinitdefaultsharedkey.go new file mode 100644 index 00000000000..b4ae5551e76 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnlinkconnectionssetorinitdefaultsharedkey.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnLinkConnectionsSetOrInitDefaultSharedKeyOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionSharedKeyResult +} + +// VpnLinkConnectionsSetOrInitDefaultSharedKey ... +func (c VirtualWANsClient) VpnLinkConnectionsSetOrInitDefaultSharedKey(ctx context.Context, id VpnLinkConnectionId, input ConnectionSharedKeyResult) (result VpnLinkConnectionsSetOrInitDefaultSharedKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/sharedKeys/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VpnLinkConnectionsSetOrInitDefaultSharedKeyThenPoll performs VpnLinkConnectionsSetOrInitDefaultSharedKey then polls until it's completed +func (c VirtualWANsClient) VpnLinkConnectionsSetOrInitDefaultSharedKeyThenPoll(ctx context.Context, id VpnLinkConnectionId, input ConnectionSharedKeyResult) error { + result, err := c.VpnLinkConnectionsSetOrInitDefaultSharedKey(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VpnLinkConnectionsSetOrInitDefaultSharedKey: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VpnLinkConnectionsSetOrInitDefaultSharedKey: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationsassociatedwithvirtualwanlist.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationsassociatedwithvirtualwanlist.go new file mode 100644 index 00000000000..2f7ae87144e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationsassociatedwithvirtualwanlist.go @@ -0,0 +1,71 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationsAssociatedWithVirtualWanListOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VpnServerConfigurationsResponse +} + +// VpnServerConfigurationsAssociatedWithVirtualWanList ... +func (c VirtualWANsClient) VpnServerConfigurationsAssociatedWithVirtualWanList(ctx context.Context, id VirtualWANId) (result VpnServerConfigurationsAssociatedWithVirtualWanListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/vpnServerConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VpnServerConfigurationsAssociatedWithVirtualWanListThenPoll performs VpnServerConfigurationsAssociatedWithVirtualWanList then polls until it's completed +func (c VirtualWANsClient) VpnServerConfigurationsAssociatedWithVirtualWanListThenPoll(ctx context.Context, id VirtualWANId) error { + result, err := c.VpnServerConfigurationsAssociatedWithVirtualWanList(ctx, id) + if err != nil { + return fmt.Errorf("performing VpnServerConfigurationsAssociatedWithVirtualWanList: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VpnServerConfigurationsAssociatedWithVirtualWanList: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationscreateorupdate.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationscreateorupdate.go new file mode 100644 index 00000000000..256562205b9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationscreateorupdate.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VpnServerConfiguration +} + +// VpnServerConfigurationsCreateOrUpdate ... +func (c VirtualWANsClient) VpnServerConfigurationsCreateOrUpdate(ctx context.Context, id VpnServerConfigurationId, input VpnServerConfiguration) (result VpnServerConfigurationsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VpnServerConfigurationsCreateOrUpdateThenPoll performs VpnServerConfigurationsCreateOrUpdate then polls until it's completed +func (c VirtualWANsClient) VpnServerConfigurationsCreateOrUpdateThenPoll(ctx context.Context, id VpnServerConfigurationId, input VpnServerConfiguration) error { + result, err := c.VpnServerConfigurationsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VpnServerConfigurationsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VpnServerConfigurationsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationsdelete.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationsdelete.go new file mode 100644 index 00000000000..2edde34518e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationsdelete.go @@ -0,0 +1,71 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VpnServerConfigurationsDelete ... +func (c VirtualWANsClient) VpnServerConfigurationsDelete(ctx context.Context, id VpnServerConfigurationId) (result VpnServerConfigurationsDeleteOperationResponse, 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 +} + +// VpnServerConfigurationsDeleteThenPoll performs VpnServerConfigurationsDelete then polls until it's completed +func (c VirtualWANsClient) VpnServerConfigurationsDeleteThenPoll(ctx context.Context, id VpnServerConfigurationId) error { + result, err := c.VpnServerConfigurationsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing VpnServerConfigurationsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VpnServerConfigurationsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationsget.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationsget.go new file mode 100644 index 00000000000..5355630843f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationsget.go @@ -0,0 +1,53 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VpnServerConfiguration +} + +// VpnServerConfigurationsGet ... +func (c VirtualWANsClient) VpnServerConfigurationsGet(ctx context.Context, id VpnServerConfigurationId) (result VpnServerConfigurationsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VpnServerConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationslist.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationslist.go new file mode 100644 index 00000000000..914118474d5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationslist.go @@ -0,0 +1,106 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VpnServerConfiguration +} + +type VpnServerConfigurationsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VpnServerConfiguration +} + +type VpnServerConfigurationsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VpnServerConfigurationsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VpnServerConfigurationsList ... +func (c VirtualWANsClient) VpnServerConfigurationsList(ctx context.Context, id commonids.SubscriptionId) (result VpnServerConfigurationsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VpnServerConfigurationsListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/vpnServerConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VpnServerConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VpnServerConfigurationsListComplete retrieves all the results into a single object +func (c VirtualWANsClient) VpnServerConfigurationsListComplete(ctx context.Context, id commonids.SubscriptionId) (VpnServerConfigurationsListCompleteResult, error) { + return c.VpnServerConfigurationsListCompleteMatchingPredicate(ctx, id, VpnServerConfigurationOperationPredicate{}) +} + +// VpnServerConfigurationsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) VpnServerConfigurationsListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate VpnServerConfigurationOperationPredicate) (result VpnServerConfigurationsListCompleteResult, err error) { + items := make([]VpnServerConfiguration, 0) + + resp, err := c.VpnServerConfigurationsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VpnServerConfigurationsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationslistbyresourcegroup.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationslistbyresourcegroup.go new file mode 100644 index 00000000000..6653716f5fe --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnserverconfigurationslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationsListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VpnServerConfiguration +} + +type VpnServerConfigurationsListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []VpnServerConfiguration +} + +type VpnServerConfigurationsListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VpnServerConfigurationsListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VpnServerConfigurationsListByResourceGroup ... +func (c VirtualWANsClient) VpnServerConfigurationsListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result VpnServerConfigurationsListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VpnServerConfigurationsListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/vpnServerConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VpnServerConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VpnServerConfigurationsListByResourceGroupComplete retrieves all the results into a single object +func (c VirtualWANsClient) VpnServerConfigurationsListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (VpnServerConfigurationsListByResourceGroupCompleteResult, error) { + return c.VpnServerConfigurationsListByResourceGroupCompleteMatchingPredicate(ctx, id, VpnServerConfigurationOperationPredicate{}) +} + +// VpnServerConfigurationsListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) VpnServerConfigurationsListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate VpnServerConfigurationOperationPredicate) (result VpnServerConfigurationsListByResourceGroupCompleteResult, err error) { + items := make([]VpnServerConfiguration, 0) + + resp, err := c.VpnServerConfigurationsListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VpnServerConfigurationsListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnsitelinkconnectionsget.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnsitelinkconnectionsget.go new file mode 100644 index 00000000000..b2fed5d6de1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnsitelinkconnectionsget.go @@ -0,0 +1,53 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSiteLinkConnectionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VpnSiteLinkConnection +} + +// VpnSiteLinkConnectionsGet ... +func (c VirtualWANsClient) VpnSiteLinkConnectionsGet(ctx context.Context, id VpnLinkConnectionId) (result VpnSiteLinkConnectionsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VpnSiteLinkConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnsitelinksget.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnsitelinksget.go new file mode 100644 index 00000000000..018f1ad8f67 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnsitelinksget.go @@ -0,0 +1,53 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSiteLinksGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VpnSiteLink +} + +// VpnSiteLinksGet ... +func (c VirtualWANsClient) VpnSiteLinksGet(ctx context.Context, id VpnSiteLinkId) (result VpnSiteLinksGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VpnSiteLink + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnsitelinkslistbyvpnsite.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnsitelinkslistbyvpnsite.go new file mode 100644 index 00000000000..584c5170718 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnsitelinkslistbyvpnsite.go @@ -0,0 +1,105 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSiteLinksListByVpnSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VpnSiteLink +} + +type VpnSiteLinksListByVpnSiteCompleteResult struct { + LatestHttpResponse *http.Response + Items []VpnSiteLink +} + +type VpnSiteLinksListByVpnSiteCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VpnSiteLinksListByVpnSiteCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VpnSiteLinksListByVpnSite ... +func (c VirtualWANsClient) VpnSiteLinksListByVpnSite(ctx context.Context, id VpnSiteId) (result VpnSiteLinksListByVpnSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VpnSiteLinksListByVpnSiteCustomPager{}, + Path: fmt.Sprintf("%s/vpnSiteLinks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VpnSiteLink `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VpnSiteLinksListByVpnSiteComplete retrieves all the results into a single object +func (c VirtualWANsClient) VpnSiteLinksListByVpnSiteComplete(ctx context.Context, id VpnSiteId) (VpnSiteLinksListByVpnSiteCompleteResult, error) { + return c.VpnSiteLinksListByVpnSiteCompleteMatchingPredicate(ctx, id, VpnSiteLinkOperationPredicate{}) +} + +// VpnSiteLinksListByVpnSiteCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) VpnSiteLinksListByVpnSiteCompleteMatchingPredicate(ctx context.Context, id VpnSiteId, predicate VpnSiteLinkOperationPredicate) (result VpnSiteLinksListByVpnSiteCompleteResult, err error) { + items := make([]VpnSiteLink, 0) + + resp, err := c.VpnSiteLinksListByVpnSite(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VpnSiteLinksListByVpnSiteCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnsitesconfigurationdownload.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnsitesconfigurationdownload.go new file mode 100644 index 00000000000..a20fd02e0fc --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnsitesconfigurationdownload.go @@ -0,0 +1,74 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSitesConfigurationDownloadOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VpnSitesConfigurationDownload ... +func (c VirtualWANsClient) VpnSitesConfigurationDownload(ctx context.Context, id VirtualWANId, input GetVpnSitesConfigurationRequest) (result VpnSitesConfigurationDownloadOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/vpnConfiguration", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VpnSitesConfigurationDownloadThenPoll performs VpnSitesConfigurationDownload then polls until it's completed +func (c VirtualWANsClient) VpnSitesConfigurationDownloadThenPoll(ctx context.Context, id VirtualWANId, input GetVpnSitesConfigurationRequest) error { + result, err := c.VpnSitesConfigurationDownload(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VpnSitesConfigurationDownload: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VpnSitesConfigurationDownload: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnsitescreateorupdate.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnsitescreateorupdate.go new file mode 100644 index 00000000000..2b93c69c66a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnsitescreateorupdate.go @@ -0,0 +1,75 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSitesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VpnSite +} + +// VpnSitesCreateOrUpdate ... +func (c VirtualWANsClient) VpnSitesCreateOrUpdate(ctx context.Context, id VpnSiteId, input VpnSite) (result VpnSitesCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// VpnSitesCreateOrUpdateThenPoll performs VpnSitesCreateOrUpdate then polls until it's completed +func (c VirtualWANsClient) VpnSitesCreateOrUpdateThenPoll(ctx context.Context, id VpnSiteId, input VpnSite) error { + result, err := c.VpnSitesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing VpnSitesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VpnSitesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnsitesdelete.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnsitesdelete.go new file mode 100644 index 00000000000..f3b27d7f18a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnsitesdelete.go @@ -0,0 +1,71 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSitesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// VpnSitesDelete ... +func (c VirtualWANsClient) VpnSitesDelete(ctx context.Context, id VpnSiteId) (result VpnSitesDeleteOperationResponse, 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 +} + +// VpnSitesDeleteThenPoll performs VpnSitesDelete then polls until it's completed +func (c VirtualWANsClient) VpnSitesDeleteThenPoll(ctx context.Context, id VpnSiteId) error { + result, err := c.VpnSitesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing VpnSitesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after VpnSitesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnsitesget.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnsitesget.go new file mode 100644 index 00000000000..a250df018ce --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnsitesget.go @@ -0,0 +1,53 @@ +package virtualwans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSitesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VpnSite +} + +// VpnSitesGet ... +func (c VirtualWANsClient) VpnSitesGet(ctx context.Context, id VpnSiteId) (result VpnSitesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VpnSite + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnsiteslist.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnsiteslist.go new file mode 100644 index 00000000000..38bc5c86363 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnsiteslist.go @@ -0,0 +1,106 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSitesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VpnSite +} + +type VpnSitesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []VpnSite +} + +type VpnSitesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VpnSitesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VpnSitesList ... +func (c VirtualWANsClient) VpnSitesList(ctx context.Context, id commonids.SubscriptionId) (result VpnSitesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VpnSitesListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/vpnSites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VpnSite `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VpnSitesListComplete retrieves all the results into a single object +func (c VirtualWANsClient) VpnSitesListComplete(ctx context.Context, id commonids.SubscriptionId) (VpnSitesListCompleteResult, error) { + return c.VpnSitesListCompleteMatchingPredicate(ctx, id, VpnSiteOperationPredicate{}) +} + +// VpnSitesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) VpnSitesListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate VpnSiteOperationPredicate) (result VpnSitesListCompleteResult, err error) { + items := make([]VpnSite, 0) + + resp, err := c.VpnSitesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VpnSitesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/method_vpnsiteslistbyresourcegroup.go b/resource-manager/network/2024-07-01/virtualwans/method_vpnsiteslistbyresourcegroup.go new file mode 100644 index 00000000000..276e64b30d1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/method_vpnsiteslistbyresourcegroup.go @@ -0,0 +1,106 @@ +package virtualwans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSitesListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VpnSite +} + +type VpnSitesListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []VpnSite +} + +type VpnSitesListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *VpnSitesListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// VpnSitesListByResourceGroup ... +func (c VirtualWANsClient) VpnSitesListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result VpnSitesListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &VpnSitesListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/vpnSites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]VpnSite `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// VpnSitesListByResourceGroupComplete retrieves all the results into a single object +func (c VirtualWANsClient) VpnSitesListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (VpnSitesListByResourceGroupCompleteResult, error) { + return c.VpnSitesListByResourceGroupCompleteMatchingPredicate(ctx, id, VpnSiteOperationPredicate{}) +} + +// VpnSitesListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VirtualWANsClient) VpnSitesListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate VpnSiteOperationPredicate) (result VpnSitesListByResourceGroupCompleteResult, err error) { + items := make([]VpnSite, 0) + + resp, err := c.VpnSitesListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = VpnSitesListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_aadauthenticationparameters.go b/resource-manager/network/2024-07-01/virtualwans/model_aadauthenticationparameters.go new file mode 100644 index 00000000000..b0d5e53c358 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_aadauthenticationparameters.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AadAuthenticationParameters struct { + AadAudience *string `json:"aadAudience,omitempty"` + AadIssuer *string `json:"aadIssuer,omitempty"` + AadTenant *string `json:"aadTenant,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_action.go b/resource-manager/network/2024-07-01/virtualwans/model_action.go new file mode 100644 index 00000000000..e3c73ef507d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_action.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Action struct { + Parameters *[]Parameter `json:"parameters,omitempty"` + Type *RouteMapActionType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_addressspace.go b/resource-manager/network/2024-07-01/virtualwans/model_addressspace.go new file mode 100644 index 00000000000..8864dd5d9f4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_addressspace.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressSpace struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/virtualwans/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..51a23d1c2c5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/virtualwans/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..adfa8110618 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..c308084cb90 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/virtualwans/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..184f4db35ed --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..96ab63c3c70 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/virtualwans/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..8df94828320 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..0db023773ff --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_backendaddresspool.go b/resource-manager/network/2024-07-01/virtualwans/model_backendaddresspool.go new file mode 100644 index 00000000000..75b3239a673 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..210c422933e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_bgpconnection.go b/resource-manager/network/2024-07-01/virtualwans/model_bgpconnection.go new file mode 100644 index 00000000000..13c77fe2225 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_bgpconnection.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BgpConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BgpConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_bgpconnectionproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_bgpconnectionproperties.go new file mode 100644 index 00000000000..4666e421984 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_bgpconnectionproperties.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BgpConnectionProperties struct { + ConnectionState *HubBgpConnectionStatus `json:"connectionState,omitempty"` + HubVirtualNetworkConnection *SubResource `json:"hubVirtualNetworkConnection,omitempty"` + PeerAsn *int64 `json:"peerAsn,omitempty"` + PeerIP *string `json:"peerIp,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_bgpsettings.go b/resource-manager/network/2024-07-01/virtualwans/model_bgpsettings.go new file mode 100644 index 00000000000..5f96d5acf14 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_bgpsettings.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BgpSettings struct { + Asn *int64 `json:"asn,omitempty"` + BgpPeeringAddress *string `json:"bgpPeeringAddress,omitempty"` + BgpPeeringAddresses *[]IPConfigurationBgpPeeringAddress `json:"bgpPeeringAddresses,omitempty"` + PeerWeight *int64 `json:"peerWeight,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_connectionsharedkeyresult.go b/resource-manager/network/2024-07-01/virtualwans/model_connectionsharedkeyresult.go new file mode 100644 index 00000000000..2ca277eba84 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_connectionsharedkeyresult.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionSharedKeyResult struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SharedKeyProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_criterion.go b/resource-manager/network/2024-07-01/virtualwans/model_criterion.go new file mode 100644 index 00000000000..e7249b64d4d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_criterion.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Criterion struct { + AsPath *[]string `json:"asPath,omitempty"` + Community *[]string `json:"community,omitempty"` + MatchCondition *RouteMapMatchCondition `json:"matchCondition,omitempty"` + RoutePrefix *[]string `json:"routePrefix,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..557a5a01a6d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_ddossettings.go b/resource-manager/network/2024-07-01/virtualwans/model_ddossettings.go new file mode 100644 index 00000000000..82eef09dc62 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_ddossettings.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_delegation.go b/resource-manager/network/2024-07-01/virtualwans/model_delegation.go new file mode 100644 index 00000000000..55eeb1fff81 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_delegation.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_deviceproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_deviceproperties.go new file mode 100644 index 00000000000..9c255349846 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_deviceproperties.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeviceProperties struct { + DeviceModel *string `json:"deviceModel,omitempty"` + DeviceVendor *string `json:"deviceVendor,omitempty"` + LinkSpeedInMbps *int64 `json:"linkSpeedInMbps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_effectiveroutemaproute.go b/resource-manager/network/2024-07-01/virtualwans/model_effectiveroutemaproute.go new file mode 100644 index 00000000000..3a565a687e8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_effectiveroutemaproute.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EffectiveRouteMapRoute struct { + AsPath *string `json:"asPath,omitempty"` + BgpCommunities *string `json:"bgpCommunities,omitempty"` + Prefix *string `json:"prefix,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_effectiveroutemaproutelist.go b/resource-manager/network/2024-07-01/virtualwans/model_effectiveroutemaproutelist.go new file mode 100644 index 00000000000..326acde877b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_effectiveroutemaproutelist.go @@ -0,0 +1,8 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EffectiveRouteMapRouteList struct { + Value *[]EffectiveRouteMapRoute `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_effectiveroutesparameters.go b/resource-manager/network/2024-07-01/virtualwans/model_effectiveroutesparameters.go new file mode 100644 index 00000000000..dab27997ab5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_effectiveroutesparameters.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EffectiveRoutesParameters struct { + ResourceId *string `json:"resourceId,omitempty"` + VirtualWanResourceType *string `json:"virtualWanResourceType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_flowlog.go b/resource-manager/network/2024-07-01/virtualwans/model_flowlog.go new file mode 100644 index 00000000000..bc406232e6a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_flowlog.go @@ -0,0 +1,19 @@ +package virtualwans + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/virtualwans/model_flowlogformatparameters.go new file mode 100644 index 00000000000..3b64c7c567a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..41747177c87 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/virtualwans/model_frontendipconfiguration.go new file mode 100644 index 00000000000..b9c97d1e6a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package virtualwans + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..62b1635a8ed --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_gatewaycustombgpipaddressipconfiguration.go b/resource-manager/network/2024-07-01/virtualwans/model_gatewaycustombgpipaddressipconfiguration.go new file mode 100644 index 00000000000..81c747c0a4a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_gatewaycustombgpipaddressipconfiguration.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayCustomBgpIPAddressIPConfiguration struct { + CustomBgpIPAddress string `json:"customBgpIpAddress"` + IPConfigurationId string `json:"ipConfigurationId"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/virtualwans/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..96c5d2b39e5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_getinboundroutesparameters.go b/resource-manager/network/2024-07-01/virtualwans/model_getinboundroutesparameters.go new file mode 100644 index 00000000000..1407618f660 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_getinboundroutesparameters.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetInboundRoutesParameters struct { + ConnectionType *string `json:"connectionType,omitempty"` + ResourceUri *string `json:"resourceUri,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_getoutboundroutesparameters.go b/resource-manager/network/2024-07-01/virtualwans/model_getoutboundroutesparameters.go new file mode 100644 index 00000000000..19a89a55b10 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_getoutboundroutesparameters.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOutboundRoutesParameters struct { + ConnectionType *string `json:"connectionType,omitempty"` + ResourceUri *string `json:"resourceUri,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_getvpnsitesconfigurationrequest.go b/resource-manager/network/2024-07-01/virtualwans/model_getvpnsitesconfigurationrequest.go new file mode 100644 index 00000000000..cd349d0cb2f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_getvpnsitesconfigurationrequest.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetVpnSitesConfigurationRequest struct { + OutputBlobSasURL string `json:"outputBlobSasUrl"` + VpnSites *[]string `json:"vpnSites,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_hubipconfiguration.go b/resource-manager/network/2024-07-01/virtualwans/model_hubipconfiguration.go new file mode 100644 index 00000000000..c666224646f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_hubipconfiguration.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HubIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_hubipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_hubipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..86c4674860b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_hubipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubIPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_hubroute.go b/resource-manager/network/2024-07-01/virtualwans/model_hubroute.go new file mode 100644 index 00000000000..bc12eef1a4a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_hubroute.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubRoute struct { + DestinationType string `json:"destinationType"` + Destinations []string `json:"destinations"` + Name string `json:"name"` + NextHop string `json:"nextHop"` + NextHopType string `json:"nextHopType"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_hubroutetable.go b/resource-manager/network/2024-07-01/virtualwans/model_hubroutetable.go new file mode 100644 index 00000000000..1214fb071b3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_hubroutetable.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubRouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HubRouteTableProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_hubroutetableproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_hubroutetableproperties.go new file mode 100644 index 00000000000..32d33bc1ec9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_hubroutetableproperties.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubRouteTableProperties struct { + AssociatedConnections *[]string `json:"associatedConnections,omitempty"` + Labels *[]string `json:"labels,omitempty"` + PropagatingConnections *[]string `json:"propagatingConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Routes *[]HubRoute `json:"routes,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_hubvirtualnetworkconnection.go b/resource-manager/network/2024-07-01/virtualwans/model_hubvirtualnetworkconnection.go new file mode 100644 index 00000000000..41f20a0a732 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_hubvirtualnetworkconnection.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubVirtualNetworkConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HubVirtualNetworkConnectionProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_hubvirtualnetworkconnectionproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_hubvirtualnetworkconnectionproperties.go new file mode 100644 index 00000000000..83313e30ed5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_hubvirtualnetworkconnectionproperties.go @@ -0,0 +1,13 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HubVirtualNetworkConnectionProperties struct { + AllowHubToRemoteVnetTransit *bool `json:"allowHubToRemoteVnetTransit,omitempty"` + AllowRemoteVnetToUseHubVnetGateways *bool `json:"allowRemoteVnetToUseHubVnetGateways,omitempty"` + EnableInternetSecurity *bool `json:"enableInternetSecurity,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RemoteVirtualNetwork *SubResource `json:"remoteVirtualNetwork,omitempty"` + RoutingConfiguration *RoutingConfiguration `json:"routingConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_inboundnatrule.go b/resource-manager/network/2024-07-01/virtualwans/model_inboundnatrule.go new file mode 100644 index 00000000000..eee8ea195cf --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..17b64e3d468 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/virtualwans/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..59514113260 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/virtualwans/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..a8f5cddb8ea --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_ipconfiguration.go b/resource-manager/network/2024-07-01/virtualwans/model_ipconfiguration.go new file mode 100644 index 00000000000..1241b6c2c3e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_ipconfigurationbgppeeringaddress.go b/resource-manager/network/2024-07-01/virtualwans/model_ipconfigurationbgppeeringaddress.go new file mode 100644 index 00000000000..fbaabbf7c1b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_ipconfigurationbgppeeringaddress.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationBgpPeeringAddress struct { + CustomBgpIPAddresses *[]string `json:"customBgpIpAddresses,omitempty"` + DefaultBgpIPAddresses *[]string `json:"defaultBgpIpAddresses,omitempty"` + IPconfigurationId *string `json:"ipconfigurationId,omitempty"` + TunnelIPAddresses *[]string `json:"tunnelIpAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/virtualwans/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..a710fe9c7f0 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..6b808468c3d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..58c575ad69f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_ipsecpolicy.go b/resource-manager/network/2024-07-01/virtualwans/model_ipsecpolicy.go new file mode 100644 index 00000000000..02267e6b24d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_ipsecpolicy.go @@ -0,0 +1,15 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPsecPolicy struct { + DhGroup DhGroup `json:"dhGroup"` + IPsecEncryption IPsecEncryption `json:"ipsecEncryption"` + IPsecIntegrity IPsecIntegrity `json:"ipsecIntegrity"` + IkeEncryption IkeEncryption `json:"ikeEncryption"` + IkeIntegrity IkeIntegrity `json:"ikeIntegrity"` + PfsGroup PfsGroup `json:"pfsGroup"` + SaDataSizeKilobytes int64 `json:"saDataSizeKilobytes"` + SaLifeTimeSeconds int64 `json:"saLifeTimeSeconds"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_iptag.go b/resource-manager/network/2024-07-01/virtualwans/model_iptag.go new file mode 100644 index 00000000000..de05365d519 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_iptag.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/virtualwans/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..37820fb13bd --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..3f6629b67eb --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_natgateway.go b/resource-manager/network/2024-07-01/virtualwans/model_natgateway.go new file mode 100644 index 00000000000..7e1a4539e08 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_natgateway.go @@ -0,0 +1,20 @@ +package virtualwans + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..cdc5f869230 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_natgatewaysku.go b/resource-manager/network/2024-07-01/virtualwans/model_natgatewaysku.go new file mode 100644 index 00000000000..4cd49e069a9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_natruleportmapping.go b/resource-manager/network/2024-07-01/virtualwans/model_natruleportmapping.go new file mode 100644 index 00000000000..2ce8b302da3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_networkinterface.go b/resource-manager/network/2024-07-01/virtualwans/model_networkinterface.go new file mode 100644 index 00000000000..b6b5bf73332 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_networkinterface.go @@ -0,0 +1,19 @@ +package virtualwans + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/virtualwans/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..d0dcb411a3e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/virtualwans/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..5c0d1edc7ad --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..9ed5a87eb91 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..09f53d0138b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..f1bab47ab04 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/virtualwans/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..d12531c2798 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..70fb9b73ddb --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/virtualwans/model_networksecuritygroup.go new file mode 100644 index 00000000000..c941605df94 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..54526eb4ea0 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_networkvirtualapplianceconnection.go b/resource-manager/network/2024-07-01/virtualwans/model_networkvirtualapplianceconnection.go new file mode 100644 index 00000000000..903d78680e7 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_networkvirtualapplianceconnection.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualApplianceConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkVirtualApplianceConnectionProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_networkvirtualapplianceconnectionproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_networkvirtualapplianceconnectionproperties.go new file mode 100644 index 00000000000..bfe5ec7a317 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_networkvirtualapplianceconnectionproperties.go @@ -0,0 +1,14 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkVirtualApplianceConnectionProperties struct { + Asn *int64 `json:"asn,omitempty"` + BgpPeerAddress *[]string `json:"bgpPeerAddress,omitempty"` + EnableInternetSecurity *bool `json:"enableInternetSecurity,omitempty"` + Name *string `json:"name,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RoutingConfiguration *RoutingConfiguration `json:"routingConfiguration,omitempty"` + TunnelIdentifier *int64 `json:"tunnelIdentifier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_o365breakoutcategorypolicies.go b/resource-manager/network/2024-07-01/virtualwans/model_o365breakoutcategorypolicies.go new file mode 100644 index 00000000000..0a9ed71a50b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_o365breakoutcategorypolicies.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type O365BreakOutCategoryPolicies struct { + Allow *bool `json:"allow,omitempty"` + Default *bool `json:"default,omitempty"` + Optimize *bool `json:"optimize,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_o365policyproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_o365policyproperties.go new file mode 100644 index 00000000000..eeae991ee3f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_o365policyproperties.go @@ -0,0 +1,8 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type O365PolicyProperties struct { + BreakOutCategories *O365BreakOutCategoryPolicies `json:"breakOutCategories,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_p2sconnectionconfiguration.go b/resource-manager/network/2024-07-01/virtualwans/model_p2sconnectionconfiguration.go new file mode 100644 index 00000000000..08a6a452843 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_p2sconnectionconfiguration.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2SConnectionConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *P2SConnectionConfigurationProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_p2sconnectionconfigurationproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_p2sconnectionconfigurationproperties.go new file mode 100644 index 00000000000..a5558cf1e48 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_p2sconnectionconfigurationproperties.go @@ -0,0 +1,13 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2SConnectionConfigurationProperties struct { + ConfigurationPolicyGroupAssociations *[]SubResource `json:"configurationPolicyGroupAssociations,omitempty"` + EnableInternetSecurity *bool `json:"enableInternetSecurity,omitempty"` + PreviousConfigurationPolicyGroupAssociations *[]VpnServerConfigurationPolicyGroup `json:"previousConfigurationPolicyGroupAssociations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RoutingConfiguration *RoutingConfiguration `json:"routingConfiguration,omitempty"` + VpnClientAddressPool *AddressSpace `json:"vpnClientAddressPool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_p2svpngateway.go b/resource-manager/network/2024-07-01/virtualwans/model_p2svpngateway.go new file mode 100644 index 00000000000..25f63025e39 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_p2svpngateway.go @@ -0,0 +1,14 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2SVpnGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *P2SVpnGatewayProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_p2svpngatewayproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_p2svpngatewayproperties.go new file mode 100644 index 00000000000..d337b304bbd --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_p2svpngatewayproperties.go @@ -0,0 +1,15 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2SVpnGatewayProperties struct { + CustomDnsServers *[]string `json:"customDnsServers,omitempty"` + IsRoutingPreferenceInternet *bool `json:"isRoutingPreferenceInternet,omitempty"` + P2SConnectionConfigurations *[]P2SConnectionConfiguration `json:"p2SConnectionConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualHub *SubResource `json:"virtualHub,omitempty"` + VpnClientConnectionHealth *VpnClientConnectionHealth `json:"vpnClientConnectionHealth,omitempty"` + VpnGatewayScaleUnit *int64 `json:"vpnGatewayScaleUnit,omitempty"` + VpnServerConfiguration *SubResource `json:"vpnServerConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_parameter.go b/resource-manager/network/2024-07-01/virtualwans/model_parameter.go new file mode 100644 index 00000000000..d1619c1138c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_parameter.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Parameter struct { + AsPath *[]string `json:"asPath,omitempty"` + Community *[]string `json:"community,omitempty"` + RoutePrefix *[]string `json:"routePrefix,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_peerroute.go b/resource-manager/network/2024-07-01/virtualwans/model_peerroute.go new file mode 100644 index 00000000000..c03bdbe8722 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_peerroute.go @@ -0,0 +1,14 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PeerRoute struct { + AsPath *string `json:"asPath,omitempty"` + LocalAddress *string `json:"localAddress,omitempty"` + Network *string `json:"network,omitempty"` + NextHop *string `json:"nextHop,omitempty"` + Origin *string `json:"origin,omitempty"` + SourcePeer *string `json:"sourcePeer,omitempty"` + Weight *int64 `json:"weight,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_privateendpoint.go b/resource-manager/network/2024-07-01/virtualwans/model_privateendpoint.go new file mode 100644 index 00000000000..d493c3ed57a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_privateendpoint.go @@ -0,0 +1,19 @@ +package virtualwans + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/virtualwans/model_privateendpointconnection.go new file mode 100644 index 00000000000..191623acf98 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..f54855d1288 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/virtualwans/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..053d067b685 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..d6794440033 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_privateendpointproperties.go new file mode 100644 index 00000000000..3af5e8a64e0 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_privatelinkservice.go b/resource-manager/network/2024-07-01/virtualwans/model_privatelinkservice.go new file mode 100644 index 00000000000..79f0f888953 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package virtualwans + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..b584feab35a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..5875bd90e15 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..c1664caec07 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..3558cb8095c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..31251b67685 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..5160f808655 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_propagatedroutetable.go b/resource-manager/network/2024-07-01/virtualwans/model_propagatedroutetable.go new file mode 100644 index 00000000000..af45ddbedf1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_propagatedroutetable.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PropagatedRouteTable struct { + Ids *[]SubResource `json:"ids,omitempty"` + Labels *[]string `json:"labels,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_publicipaddress.go b/resource-manager/network/2024-07-01/virtualwans/model_publicipaddress.go new file mode 100644 index 00000000000..8bd2fa402a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_publicipaddress.go @@ -0,0 +1,22 @@ +package virtualwans + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/virtualwans/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..2a95851cb0c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..48fecb8ae90 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/virtualwans/model_publicipaddresssku.go new file mode 100644 index 00000000000..4fcf5fb0e8f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_radiusserver.go b/resource-manager/network/2024-07-01/virtualwans/model_radiusserver.go new file mode 100644 index 00000000000..858a67625c9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_radiusserver.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RadiusServer struct { + RadiusServerAddress string `json:"radiusServerAddress"` + RadiusServerScore *int64 `json:"radiusServerScore,omitempty"` + RadiusServerSecret *string `json:"radiusServerSecret,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/virtualwans/model_resourcenavigationlink.go new file mode 100644 index 00000000000..b0d119588a3 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/virtualwans/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..9443c31d227 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_resourceset.go b/resource-manager/network/2024-07-01/virtualwans/model_resourceset.go new file mode 100644 index 00000000000..f8d5a3c0775 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_resourceset.go @@ -0,0 +1,8 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/virtualwans/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..57394822b9d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_route.go b/resource-manager/network/2024-07-01/virtualwans/model_route.go new file mode 100644 index 00000000000..5ae4b7a4ff8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_route.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_routemap.go b/resource-manager/network/2024-07-01/virtualwans/model_routemap.go new file mode 100644 index 00000000000..6c5941f5a4c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_routemap.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteMap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteMapProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_routemapproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_routemapproperties.go new file mode 100644 index 00000000000..a4a019429ff --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_routemapproperties.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteMapProperties struct { + AssociatedInboundConnections *[]string `json:"associatedInboundConnections,omitempty"` + AssociatedOutboundConnections *[]string `json:"associatedOutboundConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Rules *[]RouteMapRule `json:"rules,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_routemaprule.go b/resource-manager/network/2024-07-01/virtualwans/model_routemaprule.go new file mode 100644 index 00000000000..cdeacc9a78b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_routemaprule.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteMapRule struct { + Actions *[]Action `json:"actions,omitempty"` + MatchCriteria *[]Criterion `json:"matchCriteria,omitempty"` + Name *string `json:"name,omitempty"` + NextStepIfMatched *NextStep `json:"nextStepIfMatched,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_routepropertiesformat.go new file mode 100644 index 00000000000..51259038175 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_routetable.go b/resource-manager/network/2024-07-01/virtualwans/model_routetable.go new file mode 100644 index 00000000000..76a72a637be --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_routetable.go @@ -0,0 +1,14 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..9a5454526a4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_routingconfiguration.go b/resource-manager/network/2024-07-01/virtualwans/model_routingconfiguration.go new file mode 100644 index 00000000000..f4ca0018afa --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_routingconfiguration.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingConfiguration struct { + AssociatedRouteTable *SubResource `json:"associatedRouteTable,omitempty"` + InboundRouteMap *SubResource `json:"inboundRouteMap,omitempty"` + OutboundRouteMap *SubResource `json:"outboundRouteMap,omitempty"` + PropagatedRouteTables *PropagatedRouteTable `json:"propagatedRouteTables,omitempty"` + VnetRoutes *VnetRoute `json:"vnetRoutes,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_routingintent.go b/resource-manager/network/2024-07-01/virtualwans/model_routingintent.go new file mode 100644 index 00000000000..537f1404f3d --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_routingintent.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingIntent struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutingIntentProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_routingintentproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_routingintentproperties.go new file mode 100644 index 00000000000..38a3b8e4147 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_routingintentproperties.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingIntentProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RoutingPolicies *[]RoutingPolicy `json:"routingPolicies,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_routingpolicy.go b/resource-manager/network/2024-07-01/virtualwans/model_routingpolicy.go new file mode 100644 index 00000000000..cef221dbd58 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_routingpolicy.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingPolicy struct { + Destinations []string `json:"destinations"` + Name string `json:"name"` + NextHop string `json:"nextHop"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_securityrule.go b/resource-manager/network/2024-07-01/virtualwans/model_securityrule.go new file mode 100644 index 00000000000..72e68599476 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_securityrule.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..547a37a71ce --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/virtualwans/model_serviceassociationlink.go new file mode 100644 index 00000000000..0b2b5927b19 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..1aa80542228 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..aaeb340b2c7 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/virtualwans/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..62b85e18cbf --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/virtualwans/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..886de873aea --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..433a85d2006 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..6c09399b151 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..f8ef284cbaa --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_sharedkeyproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_sharedkeyproperties.go new file mode 100644 index 00000000000..5988e0bc6fd --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_sharedkeyproperties.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedKeyProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` + SharedKeyLength *int64 `json:"sharedKeyLength,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_staticroute.go b/resource-manager/network/2024-07-01/virtualwans/model_staticroute.go new file mode 100644 index 00000000000..c57fdb00cea --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_staticroute.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticRoute struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + Name *string `json:"name,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_staticroutesconfig.go b/resource-manager/network/2024-07-01/virtualwans/model_staticroutesconfig.go new file mode 100644 index 00000000000..c286d119b66 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_staticroutesconfig.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticRoutesConfig struct { + PropagateStaticRoutes *bool `json:"propagateStaticRoutes,omitempty"` + VnetLocalRouteOverrideCriteria *VnetLocalRouteOverrideCriteria `json:"vnetLocalRouteOverrideCriteria,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_subnet.go b/resource-manager/network/2024-07-01/virtualwans/model_subnet.go new file mode 100644 index 00000000000..ecdd88e0207 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_subnet.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..7d476a8c838 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_subresource.go b/resource-manager/network/2024-07-01/virtualwans/model_subresource.go new file mode 100644 index 00000000000..9c238c85dff --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_subresource.go @@ -0,0 +1,8 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_tagsobject.go b/resource-manager/network/2024-07-01/virtualwans/model_tagsobject.go new file mode 100644 index 00000000000..1f55b0e7a00 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_tagsobject.go @@ -0,0 +1,8 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..1e6b8ac8e23 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..56d6e09676b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_trafficselectorpolicy.go b/resource-manager/network/2024-07-01/virtualwans/model_trafficselectorpolicy.go new file mode 100644 index 00000000000..09496a292fa --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_trafficselectorpolicy.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficSelectorPolicy struct { + LocalAddressRanges []string `json:"localAddressRanges"` + RemoteAddressRanges []string `json:"remoteAddressRanges"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_virtualhub.go b/resource-manager/network/2024-07-01/virtualwans/model_virtualhub.go new file mode 100644 index 00000000000..732daa9aecc --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_virtualhub.go @@ -0,0 +1,15 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHub struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualHubProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_virtualhubeffectiveroute.go b/resource-manager/network/2024-07-01/virtualwans/model_virtualhubeffectiveroute.go new file mode 100644 index 00000000000..d46894da2a8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_virtualhubeffectiveroute.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubEffectiveRoute struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + AsPath *string `json:"asPath,omitempty"` + NextHopType *string `json:"nextHopType,omitempty"` + NextHops *[]string `json:"nextHops,omitempty"` + RouteOrigin *string `json:"routeOrigin,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_virtualhubeffectiveroutelist.go b/resource-manager/network/2024-07-01/virtualwans/model_virtualhubeffectiveroutelist.go new file mode 100644 index 00000000000..3ea5b7b15e4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_virtualhubeffectiveroutelist.go @@ -0,0 +1,8 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubEffectiveRouteList struct { + Value *[]VirtualHubEffectiveRoute `json:"value,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_virtualhubproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_virtualhubproperties.go new file mode 100644 index 00000000000..9b119e8889f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_virtualhubproperties.go @@ -0,0 +1,29 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubProperties struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AllowBranchToBranchTraffic *bool `json:"allowBranchToBranchTraffic,omitempty"` + AzureFirewall *SubResource `json:"azureFirewall,omitempty"` + BgpConnections *[]SubResource `json:"bgpConnections,omitempty"` + ExpressRouteGateway *SubResource `json:"expressRouteGateway,omitempty"` + HubRoutingPreference *HubRoutingPreference `json:"hubRoutingPreference,omitempty"` + IPConfigurations *[]SubResource `json:"ipConfigurations,omitempty"` + P2SVpnGateway *SubResource `json:"p2SVpnGateway,omitempty"` + PreferredRoutingGateway *PreferredRoutingGateway `json:"preferredRoutingGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RouteMaps *[]SubResource `json:"routeMaps,omitempty"` + RouteTable *VirtualHubRouteTable `json:"routeTable,omitempty"` + RoutingState *RoutingState `json:"routingState,omitempty"` + SecurityPartnerProvider *SubResource `json:"securityPartnerProvider,omitempty"` + SecurityProviderName *string `json:"securityProviderName,omitempty"` + Sku *string `json:"sku,omitempty"` + VirtualHubRouteTableV2s *[]VirtualHubRouteTableV2 `json:"virtualHubRouteTableV2s,omitempty"` + VirtualRouterAsn *int64 `json:"virtualRouterAsn,omitempty"` + VirtualRouterAutoScaleConfiguration *VirtualRouterAutoScaleConfiguration `json:"virtualRouterAutoScaleConfiguration,omitempty"` + VirtualRouterIPs *[]string `json:"virtualRouterIps,omitempty"` + VirtualWAN *SubResource `json:"virtualWan,omitempty"` + VpnGateway *SubResource `json:"vpnGateway,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_virtualhubroute.go b/resource-manager/network/2024-07-01/virtualwans/model_virtualhubroute.go new file mode 100644 index 00000000000..3b9b205ea1a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_virtualhubroute.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubRoute struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_virtualhubroutetable.go b/resource-manager/network/2024-07-01/virtualwans/model_virtualhubroutetable.go new file mode 100644 index 00000000000..71ec2c0bca4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_virtualhubroutetable.go @@ -0,0 +1,8 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubRouteTable struct { + Routes *[]VirtualHubRoute `json:"routes,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_virtualhubroutetablev2.go b/resource-manager/network/2024-07-01/virtualwans/model_virtualhubroutetablev2.go new file mode 100644 index 00000000000..50fa84c35f5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_virtualhubroutetablev2.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubRouteTableV2 struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualHubRouteTableV2Properties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_virtualhubroutetablev2properties.go b/resource-manager/network/2024-07-01/virtualwans/model_virtualhubroutetablev2properties.go new file mode 100644 index 00000000000..ed869d1c471 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_virtualhubroutetablev2properties.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubRouteTableV2Properties struct { + AttachedConnections *[]string `json:"attachedConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Routes *[]VirtualHubRouteV2 `json:"routes,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_virtualhubroutev2.go b/resource-manager/network/2024-07-01/virtualwans/model_virtualhubroutev2.go new file mode 100644 index 00000000000..a47739aa2a5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_virtualhubroutev2.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualHubRouteV2 struct { + DestinationType *string `json:"destinationType,omitempty"` + Destinations *[]string `json:"destinations,omitempty"` + NextHopType *string `json:"nextHopType,omitempty"` + NextHops *[]string `json:"nextHops,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/virtualwans/model_virtualnetworktap.go new file mode 100644 index 00000000000..f7d80351ab5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/virtualwans/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..efca5566dad --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_virtualrouterautoscaleconfiguration.go b/resource-manager/network/2024-07-01/virtualwans/model_virtualrouterautoscaleconfiguration.go new file mode 100644 index 00000000000..4ce6be45420 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_virtualrouterautoscaleconfiguration.go @@ -0,0 +1,8 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualRouterAutoScaleConfiguration struct { + MinCapacity *int64 `json:"minCapacity,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_virtualwan.go b/resource-manager/network/2024-07-01/virtualwans/model_virtualwan.go new file mode 100644 index 00000000000..45691c81b74 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_virtualwan.go @@ -0,0 +1,14 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualWAN struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualWanProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_virtualwanproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_virtualwanproperties.go new file mode 100644 index 00000000000..65c2eb829cb --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_virtualwanproperties.go @@ -0,0 +1,15 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualWanProperties struct { + AllowBranchToBranchTraffic *bool `json:"allowBranchToBranchTraffic,omitempty"` + AllowVnetToVnetTraffic *bool `json:"allowVnetToVnetTraffic,omitempty"` + DisableVpnEncryption *bool `json:"disableVpnEncryption,omitempty"` + Office365LocalBreakoutCategory *OfficeTrafficCategory `json:"office365LocalBreakoutCategory,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Type *string `json:"type,omitempty"` + VirtualHubs *[]SubResource `json:"virtualHubs,omitempty"` + VpnSites *[]SubResource `json:"vpnSites,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_virtualwansecurityprovider.go b/resource-manager/network/2024-07-01/virtualwans/model_virtualwansecurityprovider.go new file mode 100644 index 00000000000..d41346bc4a9 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_virtualwansecurityprovider.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualWanSecurityProvider struct { + Name *string `json:"name,omitempty"` + Type *VirtualWanSecurityProviderType `json:"type,omitempty"` + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_virtualwansecurityproviders.go b/resource-manager/network/2024-07-01/virtualwans/model_virtualwansecurityproviders.go new file mode 100644 index 00000000000..6e7e4ab59f8 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_virtualwansecurityproviders.go @@ -0,0 +1,8 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualWanSecurityProviders struct { + SupportedProviders *[]VirtualWanSecurityProvider `json:"supportedProviders,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_virtualwanvpnprofileparameters.go b/resource-manager/network/2024-07-01/virtualwans/model_virtualwanvpnprofileparameters.go new file mode 100644 index 00000000000..dd01888d247 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_virtualwanvpnprofileparameters.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualWanVpnProfileParameters struct { + AuthenticationMethod *AuthenticationMethod `json:"authenticationMethod,omitempty"` + VpnServerConfigurationResourceId *string `json:"vpnServerConfigurationResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vnetroute.go b/resource-manager/network/2024-07-01/virtualwans/model_vnetroute.go new file mode 100644 index 00000000000..cbd035f3e06 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vnetroute.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRoute struct { + BgpConnections *[]SubResource `json:"bgpConnections,omitempty"` + StaticRoutes *[]StaticRoute `json:"staticRoutes,omitempty"` + StaticRoutesConfig *StaticRoutesConfig `json:"staticRoutesConfig,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnclientconnectionhealth.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnclientconnectionhealth.go new file mode 100644 index 00000000000..82eefc44a41 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnclientconnectionhealth.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnClientConnectionHealth struct { + AllocatedIPAddresses *[]string `json:"allocatedIpAddresses,omitempty"` + TotalEgressBytesTransferred *int64 `json:"totalEgressBytesTransferred,omitempty"` + TotalIngressBytesTransferred *int64 `json:"totalIngressBytesTransferred,omitempty"` + VpnClientConnectionsCount *int64 `json:"vpnClientConnectionsCount,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnconnection.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnconnection.go new file mode 100644 index 00000000000..9d157042c70 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnconnection.go @@ -0,0 +1,11 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnConnectionProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnconnectionpacketcapturestartparameters.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnconnectionpacketcapturestartparameters.go new file mode 100644 index 00000000000..97a9e565f9e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnconnectionpacketcapturestartparameters.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnConnectionPacketCaptureStartParameters struct { + FilterData *string `json:"filterData,omitempty"` + LinkConnectionNames *[]string `json:"linkConnectionNames,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnconnectionpacketcapturestopparameters.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnconnectionpacketcapturestopparameters.go new file mode 100644 index 00000000000..a2a50d9eb92 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnconnectionpacketcapturestopparameters.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnConnectionPacketCaptureStopParameters struct { + LinkConnectionNames *[]string `json:"linkConnectionNames,omitempty"` + SasURL *string `json:"sasUrl,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnconnectionproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnconnectionproperties.go new file mode 100644 index 00000000000..1c238229449 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnconnectionproperties.go @@ -0,0 +1,26 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnConnectionProperties struct { + ConnectionBandwidth *int64 `json:"connectionBandwidth,omitempty"` + ConnectionStatus *VpnConnectionStatus `json:"connectionStatus,omitempty"` + DpdTimeoutSeconds *int64 `json:"dpdTimeoutSeconds,omitempty"` + EgressBytesTransferred *int64 `json:"egressBytesTransferred,omitempty"` + EnableBgp *bool `json:"enableBgp,omitempty"` + EnableInternetSecurity *bool `json:"enableInternetSecurity,omitempty"` + EnableRateLimiting *bool `json:"enableRateLimiting,omitempty"` + IPsecPolicies *[]IPsecPolicy `json:"ipsecPolicies,omitempty"` + IngressBytesTransferred *int64 `json:"ingressBytesTransferred,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RemoteVpnSite *SubResource `json:"remoteVpnSite,omitempty"` + RoutingConfiguration *RoutingConfiguration `json:"routingConfiguration,omitempty"` + RoutingWeight *int64 `json:"routingWeight,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` + TrafficSelectorPolicies *[]TrafficSelectorPolicy `json:"trafficSelectorPolicies,omitempty"` + UseLocalAzureIPAddress *bool `json:"useLocalAzureIpAddress,omitempty"` + UsePolicyBasedTrafficSelectors *bool `json:"usePolicyBasedTrafficSelectors,omitempty"` + VpnConnectionProtocolType *VirtualNetworkGatewayConnectionProtocol `json:"vpnConnectionProtocolType,omitempty"` + VpnLinkConnections *[]VpnSiteLinkConnection `json:"vpnLinkConnections,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpngateway.go b/resource-manager/network/2024-07-01/virtualwans/model_vpngateway.go new file mode 100644 index 00000000000..0c0f9dab77f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpngateway.go @@ -0,0 +1,14 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnGatewayProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpngatewayipconfiguration.go b/resource-manager/network/2024-07-01/virtualwans/model_vpngatewayipconfiguration.go new file mode 100644 index 00000000000..b1060397ea0 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpngatewayipconfiguration.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGatewayIPConfiguration struct { + Id *string `json:"id,omitempty"` + PrivateIPAddress *string `json:"privateIpAddress,omitempty"` + PublicIPAddress *string `json:"publicIpAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpngatewaynatrule.go b/resource-manager/network/2024-07-01/virtualwans/model_vpngatewaynatrule.go new file mode 100644 index 00000000000..2de41b7ced6 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpngatewaynatrule.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGatewayNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnGatewayNatRuleProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpngatewaynatruleproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_vpngatewaynatruleproperties.go new file mode 100644 index 00000000000..1aaf7c8f90b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpngatewaynatruleproperties.go @@ -0,0 +1,15 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGatewayNatRuleProperties struct { + EgressVpnSiteLinkConnections *[]SubResource `json:"egressVpnSiteLinkConnections,omitempty"` + ExternalMappings *[]VpnNatRuleMapping `json:"externalMappings,omitempty"` + IPConfigurationId *string `json:"ipConfigurationId,omitempty"` + IngressVpnSiteLinkConnections *[]SubResource `json:"ingressVpnSiteLinkConnections,omitempty"` + InternalMappings *[]VpnNatRuleMapping `json:"internalMappings,omitempty"` + Mode *VpnNatRuleMode `json:"mode,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Type *VpnNatRuleType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpngatewayproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_vpngatewayproperties.go new file mode 100644 index 00000000000..ab2b8b55b1b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpngatewayproperties.go @@ -0,0 +1,16 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGatewayProperties struct { + BgpSettings *BgpSettings `json:"bgpSettings,omitempty"` + Connections *[]VpnConnection `json:"connections,omitempty"` + EnableBgpRouteTranslationForNat *bool `json:"enableBgpRouteTranslationForNat,omitempty"` + IPConfigurations *[]VpnGatewayIPConfiguration `json:"ipConfigurations,omitempty"` + IsRoutingPreferenceInternet *bool `json:"isRoutingPreferenceInternet,omitempty"` + NatRules *[]VpnGatewayNatRule `json:"natRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualHub *SubResource `json:"virtualHub,omitempty"` + VpnGatewayScaleUnit *int64 `json:"vpnGatewayScaleUnit,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnlinkbgpsettings.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnlinkbgpsettings.go new file mode 100644 index 00000000000..72de7d65308 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnlinkbgpsettings.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnLinkBgpSettings struct { + Asn *int64 `json:"asn,omitempty"` + BgpPeeringAddress *string `json:"bgpPeeringAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnlinkproviderproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnlinkproviderproperties.go new file mode 100644 index 00000000000..555f8739a9b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnlinkproviderproperties.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnLinkProviderProperties struct { + LinkProviderName *string `json:"linkProviderName,omitempty"` + LinkSpeedInMbps *int64 `json:"linkSpeedInMbps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnnatrulemapping.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnnatrulemapping.go new file mode 100644 index 00000000000..09a77912d9f --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnnatrulemapping.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnNatRuleMapping struct { + AddressSpace *string `json:"addressSpace,omitempty"` + PortRange *string `json:"portRange,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnprofileresponse.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnprofileresponse.go new file mode 100644 index 00000000000..ed24cd4584e --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnprofileresponse.go @@ -0,0 +1,8 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnProfileResponse struct { + ProfileURL *string `json:"profileUrl,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigradiusclientrootcertificate.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigradiusclientrootcertificate.go new file mode 100644 index 00000000000..21a75789b34 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigradiusclientrootcertificate.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigRadiusClientRootCertificate struct { + Name *string `json:"name,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigradiusserverrootcertificate.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigradiusserverrootcertificate.go new file mode 100644 index 00000000000..6f67a020c6a --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigradiusserverrootcertificate.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigRadiusServerRootCertificate struct { + Name *string `json:"name,omitempty"` + PublicCertData *string `json:"publicCertData,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfiguration.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfiguration.go new file mode 100644 index 00000000000..debdcf03f04 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfiguration.go @@ -0,0 +1,14 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnServerConfigurationProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigurationpolicygroup.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigurationpolicygroup.go new file mode 100644 index 00000000000..e94549fb063 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigurationpolicygroup.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationPolicyGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnServerConfigurationPolicyGroupProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigurationpolicygroupmember.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigurationpolicygroupmember.go new file mode 100644 index 00000000000..f832688900b --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigurationpolicygroupmember.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationPolicyGroupMember struct { + AttributeType *VpnPolicyMemberAttributeType `json:"attributeType,omitempty"` + AttributeValue *string `json:"attributeValue,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigurationpolicygroupproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigurationpolicygroupproperties.go new file mode 100644 index 00000000000..93b015d4bd1 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigurationpolicygroupproperties.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationPolicyGroupProperties struct { + IsDefault *bool `json:"isDefault,omitempty"` + P2SConnectionConfigurations *[]SubResource `json:"p2SConnectionConfigurations,omitempty"` + PolicyMembers *[]VpnServerConfigurationPolicyGroupMember `json:"policyMembers,omitempty"` + Priority *int64 `json:"priority,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigurationproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigurationproperties.go new file mode 100644 index 00000000000..1a42b30f7aa --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigurationproperties.go @@ -0,0 +1,23 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationProperties struct { + AadAuthenticationParameters *AadAuthenticationParameters `json:"aadAuthenticationParameters,omitempty"` + ConfigurationPolicyGroups *[]VpnServerConfigurationPolicyGroup `json:"configurationPolicyGroups,omitempty"` + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + P2sVpnGateways *[]P2SVpnGateway `json:"p2SVpnGateways,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + RadiusClientRootCertificates *[]VpnServerConfigRadiusClientRootCertificate `json:"radiusClientRootCertificates,omitempty"` + RadiusServerAddress *string `json:"radiusServerAddress,omitempty"` + RadiusServerRootCertificates *[]VpnServerConfigRadiusServerRootCertificate `json:"radiusServerRootCertificates,omitempty"` + RadiusServerSecret *string `json:"radiusServerSecret,omitempty"` + RadiusServers *[]RadiusServer `json:"radiusServers,omitempty"` + VpnAuthenticationTypes *[]VpnAuthenticationType `json:"vpnAuthenticationTypes,omitempty"` + VpnClientIPsecPolicies *[]IPsecPolicy `json:"vpnClientIpsecPolicies,omitempty"` + VpnClientRevokedCertificates *[]VpnServerConfigVpnClientRevokedCertificate `json:"vpnClientRevokedCertificates,omitempty"` + VpnClientRootCertificates *[]VpnServerConfigVpnClientRootCertificate `json:"vpnClientRootCertificates,omitempty"` + VpnProtocols *[]VpnGatewayTunnelingProtocol `json:"vpnProtocols,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigurationsresponse.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigurationsresponse.go new file mode 100644 index 00000000000..185d5a549d4 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigurationsresponse.go @@ -0,0 +1,8 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationsResponse struct { + VpnServerConfigurationResourceIds *[]string `json:"vpnServerConfigurationResourceIds,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigvpnclientrevokedcertificate.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigvpnclientrevokedcertificate.go new file mode 100644 index 00000000000..9582df932b5 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigvpnclientrevokedcertificate.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigVpnClientRevokedCertificate struct { + Name *string `json:"name,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigvpnclientrootcertificate.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigvpnclientrootcertificate.go new file mode 100644 index 00000000000..606a8393665 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnserverconfigvpnclientrootcertificate.go @@ -0,0 +1,9 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigVpnClientRootCertificate struct { + Name *string `json:"name,omitempty"` + PublicCertData *string `json:"publicCertData,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnsite.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnsite.go new file mode 100644 index 00000000000..7c6dacaed50 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnsite.go @@ -0,0 +1,14 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSite struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnSiteProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnsitelink.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnsitelink.go new file mode 100644 index 00000000000..9c72c0567fd --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnsitelink.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSiteLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnSiteLinkProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnsitelinkconnection.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnsitelinkconnection.go new file mode 100644 index 00000000000..88bed41fe65 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnsitelinkconnection.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSiteLinkConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnSiteLinkConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnsitelinkconnectionproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnsitelinkconnectionproperties.go new file mode 100644 index 00000000000..d07ca0a64af --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnsitelinkconnectionproperties.go @@ -0,0 +1,26 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSiteLinkConnectionProperties struct { + ConnectionBandwidth *int64 `json:"connectionBandwidth,omitempty"` + ConnectionStatus *VpnConnectionStatus `json:"connectionStatus,omitempty"` + DpdTimeoutSeconds *int64 `json:"dpdTimeoutSeconds,omitempty"` + EgressBytesTransferred *int64 `json:"egressBytesTransferred,omitempty"` + EgressNatRules *[]SubResource `json:"egressNatRules,omitempty"` + EnableBgp *bool `json:"enableBgp,omitempty"` + EnableRateLimiting *bool `json:"enableRateLimiting,omitempty"` + IPsecPolicies *[]IPsecPolicy `json:"ipsecPolicies,omitempty"` + IngressBytesTransferred *int64 `json:"ingressBytesTransferred,omitempty"` + IngressNatRules *[]SubResource `json:"ingressNatRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RoutingWeight *int64 `json:"routingWeight,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` + UseLocalAzureIPAddress *bool `json:"useLocalAzureIpAddress,omitempty"` + UsePolicyBasedTrafficSelectors *bool `json:"usePolicyBasedTrafficSelectors,omitempty"` + VpnConnectionProtocolType *VirtualNetworkGatewayConnectionProtocol `json:"vpnConnectionProtocolType,omitempty"` + VpnGatewayCustomBgpAddresses *[]GatewayCustomBgpIPAddressIPConfiguration `json:"vpnGatewayCustomBgpAddresses,omitempty"` + VpnLinkConnectionMode *VpnLinkConnectionMode `json:"vpnLinkConnectionMode,omitempty"` + VpnSiteLink *SubResource `json:"vpnSiteLink,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnsitelinkproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnsitelinkproperties.go new file mode 100644 index 00000000000..fa7d9002a52 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnsitelinkproperties.go @@ -0,0 +1,12 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSiteLinkProperties struct { + BgpProperties *VpnLinkBgpSettings `json:"bgpProperties,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + LinkProperties *VpnLinkProviderProperties `json:"linkProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/model_vpnsiteproperties.go b/resource-manager/network/2024-07-01/virtualwans/model_vpnsiteproperties.go new file mode 100644 index 00000000000..da368da2045 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/model_vpnsiteproperties.go @@ -0,0 +1,17 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSiteProperties struct { + AddressSpace *AddressSpace `json:"addressSpace,omitempty"` + BgpProperties *BgpSettings `json:"bgpProperties,omitempty"` + DeviceProperties *DeviceProperties `json:"deviceProperties,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IsSecuritySite *bool `json:"isSecuritySite,omitempty"` + O365Policy *O365PolicyProperties `json:"o365Policy,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SiteKey *string `json:"siteKey,omitempty"` + VirtualWAN *SubResource `json:"virtualWan,omitempty"` + VpnSiteLinks *[]VpnSiteLink `json:"vpnSiteLinks,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/virtualwans/predicates.go b/resource-manager/network/2024-07-01/virtualwans/predicates.go new file mode 100644 index 00000000000..7373e09382c --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/predicates.go @@ -0,0 +1,569 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BgpConnectionOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p BgpConnectionOperationPredicate) Matches(input BgpConnection) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type ConnectionSharedKeyResultOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ConnectionSharedKeyResultOperationPredicate) Matches(input ConnectionSharedKeyResult) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type HubIPConfigurationOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p HubIPConfigurationOperationPredicate) Matches(input HubIPConfiguration) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type HubRouteTableOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p HubRouteTableOperationPredicate) Matches(input HubRouteTable) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type HubVirtualNetworkConnectionOperationPredicate struct { + Etag *string + Id *string + Name *string +} + +func (p HubVirtualNetworkConnectionOperationPredicate) Matches(input HubVirtualNetworkConnection) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + return true +} + +type NetworkVirtualApplianceConnectionOperationPredicate struct { + Id *string + Name *string +} + +func (p NetworkVirtualApplianceConnectionOperationPredicate) Matches(input NetworkVirtualApplianceConnection) 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 + } + + return true +} + +type P2SVpnGatewayOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p P2SVpnGatewayOperationPredicate) Matches(input P2SVpnGateway) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type RouteMapOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p RouteMapOperationPredicate) Matches(input RouteMap) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type RoutingIntentOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p RoutingIntentOperationPredicate) Matches(input RoutingIntent) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type VirtualHubOperationPredicate struct { + Etag *string + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p VirtualHubOperationPredicate) Matches(input VirtualHub) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type VirtualHubRouteTableV2OperationPredicate struct { + Etag *string + Id *string + Name *string +} + +func (p VirtualHubRouteTableV2OperationPredicate) Matches(input VirtualHubRouteTableV2) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + return true +} + +type VirtualWANOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p VirtualWANOperationPredicate) Matches(input VirtualWAN) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type VpnConnectionOperationPredicate struct { + Etag *string + Id *string + Name *string +} + +func (p VpnConnectionOperationPredicate) Matches(input VpnConnection) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + return true +} + +type VpnGatewayOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p VpnGatewayOperationPredicate) Matches(input VpnGateway) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type VpnGatewayNatRuleOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p VpnGatewayNatRuleOperationPredicate) Matches(input VpnGatewayNatRule) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type VpnServerConfigurationOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p VpnServerConfigurationOperationPredicate) Matches(input VpnServerConfiguration) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type VpnServerConfigurationPolicyGroupOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p VpnServerConfigurationPolicyGroupOperationPredicate) Matches(input VpnServerConfigurationPolicyGroup) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type VpnSiteOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p VpnSiteOperationPredicate) Matches(input VpnSite) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type VpnSiteLinkOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p VpnSiteLinkOperationPredicate) Matches(input VpnSiteLink) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type VpnSiteLinkConnectionOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p VpnSiteLinkConnectionOperationPredicate) Matches(input VpnSiteLinkConnection) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/virtualwans/version.go b/resource-manager/network/2024-07-01/virtualwans/version.go new file mode 100644 index 00000000000..93ce4dcbd76 --- /dev/null +++ b/resource-manager/network/2024-07-01/virtualwans/version.go @@ -0,0 +1,10 @@ +package virtualwans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/virtualwans/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/README.md b/resource-manager/network/2024-07-01/vmsspublicipaddresses/README.md new file mode 100644 index 00000000000..82f7d99e822 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/README.md @@ -0,0 +1,71 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/vmsspublicipaddresses` Documentation + +The `vmsspublicipaddresses` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/vmsspublicipaddresses" +``` + + +### Client Initialization + +```go +client := vmsspublicipaddresses.NewVMSSPublicIPAddressesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VMSSPublicIPAddressesClient.PublicIPAddressesGetVirtualMachineScaleSetPublicIPAddress` + +```go +ctx := context.TODO() +id := commonids.NewVirtualMachineScaleSetPublicIPAddressID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineScaleSetName", "virtualMachineName", "networkInterfaceName", "ipConfigurationName", "publicIPAddressName") + +read, err := client.PublicIPAddressesGetVirtualMachineScaleSetPublicIPAddress(ctx, id, vmsspublicipaddresses.DefaultPublicIPAddressesGetVirtualMachineScaleSetPublicIPAddressOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `VMSSPublicIPAddressesClient.PublicIPAddressesListVirtualMachineScaleSetPublicIPAddresses` + +```go +ctx := context.TODO() +id := vmsspublicipaddresses.NewVirtualMachineScaleSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineScaleSetName") + +// alternatively `client.PublicIPAddressesListVirtualMachineScaleSetPublicIPAddresses(ctx, id)` can be used to do batched pagination +items, err := client.PublicIPAddressesListVirtualMachineScaleSetPublicIPAddressesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `VMSSPublicIPAddressesClient.PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddresses` + +```go +ctx := context.TODO() +id := commonids.NewVirtualMachineScaleSetIPConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineScaleSetName", "virtualMachineName", "networkInterfaceName", "ipConfigurationName") + +// alternatively `client.PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddresses(ctx, id)` can be used to do batched pagination +items, err := client.PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddressesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/client.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/client.go new file mode 100644 index 00000000000..218145b65b9 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/client.go @@ -0,0 +1,26 @@ +package vmsspublicipaddresses + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VMSSPublicIPAddressesClient struct { + Client *resourcemanager.Client +} + +func NewVMSSPublicIPAddressesClientWithBaseURI(sdkApi sdkEnv.Api) (*VMSSPublicIPAddressesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "vmsspublicipaddresses", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VMSSPublicIPAddressesClient: %+v", err) + } + + return &VMSSPublicIPAddressesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/constants.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/constants.go new file mode 100644 index 00000000000..24ee31e9200 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/constants.go @@ -0,0 +1,1204 @@ +package vmsspublicipaddresses + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/id_virtualmachinescaleset.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/id_virtualmachinescaleset.go new file mode 100644 index 00000000000..4a616c362b3 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/id_virtualmachinescaleset.go @@ -0,0 +1,130 @@ +package vmsspublicipaddresses + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualMachineScaleSetId{}) +} + +var _ resourceids.ResourceId = &VirtualMachineScaleSetId{} + +// VirtualMachineScaleSetId is a struct representing the Resource ID for a Virtual Machine Scale Set +type VirtualMachineScaleSetId struct { + SubscriptionId string + ResourceGroupName string + VirtualMachineScaleSetName string +} + +// NewVirtualMachineScaleSetID returns a new VirtualMachineScaleSetId struct +func NewVirtualMachineScaleSetID(subscriptionId string, resourceGroupName string, virtualMachineScaleSetName string) VirtualMachineScaleSetId { + return VirtualMachineScaleSetId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VirtualMachineScaleSetName: virtualMachineScaleSetName, + } +} + +// ParseVirtualMachineScaleSetID parses 'input' into a VirtualMachineScaleSetId +func ParseVirtualMachineScaleSetID(input string) (*VirtualMachineScaleSetId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualMachineScaleSetId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualMachineScaleSetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualMachineScaleSetIDInsensitively parses 'input' case-insensitively into a VirtualMachineScaleSetId +// note: this method should only be used for API response data and not user input +func ParseVirtualMachineScaleSetIDInsensitively(input string) (*VirtualMachineScaleSetId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualMachineScaleSetId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualMachineScaleSetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualMachineScaleSetId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VirtualMachineScaleSetName, ok = input.Parsed["virtualMachineScaleSetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualMachineScaleSetName", input) + } + + return nil +} + +// ValidateVirtualMachineScaleSetID checks that 'input' can be parsed as a Virtual Machine Scale Set ID +func ValidateVirtualMachineScaleSetID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVirtualMachineScaleSetID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Machine Scale Set ID +func (id VirtualMachineScaleSetId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/virtualMachineScaleSets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VirtualMachineScaleSetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Machine Scale Set ID +func (id VirtualMachineScaleSetId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCompute", "Microsoft.Compute", "Microsoft.Compute"), + resourceids.StaticSegment("staticVirtualMachineScaleSets", "virtualMachineScaleSets", "virtualMachineScaleSets"), + resourceids.UserSpecifiedSegment("virtualMachineScaleSetName", "virtualMachineScaleSetName"), + } +} + +// String returns a human-readable description of this Virtual Machine Scale Set ID +func (id VirtualMachineScaleSetId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Virtual Machine Scale Set Name: %q", id.VirtualMachineScaleSetName), + } + return fmt.Sprintf("Virtual Machine Scale Set (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/id_virtualmachinescaleset_test.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/id_virtualmachinescaleset_test.go new file mode 100644 index 00000000000..430e30516f6 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/id_virtualmachinescaleset_test.go @@ -0,0 +1,282 @@ +package vmsspublicipaddresses + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualMachineScaleSetId{} + +func TestNewVirtualMachineScaleSetID(t *testing.T) { + id := NewVirtualMachineScaleSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineScaleSetName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VirtualMachineScaleSetName != "virtualMachineScaleSetName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualMachineScaleSetName'", id.VirtualMachineScaleSetName, "virtualMachineScaleSetName") + } +} + +func TestFormatVirtualMachineScaleSetID(t *testing.T) { + actual := NewVirtualMachineScaleSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "virtualMachineScaleSetName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualMachineScaleSetID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualMachineScaleSetId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName", + Expected: &VirtualMachineScaleSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualMachineScaleSetName: "virtualMachineScaleSetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualMachineScaleSetID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualMachineScaleSetName != v.Expected.VirtualMachineScaleSetName { + t.Fatalf("Expected %q but got %q for VirtualMachineScaleSetName", v.Expected.VirtualMachineScaleSetName, actual.VirtualMachineScaleSetName) + } + + } +} + +func TestParseVirtualMachineScaleSetIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualMachineScaleSetId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/vIrTuAlMaChInEsCaLeSeTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName", + Expected: &VirtualMachineScaleSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VirtualMachineScaleSetName: "virtualMachineScaleSetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/virtualMachineScaleSetName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/vIrTuAlMaChInEsCaLeSeTs/vIrTuAlMaChInEsCaLeSeTnAmE", + Expected: &VirtualMachineScaleSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VirtualMachineScaleSetName: "vIrTuAlMaChInEsCaLeSeTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOmPuTe/vIrTuAlMaChInEsCaLeSeTs/vIrTuAlMaChInEsCaLeSeTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualMachineScaleSetIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VirtualMachineScaleSetName != v.Expected.VirtualMachineScaleSetName { + t.Fatalf("Expected %q but got %q for VirtualMachineScaleSetName", v.Expected.VirtualMachineScaleSetName, actual.VirtualMachineScaleSetName) + } + + } +} + +func TestSegmentsForVirtualMachineScaleSetId(t *testing.T) { + segments := VirtualMachineScaleSetId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualMachineScaleSetId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/method_publicipaddressesgetvirtualmachinescalesetpublicipaddress.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/method_publicipaddressesgetvirtualmachinescalesetpublicipaddress.go new file mode 100644 index 00000000000..aa1a988346a --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/method_publicipaddressesgetvirtualmachinescalesetpublicipaddress.go @@ -0,0 +1,84 @@ +package vmsspublicipaddresses + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressesGetVirtualMachineScaleSetPublicIPAddressOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicIPAddress +} + +type PublicIPAddressesGetVirtualMachineScaleSetPublicIPAddressOperationOptions struct { + Expand *string +} + +func DefaultPublicIPAddressesGetVirtualMachineScaleSetPublicIPAddressOperationOptions() PublicIPAddressesGetVirtualMachineScaleSetPublicIPAddressOperationOptions { + return PublicIPAddressesGetVirtualMachineScaleSetPublicIPAddressOperationOptions{} +} + +func (o PublicIPAddressesGetVirtualMachineScaleSetPublicIPAddressOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o PublicIPAddressesGetVirtualMachineScaleSetPublicIPAddressOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o PublicIPAddressesGetVirtualMachineScaleSetPublicIPAddressOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// PublicIPAddressesGetVirtualMachineScaleSetPublicIPAddress ... +func (c VMSSPublicIPAddressesClient) PublicIPAddressesGetVirtualMachineScaleSetPublicIPAddress(ctx context.Context, id commonids.VirtualMachineScaleSetPublicIPAddressId, options PublicIPAddressesGetVirtualMachineScaleSetPublicIPAddressOperationOptions) (result PublicIPAddressesGetVirtualMachineScaleSetPublicIPAddressOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PublicIPAddress + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/method_publicipaddresseslistvirtualmachinescalesetpublicipaddresses.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/method_publicipaddresseslistvirtualmachinescalesetpublicipaddresses.go new file mode 100644 index 00000000000..c39b6848351 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/method_publicipaddresseslistvirtualmachinescalesetpublicipaddresses.go @@ -0,0 +1,105 @@ +package vmsspublicipaddresses + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressesListVirtualMachineScaleSetPublicIPAddressesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PublicIPAddress +} + +type PublicIPAddressesListVirtualMachineScaleSetPublicIPAddressesCompleteResult struct { + LatestHttpResponse *http.Response + Items []PublicIPAddress +} + +type PublicIPAddressesListVirtualMachineScaleSetPublicIPAddressesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *PublicIPAddressesListVirtualMachineScaleSetPublicIPAddressesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// PublicIPAddressesListVirtualMachineScaleSetPublicIPAddresses ... +func (c VMSSPublicIPAddressesClient) PublicIPAddressesListVirtualMachineScaleSetPublicIPAddresses(ctx context.Context, id VirtualMachineScaleSetId) (result PublicIPAddressesListVirtualMachineScaleSetPublicIPAddressesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &PublicIPAddressesListVirtualMachineScaleSetPublicIPAddressesCustomPager{}, + Path: fmt.Sprintf("%s/publicIPAddresses", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PublicIPAddress `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// PublicIPAddressesListVirtualMachineScaleSetPublicIPAddressesComplete retrieves all the results into a single object +func (c VMSSPublicIPAddressesClient) PublicIPAddressesListVirtualMachineScaleSetPublicIPAddressesComplete(ctx context.Context, id VirtualMachineScaleSetId) (PublicIPAddressesListVirtualMachineScaleSetPublicIPAddressesCompleteResult, error) { + return c.PublicIPAddressesListVirtualMachineScaleSetPublicIPAddressesCompleteMatchingPredicate(ctx, id, PublicIPAddressOperationPredicate{}) +} + +// PublicIPAddressesListVirtualMachineScaleSetPublicIPAddressesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VMSSPublicIPAddressesClient) PublicIPAddressesListVirtualMachineScaleSetPublicIPAddressesCompleteMatchingPredicate(ctx context.Context, id VirtualMachineScaleSetId, predicate PublicIPAddressOperationPredicate) (result PublicIPAddressesListVirtualMachineScaleSetPublicIPAddressesCompleteResult, err error) { + items := make([]PublicIPAddress, 0) + + resp, err := c.PublicIPAddressesListVirtualMachineScaleSetPublicIPAddresses(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = PublicIPAddressesListVirtualMachineScaleSetPublicIPAddressesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/method_publicipaddresseslistvirtualmachinescalesetvmpublicipaddresses.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/method_publicipaddresseslistvirtualmachinescalesetvmpublicipaddresses.go new file mode 100644 index 00000000000..83d7e85289f --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/method_publicipaddresseslistvirtualmachinescalesetvmpublicipaddresses.go @@ -0,0 +1,106 @@ +package vmsspublicipaddresses + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddressesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PublicIPAddress +} + +type PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddressesCompleteResult struct { + LatestHttpResponse *http.Response + Items []PublicIPAddress +} + +type PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddressesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddressesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddresses ... +func (c VMSSPublicIPAddressesClient) PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddresses(ctx context.Context, id commonids.VirtualMachineScaleSetIPConfigurationId) (result PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddressesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddressesCustomPager{}, + Path: fmt.Sprintf("%s/publicIPAddresses", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PublicIPAddress `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddressesComplete retrieves all the results into a single object +func (c VMSSPublicIPAddressesClient) PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddressesComplete(ctx context.Context, id commonids.VirtualMachineScaleSetIPConfigurationId) (PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddressesCompleteResult, error) { + return c.PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddressesCompleteMatchingPredicate(ctx, id, PublicIPAddressOperationPredicate{}) +} + +// PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddressesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c VMSSPublicIPAddressesClient) PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddressesCompleteMatchingPredicate(ctx context.Context, id commonids.VirtualMachineScaleSetIPConfigurationId, predicate PublicIPAddressOperationPredicate) (result PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddressesCompleteResult, err error) { + items := make([]PublicIPAddress, 0) + + resp, err := c.PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddresses(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = PublicIPAddressesListVirtualMachineScaleSetVMPublicIPAddressesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..b5e5db2cc91 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..a08e1bc2b3d --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..a1c62d3aff0 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..29707ea0cc0 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..3d43bc376d7 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..3886b3a62a9 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..2f9f71ffdfe --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_backendaddresspool.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_backendaddresspool.go new file mode 100644 index 00000000000..2d91da68e06 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..da2c343dcde --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..409dfc74f46 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ddossettings.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ddossettings.go new file mode 100644 index 00000000000..9db9902cfa2 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ddossettings.go @@ -0,0 +1,9 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_delegation.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_delegation.go new file mode 100644 index 00000000000..a81e856e7ea --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_delegation.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_flowlog.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_flowlog.go new file mode 100644 index 00000000000..40c6e24d7ea --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_flowlog.go @@ -0,0 +1,19 @@ +package vmsspublicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_flowlogformatparameters.go new file mode 100644 index 00000000000..bbe90b3e68a --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..444648fbefe --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_frontendipconfiguration.go new file mode 100644 index 00000000000..e9d4835cde7 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package vmsspublicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..158c303f1eb --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..a997e703d5a --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_inboundnatrule.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_inboundnatrule.go new file mode 100644 index 00000000000..8d6d17e1ee6 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..0400f6c7e24 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..539ced7c6a7 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..6e9a86e45f0 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipconfiguration.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipconfiguration.go new file mode 100644 index 00000000000..ec14aaebfb2 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..04f420bc9e7 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..cc1b778ec31 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..5c56fd40bae --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_iptag.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_iptag.go new file mode 100644 index 00000000000..0f545f4b72b --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_iptag.go @@ -0,0 +1,9 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..6c1a542cb79 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..046c6088344 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_natgateway.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_natgateway.go new file mode 100644 index 00000000000..d11b8d3920d --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_natgateway.go @@ -0,0 +1,20 @@ +package vmsspublicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..7b155a60209 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_natgatewaysku.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_natgatewaysku.go new file mode 100644 index 00000000000..3b91a6c98fb --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_natruleportmapping.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_natruleportmapping.go new file mode 100644 index 00000000000..09ace168bf2 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterface.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterface.go new file mode 100644 index 00000000000..e494f13e660 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterface.go @@ -0,0 +1,19 @@ +package vmsspublicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..178cb8cc8d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..5e15e82902b --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..5b63a7f1427 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..ef82bcec7f4 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..82517d57b07 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..89d8808f2b8 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..dd5cb5650a9 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networksecuritygroup.go new file mode 100644 index 00000000000..390dad55504 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..fd1b9110f0b --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpoint.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpoint.go new file mode 100644 index 00000000000..9d1b5059d51 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpoint.go @@ -0,0 +1,19 @@ +package vmsspublicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpointconnection.go new file mode 100644 index 00000000000..37a23931c51 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..edd52323b43 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..7e43ad06e3b --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..13d66a23bb9 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpointproperties.go new file mode 100644 index 00000000000..9d7c5581f99 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkservice.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkservice.go new file mode 100644 index 00000000000..35696ff7af8 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package vmsspublicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..15a277940b8 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..36505cb0e91 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..87693646750 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..ffcb7babff1 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..1ac62f6b573 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..bc45ddc58d7 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_publicipaddress.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_publicipaddress.go new file mode 100644 index 00000000000..007f38c15a0 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_publicipaddress.go @@ -0,0 +1,22 @@ +package vmsspublicipaddresses + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..5c5c8e381d5 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..04e2f5851e5 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_publicipaddresssku.go new file mode 100644 index 00000000000..836d26bc7cf --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_resourcenavigationlink.go new file mode 100644 index 00000000000..2001bb2021a --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..255ed3f4d7d --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_resourceset.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_resourceset.go new file mode 100644 index 00000000000..aa795989827 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_resourceset.go @@ -0,0 +1,8 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..18486b1b930 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_route.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_route.go new file mode 100644 index 00000000000..d5542b4d6a2 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_route.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_routepropertiesformat.go new file mode 100644 index 00000000000..7306e155bd1 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_routetable.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_routetable.go new file mode 100644 index 00000000000..0e623eb4de8 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_routetable.go @@ -0,0 +1,14 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..247f8d8ff0b --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_securityrule.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_securityrule.go new file mode 100644 index 00000000000..be3c680f597 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_securityrule.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..45a25e92fa7 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceassociationlink.go new file mode 100644 index 00000000000..6e209a0a72c --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..7761fb2f5e9 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..0ce0853975d --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..32e2b036118 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..d0368e894a0 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..970c54c6772 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..fd6dca6bdb5 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..095a4886e15 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_subnet.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_subnet.go new file mode 100644 index 00000000000..fd72bf01d45 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_subnet.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..692176aa486 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_subresource.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_subresource.go new file mode 100644 index 00000000000..c4627dc0146 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_subresource.go @@ -0,0 +1,8 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..9685e4269c8 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..e18abbc1afe --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_virtualnetworktap.go new file mode 100644 index 00000000000..80ebd9f850d --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..cff477ca81b --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/predicates.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/predicates.go new file mode 100644 index 00000000000..3173ab41a32 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/predicates.go @@ -0,0 +1,37 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p PublicIPAddressOperationPredicate) Matches(input PublicIPAddress) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/vmsspublicipaddresses/version.go b/resource-manager/network/2024-07-01/vmsspublicipaddresses/version.go new file mode 100644 index 00000000000..d0c6d023e93 --- /dev/null +++ b/resource-manager/network/2024-07-01/vmsspublicipaddresses/version.go @@ -0,0 +1,10 @@ +package vmsspublicipaddresses + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/vmsspublicipaddresses/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/vpngateways/README.md b/resource-manager/network/2024-07-01/vpngateways/README.md new file mode 100644 index 00000000000..b1f519d3c07 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/README.md @@ -0,0 +1,83 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/vpngateways` Documentation + +The `vpngateways` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/vpngateways" +``` + + +### Client Initialization + +```go +client := vpngateways.NewVpnGatewaysClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VpnGatewaysClient.Reset` + +```go +ctx := context.TODO() +id := vpngateways.NewVpnGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName") + +if err := client.ResetThenPoll(ctx, id, vpngateways.DefaultResetOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `VpnGatewaysClient.StartPacketCapture` + +```go +ctx := context.TODO() +id := vpngateways.NewVpnGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName") + +payload := vpngateways.VpnGatewayPacketCaptureStartParameters{ + // ... +} + + +if err := client.StartPacketCaptureThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VpnGatewaysClient.StopPacketCapture` + +```go +ctx := context.TODO() +id := vpngateways.NewVpnGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName") + +payload := vpngateways.VpnGatewayPacketCaptureStopParameters{ + // ... +} + + +if err := client.StopPacketCaptureThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `VpnGatewaysClient.UpdateTags` + +```go +ctx := context.TODO() +id := vpngateways.NewVpnGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName") + +payload := vpngateways.TagsObject{ + // ... +} + + +if err := client.UpdateTagsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/network/2024-07-01/vpngateways/client.go b/resource-manager/network/2024-07-01/vpngateways/client.go new file mode 100644 index 00000000000..c17671a8ad9 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/client.go @@ -0,0 +1,26 @@ +package vpngateways + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGatewaysClient struct { + Client *resourcemanager.Client +} + +func NewVpnGatewaysClientWithBaseURI(sdkApi sdkEnv.Api) (*VpnGatewaysClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "vpngateways", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VpnGatewaysClient: %+v", err) + } + + return &VpnGatewaysClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/vpngateways/constants.go b/resource-manager/network/2024-07-01/vpngateways/constants.go new file mode 100644 index 00000000000..2f1745c4980 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/constants.go @@ -0,0 +1,657 @@ +package vpngateways + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DhGroup string + +const ( + DhGroupDHGroupOne DhGroup = "DHGroup1" + DhGroupDHGroupOneFour DhGroup = "DHGroup14" + DhGroupDHGroupTwo DhGroup = "DHGroup2" + DhGroupDHGroupTwoFour DhGroup = "DHGroup24" + DhGroupDHGroupTwoZeroFourEight DhGroup = "DHGroup2048" + DhGroupECPThreeEightFour DhGroup = "ECP384" + DhGroupECPTwoFiveSix DhGroup = "ECP256" + DhGroupNone DhGroup = "None" +) + +func PossibleValuesForDhGroup() []string { + return []string{ + string(DhGroupDHGroupOne), + string(DhGroupDHGroupOneFour), + string(DhGroupDHGroupTwo), + string(DhGroupDHGroupTwoFour), + string(DhGroupDHGroupTwoZeroFourEight), + string(DhGroupECPThreeEightFour), + string(DhGroupECPTwoFiveSix), + string(DhGroupNone), + } +} + +func (s *DhGroup) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDhGroup(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDhGroup(input string) (*DhGroup, error) { + vals := map[string]DhGroup{ + "dhgroup1": DhGroupDHGroupOne, + "dhgroup14": DhGroupDHGroupOneFour, + "dhgroup2": DhGroupDHGroupTwo, + "dhgroup24": DhGroupDHGroupTwoFour, + "dhgroup2048": DhGroupDHGroupTwoZeroFourEight, + "ecp384": DhGroupECPThreeEightFour, + "ecp256": DhGroupECPTwoFiveSix, + "none": DhGroupNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DhGroup(input) + return &out, nil +} + +type IPsecEncryption string + +const ( + IPsecEncryptionAESOneNineTwo IPsecEncryption = "AES192" + IPsecEncryptionAESOneTwoEight IPsecEncryption = "AES128" + IPsecEncryptionAESTwoFiveSix IPsecEncryption = "AES256" + IPsecEncryptionDES IPsecEncryption = "DES" + IPsecEncryptionDESThree IPsecEncryption = "DES3" + IPsecEncryptionGCMAESOneNineTwo IPsecEncryption = "GCMAES192" + IPsecEncryptionGCMAESOneTwoEight IPsecEncryption = "GCMAES128" + IPsecEncryptionGCMAESTwoFiveSix IPsecEncryption = "GCMAES256" + IPsecEncryptionNone IPsecEncryption = "None" +) + +func PossibleValuesForIPsecEncryption() []string { + return []string{ + string(IPsecEncryptionAESOneNineTwo), + string(IPsecEncryptionAESOneTwoEight), + string(IPsecEncryptionAESTwoFiveSix), + string(IPsecEncryptionDES), + string(IPsecEncryptionDESThree), + string(IPsecEncryptionGCMAESOneNineTwo), + string(IPsecEncryptionGCMAESOneTwoEight), + string(IPsecEncryptionGCMAESTwoFiveSix), + string(IPsecEncryptionNone), + } +} + +func (s *IPsecEncryption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPsecEncryption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPsecEncryption(input string) (*IPsecEncryption, error) { + vals := map[string]IPsecEncryption{ + "aes192": IPsecEncryptionAESOneNineTwo, + "aes128": IPsecEncryptionAESOneTwoEight, + "aes256": IPsecEncryptionAESTwoFiveSix, + "des": IPsecEncryptionDES, + "des3": IPsecEncryptionDESThree, + "gcmaes192": IPsecEncryptionGCMAESOneNineTwo, + "gcmaes128": IPsecEncryptionGCMAESOneTwoEight, + "gcmaes256": IPsecEncryptionGCMAESTwoFiveSix, + "none": IPsecEncryptionNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPsecEncryption(input) + return &out, nil +} + +type IPsecIntegrity string + +const ( + IPsecIntegrityGCMAESOneNineTwo IPsecIntegrity = "GCMAES192" + IPsecIntegrityGCMAESOneTwoEight IPsecIntegrity = "GCMAES128" + IPsecIntegrityGCMAESTwoFiveSix IPsecIntegrity = "GCMAES256" + IPsecIntegrityMDFive IPsecIntegrity = "MD5" + IPsecIntegritySHAOne IPsecIntegrity = "SHA1" + IPsecIntegritySHATwoFiveSix IPsecIntegrity = "SHA256" +) + +func PossibleValuesForIPsecIntegrity() []string { + return []string{ + string(IPsecIntegrityGCMAESOneNineTwo), + string(IPsecIntegrityGCMAESOneTwoEight), + string(IPsecIntegrityGCMAESTwoFiveSix), + string(IPsecIntegrityMDFive), + string(IPsecIntegritySHAOne), + string(IPsecIntegritySHATwoFiveSix), + } +} + +func (s *IPsecIntegrity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPsecIntegrity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPsecIntegrity(input string) (*IPsecIntegrity, error) { + vals := map[string]IPsecIntegrity{ + "gcmaes192": IPsecIntegrityGCMAESOneNineTwo, + "gcmaes128": IPsecIntegrityGCMAESOneTwoEight, + "gcmaes256": IPsecIntegrityGCMAESTwoFiveSix, + "md5": IPsecIntegrityMDFive, + "sha1": IPsecIntegritySHAOne, + "sha256": IPsecIntegritySHATwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPsecIntegrity(input) + return &out, nil +} + +type IkeEncryption string + +const ( + IkeEncryptionAESOneNineTwo IkeEncryption = "AES192" + IkeEncryptionAESOneTwoEight IkeEncryption = "AES128" + IkeEncryptionAESTwoFiveSix IkeEncryption = "AES256" + IkeEncryptionDES IkeEncryption = "DES" + IkeEncryptionDESThree IkeEncryption = "DES3" + IkeEncryptionGCMAESOneTwoEight IkeEncryption = "GCMAES128" + IkeEncryptionGCMAESTwoFiveSix IkeEncryption = "GCMAES256" +) + +func PossibleValuesForIkeEncryption() []string { + return []string{ + string(IkeEncryptionAESOneNineTwo), + string(IkeEncryptionAESOneTwoEight), + string(IkeEncryptionAESTwoFiveSix), + string(IkeEncryptionDES), + string(IkeEncryptionDESThree), + string(IkeEncryptionGCMAESOneTwoEight), + string(IkeEncryptionGCMAESTwoFiveSix), + } +} + +func (s *IkeEncryption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIkeEncryption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIkeEncryption(input string) (*IkeEncryption, error) { + vals := map[string]IkeEncryption{ + "aes192": IkeEncryptionAESOneNineTwo, + "aes128": IkeEncryptionAESOneTwoEight, + "aes256": IkeEncryptionAESTwoFiveSix, + "des": IkeEncryptionDES, + "des3": IkeEncryptionDESThree, + "gcmaes128": IkeEncryptionGCMAESOneTwoEight, + "gcmaes256": IkeEncryptionGCMAESTwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IkeEncryption(input) + return &out, nil +} + +type IkeIntegrity string + +const ( + IkeIntegrityGCMAESOneTwoEight IkeIntegrity = "GCMAES128" + IkeIntegrityGCMAESTwoFiveSix IkeIntegrity = "GCMAES256" + IkeIntegrityMDFive IkeIntegrity = "MD5" + IkeIntegritySHAOne IkeIntegrity = "SHA1" + IkeIntegritySHAThreeEightFour IkeIntegrity = "SHA384" + IkeIntegritySHATwoFiveSix IkeIntegrity = "SHA256" +) + +func PossibleValuesForIkeIntegrity() []string { + return []string{ + string(IkeIntegrityGCMAESOneTwoEight), + string(IkeIntegrityGCMAESTwoFiveSix), + string(IkeIntegrityMDFive), + string(IkeIntegritySHAOne), + string(IkeIntegritySHAThreeEightFour), + string(IkeIntegritySHATwoFiveSix), + } +} + +func (s *IkeIntegrity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIkeIntegrity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIkeIntegrity(input string) (*IkeIntegrity, error) { + vals := map[string]IkeIntegrity{ + "gcmaes128": IkeIntegrityGCMAESOneTwoEight, + "gcmaes256": IkeIntegrityGCMAESTwoFiveSix, + "md5": IkeIntegrityMDFive, + "sha1": IkeIntegritySHAOne, + "sha384": IkeIntegritySHAThreeEightFour, + "sha256": IkeIntegritySHATwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IkeIntegrity(input) + return &out, nil +} + +type PfsGroup string + +const ( + PfsGroupECPThreeEightFour PfsGroup = "ECP384" + PfsGroupECPTwoFiveSix PfsGroup = "ECP256" + PfsGroupNone PfsGroup = "None" + PfsGroupPFSMM PfsGroup = "PFSMM" + PfsGroupPFSOne PfsGroup = "PFS1" + PfsGroupPFSOneFour PfsGroup = "PFS14" + PfsGroupPFSTwo PfsGroup = "PFS2" + PfsGroupPFSTwoFour PfsGroup = "PFS24" + PfsGroupPFSTwoZeroFourEight PfsGroup = "PFS2048" +) + +func PossibleValuesForPfsGroup() []string { + return []string{ + string(PfsGroupECPThreeEightFour), + string(PfsGroupECPTwoFiveSix), + string(PfsGroupNone), + string(PfsGroupPFSMM), + string(PfsGroupPFSOne), + string(PfsGroupPFSOneFour), + string(PfsGroupPFSTwo), + string(PfsGroupPFSTwoFour), + string(PfsGroupPFSTwoZeroFourEight), + } +} + +func (s *PfsGroup) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePfsGroup(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePfsGroup(input string) (*PfsGroup, error) { + vals := map[string]PfsGroup{ + "ecp384": PfsGroupECPThreeEightFour, + "ecp256": PfsGroupECPTwoFiveSix, + "none": PfsGroupNone, + "pfsmm": PfsGroupPFSMM, + "pfs1": PfsGroupPFSOne, + "pfs14": PfsGroupPFSOneFour, + "pfs2": PfsGroupPFSTwo, + "pfs24": PfsGroupPFSTwoFour, + "pfs2048": PfsGroupPFSTwoZeroFourEight, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PfsGroup(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type VirtualNetworkGatewayConnectionProtocol string + +const ( + VirtualNetworkGatewayConnectionProtocolIKEvOne VirtualNetworkGatewayConnectionProtocol = "IKEv1" + VirtualNetworkGatewayConnectionProtocolIKEvTwo VirtualNetworkGatewayConnectionProtocol = "IKEv2" +) + +func PossibleValuesForVirtualNetworkGatewayConnectionProtocol() []string { + return []string{ + string(VirtualNetworkGatewayConnectionProtocolIKEvOne), + string(VirtualNetworkGatewayConnectionProtocolIKEvTwo), + } +} + +func (s *VirtualNetworkGatewayConnectionProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkGatewayConnectionProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkGatewayConnectionProtocol(input string) (*VirtualNetworkGatewayConnectionProtocol, error) { + vals := map[string]VirtualNetworkGatewayConnectionProtocol{ + "ikev1": VirtualNetworkGatewayConnectionProtocolIKEvOne, + "ikev2": VirtualNetworkGatewayConnectionProtocolIKEvTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkGatewayConnectionProtocol(input) + return &out, nil +} + +type VnetLocalRouteOverrideCriteria string + +const ( + VnetLocalRouteOverrideCriteriaContains VnetLocalRouteOverrideCriteria = "Contains" + VnetLocalRouteOverrideCriteriaEqual VnetLocalRouteOverrideCriteria = "Equal" +) + +func PossibleValuesForVnetLocalRouteOverrideCriteria() []string { + return []string{ + string(VnetLocalRouteOverrideCriteriaContains), + string(VnetLocalRouteOverrideCriteriaEqual), + } +} + +func (s *VnetLocalRouteOverrideCriteria) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVnetLocalRouteOverrideCriteria(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVnetLocalRouteOverrideCriteria(input string) (*VnetLocalRouteOverrideCriteria, error) { + vals := map[string]VnetLocalRouteOverrideCriteria{ + "contains": VnetLocalRouteOverrideCriteriaContains, + "equal": VnetLocalRouteOverrideCriteriaEqual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VnetLocalRouteOverrideCriteria(input) + return &out, nil +} + +type VpnConnectionStatus string + +const ( + VpnConnectionStatusConnected VpnConnectionStatus = "Connected" + VpnConnectionStatusConnecting VpnConnectionStatus = "Connecting" + VpnConnectionStatusNotConnected VpnConnectionStatus = "NotConnected" + VpnConnectionStatusUnknown VpnConnectionStatus = "Unknown" +) + +func PossibleValuesForVpnConnectionStatus() []string { + return []string{ + string(VpnConnectionStatusConnected), + string(VpnConnectionStatusConnecting), + string(VpnConnectionStatusNotConnected), + string(VpnConnectionStatusUnknown), + } +} + +func (s *VpnConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnConnectionStatus(input string) (*VpnConnectionStatus, error) { + vals := map[string]VpnConnectionStatus{ + "connected": VpnConnectionStatusConnected, + "connecting": VpnConnectionStatusConnecting, + "notconnected": VpnConnectionStatusNotConnected, + "unknown": VpnConnectionStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnConnectionStatus(input) + return &out, nil +} + +type VpnLinkConnectionMode string + +const ( + VpnLinkConnectionModeDefault VpnLinkConnectionMode = "Default" + VpnLinkConnectionModeInitiatorOnly VpnLinkConnectionMode = "InitiatorOnly" + VpnLinkConnectionModeResponderOnly VpnLinkConnectionMode = "ResponderOnly" +) + +func PossibleValuesForVpnLinkConnectionMode() []string { + return []string{ + string(VpnLinkConnectionModeDefault), + string(VpnLinkConnectionModeInitiatorOnly), + string(VpnLinkConnectionModeResponderOnly), + } +} + +func (s *VpnLinkConnectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnLinkConnectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnLinkConnectionMode(input string) (*VpnLinkConnectionMode, error) { + vals := map[string]VpnLinkConnectionMode{ + "default": VpnLinkConnectionModeDefault, + "initiatoronly": VpnLinkConnectionModeInitiatorOnly, + "responderonly": VpnLinkConnectionModeResponderOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnLinkConnectionMode(input) + return &out, nil +} + +type VpnNatRuleMode string + +const ( + VpnNatRuleModeEgressSnat VpnNatRuleMode = "EgressSnat" + VpnNatRuleModeIngressSnat VpnNatRuleMode = "IngressSnat" +) + +func PossibleValuesForVpnNatRuleMode() []string { + return []string{ + string(VpnNatRuleModeEgressSnat), + string(VpnNatRuleModeIngressSnat), + } +} + +func (s *VpnNatRuleMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnNatRuleMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnNatRuleMode(input string) (*VpnNatRuleMode, error) { + vals := map[string]VpnNatRuleMode{ + "egresssnat": VpnNatRuleModeEgressSnat, + "ingresssnat": VpnNatRuleModeIngressSnat, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnNatRuleMode(input) + return &out, nil +} + +type VpnNatRuleType string + +const ( + VpnNatRuleTypeDynamic VpnNatRuleType = "Dynamic" + VpnNatRuleTypeStatic VpnNatRuleType = "Static" +) + +func PossibleValuesForVpnNatRuleType() []string { + return []string{ + string(VpnNatRuleTypeDynamic), + string(VpnNatRuleTypeStatic), + } +} + +func (s *VpnNatRuleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnNatRuleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnNatRuleType(input string) (*VpnNatRuleType, error) { + vals := map[string]VpnNatRuleType{ + "dynamic": VpnNatRuleTypeDynamic, + "static": VpnNatRuleTypeStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnNatRuleType(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/vpngateways/id_vpngateway.go b/resource-manager/network/2024-07-01/vpngateways/id_vpngateway.go new file mode 100644 index 00000000000..220d3ffa7b3 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/id_vpngateway.go @@ -0,0 +1,130 @@ +package vpngateways + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VpnGatewayId{}) +} + +var _ resourceids.ResourceId = &VpnGatewayId{} + +// VpnGatewayId is a struct representing the Resource ID for a Vpn Gateway +type VpnGatewayId struct { + SubscriptionId string + ResourceGroupName string + VpnGatewayName string +} + +// NewVpnGatewayID returns a new VpnGatewayId struct +func NewVpnGatewayID(subscriptionId string, resourceGroupName string, vpnGatewayName string) VpnGatewayId { + return VpnGatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VpnGatewayName: vpnGatewayName, + } +} + +// ParseVpnGatewayID parses 'input' into a VpnGatewayId +func ParseVpnGatewayID(input string) (*VpnGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnGatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVpnGatewayIDInsensitively parses 'input' case-insensitively into a VpnGatewayId +// note: this method should only be used for API response data and not user input +func ParseVpnGatewayIDInsensitively(input string) (*VpnGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnGatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VpnGatewayId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VpnGatewayName, ok = input.Parsed["vpnGatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vpnGatewayName", input) + } + + return nil +} + +// ValidateVpnGatewayID checks that 'input' can be parsed as a Vpn Gateway ID +func ValidateVpnGatewayID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVpnGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vpn Gateway ID +func (id VpnGatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/vpnGateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VpnGatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vpn Gateway ID +func (id VpnGatewayId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVpnGateways", "vpnGateways", "vpnGateways"), + resourceids.UserSpecifiedSegment("vpnGatewayName", "vpnGatewayName"), + } +} + +// String returns a human-readable description of this Vpn Gateway ID +func (id VpnGatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vpn Gateway Name: %q", id.VpnGatewayName), + } + return fmt.Sprintf("Vpn Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/vpngateways/id_vpngateway_test.go b/resource-manager/network/2024-07-01/vpngateways/id_vpngateway_test.go new file mode 100644 index 00000000000..c9c4abcd122 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/id_vpngateway_test.go @@ -0,0 +1,282 @@ +package vpngateways + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VpnGatewayId{} + +func TestNewVpnGatewayID(t *testing.T) { + id := NewVpnGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VpnGatewayName != "vpnGatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'VpnGatewayName'", id.VpnGatewayName, "vpnGatewayName") + } +} + +func TestFormatVpnGatewayID(t *testing.T) { + actual := NewVpnGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVpnGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName", + Expected: &VpnGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnGatewayName: "vpnGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnGatewayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnGatewayName != v.Expected.VpnGatewayName { + t.Fatalf("Expected %q but got %q for VpnGatewayName", v.Expected.VpnGatewayName, actual.VpnGatewayName) + } + + } +} + +func TestParseVpnGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName", + Expected: &VpnGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnGatewayName: "vpnGatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE", + Expected: &VpnGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VpnGatewayName: "vPnGaTeWaYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnGatewayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnGatewayName != v.Expected.VpnGatewayName { + t.Fatalf("Expected %q but got %q for VpnGatewayName", v.Expected.VpnGatewayName, actual.VpnGatewayName) + } + + } +} + +func TestSegmentsForVpnGatewayId(t *testing.T) { + segments := VpnGatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VpnGatewayId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/vpngateways/method_reset.go b/resource-manager/network/2024-07-01/vpngateways/method_reset.go new file mode 100644 index 00000000000..06856815c74 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/method_reset.go @@ -0,0 +1,100 @@ +package vpngateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResetOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VpnGateway +} + +type ResetOperationOptions struct { + IPConfigurationId *string +} + +func DefaultResetOperationOptions() ResetOperationOptions { + return ResetOperationOptions{} +} + +func (o ResetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ResetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ResetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IPConfigurationId != nil { + out.Append("ipConfigurationId", fmt.Sprintf("%v", *o.IPConfigurationId)) + } + return &out +} + +// Reset ... +func (c VpnGatewaysClient) Reset(ctx context.Context, id VpnGatewayId, options ResetOperationOptions) (result ResetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/reset", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResetThenPoll performs Reset then polls until it's completed +func (c VpnGatewaysClient) ResetThenPoll(ctx context.Context, id VpnGatewayId, options ResetOperationOptions) error { + result, err := c.Reset(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Reset: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Reset: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/vpngateways/method_startpacketcapture.go b/resource-manager/network/2024-07-01/vpngateways/method_startpacketcapture.go new file mode 100644 index 00000000000..939a677ec57 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/method_startpacketcapture.go @@ -0,0 +1,75 @@ +package vpngateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartPacketCaptureOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// StartPacketCapture ... +func (c VpnGatewaysClient) StartPacketCapture(ctx context.Context, id VpnGatewayId, input VpnGatewayPacketCaptureStartParameters) (result StartPacketCaptureOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startpacketcapture", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StartPacketCaptureThenPoll performs StartPacketCapture then polls until it's completed +func (c VpnGatewaysClient) StartPacketCaptureThenPoll(ctx context.Context, id VpnGatewayId, input VpnGatewayPacketCaptureStartParameters) error { + result, err := c.StartPacketCapture(ctx, id, input) + if err != nil { + return fmt.Errorf("performing StartPacketCapture: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartPacketCapture: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/vpngateways/method_stoppacketcapture.go b/resource-manager/network/2024-07-01/vpngateways/method_stoppacketcapture.go new file mode 100644 index 00000000000..52d225da3ca --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/method_stoppacketcapture.go @@ -0,0 +1,75 @@ +package vpngateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopPacketCaptureOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// StopPacketCapture ... +func (c VpnGatewaysClient) StopPacketCapture(ctx context.Context, id VpnGatewayId, input VpnGatewayPacketCaptureStopParameters) (result StopPacketCaptureOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stoppacketcapture", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StopPacketCaptureThenPoll performs StopPacketCapture then polls until it's completed +func (c VpnGatewaysClient) StopPacketCaptureThenPoll(ctx context.Context, id VpnGatewayId, input VpnGatewayPacketCaptureStopParameters) error { + result, err := c.StopPacketCapture(ctx, id, input) + if err != nil { + return fmt.Errorf("performing StopPacketCapture: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StopPacketCapture: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/vpngateways/method_updatetags.go b/resource-manager/network/2024-07-01/vpngateways/method_updatetags.go new file mode 100644 index 00000000000..9149232ae67 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/method_updatetags.go @@ -0,0 +1,75 @@ +package vpngateways + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *VpnGateway +} + +// UpdateTags ... +func (c VpnGatewaysClient) UpdateTags(ctx context.Context, id VpnGatewayId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateTagsThenPoll performs UpdateTags then polls until it's completed +func (c VpnGatewaysClient) UpdateTagsThenPoll(ctx context.Context, id VpnGatewayId, input TagsObject) error { + result, err := c.UpdateTags(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UpdateTags: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpdateTags: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_bgpsettings.go b/resource-manager/network/2024-07-01/vpngateways/model_bgpsettings.go new file mode 100644 index 00000000000..f2627d16bf7 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_bgpsettings.go @@ -0,0 +1,11 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BgpSettings struct { + Asn *int64 `json:"asn,omitempty"` + BgpPeeringAddress *string `json:"bgpPeeringAddress,omitempty"` + BgpPeeringAddresses *[]IPConfigurationBgpPeeringAddress `json:"bgpPeeringAddresses,omitempty"` + PeerWeight *int64 `json:"peerWeight,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_gatewaycustombgpipaddressipconfiguration.go b/resource-manager/network/2024-07-01/vpngateways/model_gatewaycustombgpipaddressipconfiguration.go new file mode 100644 index 00000000000..6b30604f2da --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_gatewaycustombgpipaddressipconfiguration.go @@ -0,0 +1,9 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayCustomBgpIPAddressIPConfiguration struct { + CustomBgpIPAddress string `json:"customBgpIpAddress"` + IPConfigurationId string `json:"ipConfigurationId"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_ipconfigurationbgppeeringaddress.go b/resource-manager/network/2024-07-01/vpngateways/model_ipconfigurationbgppeeringaddress.go new file mode 100644 index 00000000000..c3e0e46c541 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_ipconfigurationbgppeeringaddress.go @@ -0,0 +1,11 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationBgpPeeringAddress struct { + CustomBgpIPAddresses *[]string `json:"customBgpIpAddresses,omitempty"` + DefaultBgpIPAddresses *[]string `json:"defaultBgpIpAddresses,omitempty"` + IPconfigurationId *string `json:"ipconfigurationId,omitempty"` + TunnelIPAddresses *[]string `json:"tunnelIpAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_ipsecpolicy.go b/resource-manager/network/2024-07-01/vpngateways/model_ipsecpolicy.go new file mode 100644 index 00000000000..63c4e9184df --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_ipsecpolicy.go @@ -0,0 +1,15 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPsecPolicy struct { + DhGroup DhGroup `json:"dhGroup"` + IPsecEncryption IPsecEncryption `json:"ipsecEncryption"` + IPsecIntegrity IPsecIntegrity `json:"ipsecIntegrity"` + IkeEncryption IkeEncryption `json:"ikeEncryption"` + IkeIntegrity IkeIntegrity `json:"ikeIntegrity"` + PfsGroup PfsGroup `json:"pfsGroup"` + SaDataSizeKilobytes int64 `json:"saDataSizeKilobytes"` + SaLifeTimeSeconds int64 `json:"saLifeTimeSeconds"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_propagatedroutetable.go b/resource-manager/network/2024-07-01/vpngateways/model_propagatedroutetable.go new file mode 100644 index 00000000000..e838e6e2dc7 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_propagatedroutetable.go @@ -0,0 +1,9 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PropagatedRouteTable struct { + Ids *[]SubResource `json:"ids,omitempty"` + Labels *[]string `json:"labels,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_routingconfiguration.go b/resource-manager/network/2024-07-01/vpngateways/model_routingconfiguration.go new file mode 100644 index 00000000000..fe2fd37804f --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_routingconfiguration.go @@ -0,0 +1,12 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingConfiguration struct { + AssociatedRouteTable *SubResource `json:"associatedRouteTable,omitempty"` + InboundRouteMap *SubResource `json:"inboundRouteMap,omitempty"` + OutboundRouteMap *SubResource `json:"outboundRouteMap,omitempty"` + PropagatedRouteTables *PropagatedRouteTable `json:"propagatedRouteTables,omitempty"` + VnetRoutes *VnetRoute `json:"vnetRoutes,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_staticroute.go b/resource-manager/network/2024-07-01/vpngateways/model_staticroute.go new file mode 100644 index 00000000000..90806109c8c --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_staticroute.go @@ -0,0 +1,10 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticRoute struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + Name *string `json:"name,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_staticroutesconfig.go b/resource-manager/network/2024-07-01/vpngateways/model_staticroutesconfig.go new file mode 100644 index 00000000000..b973c853be2 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_staticroutesconfig.go @@ -0,0 +1,9 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticRoutesConfig struct { + PropagateStaticRoutes *bool `json:"propagateStaticRoutes,omitempty"` + VnetLocalRouteOverrideCriteria *VnetLocalRouteOverrideCriteria `json:"vnetLocalRouteOverrideCriteria,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_subresource.go b/resource-manager/network/2024-07-01/vpngateways/model_subresource.go new file mode 100644 index 00000000000..cf0dbcdeb10 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_subresource.go @@ -0,0 +1,8 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_tagsobject.go b/resource-manager/network/2024-07-01/vpngateways/model_tagsobject.go new file mode 100644 index 00000000000..dd09a7e7f34 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_tagsobject.go @@ -0,0 +1,8 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_trafficselectorpolicy.go b/resource-manager/network/2024-07-01/vpngateways/model_trafficselectorpolicy.go new file mode 100644 index 00000000000..b65874d225f --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_trafficselectorpolicy.go @@ -0,0 +1,9 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficSelectorPolicy struct { + LocalAddressRanges []string `json:"localAddressRanges"` + RemoteAddressRanges []string `json:"remoteAddressRanges"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_vnetroute.go b/resource-manager/network/2024-07-01/vpngateways/model_vnetroute.go new file mode 100644 index 00000000000..31f211b1d1d --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_vnetroute.go @@ -0,0 +1,10 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRoute struct { + BgpConnections *[]SubResource `json:"bgpConnections,omitempty"` + StaticRoutes *[]StaticRoute `json:"staticRoutes,omitempty"` + StaticRoutesConfig *StaticRoutesConfig `json:"staticRoutesConfig,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_vpnconnection.go b/resource-manager/network/2024-07-01/vpngateways/model_vpnconnection.go new file mode 100644 index 00000000000..a65d73ea9e8 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_vpnconnection.go @@ -0,0 +1,11 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnConnectionProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_vpnconnectionproperties.go b/resource-manager/network/2024-07-01/vpngateways/model_vpnconnectionproperties.go new file mode 100644 index 00000000000..df2da84d685 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_vpnconnectionproperties.go @@ -0,0 +1,26 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnConnectionProperties struct { + ConnectionBandwidth *int64 `json:"connectionBandwidth,omitempty"` + ConnectionStatus *VpnConnectionStatus `json:"connectionStatus,omitempty"` + DpdTimeoutSeconds *int64 `json:"dpdTimeoutSeconds,omitempty"` + EgressBytesTransferred *int64 `json:"egressBytesTransferred,omitempty"` + EnableBgp *bool `json:"enableBgp,omitempty"` + EnableInternetSecurity *bool `json:"enableInternetSecurity,omitempty"` + EnableRateLimiting *bool `json:"enableRateLimiting,omitempty"` + IPsecPolicies *[]IPsecPolicy `json:"ipsecPolicies,omitempty"` + IngressBytesTransferred *int64 `json:"ingressBytesTransferred,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RemoteVpnSite *SubResource `json:"remoteVpnSite,omitempty"` + RoutingConfiguration *RoutingConfiguration `json:"routingConfiguration,omitempty"` + RoutingWeight *int64 `json:"routingWeight,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` + TrafficSelectorPolicies *[]TrafficSelectorPolicy `json:"trafficSelectorPolicies,omitempty"` + UseLocalAzureIPAddress *bool `json:"useLocalAzureIpAddress,omitempty"` + UsePolicyBasedTrafficSelectors *bool `json:"usePolicyBasedTrafficSelectors,omitempty"` + VpnConnectionProtocolType *VirtualNetworkGatewayConnectionProtocol `json:"vpnConnectionProtocolType,omitempty"` + VpnLinkConnections *[]VpnSiteLinkConnection `json:"vpnLinkConnections,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_vpngateway.go b/resource-manager/network/2024-07-01/vpngateways/model_vpngateway.go new file mode 100644 index 00000000000..8117006b3a9 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_vpngateway.go @@ -0,0 +1,14 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnGatewayProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_vpngatewayipconfiguration.go b/resource-manager/network/2024-07-01/vpngateways/model_vpngatewayipconfiguration.go new file mode 100644 index 00000000000..703d0c1d833 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_vpngatewayipconfiguration.go @@ -0,0 +1,10 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGatewayIPConfiguration struct { + Id *string `json:"id,omitempty"` + PrivateIPAddress *string `json:"privateIpAddress,omitempty"` + PublicIPAddress *string `json:"publicIpAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_vpngatewaynatrule.go b/resource-manager/network/2024-07-01/vpngateways/model_vpngatewaynatrule.go new file mode 100644 index 00000000000..833a44f9a3d --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_vpngatewaynatrule.go @@ -0,0 +1,12 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGatewayNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnGatewayNatRuleProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_vpngatewaynatruleproperties.go b/resource-manager/network/2024-07-01/vpngateways/model_vpngatewaynatruleproperties.go new file mode 100644 index 00000000000..240415bacef --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_vpngatewaynatruleproperties.go @@ -0,0 +1,15 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGatewayNatRuleProperties struct { + EgressVpnSiteLinkConnections *[]SubResource `json:"egressVpnSiteLinkConnections,omitempty"` + ExternalMappings *[]VpnNatRuleMapping `json:"externalMappings,omitempty"` + IPConfigurationId *string `json:"ipConfigurationId,omitempty"` + IngressVpnSiteLinkConnections *[]SubResource `json:"ingressVpnSiteLinkConnections,omitempty"` + InternalMappings *[]VpnNatRuleMapping `json:"internalMappings,omitempty"` + Mode *VpnNatRuleMode `json:"mode,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Type *VpnNatRuleType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_vpngatewaypacketcapturestartparameters.go b/resource-manager/network/2024-07-01/vpngateways/model_vpngatewaypacketcapturestartparameters.go new file mode 100644 index 00000000000..4afb62c2a68 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_vpngatewaypacketcapturestartparameters.go @@ -0,0 +1,8 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGatewayPacketCaptureStartParameters struct { + FilterData *string `json:"filterData,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_vpngatewaypacketcapturestopparameters.go b/resource-manager/network/2024-07-01/vpngateways/model_vpngatewaypacketcapturestopparameters.go new file mode 100644 index 00000000000..95998f06000 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_vpngatewaypacketcapturestopparameters.go @@ -0,0 +1,8 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGatewayPacketCaptureStopParameters struct { + SasURL *string `json:"sasUrl,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_vpngatewayproperties.go b/resource-manager/network/2024-07-01/vpngateways/model_vpngatewayproperties.go new file mode 100644 index 00000000000..aa5ac3cbf6c --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_vpngatewayproperties.go @@ -0,0 +1,16 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnGatewayProperties struct { + BgpSettings *BgpSettings `json:"bgpSettings,omitempty"` + Connections *[]VpnConnection `json:"connections,omitempty"` + EnableBgpRouteTranslationForNat *bool `json:"enableBgpRouteTranslationForNat,omitempty"` + IPConfigurations *[]VpnGatewayIPConfiguration `json:"ipConfigurations,omitempty"` + IsRoutingPreferenceInternet *bool `json:"isRoutingPreferenceInternet,omitempty"` + NatRules *[]VpnGatewayNatRule `json:"natRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualHub *SubResource `json:"virtualHub,omitempty"` + VpnGatewayScaleUnit *int64 `json:"vpnGatewayScaleUnit,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_vpnnatrulemapping.go b/resource-manager/network/2024-07-01/vpngateways/model_vpnnatrulemapping.go new file mode 100644 index 00000000000..3cd7718da11 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_vpnnatrulemapping.go @@ -0,0 +1,9 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnNatRuleMapping struct { + AddressSpace *string `json:"addressSpace,omitempty"` + PortRange *string `json:"portRange,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_vpnsitelinkconnection.go b/resource-manager/network/2024-07-01/vpngateways/model_vpnsitelinkconnection.go new file mode 100644 index 00000000000..874a627b999 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_vpnsitelinkconnection.go @@ -0,0 +1,12 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSiteLinkConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnSiteLinkConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/model_vpnsitelinkconnectionproperties.go b/resource-manager/network/2024-07-01/vpngateways/model_vpnsitelinkconnectionproperties.go new file mode 100644 index 00000000000..26f15913a23 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/model_vpnsitelinkconnectionproperties.go @@ -0,0 +1,26 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSiteLinkConnectionProperties struct { + ConnectionBandwidth *int64 `json:"connectionBandwidth,omitempty"` + ConnectionStatus *VpnConnectionStatus `json:"connectionStatus,omitempty"` + DpdTimeoutSeconds *int64 `json:"dpdTimeoutSeconds,omitempty"` + EgressBytesTransferred *int64 `json:"egressBytesTransferred,omitempty"` + EgressNatRules *[]SubResource `json:"egressNatRules,omitempty"` + EnableBgp *bool `json:"enableBgp,omitempty"` + EnableRateLimiting *bool `json:"enableRateLimiting,omitempty"` + IPsecPolicies *[]IPsecPolicy `json:"ipsecPolicies,omitempty"` + IngressBytesTransferred *int64 `json:"ingressBytesTransferred,omitempty"` + IngressNatRules *[]SubResource `json:"ingressNatRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RoutingWeight *int64 `json:"routingWeight,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` + UseLocalAzureIPAddress *bool `json:"useLocalAzureIpAddress,omitempty"` + UsePolicyBasedTrafficSelectors *bool `json:"usePolicyBasedTrafficSelectors,omitempty"` + VpnConnectionProtocolType *VirtualNetworkGatewayConnectionProtocol `json:"vpnConnectionProtocolType,omitempty"` + VpnGatewayCustomBgpAddresses *[]GatewayCustomBgpIPAddressIPConfiguration `json:"vpnGatewayCustomBgpAddresses,omitempty"` + VpnLinkConnectionMode *VpnLinkConnectionMode `json:"vpnLinkConnectionMode,omitempty"` + VpnSiteLink *SubResource `json:"vpnSiteLink,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpngateways/version.go b/resource-manager/network/2024-07-01/vpngateways/version.go new file mode 100644 index 00000000000..758adec38ba --- /dev/null +++ b/resource-manager/network/2024-07-01/vpngateways/version.go @@ -0,0 +1,10 @@ +package vpngateways + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/vpngateways/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/vpnlinkconnections/client.go b/resource-manager/network/2024-07-01/vpnlinkconnections/client.go new file mode 100644 index 00000000000..abb23ca4c39 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnlinkconnections/client.go @@ -0,0 +1,26 @@ +package vpnlinkconnections + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnLinkConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewVpnLinkConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*VpnLinkConnectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "vpnlinkconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VpnLinkConnectionsClient: %+v", err) + } + + return &VpnLinkConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/vpnlinkconnections/id_vpnlinkconnection.go b/resource-manager/network/2024-07-01/vpnlinkconnections/id_vpnlinkconnection.go new file mode 100644 index 00000000000..986725e2fc1 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnlinkconnections/id_vpnlinkconnection.go @@ -0,0 +1,148 @@ +package vpnlinkconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VpnLinkConnectionId{}) +} + +var _ resourceids.ResourceId = &VpnLinkConnectionId{} + +// VpnLinkConnectionId is a struct representing the Resource ID for a Vpn Link Connection +type VpnLinkConnectionId struct { + SubscriptionId string + ResourceGroupName string + VpnGatewayName string + VpnConnectionName string + VpnLinkConnectionName string +} + +// NewVpnLinkConnectionID returns a new VpnLinkConnectionId struct +func NewVpnLinkConnectionID(subscriptionId string, resourceGroupName string, vpnGatewayName string, vpnConnectionName string, vpnLinkConnectionName string) VpnLinkConnectionId { + return VpnLinkConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VpnGatewayName: vpnGatewayName, + VpnConnectionName: vpnConnectionName, + VpnLinkConnectionName: vpnLinkConnectionName, + } +} + +// ParseVpnLinkConnectionID parses 'input' into a VpnLinkConnectionId +func ParseVpnLinkConnectionID(input string) (*VpnLinkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnLinkConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnLinkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVpnLinkConnectionIDInsensitively parses 'input' case-insensitively into a VpnLinkConnectionId +// note: this method should only be used for API response data and not user input +func ParseVpnLinkConnectionIDInsensitively(input string) (*VpnLinkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnLinkConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnLinkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VpnLinkConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VpnGatewayName, ok = input.Parsed["vpnGatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vpnGatewayName", input) + } + + if id.VpnConnectionName, ok = input.Parsed["vpnConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vpnConnectionName", input) + } + + if id.VpnLinkConnectionName, ok = input.Parsed["vpnLinkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vpnLinkConnectionName", input) + } + + return nil +} + +// ValidateVpnLinkConnectionID checks that 'input' can be parsed as a Vpn Link Connection ID +func ValidateVpnLinkConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVpnLinkConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vpn Link Connection ID +func (id VpnLinkConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/vpnGateways/%s/vpnConnections/%s/vpnLinkConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VpnGatewayName, id.VpnConnectionName, id.VpnLinkConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vpn Link Connection ID +func (id VpnLinkConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVpnGateways", "vpnGateways", "vpnGateways"), + resourceids.UserSpecifiedSegment("vpnGatewayName", "vpnGatewayName"), + resourceids.StaticSegment("staticVpnConnections", "vpnConnections", "vpnConnections"), + resourceids.UserSpecifiedSegment("vpnConnectionName", "vpnConnectionName"), + resourceids.StaticSegment("staticVpnLinkConnections", "vpnLinkConnections", "vpnLinkConnections"), + resourceids.UserSpecifiedSegment("vpnLinkConnectionName", "vpnLinkConnectionName"), + } +} + +// String returns a human-readable description of this Vpn Link Connection ID +func (id VpnLinkConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vpn Gateway Name: %q", id.VpnGatewayName), + fmt.Sprintf("Vpn Connection Name: %q", id.VpnConnectionName), + fmt.Sprintf("Vpn Link Connection Name: %q", id.VpnLinkConnectionName), + } + return fmt.Sprintf("Vpn Link Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/vpnlinkconnections/id_vpnlinkconnection_test.go b/resource-manager/network/2024-07-01/vpnlinkconnections/id_vpnlinkconnection_test.go new file mode 100644 index 00000000000..59a74f2f8ea --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnlinkconnections/id_vpnlinkconnection_test.go @@ -0,0 +1,372 @@ +package vpnlinkconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VpnLinkConnectionId{} + +func TestNewVpnLinkConnectionID(t *testing.T) { + id := NewVpnLinkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "vpnConnectionName", "vpnLinkConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VpnGatewayName != "vpnGatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'VpnGatewayName'", id.VpnGatewayName, "vpnGatewayName") + } + + if id.VpnConnectionName != "vpnConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VpnConnectionName'", id.VpnConnectionName, "vpnConnectionName") + } + + if id.VpnLinkConnectionName != "vpnLinkConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VpnLinkConnectionName'", id.VpnLinkConnectionName, "vpnLinkConnectionName") + } +} + +func TestFormatVpnLinkConnectionID(t *testing.T) { + actual := NewVpnLinkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnGatewayName", "vpnConnectionName", "vpnLinkConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName/vpnLinkConnections/vpnLinkConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVpnLinkConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnLinkConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName/vpnLinkConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName/vpnLinkConnections/vpnLinkConnectionName", + Expected: &VpnLinkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnGatewayName: "vpnGatewayName", + VpnConnectionName: "vpnConnectionName", + VpnLinkConnectionName: "vpnLinkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName/vpnLinkConnections/vpnLinkConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnLinkConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnGatewayName != v.Expected.VpnGatewayName { + t.Fatalf("Expected %q but got %q for VpnGatewayName", v.Expected.VpnGatewayName, actual.VpnGatewayName) + } + + if actual.VpnConnectionName != v.Expected.VpnConnectionName { + t.Fatalf("Expected %q but got %q for VpnConnectionName", v.Expected.VpnConnectionName, actual.VpnConnectionName) + } + + if actual.VpnLinkConnectionName != v.Expected.VpnLinkConnectionName { + t.Fatalf("Expected %q but got %q for VpnLinkConnectionName", v.Expected.VpnLinkConnectionName, actual.VpnLinkConnectionName) + } + + } +} + +func TestParseVpnLinkConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnLinkConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE/vPnCoNnEcTiOnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE/vPnCoNnEcTiOnS/vPnCoNnEcTiOnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName/vpnLinkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE/vPnCoNnEcTiOnS/vPnCoNnEcTiOnNaMe/vPnLiNkCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName/vpnLinkConnections/vpnLinkConnectionName", + Expected: &VpnLinkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnGatewayName: "vpnGatewayName", + VpnConnectionName: "vpnConnectionName", + VpnLinkConnectionName: "vpnLinkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnGateways/vpnGatewayName/vpnConnections/vpnConnectionName/vpnLinkConnections/vpnLinkConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE/vPnCoNnEcTiOnS/vPnCoNnEcTiOnNaMe/vPnLiNkCoNnEcTiOnS/vPnLiNkCoNnEcTiOnNaMe", + Expected: &VpnLinkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VpnGatewayName: "vPnGaTeWaYnAmE", + VpnConnectionName: "vPnCoNnEcTiOnNaMe", + VpnLinkConnectionName: "vPnLiNkCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnGaTeWaYs/vPnGaTeWaYnAmE/vPnCoNnEcTiOnS/vPnCoNnEcTiOnNaMe/vPnLiNkCoNnEcTiOnS/vPnLiNkCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnLinkConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnGatewayName != v.Expected.VpnGatewayName { + t.Fatalf("Expected %q but got %q for VpnGatewayName", v.Expected.VpnGatewayName, actual.VpnGatewayName) + } + + if actual.VpnConnectionName != v.Expected.VpnConnectionName { + t.Fatalf("Expected %q but got %q for VpnConnectionName", v.Expected.VpnConnectionName, actual.VpnConnectionName) + } + + if actual.VpnLinkConnectionName != v.Expected.VpnLinkConnectionName { + t.Fatalf("Expected %q but got %q for VpnLinkConnectionName", v.Expected.VpnLinkConnectionName, actual.VpnLinkConnectionName) + } + + } +} + +func TestSegmentsForVpnLinkConnectionId(t *testing.T) { + segments := VpnLinkConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VpnLinkConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/vpnlinkconnections/method_resetconnection.go b/resource-manager/network/2024-07-01/vpnlinkconnections/method_resetconnection.go new file mode 100644 index 00000000000..526963414ea --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnlinkconnections/method_resetconnection.go @@ -0,0 +1,69 @@ +package vpnlinkconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResetConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ResetConnection ... +func (c VpnLinkConnectionsClient) ResetConnection(ctx context.Context, id VpnLinkConnectionId) (result ResetConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetconnection", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResetConnectionThenPoll performs ResetConnection then polls until it's completed +func (c VpnLinkConnectionsClient) ResetConnectionThenPoll(ctx context.Context, id VpnLinkConnectionId) error { + result, err := c.ResetConnection(ctx, id) + if err != nil { + return fmt.Errorf("performing ResetConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResetConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/vpnlinkconnections/version.go b/resource-manager/network/2024-07-01/vpnlinkconnections/version.go new file mode 100644 index 00000000000..c52bafb1392 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnlinkconnections/version.go @@ -0,0 +1,10 @@ +package vpnlinkconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/vpnlinkconnections/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/README.md b/resource-manager/network/2024-07-01/vpnserverconfigurations/README.md new file mode 100644 index 00000000000..7ca7d999dc0 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/vpnserverconfigurations` Documentation + +The `vpnserverconfigurations` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/vpnserverconfigurations" +``` + + +### Client Initialization + +```go +client := vpnserverconfigurations.NewVpnServerConfigurationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VpnServerConfigurationsClient.UpdateTags` + +```go +ctx := context.TODO() +id := vpnserverconfigurations.NewVpnServerConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnServerConfigurationName") + +payload := vpnserverconfigurations.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/client.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/client.go new file mode 100644 index 00000000000..661d154e519 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/client.go @@ -0,0 +1,26 @@ +package vpnserverconfigurations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationsClient struct { + Client *resourcemanager.Client +} + +func NewVpnServerConfigurationsClientWithBaseURI(sdkApi sdkEnv.Api) (*VpnServerConfigurationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "vpnserverconfigurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VpnServerConfigurationsClient: %+v", err) + } + + return &VpnServerConfigurationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/constants.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/constants.go new file mode 100644 index 00000000000..f297d6e8b17 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/constants.go @@ -0,0 +1,572 @@ +package vpnserverconfigurations + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DhGroup string + +const ( + DhGroupDHGroupOne DhGroup = "DHGroup1" + DhGroupDHGroupOneFour DhGroup = "DHGroup14" + DhGroupDHGroupTwo DhGroup = "DHGroup2" + DhGroupDHGroupTwoFour DhGroup = "DHGroup24" + DhGroupDHGroupTwoZeroFourEight DhGroup = "DHGroup2048" + DhGroupECPThreeEightFour DhGroup = "ECP384" + DhGroupECPTwoFiveSix DhGroup = "ECP256" + DhGroupNone DhGroup = "None" +) + +func PossibleValuesForDhGroup() []string { + return []string{ + string(DhGroupDHGroupOne), + string(DhGroupDHGroupOneFour), + string(DhGroupDHGroupTwo), + string(DhGroupDHGroupTwoFour), + string(DhGroupDHGroupTwoZeroFourEight), + string(DhGroupECPThreeEightFour), + string(DhGroupECPTwoFiveSix), + string(DhGroupNone), + } +} + +func (s *DhGroup) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDhGroup(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDhGroup(input string) (*DhGroup, error) { + vals := map[string]DhGroup{ + "dhgroup1": DhGroupDHGroupOne, + "dhgroup14": DhGroupDHGroupOneFour, + "dhgroup2": DhGroupDHGroupTwo, + "dhgroup24": DhGroupDHGroupTwoFour, + "dhgroup2048": DhGroupDHGroupTwoZeroFourEight, + "ecp384": DhGroupECPThreeEightFour, + "ecp256": DhGroupECPTwoFiveSix, + "none": DhGroupNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DhGroup(input) + return &out, nil +} + +type IPsecEncryption string + +const ( + IPsecEncryptionAESOneNineTwo IPsecEncryption = "AES192" + IPsecEncryptionAESOneTwoEight IPsecEncryption = "AES128" + IPsecEncryptionAESTwoFiveSix IPsecEncryption = "AES256" + IPsecEncryptionDES IPsecEncryption = "DES" + IPsecEncryptionDESThree IPsecEncryption = "DES3" + IPsecEncryptionGCMAESOneNineTwo IPsecEncryption = "GCMAES192" + IPsecEncryptionGCMAESOneTwoEight IPsecEncryption = "GCMAES128" + IPsecEncryptionGCMAESTwoFiveSix IPsecEncryption = "GCMAES256" + IPsecEncryptionNone IPsecEncryption = "None" +) + +func PossibleValuesForIPsecEncryption() []string { + return []string{ + string(IPsecEncryptionAESOneNineTwo), + string(IPsecEncryptionAESOneTwoEight), + string(IPsecEncryptionAESTwoFiveSix), + string(IPsecEncryptionDES), + string(IPsecEncryptionDESThree), + string(IPsecEncryptionGCMAESOneNineTwo), + string(IPsecEncryptionGCMAESOneTwoEight), + string(IPsecEncryptionGCMAESTwoFiveSix), + string(IPsecEncryptionNone), + } +} + +func (s *IPsecEncryption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPsecEncryption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPsecEncryption(input string) (*IPsecEncryption, error) { + vals := map[string]IPsecEncryption{ + "aes192": IPsecEncryptionAESOneNineTwo, + "aes128": IPsecEncryptionAESOneTwoEight, + "aes256": IPsecEncryptionAESTwoFiveSix, + "des": IPsecEncryptionDES, + "des3": IPsecEncryptionDESThree, + "gcmaes192": IPsecEncryptionGCMAESOneNineTwo, + "gcmaes128": IPsecEncryptionGCMAESOneTwoEight, + "gcmaes256": IPsecEncryptionGCMAESTwoFiveSix, + "none": IPsecEncryptionNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPsecEncryption(input) + return &out, nil +} + +type IPsecIntegrity string + +const ( + IPsecIntegrityGCMAESOneNineTwo IPsecIntegrity = "GCMAES192" + IPsecIntegrityGCMAESOneTwoEight IPsecIntegrity = "GCMAES128" + IPsecIntegrityGCMAESTwoFiveSix IPsecIntegrity = "GCMAES256" + IPsecIntegrityMDFive IPsecIntegrity = "MD5" + IPsecIntegritySHAOne IPsecIntegrity = "SHA1" + IPsecIntegritySHATwoFiveSix IPsecIntegrity = "SHA256" +) + +func PossibleValuesForIPsecIntegrity() []string { + return []string{ + string(IPsecIntegrityGCMAESOneNineTwo), + string(IPsecIntegrityGCMAESOneTwoEight), + string(IPsecIntegrityGCMAESTwoFiveSix), + string(IPsecIntegrityMDFive), + string(IPsecIntegritySHAOne), + string(IPsecIntegritySHATwoFiveSix), + } +} + +func (s *IPsecIntegrity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPsecIntegrity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPsecIntegrity(input string) (*IPsecIntegrity, error) { + vals := map[string]IPsecIntegrity{ + "gcmaes192": IPsecIntegrityGCMAESOneNineTwo, + "gcmaes128": IPsecIntegrityGCMAESOneTwoEight, + "gcmaes256": IPsecIntegrityGCMAESTwoFiveSix, + "md5": IPsecIntegrityMDFive, + "sha1": IPsecIntegritySHAOne, + "sha256": IPsecIntegritySHATwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPsecIntegrity(input) + return &out, nil +} + +type IkeEncryption string + +const ( + IkeEncryptionAESOneNineTwo IkeEncryption = "AES192" + IkeEncryptionAESOneTwoEight IkeEncryption = "AES128" + IkeEncryptionAESTwoFiveSix IkeEncryption = "AES256" + IkeEncryptionDES IkeEncryption = "DES" + IkeEncryptionDESThree IkeEncryption = "DES3" + IkeEncryptionGCMAESOneTwoEight IkeEncryption = "GCMAES128" + IkeEncryptionGCMAESTwoFiveSix IkeEncryption = "GCMAES256" +) + +func PossibleValuesForIkeEncryption() []string { + return []string{ + string(IkeEncryptionAESOneNineTwo), + string(IkeEncryptionAESOneTwoEight), + string(IkeEncryptionAESTwoFiveSix), + string(IkeEncryptionDES), + string(IkeEncryptionDESThree), + string(IkeEncryptionGCMAESOneTwoEight), + string(IkeEncryptionGCMAESTwoFiveSix), + } +} + +func (s *IkeEncryption) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIkeEncryption(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIkeEncryption(input string) (*IkeEncryption, error) { + vals := map[string]IkeEncryption{ + "aes192": IkeEncryptionAESOneNineTwo, + "aes128": IkeEncryptionAESOneTwoEight, + "aes256": IkeEncryptionAESTwoFiveSix, + "des": IkeEncryptionDES, + "des3": IkeEncryptionDESThree, + "gcmaes128": IkeEncryptionGCMAESOneTwoEight, + "gcmaes256": IkeEncryptionGCMAESTwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IkeEncryption(input) + return &out, nil +} + +type IkeIntegrity string + +const ( + IkeIntegrityGCMAESOneTwoEight IkeIntegrity = "GCMAES128" + IkeIntegrityGCMAESTwoFiveSix IkeIntegrity = "GCMAES256" + IkeIntegrityMDFive IkeIntegrity = "MD5" + IkeIntegritySHAOne IkeIntegrity = "SHA1" + IkeIntegritySHAThreeEightFour IkeIntegrity = "SHA384" + IkeIntegritySHATwoFiveSix IkeIntegrity = "SHA256" +) + +func PossibleValuesForIkeIntegrity() []string { + return []string{ + string(IkeIntegrityGCMAESOneTwoEight), + string(IkeIntegrityGCMAESTwoFiveSix), + string(IkeIntegrityMDFive), + string(IkeIntegritySHAOne), + string(IkeIntegritySHAThreeEightFour), + string(IkeIntegritySHATwoFiveSix), + } +} + +func (s *IkeIntegrity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIkeIntegrity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIkeIntegrity(input string) (*IkeIntegrity, error) { + vals := map[string]IkeIntegrity{ + "gcmaes128": IkeIntegrityGCMAESOneTwoEight, + "gcmaes256": IkeIntegrityGCMAESTwoFiveSix, + "md5": IkeIntegrityMDFive, + "sha1": IkeIntegritySHAOne, + "sha384": IkeIntegritySHAThreeEightFour, + "sha256": IkeIntegritySHATwoFiveSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IkeIntegrity(input) + return &out, nil +} + +type PfsGroup string + +const ( + PfsGroupECPThreeEightFour PfsGroup = "ECP384" + PfsGroupECPTwoFiveSix PfsGroup = "ECP256" + PfsGroupNone PfsGroup = "None" + PfsGroupPFSMM PfsGroup = "PFSMM" + PfsGroupPFSOne PfsGroup = "PFS1" + PfsGroupPFSOneFour PfsGroup = "PFS14" + PfsGroupPFSTwo PfsGroup = "PFS2" + PfsGroupPFSTwoFour PfsGroup = "PFS24" + PfsGroupPFSTwoZeroFourEight PfsGroup = "PFS2048" +) + +func PossibleValuesForPfsGroup() []string { + return []string{ + string(PfsGroupECPThreeEightFour), + string(PfsGroupECPTwoFiveSix), + string(PfsGroupNone), + string(PfsGroupPFSMM), + string(PfsGroupPFSOne), + string(PfsGroupPFSOneFour), + string(PfsGroupPFSTwo), + string(PfsGroupPFSTwoFour), + string(PfsGroupPFSTwoZeroFourEight), + } +} + +func (s *PfsGroup) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePfsGroup(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePfsGroup(input string) (*PfsGroup, error) { + vals := map[string]PfsGroup{ + "ecp384": PfsGroupECPThreeEightFour, + "ecp256": PfsGroupECPTwoFiveSix, + "none": PfsGroupNone, + "pfsmm": PfsGroupPFSMM, + "pfs1": PfsGroupPFSOne, + "pfs14": PfsGroupPFSOneFour, + "pfs2": PfsGroupPFSTwo, + "pfs24": PfsGroupPFSTwoFour, + "pfs2048": PfsGroupPFSTwoZeroFourEight, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PfsGroup(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type VnetLocalRouteOverrideCriteria string + +const ( + VnetLocalRouteOverrideCriteriaContains VnetLocalRouteOverrideCriteria = "Contains" + VnetLocalRouteOverrideCriteriaEqual VnetLocalRouteOverrideCriteria = "Equal" +) + +func PossibleValuesForVnetLocalRouteOverrideCriteria() []string { + return []string{ + string(VnetLocalRouteOverrideCriteriaContains), + string(VnetLocalRouteOverrideCriteriaEqual), + } +} + +func (s *VnetLocalRouteOverrideCriteria) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVnetLocalRouteOverrideCriteria(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVnetLocalRouteOverrideCriteria(input string) (*VnetLocalRouteOverrideCriteria, error) { + vals := map[string]VnetLocalRouteOverrideCriteria{ + "contains": VnetLocalRouteOverrideCriteriaContains, + "equal": VnetLocalRouteOverrideCriteriaEqual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VnetLocalRouteOverrideCriteria(input) + return &out, nil +} + +type VpnAuthenticationType string + +const ( + VpnAuthenticationTypeAAD VpnAuthenticationType = "AAD" + VpnAuthenticationTypeCertificate VpnAuthenticationType = "Certificate" + VpnAuthenticationTypeRadius VpnAuthenticationType = "Radius" +) + +func PossibleValuesForVpnAuthenticationType() []string { + return []string{ + string(VpnAuthenticationTypeAAD), + string(VpnAuthenticationTypeCertificate), + string(VpnAuthenticationTypeRadius), + } +} + +func (s *VpnAuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnAuthenticationType(input string) (*VpnAuthenticationType, error) { + vals := map[string]VpnAuthenticationType{ + "aad": VpnAuthenticationTypeAAD, + "certificate": VpnAuthenticationTypeCertificate, + "radius": VpnAuthenticationTypeRadius, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnAuthenticationType(input) + return &out, nil +} + +type VpnGatewayTunnelingProtocol string + +const ( + VpnGatewayTunnelingProtocolIkeVTwo VpnGatewayTunnelingProtocol = "IkeV2" + VpnGatewayTunnelingProtocolOpenVPN VpnGatewayTunnelingProtocol = "OpenVPN" +) + +func PossibleValuesForVpnGatewayTunnelingProtocol() []string { + return []string{ + string(VpnGatewayTunnelingProtocolIkeVTwo), + string(VpnGatewayTunnelingProtocolOpenVPN), + } +} + +func (s *VpnGatewayTunnelingProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnGatewayTunnelingProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnGatewayTunnelingProtocol(input string) (*VpnGatewayTunnelingProtocol, error) { + vals := map[string]VpnGatewayTunnelingProtocol{ + "ikev2": VpnGatewayTunnelingProtocolIkeVTwo, + "openvpn": VpnGatewayTunnelingProtocolOpenVPN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnGatewayTunnelingProtocol(input) + return &out, nil +} + +type VpnPolicyMemberAttributeType string + +const ( + VpnPolicyMemberAttributeTypeAADGroupId VpnPolicyMemberAttributeType = "AADGroupId" + VpnPolicyMemberAttributeTypeCertificateGroupId VpnPolicyMemberAttributeType = "CertificateGroupId" + VpnPolicyMemberAttributeTypeRadiusAzureGroupId VpnPolicyMemberAttributeType = "RadiusAzureGroupId" +) + +func PossibleValuesForVpnPolicyMemberAttributeType() []string { + return []string{ + string(VpnPolicyMemberAttributeTypeAADGroupId), + string(VpnPolicyMemberAttributeTypeCertificateGroupId), + string(VpnPolicyMemberAttributeTypeRadiusAzureGroupId), + } +} + +func (s *VpnPolicyMemberAttributeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVpnPolicyMemberAttributeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVpnPolicyMemberAttributeType(input string) (*VpnPolicyMemberAttributeType, error) { + vals := map[string]VpnPolicyMemberAttributeType{ + "aadgroupid": VpnPolicyMemberAttributeTypeAADGroupId, + "certificategroupid": VpnPolicyMemberAttributeTypeCertificateGroupId, + "radiusazuregroupid": VpnPolicyMemberAttributeTypeRadiusAzureGroupId, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VpnPolicyMemberAttributeType(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/id_vpnserverconfiguration.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/id_vpnserverconfiguration.go new file mode 100644 index 00000000000..73435f9a776 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/id_vpnserverconfiguration.go @@ -0,0 +1,130 @@ +package vpnserverconfigurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VpnServerConfigurationId{}) +} + +var _ resourceids.ResourceId = &VpnServerConfigurationId{} + +// VpnServerConfigurationId is a struct representing the Resource ID for a Vpn Server Configuration +type VpnServerConfigurationId struct { + SubscriptionId string + ResourceGroupName string + VpnServerConfigurationName string +} + +// NewVpnServerConfigurationID returns a new VpnServerConfigurationId struct +func NewVpnServerConfigurationID(subscriptionId string, resourceGroupName string, vpnServerConfigurationName string) VpnServerConfigurationId { + return VpnServerConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VpnServerConfigurationName: vpnServerConfigurationName, + } +} + +// ParseVpnServerConfigurationID parses 'input' into a VpnServerConfigurationId +func ParseVpnServerConfigurationID(input string) (*VpnServerConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnServerConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnServerConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVpnServerConfigurationIDInsensitively parses 'input' case-insensitively into a VpnServerConfigurationId +// note: this method should only be used for API response data and not user input +func ParseVpnServerConfigurationIDInsensitively(input string) (*VpnServerConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnServerConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnServerConfigurationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VpnServerConfigurationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VpnServerConfigurationName, ok = input.Parsed["vpnServerConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vpnServerConfigurationName", input) + } + + return nil +} + +// ValidateVpnServerConfigurationID checks that 'input' can be parsed as a Vpn Server Configuration ID +func ValidateVpnServerConfigurationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVpnServerConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vpn Server Configuration ID +func (id VpnServerConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/vpnServerConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VpnServerConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vpn Server Configuration ID +func (id VpnServerConfigurationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVpnServerConfigurations", "vpnServerConfigurations", "vpnServerConfigurations"), + resourceids.UserSpecifiedSegment("vpnServerConfigurationName", "vpnServerConfigurationName"), + } +} + +// String returns a human-readable description of this Vpn Server Configuration ID +func (id VpnServerConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vpn Server Configuration Name: %q", id.VpnServerConfigurationName), + } + return fmt.Sprintf("Vpn Server Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/id_vpnserverconfiguration_test.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/id_vpnserverconfiguration_test.go new file mode 100644 index 00000000000..575d80907f4 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/id_vpnserverconfiguration_test.go @@ -0,0 +1,282 @@ +package vpnserverconfigurations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VpnServerConfigurationId{} + +func TestNewVpnServerConfigurationID(t *testing.T) { + id := NewVpnServerConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnServerConfigurationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VpnServerConfigurationName != "vpnServerConfigurationName" { + t.Fatalf("Expected %q but got %q for Segment 'VpnServerConfigurationName'", id.VpnServerConfigurationName, "vpnServerConfigurationName") + } +} + +func TestFormatVpnServerConfigurationID(t *testing.T) { + actual := NewVpnServerConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnServerConfigurationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVpnServerConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnServerConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName", + Expected: &VpnServerConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnServerConfigurationName: "vpnServerConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnServerConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnServerConfigurationName != v.Expected.VpnServerConfigurationName { + t.Fatalf("Expected %q but got %q for VpnServerConfigurationName", v.Expected.VpnServerConfigurationName, actual.VpnServerConfigurationName) + } + + } +} + +func TestParseVpnServerConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnServerConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSeRvErCoNfIgUrAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName", + Expected: &VpnServerConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnServerConfigurationName: "vpnServerConfigurationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfigurationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSeRvErCoNfIgUrAtIoNs/vPnSeRvErCoNfIgUrAtIoNnAmE", + Expected: &VpnServerConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VpnServerConfigurationName: "vPnSeRvErCoNfIgUrAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSeRvErCoNfIgUrAtIoNs/vPnSeRvErCoNfIgUrAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnServerConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnServerConfigurationName != v.Expected.VpnServerConfigurationName { + t.Fatalf("Expected %q but got %q for VpnServerConfigurationName", v.Expected.VpnServerConfigurationName, actual.VpnServerConfigurationName) + } + + } +} + +func TestSegmentsForVpnServerConfigurationId(t *testing.T) { + segments := VpnServerConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VpnServerConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/method_updatetags.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/method_updatetags.go new file mode 100644 index 00000000000..f9decf387a7 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/method_updatetags.go @@ -0,0 +1,57 @@ +package vpnserverconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VpnServerConfiguration +} + +// UpdateTags ... +func (c VpnServerConfigurationsClient) UpdateTags(ctx context.Context, id VpnServerConfigurationId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VpnServerConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_aadauthenticationparameters.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_aadauthenticationparameters.go new file mode 100644 index 00000000000..8751fdb95f4 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_aadauthenticationparameters.go @@ -0,0 +1,10 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AadAuthenticationParameters struct { + AadAudience *string `json:"aadAudience,omitempty"` + AadIssuer *string `json:"aadIssuer,omitempty"` + AadTenant *string `json:"aadTenant,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_addressspace.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_addressspace.go new file mode 100644 index 00000000000..b6f6c36d85a --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_addressspace.go @@ -0,0 +1,9 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressSpace struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..f340109c5be --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..d15a0b0b677 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_ipsecpolicy.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_ipsecpolicy.go new file mode 100644 index 00000000000..82c3d0cee04 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_ipsecpolicy.go @@ -0,0 +1,15 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPsecPolicy struct { + DhGroup DhGroup `json:"dhGroup"` + IPsecEncryption IPsecEncryption `json:"ipsecEncryption"` + IPsecIntegrity IPsecIntegrity `json:"ipsecIntegrity"` + IkeEncryption IkeEncryption `json:"ikeEncryption"` + IkeIntegrity IkeIntegrity `json:"ikeIntegrity"` + PfsGroup PfsGroup `json:"pfsGroup"` + SaDataSizeKilobytes int64 `json:"saDataSizeKilobytes"` + SaLifeTimeSeconds int64 `json:"saLifeTimeSeconds"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_p2sconnectionconfiguration.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_p2sconnectionconfiguration.go new file mode 100644 index 00000000000..a5da2b6e9f5 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_p2sconnectionconfiguration.go @@ -0,0 +1,11 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2SConnectionConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *P2SConnectionConfigurationProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_p2sconnectionconfigurationproperties.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_p2sconnectionconfigurationproperties.go new file mode 100644 index 00000000000..5409c6397bf --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_p2sconnectionconfigurationproperties.go @@ -0,0 +1,13 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2SConnectionConfigurationProperties struct { + ConfigurationPolicyGroupAssociations *[]SubResource `json:"configurationPolicyGroupAssociations,omitempty"` + EnableInternetSecurity *bool `json:"enableInternetSecurity,omitempty"` + PreviousConfigurationPolicyGroupAssociations *[]VpnServerConfigurationPolicyGroup `json:"previousConfigurationPolicyGroupAssociations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RoutingConfiguration *RoutingConfiguration `json:"routingConfiguration,omitempty"` + VpnClientAddressPool *AddressSpace `json:"vpnClientAddressPool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_p2svpngateway.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_p2svpngateway.go new file mode 100644 index 00000000000..048301aca56 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_p2svpngateway.go @@ -0,0 +1,14 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2SVpnGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *P2SVpnGatewayProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_p2svpngatewayproperties.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_p2svpngatewayproperties.go new file mode 100644 index 00000000000..fcd2e68d61e --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_p2svpngatewayproperties.go @@ -0,0 +1,15 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type P2SVpnGatewayProperties struct { + CustomDnsServers *[]string `json:"customDnsServers,omitempty"` + IsRoutingPreferenceInternet *bool `json:"isRoutingPreferenceInternet,omitempty"` + P2SConnectionConfigurations *[]P2SConnectionConfiguration `json:"p2SConnectionConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualHub *SubResource `json:"virtualHub,omitempty"` + VpnClientConnectionHealth *VpnClientConnectionHealth `json:"vpnClientConnectionHealth,omitempty"` + VpnGatewayScaleUnit *int64 `json:"vpnGatewayScaleUnit,omitempty"` + VpnServerConfiguration *SubResource `json:"vpnServerConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_propagatedroutetable.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_propagatedroutetable.go new file mode 100644 index 00000000000..d9197431e38 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_propagatedroutetable.go @@ -0,0 +1,9 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PropagatedRouteTable struct { + Ids *[]SubResource `json:"ids,omitempty"` + Labels *[]string `json:"labels,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_radiusserver.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_radiusserver.go new file mode 100644 index 00000000000..0a8e8ea7a2b --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_radiusserver.go @@ -0,0 +1,10 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RadiusServer struct { + RadiusServerAddress string `json:"radiusServerAddress"` + RadiusServerScore *int64 `json:"radiusServerScore,omitempty"` + RadiusServerSecret *string `json:"radiusServerSecret,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_routingconfiguration.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_routingconfiguration.go new file mode 100644 index 00000000000..418b0d86c12 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_routingconfiguration.go @@ -0,0 +1,12 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutingConfiguration struct { + AssociatedRouteTable *SubResource `json:"associatedRouteTable,omitempty"` + InboundRouteMap *SubResource `json:"inboundRouteMap,omitempty"` + OutboundRouteMap *SubResource `json:"outboundRouteMap,omitempty"` + PropagatedRouteTables *PropagatedRouteTable `json:"propagatedRouteTables,omitempty"` + VnetRoutes *VnetRoute `json:"vnetRoutes,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_staticroute.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_staticroute.go new file mode 100644 index 00000000000..d9a40cf7abe --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_staticroute.go @@ -0,0 +1,10 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticRoute struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + Name *string `json:"name,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_staticroutesconfig.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_staticroutesconfig.go new file mode 100644 index 00000000000..0d9a0db3cfd --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_staticroutesconfig.go @@ -0,0 +1,9 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticRoutesConfig struct { + PropagateStaticRoutes *bool `json:"propagateStaticRoutes,omitempty"` + VnetLocalRouteOverrideCriteria *VnetLocalRouteOverrideCriteria `json:"vnetLocalRouteOverrideCriteria,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_subresource.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_subresource.go new file mode 100644 index 00000000000..b06b768283f --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_subresource.go @@ -0,0 +1,8 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_tagsobject.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_tagsobject.go new file mode 100644 index 00000000000..73b0464bd7d --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_tagsobject.go @@ -0,0 +1,8 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vnetroute.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vnetroute.go new file mode 100644 index 00000000000..26ac1388d05 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vnetroute.go @@ -0,0 +1,10 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRoute struct { + BgpConnections *[]SubResource `json:"bgpConnections,omitempty"` + StaticRoutes *[]StaticRoute `json:"staticRoutes,omitempty"` + StaticRoutesConfig *StaticRoutesConfig `json:"staticRoutesConfig,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnclientconnectionhealth.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnclientconnectionhealth.go new file mode 100644 index 00000000000..f4b6bee5adb --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnclientconnectionhealth.go @@ -0,0 +1,11 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnClientConnectionHealth struct { + AllocatedIPAddresses *[]string `json:"allocatedIpAddresses,omitempty"` + TotalEgressBytesTransferred *int64 `json:"totalEgressBytesTransferred,omitempty"` + TotalIngressBytesTransferred *int64 `json:"totalIngressBytesTransferred,omitempty"` + VpnClientConnectionsCount *int64 `json:"vpnClientConnectionsCount,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigradiusclientrootcertificate.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigradiusclientrootcertificate.go new file mode 100644 index 00000000000..32cd3b0c3ce --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigradiusclientrootcertificate.go @@ -0,0 +1,9 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigRadiusClientRootCertificate struct { + Name *string `json:"name,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigradiusserverrootcertificate.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigradiusserverrootcertificate.go new file mode 100644 index 00000000000..f5a02d320d4 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigradiusserverrootcertificate.go @@ -0,0 +1,9 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigRadiusServerRootCertificate struct { + Name *string `json:"name,omitempty"` + PublicCertData *string `json:"publicCertData,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfiguration.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfiguration.go new file mode 100644 index 00000000000..1f8b56984ce --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfiguration.go @@ -0,0 +1,14 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnServerConfigurationProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigurationpolicygroup.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigurationpolicygroup.go new file mode 100644 index 00000000000..df7554b1ec5 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigurationpolicygroup.go @@ -0,0 +1,12 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationPolicyGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnServerConfigurationPolicyGroupProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigurationpolicygroupmember.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigurationpolicygroupmember.go new file mode 100644 index 00000000000..5f72d492483 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigurationpolicygroupmember.go @@ -0,0 +1,10 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationPolicyGroupMember struct { + AttributeType *VpnPolicyMemberAttributeType `json:"attributeType,omitempty"` + AttributeValue *string `json:"attributeValue,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigurationpolicygroupproperties.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigurationpolicygroupproperties.go new file mode 100644 index 00000000000..d1f956dc56b --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigurationpolicygroupproperties.go @@ -0,0 +1,12 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationPolicyGroupProperties struct { + IsDefault *bool `json:"isDefault,omitempty"` + P2SConnectionConfigurations *[]SubResource `json:"p2SConnectionConfigurations,omitempty"` + PolicyMembers *[]VpnServerConfigurationPolicyGroupMember `json:"policyMembers,omitempty"` + Priority *int64 `json:"priority,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigurationproperties.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigurationproperties.go new file mode 100644 index 00000000000..bba2bd56557 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigurationproperties.go @@ -0,0 +1,23 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigurationProperties struct { + AadAuthenticationParameters *AadAuthenticationParameters `json:"aadAuthenticationParameters,omitempty"` + ConfigurationPolicyGroups *[]VpnServerConfigurationPolicyGroup `json:"configurationPolicyGroups,omitempty"` + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + P2sVpnGateways *[]P2SVpnGateway `json:"p2SVpnGateways,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + RadiusClientRootCertificates *[]VpnServerConfigRadiusClientRootCertificate `json:"radiusClientRootCertificates,omitempty"` + RadiusServerAddress *string `json:"radiusServerAddress,omitempty"` + RadiusServerRootCertificates *[]VpnServerConfigRadiusServerRootCertificate `json:"radiusServerRootCertificates,omitempty"` + RadiusServerSecret *string `json:"radiusServerSecret,omitempty"` + RadiusServers *[]RadiusServer `json:"radiusServers,omitempty"` + VpnAuthenticationTypes *[]VpnAuthenticationType `json:"vpnAuthenticationTypes,omitempty"` + VpnClientIPsecPolicies *[]IPsecPolicy `json:"vpnClientIpsecPolicies,omitempty"` + VpnClientRevokedCertificates *[]VpnServerConfigVpnClientRevokedCertificate `json:"vpnClientRevokedCertificates,omitempty"` + VpnClientRootCertificates *[]VpnServerConfigVpnClientRootCertificate `json:"vpnClientRootCertificates,omitempty"` + VpnProtocols *[]VpnGatewayTunnelingProtocol `json:"vpnProtocols,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigvpnclientrevokedcertificate.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigvpnclientrevokedcertificate.go new file mode 100644 index 00000000000..b2e7cac735e --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigvpnclientrevokedcertificate.go @@ -0,0 +1,9 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigVpnClientRevokedCertificate struct { + Name *string `json:"name,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigvpnclientrootcertificate.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigvpnclientrootcertificate.go new file mode 100644 index 00000000000..eda4a0c8837 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/model_vpnserverconfigvpnclientrootcertificate.go @@ -0,0 +1,9 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnServerConfigVpnClientRootCertificate struct { + Name *string `json:"name,omitempty"` + PublicCertData *string `json:"publicCertData,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnserverconfigurations/version.go b/resource-manager/network/2024-07-01/vpnserverconfigurations/version.go new file mode 100644 index 00000000000..c66cf81010d --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnserverconfigurations/version.go @@ -0,0 +1,10 @@ +package vpnserverconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/vpnserverconfigurations/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/vpnsites/README.md b/resource-manager/network/2024-07-01/vpnsites/README.md new file mode 100644 index 00000000000..38cb39d6ab6 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/vpnsites` Documentation + +The `vpnsites` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/vpnsites" +``` + + +### Client Initialization + +```go +client := vpnsites.NewVpnSitesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VpnSitesClient.UpdateTags` + +```go +ctx := context.TODO() +id := vpnsites.NewVpnSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnSiteName") + +payload := vpnsites.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/network/2024-07-01/vpnsites/client.go b/resource-manager/network/2024-07-01/vpnsites/client.go new file mode 100644 index 00000000000..2c56ae704cd --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/client.go @@ -0,0 +1,26 @@ +package vpnsites + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSitesClient struct { + Client *resourcemanager.Client +} + +func NewVpnSitesClientWithBaseURI(sdkApi sdkEnv.Api) (*VpnSitesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "vpnsites", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VpnSitesClient: %+v", err) + } + + return &VpnSitesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/vpnsites/constants.go b/resource-manager/network/2024-07-01/vpnsites/constants.go new file mode 100644 index 00000000000..58eca968713 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/constants.go @@ -0,0 +1,57 @@ +package vpnsites + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/vpnsites/id_vpnsite.go b/resource-manager/network/2024-07-01/vpnsites/id_vpnsite.go new file mode 100644 index 00000000000..3f8913159cb --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/id_vpnsite.go @@ -0,0 +1,130 @@ +package vpnsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VpnSiteId{}) +} + +var _ resourceids.ResourceId = &VpnSiteId{} + +// VpnSiteId is a struct representing the Resource ID for a Vpn Site +type VpnSiteId struct { + SubscriptionId string + ResourceGroupName string + VpnSiteName string +} + +// NewVpnSiteID returns a new VpnSiteId struct +func NewVpnSiteID(subscriptionId string, resourceGroupName string, vpnSiteName string) VpnSiteId { + return VpnSiteId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + VpnSiteName: vpnSiteName, + } +} + +// ParseVpnSiteID parses 'input' into a VpnSiteId +func ParseVpnSiteID(input string) (*VpnSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnSiteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVpnSiteIDInsensitively parses 'input' case-insensitively into a VpnSiteId +// note: this method should only be used for API response data and not user input +func ParseVpnSiteIDInsensitively(input string) (*VpnSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&VpnSiteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VpnSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VpnSiteId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.VpnSiteName, ok = input.Parsed["vpnSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "vpnSiteName", input) + } + + return nil +} + +// ValidateVpnSiteID checks that 'input' can be parsed as a Vpn Site ID +func ValidateVpnSiteID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVpnSiteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Vpn Site ID +func (id VpnSiteId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/vpnSites/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.VpnSiteName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Vpn Site ID +func (id VpnSiteId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticVpnSites", "vpnSites", "vpnSites"), + resourceids.UserSpecifiedSegment("vpnSiteName", "vpnSiteName"), + } +} + +// String returns a human-readable description of this Vpn Site ID +func (id VpnSiteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Vpn Site Name: %q", id.VpnSiteName), + } + return fmt.Sprintf("Vpn Site (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/vpnsites/id_vpnsite_test.go b/resource-manager/network/2024-07-01/vpnsites/id_vpnsite_test.go new file mode 100644 index 00000000000..17b07169051 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/id_vpnsite_test.go @@ -0,0 +1,282 @@ +package vpnsites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VpnSiteId{} + +func TestNewVpnSiteID(t *testing.T) { + id := NewVpnSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnSiteName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.VpnSiteName != "vpnSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'VpnSiteName'", id.VpnSiteName, "vpnSiteName") + } +} + +func TestFormatVpnSiteID(t *testing.T) { + actual := NewVpnSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vpnSiteName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVpnSiteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnSiteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName", + Expected: &VpnSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnSiteName: "vpnSiteName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnSiteID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnSiteName != v.Expected.VpnSiteName { + t.Fatalf("Expected %q but got %q for VpnSiteName", v.Expected.VpnSiteName, actual.VpnSiteName) + } + + } +} + +func TestParseVpnSiteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VpnSiteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSiTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName", + Expected: &VpnSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + VpnSiteName: "vpnSiteName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/vpnSites/vpnSiteName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSiTeS/vPnSiTeNaMe", + Expected: &VpnSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + VpnSiteName: "vPnSiTeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/vPnSiTeS/vPnSiTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVpnSiteIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.VpnSiteName != v.Expected.VpnSiteName { + t.Fatalf("Expected %q but got %q for VpnSiteName", v.Expected.VpnSiteName, actual.VpnSiteName) + } + + } +} + +func TestSegmentsForVpnSiteId(t *testing.T) { + segments := VpnSiteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VpnSiteId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/vpnsites/method_updatetags.go b/resource-manager/network/2024-07-01/vpnsites/method_updatetags.go new file mode 100644 index 00000000000..aa5af2cd330 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/method_updatetags.go @@ -0,0 +1,57 @@ +package vpnsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VpnSite +} + +// UpdateTags ... +func (c VpnSitesClient) UpdateTags(ctx context.Context, id VpnSiteId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VpnSite + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/vpnsites/model_addressspace.go b/resource-manager/network/2024-07-01/vpnsites/model_addressspace.go new file mode 100644 index 00000000000..f280616c5e6 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/model_addressspace.go @@ -0,0 +1,9 @@ +package vpnsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressSpace struct { + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnsites/model_bgpsettings.go b/resource-manager/network/2024-07-01/vpnsites/model_bgpsettings.go new file mode 100644 index 00000000000..09643cee4ab --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/model_bgpsettings.go @@ -0,0 +1,11 @@ +package vpnsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BgpSettings struct { + Asn *int64 `json:"asn,omitempty"` + BgpPeeringAddress *string `json:"bgpPeeringAddress,omitempty"` + BgpPeeringAddresses *[]IPConfigurationBgpPeeringAddress `json:"bgpPeeringAddresses,omitempty"` + PeerWeight *int64 `json:"peerWeight,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnsites/model_deviceproperties.go b/resource-manager/network/2024-07-01/vpnsites/model_deviceproperties.go new file mode 100644 index 00000000000..6b9a69dd5df --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/model_deviceproperties.go @@ -0,0 +1,10 @@ +package vpnsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeviceProperties struct { + DeviceModel *string `json:"deviceModel,omitempty"` + DeviceVendor *string `json:"deviceVendor,omitempty"` + LinkSpeedInMbps *int64 `json:"linkSpeedInMbps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnsites/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/vpnsites/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..b24353f5081 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package vpnsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnsites/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/vpnsites/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..b407e002a84 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package vpnsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnsites/model_ipconfigurationbgppeeringaddress.go b/resource-manager/network/2024-07-01/vpnsites/model_ipconfigurationbgppeeringaddress.go new file mode 100644 index 00000000000..ce931dc8949 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/model_ipconfigurationbgppeeringaddress.go @@ -0,0 +1,11 @@ +package vpnsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationBgpPeeringAddress struct { + CustomBgpIPAddresses *[]string `json:"customBgpIpAddresses,omitempty"` + DefaultBgpIPAddresses *[]string `json:"defaultBgpIpAddresses,omitempty"` + IPconfigurationId *string `json:"ipconfigurationId,omitempty"` + TunnelIPAddresses *[]string `json:"tunnelIpAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnsites/model_o365breakoutcategorypolicies.go b/resource-manager/network/2024-07-01/vpnsites/model_o365breakoutcategorypolicies.go new file mode 100644 index 00000000000..2d1e7f02cf9 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/model_o365breakoutcategorypolicies.go @@ -0,0 +1,10 @@ +package vpnsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type O365BreakOutCategoryPolicies struct { + Allow *bool `json:"allow,omitempty"` + Default *bool `json:"default,omitempty"` + Optimize *bool `json:"optimize,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnsites/model_o365policyproperties.go b/resource-manager/network/2024-07-01/vpnsites/model_o365policyproperties.go new file mode 100644 index 00000000000..18b5f663387 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/model_o365policyproperties.go @@ -0,0 +1,8 @@ +package vpnsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type O365PolicyProperties struct { + BreakOutCategories *O365BreakOutCategoryPolicies `json:"breakOutCategories,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnsites/model_subresource.go b/resource-manager/network/2024-07-01/vpnsites/model_subresource.go new file mode 100644 index 00000000000..2b90b3f784d --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/model_subresource.go @@ -0,0 +1,8 @@ +package vpnsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnsites/model_tagsobject.go b/resource-manager/network/2024-07-01/vpnsites/model_tagsobject.go new file mode 100644 index 00000000000..c05667ddc1a --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/model_tagsobject.go @@ -0,0 +1,8 @@ +package vpnsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnsites/model_vpnlinkbgpsettings.go b/resource-manager/network/2024-07-01/vpnsites/model_vpnlinkbgpsettings.go new file mode 100644 index 00000000000..cae11e9a335 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/model_vpnlinkbgpsettings.go @@ -0,0 +1,9 @@ +package vpnsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnLinkBgpSettings struct { + Asn *int64 `json:"asn,omitempty"` + BgpPeeringAddress *string `json:"bgpPeeringAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnsites/model_vpnlinkproviderproperties.go b/resource-manager/network/2024-07-01/vpnsites/model_vpnlinkproviderproperties.go new file mode 100644 index 00000000000..aa802b7bc05 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/model_vpnlinkproviderproperties.go @@ -0,0 +1,9 @@ +package vpnsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnLinkProviderProperties struct { + LinkProviderName *string `json:"linkProviderName,omitempty"` + LinkSpeedInMbps *int64 `json:"linkSpeedInMbps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnsites/model_vpnsite.go b/resource-manager/network/2024-07-01/vpnsites/model_vpnsite.go new file mode 100644 index 00000000000..a7ccb293a6c --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/model_vpnsite.go @@ -0,0 +1,14 @@ +package vpnsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSite struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnSiteProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnsites/model_vpnsitelink.go b/resource-manager/network/2024-07-01/vpnsites/model_vpnsitelink.go new file mode 100644 index 00000000000..0d815e3b164 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/model_vpnsitelink.go @@ -0,0 +1,12 @@ +package vpnsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSiteLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VpnSiteLinkProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnsites/model_vpnsitelinkproperties.go b/resource-manager/network/2024-07-01/vpnsites/model_vpnsitelinkproperties.go new file mode 100644 index 00000000000..3d9dedc099d --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/model_vpnsitelinkproperties.go @@ -0,0 +1,12 @@ +package vpnsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSiteLinkProperties struct { + BgpProperties *VpnLinkBgpSettings `json:"bgpProperties,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + LinkProperties *VpnLinkProviderProperties `json:"linkProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnsites/model_vpnsiteproperties.go b/resource-manager/network/2024-07-01/vpnsites/model_vpnsiteproperties.go new file mode 100644 index 00000000000..b404c9ab09b --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/model_vpnsiteproperties.go @@ -0,0 +1,17 @@ +package vpnsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VpnSiteProperties struct { + AddressSpace *AddressSpace `json:"addressSpace,omitempty"` + BgpProperties *BgpSettings `json:"bgpProperties,omitempty"` + DeviceProperties *DeviceProperties `json:"deviceProperties,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IsSecuritySite *bool `json:"isSecuritySite,omitempty"` + O365Policy *O365PolicyProperties `json:"o365Policy,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SiteKey *string `json:"siteKey,omitempty"` + VirtualWAN *SubResource `json:"virtualWan,omitempty"` + VpnSiteLinks *[]VpnSiteLink `json:"vpnSiteLinks,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/vpnsites/version.go b/resource-manager/network/2024-07-01/vpnsites/version.go new file mode 100644 index 00000000000..975d5b19c87 --- /dev/null +++ b/resource-manager/network/2024-07-01/vpnsites/version.go @@ -0,0 +1,10 @@ +package vpnsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/vpnsites/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/README.md b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/README.md new file mode 100644 index 00000000000..dfe9af0e780 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/README.md @@ -0,0 +1,104 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/webapplicationfirewallpolicies` Documentation + +The `webapplicationfirewallpolicies` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/webapplicationfirewallpolicies" +``` + + +### Client Initialization + +```go +client := webapplicationfirewallpolicies.NewWebApplicationFirewallPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WebApplicationFirewallPoliciesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := webapplicationfirewallpolicies.NewApplicationGatewayWebApplicationFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayWebApplicationFirewallPolicyName") + +payload := webapplicationfirewallpolicies.WebApplicationFirewallPolicy{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebApplicationFirewallPoliciesClient.Delete` + +```go +ctx := context.TODO() +id := webapplicationfirewallpolicies.NewApplicationGatewayWebApplicationFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayWebApplicationFirewallPolicyName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebApplicationFirewallPoliciesClient.Get` + +```go +ctx := context.TODO() +id := webapplicationfirewallpolicies.NewApplicationGatewayWebApplicationFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayWebApplicationFirewallPolicyName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebApplicationFirewallPoliciesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebApplicationFirewallPoliciesClient.ListAll` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAll(ctx, id)` can be used to do batched pagination +items, err := client.ListAllComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/client.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/client.go new file mode 100644 index 00000000000..225049a7361 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/client.go @@ -0,0 +1,26 @@ +package webapplicationfirewallpolicies + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebApplicationFirewallPoliciesClient struct { + Client *resourcemanager.Client +} + +func NewWebApplicationFirewallPoliciesClientWithBaseURI(sdkApi sdkEnv.Api) (*WebApplicationFirewallPoliciesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "webapplicationfirewallpolicies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WebApplicationFirewallPoliciesClient: %+v", err) + } + + return &WebApplicationFirewallPoliciesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/constants.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/constants.go new file mode 100644 index 00000000000..a2195779335 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/constants.go @@ -0,0 +1,3136 @@ +package webapplicationfirewallpolicies + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ActionType string + +const ( + ActionTypeAllow ActionType = "Allow" + ActionTypeAnomalyScoring ActionType = "AnomalyScoring" + ActionTypeBlock ActionType = "Block" + ActionTypeJSChallenge ActionType = "JSChallenge" + ActionTypeLog ActionType = "Log" +) + +func PossibleValuesForActionType() []string { + return []string{ + string(ActionTypeAllow), + string(ActionTypeAnomalyScoring), + string(ActionTypeBlock), + string(ActionTypeJSChallenge), + string(ActionTypeLog), + } +} + +func (s *ActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseActionType(input string) (*ActionType, error) { + vals := map[string]ActionType{ + "allow": ActionTypeAllow, + "anomalyscoring": ActionTypeAnomalyScoring, + "block": ActionTypeBlock, + "jschallenge": ActionTypeJSChallenge, + "log": ActionTypeLog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ActionType(input) + return &out, nil +} + +type ApplicationGatewayClientRevocationOptions string + +const ( + ApplicationGatewayClientRevocationOptionsNone ApplicationGatewayClientRevocationOptions = "None" + ApplicationGatewayClientRevocationOptionsOCSP ApplicationGatewayClientRevocationOptions = "OCSP" +) + +func PossibleValuesForApplicationGatewayClientRevocationOptions() []string { + return []string{ + string(ApplicationGatewayClientRevocationOptionsNone), + string(ApplicationGatewayClientRevocationOptionsOCSP), + } +} + +func (s *ApplicationGatewayClientRevocationOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayClientRevocationOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayClientRevocationOptions(input string) (*ApplicationGatewayClientRevocationOptions, error) { + vals := map[string]ApplicationGatewayClientRevocationOptions{ + "none": ApplicationGatewayClientRevocationOptionsNone, + "ocsp": ApplicationGatewayClientRevocationOptionsOCSP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayClientRevocationOptions(input) + return &out, nil +} + +type ApplicationGatewayCookieBasedAffinity string + +const ( + ApplicationGatewayCookieBasedAffinityDisabled ApplicationGatewayCookieBasedAffinity = "Disabled" + ApplicationGatewayCookieBasedAffinityEnabled ApplicationGatewayCookieBasedAffinity = "Enabled" +) + +func PossibleValuesForApplicationGatewayCookieBasedAffinity() []string { + return []string{ + string(ApplicationGatewayCookieBasedAffinityDisabled), + string(ApplicationGatewayCookieBasedAffinityEnabled), + } +} + +func (s *ApplicationGatewayCookieBasedAffinity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayCookieBasedAffinity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayCookieBasedAffinity(input string) (*ApplicationGatewayCookieBasedAffinity, error) { + vals := map[string]ApplicationGatewayCookieBasedAffinity{ + "disabled": ApplicationGatewayCookieBasedAffinityDisabled, + "enabled": ApplicationGatewayCookieBasedAffinityEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayCookieBasedAffinity(input) + return &out, nil +} + +type ApplicationGatewayCustomErrorStatusCode string + +const ( + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveHundred ApplicationGatewayCustomErrorStatusCode = "HttpStatus500" + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroFour ApplicationGatewayCustomErrorStatusCode = "HttpStatus504" + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroThree ApplicationGatewayCustomErrorStatusCode = "HttpStatus503" + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroTwo ApplicationGatewayCustomErrorStatusCode = "HttpStatus502" + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourHundred ApplicationGatewayCustomErrorStatusCode = "HttpStatus400" + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroEight ApplicationGatewayCustomErrorStatusCode = "HttpStatus408" + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroFive ApplicationGatewayCustomErrorStatusCode = "HttpStatus405" + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroFour ApplicationGatewayCustomErrorStatusCode = "HttpStatus404" + ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroThree ApplicationGatewayCustomErrorStatusCode = "HttpStatus403" +) + +func PossibleValuesForApplicationGatewayCustomErrorStatusCode() []string { + return []string{ + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveHundred), + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroFour), + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroThree), + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroTwo), + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourHundred), + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroEight), + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroFive), + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroFour), + string(ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroThree), + } +} + +func (s *ApplicationGatewayCustomErrorStatusCode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayCustomErrorStatusCode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayCustomErrorStatusCode(input string) (*ApplicationGatewayCustomErrorStatusCode, error) { + vals := map[string]ApplicationGatewayCustomErrorStatusCode{ + "httpstatus500": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveHundred, + "httpstatus504": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroFour, + "httpstatus503": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroThree, + "httpstatus502": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFiveZeroTwo, + "httpstatus400": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourHundred, + "httpstatus408": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroEight, + "httpstatus405": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroFive, + "httpstatus404": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroFour, + "httpstatus403": ApplicationGatewayCustomErrorStatusCodeHTTPStatusFourZeroThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayCustomErrorStatusCode(input) + return &out, nil +} + +type ApplicationGatewayFirewallMode string + +const ( + ApplicationGatewayFirewallModeDetection ApplicationGatewayFirewallMode = "Detection" + ApplicationGatewayFirewallModePrevention ApplicationGatewayFirewallMode = "Prevention" +) + +func PossibleValuesForApplicationGatewayFirewallMode() []string { + return []string{ + string(ApplicationGatewayFirewallModeDetection), + string(ApplicationGatewayFirewallModePrevention), + } +} + +func (s *ApplicationGatewayFirewallMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayFirewallMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayFirewallMode(input string) (*ApplicationGatewayFirewallMode, error) { + vals := map[string]ApplicationGatewayFirewallMode{ + "detection": ApplicationGatewayFirewallModeDetection, + "prevention": ApplicationGatewayFirewallModePrevention, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayFirewallMode(input) + return &out, nil +} + +type ApplicationGatewayFirewallRateLimitDuration string + +const ( + ApplicationGatewayFirewallRateLimitDurationFiveMins ApplicationGatewayFirewallRateLimitDuration = "FiveMins" + ApplicationGatewayFirewallRateLimitDurationOneMin ApplicationGatewayFirewallRateLimitDuration = "OneMin" +) + +func PossibleValuesForApplicationGatewayFirewallRateLimitDuration() []string { + return []string{ + string(ApplicationGatewayFirewallRateLimitDurationFiveMins), + string(ApplicationGatewayFirewallRateLimitDurationOneMin), + } +} + +func (s *ApplicationGatewayFirewallRateLimitDuration) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayFirewallRateLimitDuration(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayFirewallRateLimitDuration(input string) (*ApplicationGatewayFirewallRateLimitDuration, error) { + vals := map[string]ApplicationGatewayFirewallRateLimitDuration{ + "fivemins": ApplicationGatewayFirewallRateLimitDurationFiveMins, + "onemin": ApplicationGatewayFirewallRateLimitDurationOneMin, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayFirewallRateLimitDuration(input) + return &out, nil +} + +type ApplicationGatewayFirewallUserSessionVariable string + +const ( + ApplicationGatewayFirewallUserSessionVariableClientAddr ApplicationGatewayFirewallUserSessionVariable = "ClientAddr" + ApplicationGatewayFirewallUserSessionVariableClientAddrXFFHeader ApplicationGatewayFirewallUserSessionVariable = "ClientAddrXFFHeader" + ApplicationGatewayFirewallUserSessionVariableGeoLocation ApplicationGatewayFirewallUserSessionVariable = "GeoLocation" + ApplicationGatewayFirewallUserSessionVariableGeoLocationXFFHeader ApplicationGatewayFirewallUserSessionVariable = "GeoLocationXFFHeader" + ApplicationGatewayFirewallUserSessionVariableNone ApplicationGatewayFirewallUserSessionVariable = "None" +) + +func PossibleValuesForApplicationGatewayFirewallUserSessionVariable() []string { + return []string{ + string(ApplicationGatewayFirewallUserSessionVariableClientAddr), + string(ApplicationGatewayFirewallUserSessionVariableClientAddrXFFHeader), + string(ApplicationGatewayFirewallUserSessionVariableGeoLocation), + string(ApplicationGatewayFirewallUserSessionVariableGeoLocationXFFHeader), + string(ApplicationGatewayFirewallUserSessionVariableNone), + } +} + +func (s *ApplicationGatewayFirewallUserSessionVariable) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayFirewallUserSessionVariable(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayFirewallUserSessionVariable(input string) (*ApplicationGatewayFirewallUserSessionVariable, error) { + vals := map[string]ApplicationGatewayFirewallUserSessionVariable{ + "clientaddr": ApplicationGatewayFirewallUserSessionVariableClientAddr, + "clientaddrxffheader": ApplicationGatewayFirewallUserSessionVariableClientAddrXFFHeader, + "geolocation": ApplicationGatewayFirewallUserSessionVariableGeoLocation, + "geolocationxffheader": ApplicationGatewayFirewallUserSessionVariableGeoLocationXFFHeader, + "none": ApplicationGatewayFirewallUserSessionVariableNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayFirewallUserSessionVariable(input) + return &out, nil +} + +type ApplicationGatewayLoadDistributionAlgorithm string + +const ( + ApplicationGatewayLoadDistributionAlgorithmIPHash ApplicationGatewayLoadDistributionAlgorithm = "IpHash" + ApplicationGatewayLoadDistributionAlgorithmLeastConnections ApplicationGatewayLoadDistributionAlgorithm = "LeastConnections" + ApplicationGatewayLoadDistributionAlgorithmRoundRobin ApplicationGatewayLoadDistributionAlgorithm = "RoundRobin" +) + +func PossibleValuesForApplicationGatewayLoadDistributionAlgorithm() []string { + return []string{ + string(ApplicationGatewayLoadDistributionAlgorithmIPHash), + string(ApplicationGatewayLoadDistributionAlgorithmLeastConnections), + string(ApplicationGatewayLoadDistributionAlgorithmRoundRobin), + } +} + +func (s *ApplicationGatewayLoadDistributionAlgorithm) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayLoadDistributionAlgorithm(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayLoadDistributionAlgorithm(input string) (*ApplicationGatewayLoadDistributionAlgorithm, error) { + vals := map[string]ApplicationGatewayLoadDistributionAlgorithm{ + "iphash": ApplicationGatewayLoadDistributionAlgorithmIPHash, + "leastconnections": ApplicationGatewayLoadDistributionAlgorithmLeastConnections, + "roundrobin": ApplicationGatewayLoadDistributionAlgorithmRoundRobin, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayLoadDistributionAlgorithm(input) + return &out, nil +} + +type ApplicationGatewayOperationalState string + +const ( + ApplicationGatewayOperationalStateRunning ApplicationGatewayOperationalState = "Running" + ApplicationGatewayOperationalStateStarting ApplicationGatewayOperationalState = "Starting" + ApplicationGatewayOperationalStateStopped ApplicationGatewayOperationalState = "Stopped" + ApplicationGatewayOperationalStateStopping ApplicationGatewayOperationalState = "Stopping" +) + +func PossibleValuesForApplicationGatewayOperationalState() []string { + return []string{ + string(ApplicationGatewayOperationalStateRunning), + string(ApplicationGatewayOperationalStateStarting), + string(ApplicationGatewayOperationalStateStopped), + string(ApplicationGatewayOperationalStateStopping), + } +} + +func (s *ApplicationGatewayOperationalState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayOperationalState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayOperationalState(input string) (*ApplicationGatewayOperationalState, error) { + vals := map[string]ApplicationGatewayOperationalState{ + "running": ApplicationGatewayOperationalStateRunning, + "starting": ApplicationGatewayOperationalStateStarting, + "stopped": ApplicationGatewayOperationalStateStopped, + "stopping": ApplicationGatewayOperationalStateStopping, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayOperationalState(input) + return &out, nil +} + +type ApplicationGatewayProtocol string + +const ( + ApplicationGatewayProtocolHTTP ApplicationGatewayProtocol = "Http" + ApplicationGatewayProtocolHTTPS ApplicationGatewayProtocol = "Https" + ApplicationGatewayProtocolTcp ApplicationGatewayProtocol = "Tcp" + ApplicationGatewayProtocolTls ApplicationGatewayProtocol = "Tls" +) + +func PossibleValuesForApplicationGatewayProtocol() []string { + return []string{ + string(ApplicationGatewayProtocolHTTP), + string(ApplicationGatewayProtocolHTTPS), + string(ApplicationGatewayProtocolTcp), + string(ApplicationGatewayProtocolTls), + } +} + +func (s *ApplicationGatewayProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayProtocol(input string) (*ApplicationGatewayProtocol, error) { + vals := map[string]ApplicationGatewayProtocol{ + "http": ApplicationGatewayProtocolHTTP, + "https": ApplicationGatewayProtocolHTTPS, + "tcp": ApplicationGatewayProtocolTcp, + "tls": ApplicationGatewayProtocolTls, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayProtocol(input) + return &out, nil +} + +type ApplicationGatewayRedirectType string + +const ( + ApplicationGatewayRedirectTypeFound ApplicationGatewayRedirectType = "Found" + ApplicationGatewayRedirectTypePermanent ApplicationGatewayRedirectType = "Permanent" + ApplicationGatewayRedirectTypeSeeOther ApplicationGatewayRedirectType = "SeeOther" + ApplicationGatewayRedirectTypeTemporary ApplicationGatewayRedirectType = "Temporary" +) + +func PossibleValuesForApplicationGatewayRedirectType() []string { + return []string{ + string(ApplicationGatewayRedirectTypeFound), + string(ApplicationGatewayRedirectTypePermanent), + string(ApplicationGatewayRedirectTypeSeeOther), + string(ApplicationGatewayRedirectTypeTemporary), + } +} + +func (s *ApplicationGatewayRedirectType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayRedirectType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayRedirectType(input string) (*ApplicationGatewayRedirectType, error) { + vals := map[string]ApplicationGatewayRedirectType{ + "found": ApplicationGatewayRedirectTypeFound, + "permanent": ApplicationGatewayRedirectTypePermanent, + "seeother": ApplicationGatewayRedirectTypeSeeOther, + "temporary": ApplicationGatewayRedirectTypeTemporary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayRedirectType(input) + return &out, nil +} + +type ApplicationGatewayRequestRoutingRuleType string + +const ( + ApplicationGatewayRequestRoutingRuleTypeBasic ApplicationGatewayRequestRoutingRuleType = "Basic" + ApplicationGatewayRequestRoutingRuleTypePathBasedRouting ApplicationGatewayRequestRoutingRuleType = "PathBasedRouting" +) + +func PossibleValuesForApplicationGatewayRequestRoutingRuleType() []string { + return []string{ + string(ApplicationGatewayRequestRoutingRuleTypeBasic), + string(ApplicationGatewayRequestRoutingRuleTypePathBasedRouting), + } +} + +func (s *ApplicationGatewayRequestRoutingRuleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayRequestRoutingRuleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayRequestRoutingRuleType(input string) (*ApplicationGatewayRequestRoutingRuleType, error) { + vals := map[string]ApplicationGatewayRequestRoutingRuleType{ + "basic": ApplicationGatewayRequestRoutingRuleTypeBasic, + "pathbasedrouting": ApplicationGatewayRequestRoutingRuleTypePathBasedRouting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayRequestRoutingRuleType(input) + return &out, nil +} + +type ApplicationGatewaySkuFamily string + +const ( + ApplicationGatewaySkuFamilyGenerationOne ApplicationGatewaySkuFamily = "Generation_1" + ApplicationGatewaySkuFamilyGenerationTwo ApplicationGatewaySkuFamily = "Generation_2" +) + +func PossibleValuesForApplicationGatewaySkuFamily() []string { + return []string{ + string(ApplicationGatewaySkuFamilyGenerationOne), + string(ApplicationGatewaySkuFamilyGenerationTwo), + } +} + +func (s *ApplicationGatewaySkuFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewaySkuFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewaySkuFamily(input string) (*ApplicationGatewaySkuFamily, error) { + vals := map[string]ApplicationGatewaySkuFamily{ + "generation_1": ApplicationGatewaySkuFamilyGenerationOne, + "generation_2": ApplicationGatewaySkuFamilyGenerationTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewaySkuFamily(input) + return &out, nil +} + +type ApplicationGatewaySkuName string + +const ( + ApplicationGatewaySkuNameBasic ApplicationGatewaySkuName = "Basic" + ApplicationGatewaySkuNameStandardLarge ApplicationGatewaySkuName = "Standard_Large" + ApplicationGatewaySkuNameStandardMedium ApplicationGatewaySkuName = "Standard_Medium" + ApplicationGatewaySkuNameStandardSmall ApplicationGatewaySkuName = "Standard_Small" + ApplicationGatewaySkuNameStandardVTwo ApplicationGatewaySkuName = "Standard_v2" + ApplicationGatewaySkuNameWAFLarge ApplicationGatewaySkuName = "WAF_Large" + ApplicationGatewaySkuNameWAFMedium ApplicationGatewaySkuName = "WAF_Medium" + ApplicationGatewaySkuNameWAFVTwo ApplicationGatewaySkuName = "WAF_v2" +) + +func PossibleValuesForApplicationGatewaySkuName() []string { + return []string{ + string(ApplicationGatewaySkuNameBasic), + string(ApplicationGatewaySkuNameStandardLarge), + string(ApplicationGatewaySkuNameStandardMedium), + string(ApplicationGatewaySkuNameStandardSmall), + string(ApplicationGatewaySkuNameStandardVTwo), + string(ApplicationGatewaySkuNameWAFLarge), + string(ApplicationGatewaySkuNameWAFMedium), + string(ApplicationGatewaySkuNameWAFVTwo), + } +} + +func (s *ApplicationGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewaySkuName(input string) (*ApplicationGatewaySkuName, error) { + vals := map[string]ApplicationGatewaySkuName{ + "basic": ApplicationGatewaySkuNameBasic, + "standard_large": ApplicationGatewaySkuNameStandardLarge, + "standard_medium": ApplicationGatewaySkuNameStandardMedium, + "standard_small": ApplicationGatewaySkuNameStandardSmall, + "standard_v2": ApplicationGatewaySkuNameStandardVTwo, + "waf_large": ApplicationGatewaySkuNameWAFLarge, + "waf_medium": ApplicationGatewaySkuNameWAFMedium, + "waf_v2": ApplicationGatewaySkuNameWAFVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewaySkuName(input) + return &out, nil +} + +type ApplicationGatewaySslCipherSuite string + +const ( + ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESOneTwoEightCBCSHA ApplicationGatewaySslCipherSuite = "TLS_DHE_DSS_WITH_AES_128_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESOneTwoEightCBCSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256" + ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESTwoFiveSixCBCSHA ApplicationGatewaySslCipherSuite = "TLS_DHE_DSS_WITH_AES_256_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESTwoFiveSixCBCSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256" + ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHThreeDESEDECBCSHA ApplicationGatewaySslCipherSuite = "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESOneTwoEightCBCSHA ApplicationGatewaySslCipherSuite = "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" + ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESTwoFiveSixCBCSHA ApplicationGatewaySslCipherSuite = "TLS_DHE_RSA_WITH_AES_256_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour ApplicationGatewaySslCipherSuite = "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384" + ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightCBCSHA ApplicationGatewaySslCipherSuite = "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" + ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" + ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixCBCSHA ApplicationGatewaySslCipherSuite = "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixCBCSHAThreeEightFour ApplicationGatewaySslCipherSuite = "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384" + ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour ApplicationGatewaySslCipherSuite = "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" + ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightCBCSHA ApplicationGatewaySslCipherSuite = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" + ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" + ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixCBCSHA ApplicationGatewaySslCipherSuite = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour ApplicationGatewaySslCipherSuite = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" + ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour ApplicationGatewaySslCipherSuite = "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" + ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightCBCSHA ApplicationGatewaySslCipherSuite = "TLS_RSA_WITH_AES_128_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_RSA_WITH_AES_128_CBC_SHA256" + ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_RSA_WITH_AES_128_GCM_SHA256" + ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixCBCSHA ApplicationGatewaySslCipherSuite = "TLS_RSA_WITH_AES_256_CBC_SHA" + ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix ApplicationGatewaySslCipherSuite = "TLS_RSA_WITH_AES_256_CBC_SHA256" + ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour ApplicationGatewaySslCipherSuite = "TLS_RSA_WITH_AES_256_GCM_SHA384" + ApplicationGatewaySslCipherSuiteTLSRSAWITHThreeDESEDECBCSHA ApplicationGatewaySslCipherSuite = "TLS_RSA_WITH_3DES_EDE_CBC_SHA" +) + +func PossibleValuesForApplicationGatewaySslCipherSuite() []string { + return []string{ + string(ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESOneTwoEightCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESOneTwoEightCBCSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESTwoFiveSixCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESTwoFiveSixCBCSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHThreeDESEDECBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESOneTwoEightCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESTwoFiveSixCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixCBCSHAThreeEightFour), + string(ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour), + string(ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixCBCSHA), + string(ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix), + string(ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(ApplicationGatewaySslCipherSuiteTLSRSAWITHThreeDESEDECBCSHA), + } +} + +func (s *ApplicationGatewaySslCipherSuite) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewaySslCipherSuite(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewaySslCipherSuite(input string) (*ApplicationGatewaySslCipherSuite, error) { + vals := map[string]ApplicationGatewaySslCipherSuite{ + "tls_dhe_dss_with_aes_128_cbc_sha": ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESOneTwoEightCBCSHA, + "tls_dhe_dss_with_aes_128_cbc_sha256": ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_dhe_dss_with_aes_256_cbc_sha": ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESTwoFiveSixCBCSHA, + "tls_dhe_dss_with_aes_256_cbc_sha256": ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHAESTwoFiveSixCBCSHATwoFiveSix, + "tls_dhe_dss_with_3des_ede_cbc_sha": ApplicationGatewaySslCipherSuiteTLSDHEDSSWITHThreeDESEDECBCSHA, + "tls_dhe_rsa_with_aes_128_cbc_sha": ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESOneTwoEightCBCSHA, + "tls_dhe_rsa_with_aes_128_gcm_sha256": ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_dhe_rsa_with_aes_256_cbc_sha": ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESTwoFiveSixCBCSHA, + "tls_dhe_rsa_with_aes_256_gcm_sha384": ApplicationGatewaySslCipherSuiteTLSDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_ecdsa_with_aes_128_cbc_sha": ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightCBCSHA, + "tls_ecdhe_ecdsa_with_aes_128_cbc_sha256": ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_128_gcm_sha256": ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_256_cbc_sha": ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixCBCSHA, + "tls_ecdhe_ecdsa_with_aes_256_cbc_sha384": ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixCBCSHAThreeEightFour, + "tls_ecdhe_ecdsa_with_aes_256_gcm_sha384": ApplicationGatewaySslCipherSuiteTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_128_cbc_sha": ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightCBCSHA, + "tls_ecdhe_rsa_with_aes_128_cbc_sha256": ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_128_gcm_sha256": ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_256_cbc_sha": ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixCBCSHA, + "tls_ecdhe_rsa_with_aes_256_cbc_sha384": ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_256_gcm_sha384": ApplicationGatewaySslCipherSuiteTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_rsa_with_aes_128_cbc_sha": ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightCBCSHA, + "tls_rsa_with_aes_128_cbc_sha256": ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_rsa_with_aes_128_gcm_sha256": ApplicationGatewaySslCipherSuiteTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_rsa_with_aes_256_cbc_sha": ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixCBCSHA, + "tls_rsa_with_aes_256_cbc_sha256": ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix, + "tls_rsa_with_aes_256_gcm_sha384": ApplicationGatewaySslCipherSuiteTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_rsa_with_3des_ede_cbc_sha": ApplicationGatewaySslCipherSuiteTLSRSAWITHThreeDESEDECBCSHA, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewaySslCipherSuite(input) + return &out, nil +} + +type ApplicationGatewaySslPolicyName string + +const ( + ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneFiveZeroFiveZeroOne ApplicationGatewaySslPolicyName = "AppGwSslPolicy20150501" + ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneSevenZeroFourZeroOne ApplicationGatewaySslPolicyName = "AppGwSslPolicy20170401" + ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneSevenZeroFourZeroOneS ApplicationGatewaySslPolicyName = "AppGwSslPolicy20170401S" + ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroTwoTwoZeroOneZeroOne ApplicationGatewaySslPolicyName = "AppGwSslPolicy20220101" + ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroTwoTwoZeroOneZeroOneS ApplicationGatewaySslPolicyName = "AppGwSslPolicy20220101S" +) + +func PossibleValuesForApplicationGatewaySslPolicyName() []string { + return []string{ + string(ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneFiveZeroFiveZeroOne), + string(ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneSevenZeroFourZeroOne), + string(ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneSevenZeroFourZeroOneS), + string(ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroTwoTwoZeroOneZeroOne), + string(ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroTwoTwoZeroOneZeroOneS), + } +} + +func (s *ApplicationGatewaySslPolicyName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewaySslPolicyName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewaySslPolicyName(input string) (*ApplicationGatewaySslPolicyName, error) { + vals := map[string]ApplicationGatewaySslPolicyName{ + "appgwsslpolicy20150501": ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneFiveZeroFiveZeroOne, + "appgwsslpolicy20170401": ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneSevenZeroFourZeroOne, + "appgwsslpolicy20170401s": ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroOneSevenZeroFourZeroOneS, + "appgwsslpolicy20220101": ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroTwoTwoZeroOneZeroOne, + "appgwsslpolicy20220101s": ApplicationGatewaySslPolicyNameAppGwSslPolicyTwoZeroTwoTwoZeroOneZeroOneS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewaySslPolicyName(input) + return &out, nil +} + +type ApplicationGatewaySslPolicyType string + +const ( + ApplicationGatewaySslPolicyTypeCustom ApplicationGatewaySslPolicyType = "Custom" + ApplicationGatewaySslPolicyTypeCustomVTwo ApplicationGatewaySslPolicyType = "CustomV2" + ApplicationGatewaySslPolicyTypePredefined ApplicationGatewaySslPolicyType = "Predefined" +) + +func PossibleValuesForApplicationGatewaySslPolicyType() []string { + return []string{ + string(ApplicationGatewaySslPolicyTypeCustom), + string(ApplicationGatewaySslPolicyTypeCustomVTwo), + string(ApplicationGatewaySslPolicyTypePredefined), + } +} + +func (s *ApplicationGatewaySslPolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewaySslPolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewaySslPolicyType(input string) (*ApplicationGatewaySslPolicyType, error) { + vals := map[string]ApplicationGatewaySslPolicyType{ + "custom": ApplicationGatewaySslPolicyTypeCustom, + "customv2": ApplicationGatewaySslPolicyTypeCustomVTwo, + "predefined": ApplicationGatewaySslPolicyTypePredefined, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewaySslPolicyType(input) + return &out, nil +} + +type ApplicationGatewaySslProtocol string + +const ( + ApplicationGatewaySslProtocolTLSvOneOne ApplicationGatewaySslProtocol = "TLSv1_1" + ApplicationGatewaySslProtocolTLSvOneThree ApplicationGatewaySslProtocol = "TLSv1_3" + ApplicationGatewaySslProtocolTLSvOneTwo ApplicationGatewaySslProtocol = "TLSv1_2" + ApplicationGatewaySslProtocolTLSvOneZero ApplicationGatewaySslProtocol = "TLSv1_0" +) + +func PossibleValuesForApplicationGatewaySslProtocol() []string { + return []string{ + string(ApplicationGatewaySslProtocolTLSvOneOne), + string(ApplicationGatewaySslProtocolTLSvOneThree), + string(ApplicationGatewaySslProtocolTLSvOneTwo), + string(ApplicationGatewaySslProtocolTLSvOneZero), + } +} + +func (s *ApplicationGatewaySslProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewaySslProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewaySslProtocol(input string) (*ApplicationGatewaySslProtocol, error) { + vals := map[string]ApplicationGatewaySslProtocol{ + "tlsv1_1": ApplicationGatewaySslProtocolTLSvOneOne, + "tlsv1_3": ApplicationGatewaySslProtocolTLSvOneThree, + "tlsv1_2": ApplicationGatewaySslProtocolTLSvOneTwo, + "tlsv1_0": ApplicationGatewaySslProtocolTLSvOneZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewaySslProtocol(input) + return &out, nil +} + +type ApplicationGatewayTier string + +const ( + ApplicationGatewayTierBasic ApplicationGatewayTier = "Basic" + ApplicationGatewayTierStandard ApplicationGatewayTier = "Standard" + ApplicationGatewayTierStandardVTwo ApplicationGatewayTier = "Standard_v2" + ApplicationGatewayTierWAF ApplicationGatewayTier = "WAF" + ApplicationGatewayTierWAFVTwo ApplicationGatewayTier = "WAF_v2" +) + +func PossibleValuesForApplicationGatewayTier() []string { + return []string{ + string(ApplicationGatewayTierBasic), + string(ApplicationGatewayTierStandard), + string(ApplicationGatewayTierStandardVTwo), + string(ApplicationGatewayTierWAF), + string(ApplicationGatewayTierWAFVTwo), + } +} + +func (s *ApplicationGatewayTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationGatewayTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationGatewayTier(input string) (*ApplicationGatewayTier, error) { + vals := map[string]ApplicationGatewayTier{ + "basic": ApplicationGatewayTierBasic, + "standard": ApplicationGatewayTierStandard, + "standard_v2": ApplicationGatewayTierStandardVTwo, + "waf": ApplicationGatewayTierWAF, + "waf_v2": ApplicationGatewayTierWAFVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationGatewayTier(input) + return &out, nil +} + +type DdosSettingsProtectionMode string + +const ( + DdosSettingsProtectionModeDisabled DdosSettingsProtectionMode = "Disabled" + DdosSettingsProtectionModeEnabled DdosSettingsProtectionMode = "Enabled" + DdosSettingsProtectionModeVirtualNetworkInherited DdosSettingsProtectionMode = "VirtualNetworkInherited" +) + +func PossibleValuesForDdosSettingsProtectionMode() []string { + return []string{ + string(DdosSettingsProtectionModeDisabled), + string(DdosSettingsProtectionModeEnabled), + string(DdosSettingsProtectionModeVirtualNetworkInherited), + } +} + +func (s *DdosSettingsProtectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDdosSettingsProtectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDdosSettingsProtectionMode(input string) (*DdosSettingsProtectionMode, error) { + vals := map[string]DdosSettingsProtectionMode{ + "disabled": DdosSettingsProtectionModeDisabled, + "enabled": DdosSettingsProtectionModeEnabled, + "virtualnetworkinherited": DdosSettingsProtectionModeVirtualNetworkInherited, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DdosSettingsProtectionMode(input) + return &out, nil +} + +type DeleteOptions string + +const ( + DeleteOptionsDelete DeleteOptions = "Delete" + DeleteOptionsDetach DeleteOptions = "Detach" +) + +func PossibleValuesForDeleteOptions() []string { + return []string{ + string(DeleteOptionsDelete), + string(DeleteOptionsDetach), + } +} + +func (s *DeleteOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeleteOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeleteOptions(input string) (*DeleteOptions, error) { + vals := map[string]DeleteOptions{ + "delete": DeleteOptionsDelete, + "detach": DeleteOptionsDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeleteOptions(input) + return &out, nil +} + +type ExceptionEntryMatchVariable string + +const ( + ExceptionEntryMatchVariableRemoteAddr ExceptionEntryMatchVariable = "RemoteAddr" + ExceptionEntryMatchVariableRequestHeader ExceptionEntryMatchVariable = "RequestHeader" + ExceptionEntryMatchVariableRequestURI ExceptionEntryMatchVariable = "RequestURI" +) + +func PossibleValuesForExceptionEntryMatchVariable() []string { + return []string{ + string(ExceptionEntryMatchVariableRemoteAddr), + string(ExceptionEntryMatchVariableRequestHeader), + string(ExceptionEntryMatchVariableRequestURI), + } +} + +func (s *ExceptionEntryMatchVariable) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExceptionEntryMatchVariable(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExceptionEntryMatchVariable(input string) (*ExceptionEntryMatchVariable, error) { + vals := map[string]ExceptionEntryMatchVariable{ + "remoteaddr": ExceptionEntryMatchVariableRemoteAddr, + "requestheader": ExceptionEntryMatchVariableRequestHeader, + "requesturi": ExceptionEntryMatchVariableRequestURI, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExceptionEntryMatchVariable(input) + return &out, nil +} + +type ExceptionEntrySelectorMatchOperator string + +const ( + ExceptionEntrySelectorMatchOperatorContains ExceptionEntrySelectorMatchOperator = "Contains" + ExceptionEntrySelectorMatchOperatorEndsWith ExceptionEntrySelectorMatchOperator = "EndsWith" + ExceptionEntrySelectorMatchOperatorEquals ExceptionEntrySelectorMatchOperator = "Equals" + ExceptionEntrySelectorMatchOperatorStartsWith ExceptionEntrySelectorMatchOperator = "StartsWith" +) + +func PossibleValuesForExceptionEntrySelectorMatchOperator() []string { + return []string{ + string(ExceptionEntrySelectorMatchOperatorContains), + string(ExceptionEntrySelectorMatchOperatorEndsWith), + string(ExceptionEntrySelectorMatchOperatorEquals), + string(ExceptionEntrySelectorMatchOperatorStartsWith), + } +} + +func (s *ExceptionEntrySelectorMatchOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExceptionEntrySelectorMatchOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExceptionEntrySelectorMatchOperator(input string) (*ExceptionEntrySelectorMatchOperator, error) { + vals := map[string]ExceptionEntrySelectorMatchOperator{ + "contains": ExceptionEntrySelectorMatchOperatorContains, + "endswith": ExceptionEntrySelectorMatchOperatorEndsWith, + "equals": ExceptionEntrySelectorMatchOperatorEquals, + "startswith": ExceptionEntrySelectorMatchOperatorStartsWith, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExceptionEntrySelectorMatchOperator(input) + return &out, nil +} + +type ExceptionEntryValueMatchOperator string + +const ( + ExceptionEntryValueMatchOperatorContains ExceptionEntryValueMatchOperator = "Contains" + ExceptionEntryValueMatchOperatorEndsWith ExceptionEntryValueMatchOperator = "EndsWith" + ExceptionEntryValueMatchOperatorEquals ExceptionEntryValueMatchOperator = "Equals" + ExceptionEntryValueMatchOperatorIPMatch ExceptionEntryValueMatchOperator = "IPMatch" + ExceptionEntryValueMatchOperatorStartsWith ExceptionEntryValueMatchOperator = "StartsWith" +) + +func PossibleValuesForExceptionEntryValueMatchOperator() []string { + return []string{ + string(ExceptionEntryValueMatchOperatorContains), + string(ExceptionEntryValueMatchOperatorEndsWith), + string(ExceptionEntryValueMatchOperatorEquals), + string(ExceptionEntryValueMatchOperatorIPMatch), + string(ExceptionEntryValueMatchOperatorStartsWith), + } +} + +func (s *ExceptionEntryValueMatchOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExceptionEntryValueMatchOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExceptionEntryValueMatchOperator(input string) (*ExceptionEntryValueMatchOperator, error) { + vals := map[string]ExceptionEntryValueMatchOperator{ + "contains": ExceptionEntryValueMatchOperatorContains, + "endswith": ExceptionEntryValueMatchOperatorEndsWith, + "equals": ExceptionEntryValueMatchOperatorEquals, + "ipmatch": ExceptionEntryValueMatchOperatorIPMatch, + "startswith": ExceptionEntryValueMatchOperatorStartsWith, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ExceptionEntryValueMatchOperator(input) + return &out, nil +} + +type FlowLogFormatType string + +const ( + FlowLogFormatTypeJSON FlowLogFormatType = "JSON" +) + +func PossibleValuesForFlowLogFormatType() []string { + return []string{ + string(FlowLogFormatTypeJSON), + } +} + +func (s *FlowLogFormatType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFlowLogFormatType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFlowLogFormatType(input string) (*FlowLogFormatType, error) { + vals := map[string]FlowLogFormatType{ + "json": FlowLogFormatTypeJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FlowLogFormatType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelInterfaceType string + +const ( + GatewayLoadBalancerTunnelInterfaceTypeExternal GatewayLoadBalancerTunnelInterfaceType = "External" + GatewayLoadBalancerTunnelInterfaceTypeInternal GatewayLoadBalancerTunnelInterfaceType = "Internal" + GatewayLoadBalancerTunnelInterfaceTypeNone GatewayLoadBalancerTunnelInterfaceType = "None" +) + +func PossibleValuesForGatewayLoadBalancerTunnelInterfaceType() []string { + return []string{ + string(GatewayLoadBalancerTunnelInterfaceTypeExternal), + string(GatewayLoadBalancerTunnelInterfaceTypeInternal), + string(GatewayLoadBalancerTunnelInterfaceTypeNone), + } +} + +func (s *GatewayLoadBalancerTunnelInterfaceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelInterfaceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelInterfaceType(input string) (*GatewayLoadBalancerTunnelInterfaceType, error) { + vals := map[string]GatewayLoadBalancerTunnelInterfaceType{ + "external": GatewayLoadBalancerTunnelInterfaceTypeExternal, + "internal": GatewayLoadBalancerTunnelInterfaceTypeInternal, + "none": GatewayLoadBalancerTunnelInterfaceTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelInterfaceType(input) + return &out, nil +} + +type GatewayLoadBalancerTunnelProtocol string + +const ( + GatewayLoadBalancerTunnelProtocolNative GatewayLoadBalancerTunnelProtocol = "Native" + GatewayLoadBalancerTunnelProtocolNone GatewayLoadBalancerTunnelProtocol = "None" + GatewayLoadBalancerTunnelProtocolVXLAN GatewayLoadBalancerTunnelProtocol = "VXLAN" +) + +func PossibleValuesForGatewayLoadBalancerTunnelProtocol() []string { + return []string{ + string(GatewayLoadBalancerTunnelProtocolNative), + string(GatewayLoadBalancerTunnelProtocolNone), + string(GatewayLoadBalancerTunnelProtocolVXLAN), + } +} + +func (s *GatewayLoadBalancerTunnelProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGatewayLoadBalancerTunnelProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGatewayLoadBalancerTunnelProtocol(input string) (*GatewayLoadBalancerTunnelProtocol, error) { + vals := map[string]GatewayLoadBalancerTunnelProtocol{ + "native": GatewayLoadBalancerTunnelProtocolNative, + "none": GatewayLoadBalancerTunnelProtocolNone, + "vxlan": GatewayLoadBalancerTunnelProtocolVXLAN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GatewayLoadBalancerTunnelProtocol(input) + return &out, nil +} + +type IPAllocationMethod string + +const ( + IPAllocationMethodDynamic IPAllocationMethod = "Dynamic" + IPAllocationMethodStatic IPAllocationMethod = "Static" +) + +func PossibleValuesForIPAllocationMethod() []string { + return []string{ + string(IPAllocationMethodDynamic), + string(IPAllocationMethodStatic), + } +} + +func (s *IPAllocationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPAllocationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPAllocationMethod(input string) (*IPAllocationMethod, error) { + vals := map[string]IPAllocationMethod{ + "dynamic": IPAllocationMethodDynamic, + "static": IPAllocationMethodStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPAllocationMethod(input) + return &out, nil +} + +type IPVersion string + +const ( + IPVersionIPvFour IPVersion = "IPv4" + IPVersionIPvSix IPVersion = "IPv6" +) + +func PossibleValuesForIPVersion() []string { + return []string{ + string(IPVersionIPvFour), + string(IPVersionIPvSix), + } +} + +func (s *IPVersion) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPVersion(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPVersion(input string) (*IPVersion, error) { + vals := map[string]IPVersion{ + "ipv4": IPVersionIPvFour, + "ipv6": IPVersionIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPVersion(input) + return &out, nil +} + +type LoadBalancerBackendAddressAdminState string + +const ( + LoadBalancerBackendAddressAdminStateDown LoadBalancerBackendAddressAdminState = "Down" + LoadBalancerBackendAddressAdminStateNone LoadBalancerBackendAddressAdminState = "None" + LoadBalancerBackendAddressAdminStateUp LoadBalancerBackendAddressAdminState = "Up" +) + +func PossibleValuesForLoadBalancerBackendAddressAdminState() []string { + return []string{ + string(LoadBalancerBackendAddressAdminStateDown), + string(LoadBalancerBackendAddressAdminStateNone), + string(LoadBalancerBackendAddressAdminStateUp), + } +} + +func (s *LoadBalancerBackendAddressAdminState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerBackendAddressAdminState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerBackendAddressAdminState(input string) (*LoadBalancerBackendAddressAdminState, error) { + vals := map[string]LoadBalancerBackendAddressAdminState{ + "down": LoadBalancerBackendAddressAdminStateDown, + "none": LoadBalancerBackendAddressAdminStateNone, + "up": LoadBalancerBackendAddressAdminStateUp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerBackendAddressAdminState(input) + return &out, nil +} + +type ManagedRuleEnabledState string + +const ( + ManagedRuleEnabledStateDisabled ManagedRuleEnabledState = "Disabled" + ManagedRuleEnabledStateEnabled ManagedRuleEnabledState = "Enabled" +) + +func PossibleValuesForManagedRuleEnabledState() []string { + return []string{ + string(ManagedRuleEnabledStateDisabled), + string(ManagedRuleEnabledStateEnabled), + } +} + +func (s *ManagedRuleEnabledState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedRuleEnabledState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedRuleEnabledState(input string) (*ManagedRuleEnabledState, error) { + vals := map[string]ManagedRuleEnabledState{ + "disabled": ManagedRuleEnabledStateDisabled, + "enabled": ManagedRuleEnabledStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedRuleEnabledState(input) + return &out, nil +} + +type NatGatewaySkuName string + +const ( + NatGatewaySkuNameStandard NatGatewaySkuName = "Standard" + NatGatewaySkuNameStandardVTwo NatGatewaySkuName = "StandardV2" +) + +func PossibleValuesForNatGatewaySkuName() []string { + return []string{ + string(NatGatewaySkuNameStandard), + string(NatGatewaySkuNameStandardVTwo), + } +} + +func (s *NatGatewaySkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNatGatewaySkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNatGatewaySkuName(input string) (*NatGatewaySkuName, error) { + vals := map[string]NatGatewaySkuName{ + "standard": NatGatewaySkuNameStandard, + "standardv2": NatGatewaySkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NatGatewaySkuName(input) + return &out, nil +} + +type NetworkInterfaceAuxiliaryMode string + +const ( + NetworkInterfaceAuxiliaryModeAcceleratedConnections NetworkInterfaceAuxiliaryMode = "AcceleratedConnections" + NetworkInterfaceAuxiliaryModeFloating NetworkInterfaceAuxiliaryMode = "Floating" + NetworkInterfaceAuxiliaryModeMaxConnections NetworkInterfaceAuxiliaryMode = "MaxConnections" + NetworkInterfaceAuxiliaryModeNone NetworkInterfaceAuxiliaryMode = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliaryMode() []string { + return []string{ + string(NetworkInterfaceAuxiliaryModeAcceleratedConnections), + string(NetworkInterfaceAuxiliaryModeFloating), + string(NetworkInterfaceAuxiliaryModeMaxConnections), + string(NetworkInterfaceAuxiliaryModeNone), + } +} + +func (s *NetworkInterfaceAuxiliaryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliaryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliaryMode(input string) (*NetworkInterfaceAuxiliaryMode, error) { + vals := map[string]NetworkInterfaceAuxiliaryMode{ + "acceleratedconnections": NetworkInterfaceAuxiliaryModeAcceleratedConnections, + "floating": NetworkInterfaceAuxiliaryModeFloating, + "maxconnections": NetworkInterfaceAuxiliaryModeMaxConnections, + "none": NetworkInterfaceAuxiliaryModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliaryMode(input) + return &out, nil +} + +type NetworkInterfaceAuxiliarySku string + +const ( + NetworkInterfaceAuxiliarySkuAEight NetworkInterfaceAuxiliarySku = "A8" + NetworkInterfaceAuxiliarySkuAFour NetworkInterfaceAuxiliarySku = "A4" + NetworkInterfaceAuxiliarySkuAOne NetworkInterfaceAuxiliarySku = "A1" + NetworkInterfaceAuxiliarySkuATwo NetworkInterfaceAuxiliarySku = "A2" + NetworkInterfaceAuxiliarySkuNone NetworkInterfaceAuxiliarySku = "None" +) + +func PossibleValuesForNetworkInterfaceAuxiliarySku() []string { + return []string{ + string(NetworkInterfaceAuxiliarySkuAEight), + string(NetworkInterfaceAuxiliarySkuAFour), + string(NetworkInterfaceAuxiliarySkuAOne), + string(NetworkInterfaceAuxiliarySkuATwo), + string(NetworkInterfaceAuxiliarySkuNone), + } +} + +func (s *NetworkInterfaceAuxiliarySku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceAuxiliarySku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceAuxiliarySku(input string) (*NetworkInterfaceAuxiliarySku, error) { + vals := map[string]NetworkInterfaceAuxiliarySku{ + "a8": NetworkInterfaceAuxiliarySkuAEight, + "a4": NetworkInterfaceAuxiliarySkuAFour, + "a1": NetworkInterfaceAuxiliarySkuAOne, + "a2": NetworkInterfaceAuxiliarySkuATwo, + "none": NetworkInterfaceAuxiliarySkuNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceAuxiliarySku(input) + return &out, nil +} + +type NetworkInterfaceMigrationPhase string + +const ( + NetworkInterfaceMigrationPhaseAbort NetworkInterfaceMigrationPhase = "Abort" + NetworkInterfaceMigrationPhaseCommit NetworkInterfaceMigrationPhase = "Commit" + NetworkInterfaceMigrationPhaseCommitted NetworkInterfaceMigrationPhase = "Committed" + NetworkInterfaceMigrationPhaseNone NetworkInterfaceMigrationPhase = "None" + NetworkInterfaceMigrationPhasePrepare NetworkInterfaceMigrationPhase = "Prepare" +) + +func PossibleValuesForNetworkInterfaceMigrationPhase() []string { + return []string{ + string(NetworkInterfaceMigrationPhaseAbort), + string(NetworkInterfaceMigrationPhaseCommit), + string(NetworkInterfaceMigrationPhaseCommitted), + string(NetworkInterfaceMigrationPhaseNone), + string(NetworkInterfaceMigrationPhasePrepare), + } +} + +func (s *NetworkInterfaceMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceMigrationPhase(input string) (*NetworkInterfaceMigrationPhase, error) { + vals := map[string]NetworkInterfaceMigrationPhase{ + "abort": NetworkInterfaceMigrationPhaseAbort, + "commit": NetworkInterfaceMigrationPhaseCommit, + "committed": NetworkInterfaceMigrationPhaseCommitted, + "none": NetworkInterfaceMigrationPhaseNone, + "prepare": NetworkInterfaceMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceMigrationPhase(input) + return &out, nil +} + +type NetworkInterfaceNicType string + +const ( + NetworkInterfaceNicTypeElastic NetworkInterfaceNicType = "Elastic" + NetworkInterfaceNicTypeStandard NetworkInterfaceNicType = "Standard" +) + +func PossibleValuesForNetworkInterfaceNicType() []string { + return []string{ + string(NetworkInterfaceNicTypeElastic), + string(NetworkInterfaceNicTypeStandard), + } +} + +func (s *NetworkInterfaceNicType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkInterfaceNicType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkInterfaceNicType(input string) (*NetworkInterfaceNicType, error) { + vals := map[string]NetworkInterfaceNicType{ + "elastic": NetworkInterfaceNicTypeElastic, + "standard": NetworkInterfaceNicTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkInterfaceNicType(input) + return &out, nil +} + +type OwaspCrsExclusionEntryMatchVariable string + +const ( + OwaspCrsExclusionEntryMatchVariableRequestArgKeys OwaspCrsExclusionEntryMatchVariable = "RequestArgKeys" + OwaspCrsExclusionEntryMatchVariableRequestArgNames OwaspCrsExclusionEntryMatchVariable = "RequestArgNames" + OwaspCrsExclusionEntryMatchVariableRequestArgValues OwaspCrsExclusionEntryMatchVariable = "RequestArgValues" + OwaspCrsExclusionEntryMatchVariableRequestCookieKeys OwaspCrsExclusionEntryMatchVariable = "RequestCookieKeys" + OwaspCrsExclusionEntryMatchVariableRequestCookieNames OwaspCrsExclusionEntryMatchVariable = "RequestCookieNames" + OwaspCrsExclusionEntryMatchVariableRequestCookieValues OwaspCrsExclusionEntryMatchVariable = "RequestCookieValues" + OwaspCrsExclusionEntryMatchVariableRequestHeaderKeys OwaspCrsExclusionEntryMatchVariable = "RequestHeaderKeys" + OwaspCrsExclusionEntryMatchVariableRequestHeaderNames OwaspCrsExclusionEntryMatchVariable = "RequestHeaderNames" + OwaspCrsExclusionEntryMatchVariableRequestHeaderValues OwaspCrsExclusionEntryMatchVariable = "RequestHeaderValues" +) + +func PossibleValuesForOwaspCrsExclusionEntryMatchVariable() []string { + return []string{ + string(OwaspCrsExclusionEntryMatchVariableRequestArgKeys), + string(OwaspCrsExclusionEntryMatchVariableRequestArgNames), + string(OwaspCrsExclusionEntryMatchVariableRequestArgValues), + string(OwaspCrsExclusionEntryMatchVariableRequestCookieKeys), + string(OwaspCrsExclusionEntryMatchVariableRequestCookieNames), + string(OwaspCrsExclusionEntryMatchVariableRequestCookieValues), + string(OwaspCrsExclusionEntryMatchVariableRequestHeaderKeys), + string(OwaspCrsExclusionEntryMatchVariableRequestHeaderNames), + string(OwaspCrsExclusionEntryMatchVariableRequestHeaderValues), + } +} + +func (s *OwaspCrsExclusionEntryMatchVariable) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOwaspCrsExclusionEntryMatchVariable(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOwaspCrsExclusionEntryMatchVariable(input string) (*OwaspCrsExclusionEntryMatchVariable, error) { + vals := map[string]OwaspCrsExclusionEntryMatchVariable{ + "requestargkeys": OwaspCrsExclusionEntryMatchVariableRequestArgKeys, + "requestargnames": OwaspCrsExclusionEntryMatchVariableRequestArgNames, + "requestargvalues": OwaspCrsExclusionEntryMatchVariableRequestArgValues, + "requestcookiekeys": OwaspCrsExclusionEntryMatchVariableRequestCookieKeys, + "requestcookienames": OwaspCrsExclusionEntryMatchVariableRequestCookieNames, + "requestcookievalues": OwaspCrsExclusionEntryMatchVariableRequestCookieValues, + "requestheaderkeys": OwaspCrsExclusionEntryMatchVariableRequestHeaderKeys, + "requestheadernames": OwaspCrsExclusionEntryMatchVariableRequestHeaderNames, + "requestheadervalues": OwaspCrsExclusionEntryMatchVariableRequestHeaderValues, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OwaspCrsExclusionEntryMatchVariable(input) + return &out, nil +} + +type OwaspCrsExclusionEntrySelectorMatchOperator string + +const ( + OwaspCrsExclusionEntrySelectorMatchOperatorContains OwaspCrsExclusionEntrySelectorMatchOperator = "Contains" + OwaspCrsExclusionEntrySelectorMatchOperatorEndsWith OwaspCrsExclusionEntrySelectorMatchOperator = "EndsWith" + OwaspCrsExclusionEntrySelectorMatchOperatorEquals OwaspCrsExclusionEntrySelectorMatchOperator = "Equals" + OwaspCrsExclusionEntrySelectorMatchOperatorEqualsAny OwaspCrsExclusionEntrySelectorMatchOperator = "EqualsAny" + OwaspCrsExclusionEntrySelectorMatchOperatorStartsWith OwaspCrsExclusionEntrySelectorMatchOperator = "StartsWith" +) + +func PossibleValuesForOwaspCrsExclusionEntrySelectorMatchOperator() []string { + return []string{ + string(OwaspCrsExclusionEntrySelectorMatchOperatorContains), + string(OwaspCrsExclusionEntrySelectorMatchOperatorEndsWith), + string(OwaspCrsExclusionEntrySelectorMatchOperatorEquals), + string(OwaspCrsExclusionEntrySelectorMatchOperatorEqualsAny), + string(OwaspCrsExclusionEntrySelectorMatchOperatorStartsWith), + } +} + +func (s *OwaspCrsExclusionEntrySelectorMatchOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOwaspCrsExclusionEntrySelectorMatchOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOwaspCrsExclusionEntrySelectorMatchOperator(input string) (*OwaspCrsExclusionEntrySelectorMatchOperator, error) { + vals := map[string]OwaspCrsExclusionEntrySelectorMatchOperator{ + "contains": OwaspCrsExclusionEntrySelectorMatchOperatorContains, + "endswith": OwaspCrsExclusionEntrySelectorMatchOperatorEndsWith, + "equals": OwaspCrsExclusionEntrySelectorMatchOperatorEquals, + "equalsany": OwaspCrsExclusionEntrySelectorMatchOperatorEqualsAny, + "startswith": OwaspCrsExclusionEntrySelectorMatchOperatorStartsWith, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OwaspCrsExclusionEntrySelectorMatchOperator(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type PublicIPAddressDnsSettingsDomainNameLabelScope string + +const ( + PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "NoReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "ResourceGroupReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "SubscriptionReuse" + PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse PublicIPAddressDnsSettingsDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForPublicIPAddressDnsSettingsDomainNameLabelScope() []string { + return []string{ + string(PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse), + string(PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse), + } +} + +func (s *PublicIPAddressDnsSettingsDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressDnsSettingsDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressDnsSettingsDomainNameLabelScope(input string) (*PublicIPAddressDnsSettingsDomainNameLabelScope, error) { + vals := map[string]PublicIPAddressDnsSettingsDomainNameLabelScope{ + "noreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeNoReuse, + "resourcegroupreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": PublicIPAddressDnsSettingsDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressDnsSettingsDomainNameLabelScope(input) + return &out, nil +} + +type PublicIPAddressMigrationPhase string + +const ( + PublicIPAddressMigrationPhaseAbort PublicIPAddressMigrationPhase = "Abort" + PublicIPAddressMigrationPhaseCommit PublicIPAddressMigrationPhase = "Commit" + PublicIPAddressMigrationPhaseCommitted PublicIPAddressMigrationPhase = "Committed" + PublicIPAddressMigrationPhaseNone PublicIPAddressMigrationPhase = "None" + PublicIPAddressMigrationPhasePrepare PublicIPAddressMigrationPhase = "Prepare" +) + +func PossibleValuesForPublicIPAddressMigrationPhase() []string { + return []string{ + string(PublicIPAddressMigrationPhaseAbort), + string(PublicIPAddressMigrationPhaseCommit), + string(PublicIPAddressMigrationPhaseCommitted), + string(PublicIPAddressMigrationPhaseNone), + string(PublicIPAddressMigrationPhasePrepare), + } +} + +func (s *PublicIPAddressMigrationPhase) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressMigrationPhase(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressMigrationPhase(input string) (*PublicIPAddressMigrationPhase, error) { + vals := map[string]PublicIPAddressMigrationPhase{ + "abort": PublicIPAddressMigrationPhaseAbort, + "commit": PublicIPAddressMigrationPhaseCommit, + "committed": PublicIPAddressMigrationPhaseCommitted, + "none": PublicIPAddressMigrationPhaseNone, + "prepare": PublicIPAddressMigrationPhasePrepare, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressMigrationPhase(input) + return &out, nil +} + +type PublicIPAddressSkuName string + +const ( + PublicIPAddressSkuNameBasic PublicIPAddressSkuName = "Basic" + PublicIPAddressSkuNameStandard PublicIPAddressSkuName = "Standard" + PublicIPAddressSkuNameStandardVTwo PublicIPAddressSkuName = "StandardV2" +) + +func PossibleValuesForPublicIPAddressSkuName() []string { + return []string{ + string(PublicIPAddressSkuNameBasic), + string(PublicIPAddressSkuNameStandard), + string(PublicIPAddressSkuNameStandardVTwo), + } +} + +func (s *PublicIPAddressSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuName(input string) (*PublicIPAddressSkuName, error) { + vals := map[string]PublicIPAddressSkuName{ + "basic": PublicIPAddressSkuNameBasic, + "standard": PublicIPAddressSkuNameStandard, + "standardv2": PublicIPAddressSkuNameStandardVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuName(input) + return &out, nil +} + +type PublicIPAddressSkuTier string + +const ( + PublicIPAddressSkuTierGlobal PublicIPAddressSkuTier = "Global" + PublicIPAddressSkuTierRegional PublicIPAddressSkuTier = "Regional" +) + +func PossibleValuesForPublicIPAddressSkuTier() []string { + return []string{ + string(PublicIPAddressSkuTierGlobal), + string(PublicIPAddressSkuTierRegional), + } +} + +func (s *PublicIPAddressSkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicIPAddressSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicIPAddressSkuTier(input string) (*PublicIPAddressSkuTier, error) { + vals := map[string]PublicIPAddressSkuTier{ + "global": PublicIPAddressSkuTierGlobal, + "regional": PublicIPAddressSkuTierRegional, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicIPAddressSkuTier(input) + return &out, nil +} + +type RouteNextHopType string + +const ( + RouteNextHopTypeInternet RouteNextHopType = "Internet" + RouteNextHopTypeNone RouteNextHopType = "None" + RouteNextHopTypeVirtualAppliance RouteNextHopType = "VirtualAppliance" + RouteNextHopTypeVirtualNetworkGateway RouteNextHopType = "VirtualNetworkGateway" + RouteNextHopTypeVnetLocal RouteNextHopType = "VnetLocal" +) + +func PossibleValuesForRouteNextHopType() []string { + return []string{ + string(RouteNextHopTypeInternet), + string(RouteNextHopTypeNone), + string(RouteNextHopTypeVirtualAppliance), + string(RouteNextHopTypeVirtualNetworkGateway), + string(RouteNextHopTypeVnetLocal), + } +} + +func (s *RouteNextHopType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteNextHopType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteNextHopType(input string) (*RouteNextHopType, error) { + vals := map[string]RouteNextHopType{ + "internet": RouteNextHopTypeInternet, + "none": RouteNextHopTypeNone, + "virtualappliance": RouteNextHopTypeVirtualAppliance, + "virtualnetworkgateway": RouteNextHopTypeVirtualNetworkGateway, + "vnetlocal": RouteNextHopTypeVnetLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteNextHopType(input) + return &out, nil +} + +type ScrubbingRuleEntryMatchOperator string + +const ( + ScrubbingRuleEntryMatchOperatorEquals ScrubbingRuleEntryMatchOperator = "Equals" + ScrubbingRuleEntryMatchOperatorEqualsAny ScrubbingRuleEntryMatchOperator = "EqualsAny" +) + +func PossibleValuesForScrubbingRuleEntryMatchOperator() []string { + return []string{ + string(ScrubbingRuleEntryMatchOperatorEquals), + string(ScrubbingRuleEntryMatchOperatorEqualsAny), + } +} + +func (s *ScrubbingRuleEntryMatchOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScrubbingRuleEntryMatchOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScrubbingRuleEntryMatchOperator(input string) (*ScrubbingRuleEntryMatchOperator, error) { + vals := map[string]ScrubbingRuleEntryMatchOperator{ + "equals": ScrubbingRuleEntryMatchOperatorEquals, + "equalsany": ScrubbingRuleEntryMatchOperatorEqualsAny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScrubbingRuleEntryMatchOperator(input) + return &out, nil +} + +type ScrubbingRuleEntryMatchVariable string + +const ( + ScrubbingRuleEntryMatchVariableRequestArgNames ScrubbingRuleEntryMatchVariable = "RequestArgNames" + ScrubbingRuleEntryMatchVariableRequestCookieNames ScrubbingRuleEntryMatchVariable = "RequestCookieNames" + ScrubbingRuleEntryMatchVariableRequestHeaderNames ScrubbingRuleEntryMatchVariable = "RequestHeaderNames" + ScrubbingRuleEntryMatchVariableRequestIPAddress ScrubbingRuleEntryMatchVariable = "RequestIPAddress" + ScrubbingRuleEntryMatchVariableRequestJSONArgNames ScrubbingRuleEntryMatchVariable = "RequestJSONArgNames" + ScrubbingRuleEntryMatchVariableRequestPostArgNames ScrubbingRuleEntryMatchVariable = "RequestPostArgNames" +) + +func PossibleValuesForScrubbingRuleEntryMatchVariable() []string { + return []string{ + string(ScrubbingRuleEntryMatchVariableRequestArgNames), + string(ScrubbingRuleEntryMatchVariableRequestCookieNames), + string(ScrubbingRuleEntryMatchVariableRequestHeaderNames), + string(ScrubbingRuleEntryMatchVariableRequestIPAddress), + string(ScrubbingRuleEntryMatchVariableRequestJSONArgNames), + string(ScrubbingRuleEntryMatchVariableRequestPostArgNames), + } +} + +func (s *ScrubbingRuleEntryMatchVariable) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScrubbingRuleEntryMatchVariable(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScrubbingRuleEntryMatchVariable(input string) (*ScrubbingRuleEntryMatchVariable, error) { + vals := map[string]ScrubbingRuleEntryMatchVariable{ + "requestargnames": ScrubbingRuleEntryMatchVariableRequestArgNames, + "requestcookienames": ScrubbingRuleEntryMatchVariableRequestCookieNames, + "requestheadernames": ScrubbingRuleEntryMatchVariableRequestHeaderNames, + "requestipaddress": ScrubbingRuleEntryMatchVariableRequestIPAddress, + "requestjsonargnames": ScrubbingRuleEntryMatchVariableRequestJSONArgNames, + "requestpostargnames": ScrubbingRuleEntryMatchVariableRequestPostArgNames, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScrubbingRuleEntryMatchVariable(input) + return &out, nil +} + +type ScrubbingRuleEntryState string + +const ( + ScrubbingRuleEntryStateDisabled ScrubbingRuleEntryState = "Disabled" + ScrubbingRuleEntryStateEnabled ScrubbingRuleEntryState = "Enabled" +) + +func PossibleValuesForScrubbingRuleEntryState() []string { + return []string{ + string(ScrubbingRuleEntryStateDisabled), + string(ScrubbingRuleEntryStateEnabled), + } +} + +func (s *ScrubbingRuleEntryState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScrubbingRuleEntryState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScrubbingRuleEntryState(input string) (*ScrubbingRuleEntryState, error) { + vals := map[string]ScrubbingRuleEntryState{ + "disabled": ScrubbingRuleEntryStateDisabled, + "enabled": ScrubbingRuleEntryStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScrubbingRuleEntryState(input) + return &out, nil +} + +type SecurityRuleAccess string + +const ( + SecurityRuleAccessAllow SecurityRuleAccess = "Allow" + SecurityRuleAccessDeny SecurityRuleAccess = "Deny" +) + +func PossibleValuesForSecurityRuleAccess() []string { + return []string{ + string(SecurityRuleAccessAllow), + string(SecurityRuleAccessDeny), + } +} + +func (s *SecurityRuleAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleAccess(input string) (*SecurityRuleAccess, error) { + vals := map[string]SecurityRuleAccess{ + "allow": SecurityRuleAccessAllow, + "deny": SecurityRuleAccessDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleAccess(input) + return &out, nil +} + +type SecurityRuleDirection string + +const ( + SecurityRuleDirectionInbound SecurityRuleDirection = "Inbound" + SecurityRuleDirectionOutbound SecurityRuleDirection = "Outbound" +) + +func PossibleValuesForSecurityRuleDirection() []string { + return []string{ + string(SecurityRuleDirectionInbound), + string(SecurityRuleDirectionOutbound), + } +} + +func (s *SecurityRuleDirection) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleDirection(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleDirection(input string) (*SecurityRuleDirection, error) { + vals := map[string]SecurityRuleDirection{ + "inbound": SecurityRuleDirectionInbound, + "outbound": SecurityRuleDirectionOutbound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleDirection(input) + return &out, nil +} + +type SecurityRuleProtocol string + +const ( + SecurityRuleProtocolAh SecurityRuleProtocol = "Ah" + SecurityRuleProtocolAny SecurityRuleProtocol = "*" + SecurityRuleProtocolEsp SecurityRuleProtocol = "Esp" + SecurityRuleProtocolIcmp SecurityRuleProtocol = "Icmp" + SecurityRuleProtocolTcp SecurityRuleProtocol = "Tcp" + SecurityRuleProtocolUdp SecurityRuleProtocol = "Udp" +) + +func PossibleValuesForSecurityRuleProtocol() []string { + return []string{ + string(SecurityRuleProtocolAh), + string(SecurityRuleProtocolAny), + string(SecurityRuleProtocolEsp), + string(SecurityRuleProtocolIcmp), + string(SecurityRuleProtocolTcp), + string(SecurityRuleProtocolUdp), + } +} + +func (s *SecurityRuleProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecurityRuleProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecurityRuleProtocol(input string) (*SecurityRuleProtocol, error) { + vals := map[string]SecurityRuleProtocol{ + "ah": SecurityRuleProtocolAh, + "*": SecurityRuleProtocolAny, + "esp": SecurityRuleProtocolEsp, + "icmp": SecurityRuleProtocolIcmp, + "tcp": SecurityRuleProtocolTcp, + "udp": SecurityRuleProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecurityRuleProtocol(input) + return &out, nil +} + +type SensitivityType string + +const ( + SensitivityTypeHigh SensitivityType = "High" + SensitivityTypeLow SensitivityType = "Low" + SensitivityTypeMedium SensitivityType = "Medium" + SensitivityTypeNone SensitivityType = "None" +) + +func PossibleValuesForSensitivityType() []string { + return []string{ + string(SensitivityTypeHigh), + string(SensitivityTypeLow), + string(SensitivityTypeMedium), + string(SensitivityTypeNone), + } +} + +func (s *SensitivityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSensitivityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSensitivityType(input string) (*SensitivityType, error) { + vals := map[string]SensitivityType{ + "high": SensitivityTypeHigh, + "low": SensitivityTypeLow, + "medium": SensitivityTypeMedium, + "none": SensitivityTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SensitivityType(input) + return &out, nil +} + +type SharingScope string + +const ( + SharingScopeDelegatedServices SharingScope = "DelegatedServices" + SharingScopeTenant SharingScope = "Tenant" +) + +func PossibleValuesForSharingScope() []string { + return []string{ + string(SharingScopeDelegatedServices), + string(SharingScopeTenant), + } +} + +func (s *SharingScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSharingScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSharingScope(input string) (*SharingScope, error) { + vals := map[string]SharingScope{ + "delegatedservices": SharingScopeDelegatedServices, + "tenant": SharingScopeTenant, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SharingScope(input) + return &out, nil +} + +type SyncMode string + +const ( + SyncModeAutomatic SyncMode = "Automatic" + SyncModeManual SyncMode = "Manual" +) + +func PossibleValuesForSyncMode() []string { + return []string{ + string(SyncModeAutomatic), + string(SyncModeManual), + } +} + +func (s *SyncMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSyncMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSyncMode(input string) (*SyncMode, error) { + vals := map[string]SyncMode{ + "automatic": SyncModeAutomatic, + "manual": SyncModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SyncMode(input) + return &out, nil +} + +type TransportProtocol string + +const ( + TransportProtocolAll TransportProtocol = "All" + TransportProtocolTcp TransportProtocol = "Tcp" + TransportProtocolUdp TransportProtocol = "Udp" +) + +func PossibleValuesForTransportProtocol() []string { + return []string{ + string(TransportProtocolAll), + string(TransportProtocolTcp), + string(TransportProtocolUdp), + } +} + +func (s *TransportProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTransportProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTransportProtocol(input string) (*TransportProtocol, error) { + vals := map[string]TransportProtocol{ + "all": TransportProtocolAll, + "tcp": TransportProtocolTcp, + "udp": TransportProtocolUdp, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TransportProtocol(input) + return &out, nil +} + +type VirtualNetworkPrivateEndpointNetworkPolicies string + +const ( + VirtualNetworkPrivateEndpointNetworkPoliciesDisabled VirtualNetworkPrivateEndpointNetworkPolicies = "Disabled" + VirtualNetworkPrivateEndpointNetworkPoliciesEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "Enabled" + VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "NetworkSecurityGroupEnabled" + VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled VirtualNetworkPrivateEndpointNetworkPolicies = "RouteTableEnabled" +) + +func PossibleValuesForVirtualNetworkPrivateEndpointNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateEndpointNetworkPoliciesDisabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled), + string(VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled), + } +} + +func (s *VirtualNetworkPrivateEndpointNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateEndpointNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateEndpointNetworkPolicies(input string) (*VirtualNetworkPrivateEndpointNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateEndpointNetworkPolicies{ + "disabled": VirtualNetworkPrivateEndpointNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateEndpointNetworkPoliciesEnabled, + "networksecuritygroupenabled": VirtualNetworkPrivateEndpointNetworkPoliciesNetworkSecurityGroupEnabled, + "routetableenabled": VirtualNetworkPrivateEndpointNetworkPoliciesRouteTableEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateEndpointNetworkPolicies(input) + return &out, nil +} + +type VirtualNetworkPrivateLinkServiceNetworkPolicies string + +const ( + VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Disabled" + VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled VirtualNetworkPrivateLinkServiceNetworkPolicies = "Enabled" +) + +func PossibleValuesForVirtualNetworkPrivateLinkServiceNetworkPolicies() []string { + return []string{ + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled), + string(VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled), + } +} + +func (s *VirtualNetworkPrivateLinkServiceNetworkPolicies) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVirtualNetworkPrivateLinkServiceNetworkPolicies(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVirtualNetworkPrivateLinkServiceNetworkPolicies(input string) (*VirtualNetworkPrivateLinkServiceNetworkPolicies, error) { + vals := map[string]VirtualNetworkPrivateLinkServiceNetworkPolicies{ + "disabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesDisabled, + "enabled": VirtualNetworkPrivateLinkServiceNetworkPoliciesEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VirtualNetworkPrivateLinkServiceNetworkPolicies(input) + return &out, nil +} + +type WebApplicationFirewallAction string + +const ( + WebApplicationFirewallActionAllow WebApplicationFirewallAction = "Allow" + WebApplicationFirewallActionBlock WebApplicationFirewallAction = "Block" + WebApplicationFirewallActionJSChallenge WebApplicationFirewallAction = "JSChallenge" + WebApplicationFirewallActionLog WebApplicationFirewallAction = "Log" +) + +func PossibleValuesForWebApplicationFirewallAction() []string { + return []string{ + string(WebApplicationFirewallActionAllow), + string(WebApplicationFirewallActionBlock), + string(WebApplicationFirewallActionJSChallenge), + string(WebApplicationFirewallActionLog), + } +} + +func (s *WebApplicationFirewallAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebApplicationFirewallAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebApplicationFirewallAction(input string) (*WebApplicationFirewallAction, error) { + vals := map[string]WebApplicationFirewallAction{ + "allow": WebApplicationFirewallActionAllow, + "block": WebApplicationFirewallActionBlock, + "jschallenge": WebApplicationFirewallActionJSChallenge, + "log": WebApplicationFirewallActionLog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebApplicationFirewallAction(input) + return &out, nil +} + +type WebApplicationFirewallEnabledState string + +const ( + WebApplicationFirewallEnabledStateDisabled WebApplicationFirewallEnabledState = "Disabled" + WebApplicationFirewallEnabledStateEnabled WebApplicationFirewallEnabledState = "Enabled" +) + +func PossibleValuesForWebApplicationFirewallEnabledState() []string { + return []string{ + string(WebApplicationFirewallEnabledStateDisabled), + string(WebApplicationFirewallEnabledStateEnabled), + } +} + +func (s *WebApplicationFirewallEnabledState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebApplicationFirewallEnabledState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebApplicationFirewallEnabledState(input string) (*WebApplicationFirewallEnabledState, error) { + vals := map[string]WebApplicationFirewallEnabledState{ + "disabled": WebApplicationFirewallEnabledStateDisabled, + "enabled": WebApplicationFirewallEnabledStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebApplicationFirewallEnabledState(input) + return &out, nil +} + +type WebApplicationFirewallMatchVariable string + +const ( + WebApplicationFirewallMatchVariablePostArgs WebApplicationFirewallMatchVariable = "PostArgs" + WebApplicationFirewallMatchVariableQueryString WebApplicationFirewallMatchVariable = "QueryString" + WebApplicationFirewallMatchVariableRemoteAddr WebApplicationFirewallMatchVariable = "RemoteAddr" + WebApplicationFirewallMatchVariableRequestBody WebApplicationFirewallMatchVariable = "RequestBody" + WebApplicationFirewallMatchVariableRequestCookies WebApplicationFirewallMatchVariable = "RequestCookies" + WebApplicationFirewallMatchVariableRequestHeaders WebApplicationFirewallMatchVariable = "RequestHeaders" + WebApplicationFirewallMatchVariableRequestMethod WebApplicationFirewallMatchVariable = "RequestMethod" + WebApplicationFirewallMatchVariableRequestUri WebApplicationFirewallMatchVariable = "RequestUri" +) + +func PossibleValuesForWebApplicationFirewallMatchVariable() []string { + return []string{ + string(WebApplicationFirewallMatchVariablePostArgs), + string(WebApplicationFirewallMatchVariableQueryString), + string(WebApplicationFirewallMatchVariableRemoteAddr), + string(WebApplicationFirewallMatchVariableRequestBody), + string(WebApplicationFirewallMatchVariableRequestCookies), + string(WebApplicationFirewallMatchVariableRequestHeaders), + string(WebApplicationFirewallMatchVariableRequestMethod), + string(WebApplicationFirewallMatchVariableRequestUri), + } +} + +func (s *WebApplicationFirewallMatchVariable) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebApplicationFirewallMatchVariable(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebApplicationFirewallMatchVariable(input string) (*WebApplicationFirewallMatchVariable, error) { + vals := map[string]WebApplicationFirewallMatchVariable{ + "postargs": WebApplicationFirewallMatchVariablePostArgs, + "querystring": WebApplicationFirewallMatchVariableQueryString, + "remoteaddr": WebApplicationFirewallMatchVariableRemoteAddr, + "requestbody": WebApplicationFirewallMatchVariableRequestBody, + "requestcookies": WebApplicationFirewallMatchVariableRequestCookies, + "requestheaders": WebApplicationFirewallMatchVariableRequestHeaders, + "requestmethod": WebApplicationFirewallMatchVariableRequestMethod, + "requesturi": WebApplicationFirewallMatchVariableRequestUri, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebApplicationFirewallMatchVariable(input) + return &out, nil +} + +type WebApplicationFirewallMode string + +const ( + WebApplicationFirewallModeDetection WebApplicationFirewallMode = "Detection" + WebApplicationFirewallModePrevention WebApplicationFirewallMode = "Prevention" +) + +func PossibleValuesForWebApplicationFirewallMode() []string { + return []string{ + string(WebApplicationFirewallModeDetection), + string(WebApplicationFirewallModePrevention), + } +} + +func (s *WebApplicationFirewallMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebApplicationFirewallMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebApplicationFirewallMode(input string) (*WebApplicationFirewallMode, error) { + vals := map[string]WebApplicationFirewallMode{ + "detection": WebApplicationFirewallModeDetection, + "prevention": WebApplicationFirewallModePrevention, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebApplicationFirewallMode(input) + return &out, nil +} + +type WebApplicationFirewallOperator string + +const ( + WebApplicationFirewallOperatorAny WebApplicationFirewallOperator = "Any" + WebApplicationFirewallOperatorBeginsWith WebApplicationFirewallOperator = "BeginsWith" + WebApplicationFirewallOperatorContains WebApplicationFirewallOperator = "Contains" + WebApplicationFirewallOperatorEndsWith WebApplicationFirewallOperator = "EndsWith" + WebApplicationFirewallOperatorEqual WebApplicationFirewallOperator = "Equal" + WebApplicationFirewallOperatorGeoMatch WebApplicationFirewallOperator = "GeoMatch" + WebApplicationFirewallOperatorGreaterThan WebApplicationFirewallOperator = "GreaterThan" + WebApplicationFirewallOperatorGreaterThanOrEqual WebApplicationFirewallOperator = "GreaterThanOrEqual" + WebApplicationFirewallOperatorIPMatch WebApplicationFirewallOperator = "IPMatch" + WebApplicationFirewallOperatorLessThan WebApplicationFirewallOperator = "LessThan" + WebApplicationFirewallOperatorLessThanOrEqual WebApplicationFirewallOperator = "LessThanOrEqual" + WebApplicationFirewallOperatorRegex WebApplicationFirewallOperator = "Regex" +) + +func PossibleValuesForWebApplicationFirewallOperator() []string { + return []string{ + string(WebApplicationFirewallOperatorAny), + string(WebApplicationFirewallOperatorBeginsWith), + string(WebApplicationFirewallOperatorContains), + string(WebApplicationFirewallOperatorEndsWith), + string(WebApplicationFirewallOperatorEqual), + string(WebApplicationFirewallOperatorGeoMatch), + string(WebApplicationFirewallOperatorGreaterThan), + string(WebApplicationFirewallOperatorGreaterThanOrEqual), + string(WebApplicationFirewallOperatorIPMatch), + string(WebApplicationFirewallOperatorLessThan), + string(WebApplicationFirewallOperatorLessThanOrEqual), + string(WebApplicationFirewallOperatorRegex), + } +} + +func (s *WebApplicationFirewallOperator) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebApplicationFirewallOperator(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebApplicationFirewallOperator(input string) (*WebApplicationFirewallOperator, error) { + vals := map[string]WebApplicationFirewallOperator{ + "any": WebApplicationFirewallOperatorAny, + "beginswith": WebApplicationFirewallOperatorBeginsWith, + "contains": WebApplicationFirewallOperatorContains, + "endswith": WebApplicationFirewallOperatorEndsWith, + "equal": WebApplicationFirewallOperatorEqual, + "geomatch": WebApplicationFirewallOperatorGeoMatch, + "greaterthan": WebApplicationFirewallOperatorGreaterThan, + "greaterthanorequal": WebApplicationFirewallOperatorGreaterThanOrEqual, + "ipmatch": WebApplicationFirewallOperatorIPMatch, + "lessthan": WebApplicationFirewallOperatorLessThan, + "lessthanorequal": WebApplicationFirewallOperatorLessThanOrEqual, + "regex": WebApplicationFirewallOperatorRegex, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebApplicationFirewallOperator(input) + return &out, nil +} + +type WebApplicationFirewallPolicyResourceState string + +const ( + WebApplicationFirewallPolicyResourceStateCreating WebApplicationFirewallPolicyResourceState = "Creating" + WebApplicationFirewallPolicyResourceStateDeleting WebApplicationFirewallPolicyResourceState = "Deleting" + WebApplicationFirewallPolicyResourceStateDisabled WebApplicationFirewallPolicyResourceState = "Disabled" + WebApplicationFirewallPolicyResourceStateDisabling WebApplicationFirewallPolicyResourceState = "Disabling" + WebApplicationFirewallPolicyResourceStateEnabled WebApplicationFirewallPolicyResourceState = "Enabled" + WebApplicationFirewallPolicyResourceStateEnabling WebApplicationFirewallPolicyResourceState = "Enabling" +) + +func PossibleValuesForWebApplicationFirewallPolicyResourceState() []string { + return []string{ + string(WebApplicationFirewallPolicyResourceStateCreating), + string(WebApplicationFirewallPolicyResourceStateDeleting), + string(WebApplicationFirewallPolicyResourceStateDisabled), + string(WebApplicationFirewallPolicyResourceStateDisabling), + string(WebApplicationFirewallPolicyResourceStateEnabled), + string(WebApplicationFirewallPolicyResourceStateEnabling), + } +} + +func (s *WebApplicationFirewallPolicyResourceState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebApplicationFirewallPolicyResourceState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebApplicationFirewallPolicyResourceState(input string) (*WebApplicationFirewallPolicyResourceState, error) { + vals := map[string]WebApplicationFirewallPolicyResourceState{ + "creating": WebApplicationFirewallPolicyResourceStateCreating, + "deleting": WebApplicationFirewallPolicyResourceStateDeleting, + "disabled": WebApplicationFirewallPolicyResourceStateDisabled, + "disabling": WebApplicationFirewallPolicyResourceStateDisabling, + "enabled": WebApplicationFirewallPolicyResourceStateEnabled, + "enabling": WebApplicationFirewallPolicyResourceStateEnabling, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebApplicationFirewallPolicyResourceState(input) + return &out, nil +} + +type WebApplicationFirewallRuleType string + +const ( + WebApplicationFirewallRuleTypeInvalid WebApplicationFirewallRuleType = "Invalid" + WebApplicationFirewallRuleTypeMatchRule WebApplicationFirewallRuleType = "MatchRule" + WebApplicationFirewallRuleTypeRateLimitRule WebApplicationFirewallRuleType = "RateLimitRule" +) + +func PossibleValuesForWebApplicationFirewallRuleType() []string { + return []string{ + string(WebApplicationFirewallRuleTypeInvalid), + string(WebApplicationFirewallRuleTypeMatchRule), + string(WebApplicationFirewallRuleTypeRateLimitRule), + } +} + +func (s *WebApplicationFirewallRuleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebApplicationFirewallRuleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebApplicationFirewallRuleType(input string) (*WebApplicationFirewallRuleType, error) { + vals := map[string]WebApplicationFirewallRuleType{ + "invalid": WebApplicationFirewallRuleTypeInvalid, + "matchrule": WebApplicationFirewallRuleTypeMatchRule, + "ratelimitrule": WebApplicationFirewallRuleTypeRateLimitRule, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebApplicationFirewallRuleType(input) + return &out, nil +} + +type WebApplicationFirewallScrubbingState string + +const ( + WebApplicationFirewallScrubbingStateDisabled WebApplicationFirewallScrubbingState = "Disabled" + WebApplicationFirewallScrubbingStateEnabled WebApplicationFirewallScrubbingState = "Enabled" +) + +func PossibleValuesForWebApplicationFirewallScrubbingState() []string { + return []string{ + string(WebApplicationFirewallScrubbingStateDisabled), + string(WebApplicationFirewallScrubbingStateEnabled), + } +} + +func (s *WebApplicationFirewallScrubbingState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebApplicationFirewallScrubbingState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebApplicationFirewallScrubbingState(input string) (*WebApplicationFirewallScrubbingState, error) { + vals := map[string]WebApplicationFirewallScrubbingState{ + "disabled": WebApplicationFirewallScrubbingStateDisabled, + "enabled": WebApplicationFirewallScrubbingStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebApplicationFirewallScrubbingState(input) + return &out, nil +} + +type WebApplicationFirewallState string + +const ( + WebApplicationFirewallStateDisabled WebApplicationFirewallState = "Disabled" + WebApplicationFirewallStateEnabled WebApplicationFirewallState = "Enabled" +) + +func PossibleValuesForWebApplicationFirewallState() []string { + return []string{ + string(WebApplicationFirewallStateDisabled), + string(WebApplicationFirewallStateEnabled), + } +} + +func (s *WebApplicationFirewallState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebApplicationFirewallState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebApplicationFirewallState(input string) (*WebApplicationFirewallState, error) { + vals := map[string]WebApplicationFirewallState{ + "disabled": WebApplicationFirewallStateDisabled, + "enabled": WebApplicationFirewallStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebApplicationFirewallState(input) + return &out, nil +} + +type WebApplicationFirewallTransform string + +const ( + WebApplicationFirewallTransformHtmlEntityDecode WebApplicationFirewallTransform = "HtmlEntityDecode" + WebApplicationFirewallTransformLowercase WebApplicationFirewallTransform = "Lowercase" + WebApplicationFirewallTransformRemoveNulls WebApplicationFirewallTransform = "RemoveNulls" + WebApplicationFirewallTransformTrim WebApplicationFirewallTransform = "Trim" + WebApplicationFirewallTransformURLDecode WebApplicationFirewallTransform = "UrlDecode" + WebApplicationFirewallTransformURLEncode WebApplicationFirewallTransform = "UrlEncode" + WebApplicationFirewallTransformUppercase WebApplicationFirewallTransform = "Uppercase" +) + +func PossibleValuesForWebApplicationFirewallTransform() []string { + return []string{ + string(WebApplicationFirewallTransformHtmlEntityDecode), + string(WebApplicationFirewallTransformLowercase), + string(WebApplicationFirewallTransformRemoveNulls), + string(WebApplicationFirewallTransformTrim), + string(WebApplicationFirewallTransformURLDecode), + string(WebApplicationFirewallTransformURLEncode), + string(WebApplicationFirewallTransformUppercase), + } +} + +func (s *WebApplicationFirewallTransform) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebApplicationFirewallTransform(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebApplicationFirewallTransform(input string) (*WebApplicationFirewallTransform, error) { + vals := map[string]WebApplicationFirewallTransform{ + "htmlentitydecode": WebApplicationFirewallTransformHtmlEntityDecode, + "lowercase": WebApplicationFirewallTransformLowercase, + "removenulls": WebApplicationFirewallTransformRemoveNulls, + "trim": WebApplicationFirewallTransformTrim, + "urldecode": WebApplicationFirewallTransformURLDecode, + "urlencode": WebApplicationFirewallTransformURLEncode, + "uppercase": WebApplicationFirewallTransformUppercase, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebApplicationFirewallTransform(input) + return &out, nil +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/id_applicationgatewaywebapplicationfirewallpolicy.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/id_applicationgatewaywebapplicationfirewallpolicy.go new file mode 100644 index 00000000000..3004461fd8a --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/id_applicationgatewaywebapplicationfirewallpolicy.go @@ -0,0 +1,130 @@ +package webapplicationfirewallpolicies + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ApplicationGatewayWebApplicationFirewallPolicyId{}) +} + +var _ resourceids.ResourceId = &ApplicationGatewayWebApplicationFirewallPolicyId{} + +// ApplicationGatewayWebApplicationFirewallPolicyId is a struct representing the Resource ID for a Application Gateway Web Application Firewall Policy +type ApplicationGatewayWebApplicationFirewallPolicyId struct { + SubscriptionId string + ResourceGroupName string + ApplicationGatewayWebApplicationFirewallPolicyName string +} + +// NewApplicationGatewayWebApplicationFirewallPolicyID returns a new ApplicationGatewayWebApplicationFirewallPolicyId struct +func NewApplicationGatewayWebApplicationFirewallPolicyID(subscriptionId string, resourceGroupName string, applicationGatewayWebApplicationFirewallPolicyName string) ApplicationGatewayWebApplicationFirewallPolicyId { + return ApplicationGatewayWebApplicationFirewallPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ApplicationGatewayWebApplicationFirewallPolicyName: applicationGatewayWebApplicationFirewallPolicyName, + } +} + +// ParseApplicationGatewayWebApplicationFirewallPolicyID parses 'input' into a ApplicationGatewayWebApplicationFirewallPolicyId +func ParseApplicationGatewayWebApplicationFirewallPolicyID(input string) (*ApplicationGatewayWebApplicationFirewallPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGatewayWebApplicationFirewallPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGatewayWebApplicationFirewallPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseApplicationGatewayWebApplicationFirewallPolicyIDInsensitively parses 'input' case-insensitively into a ApplicationGatewayWebApplicationFirewallPolicyId +// note: this method should only be used for API response data and not user input +func ParseApplicationGatewayWebApplicationFirewallPolicyIDInsensitively(input string) (*ApplicationGatewayWebApplicationFirewallPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&ApplicationGatewayWebApplicationFirewallPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ApplicationGatewayWebApplicationFirewallPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ApplicationGatewayWebApplicationFirewallPolicyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ApplicationGatewayWebApplicationFirewallPolicyName, ok = input.Parsed["applicationGatewayWebApplicationFirewallPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "applicationGatewayWebApplicationFirewallPolicyName", input) + } + + return nil +} + +// ValidateApplicationGatewayWebApplicationFirewallPolicyID checks that 'input' can be parsed as a Application Gateway Web Application Firewall Policy ID +func ValidateApplicationGatewayWebApplicationFirewallPolicyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseApplicationGatewayWebApplicationFirewallPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Application Gateway Web Application Firewall Policy ID +func (id ApplicationGatewayWebApplicationFirewallPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ApplicationGatewayWebApplicationFirewallPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Application Gateway Web Application Firewall Policy ID +func (id ApplicationGatewayWebApplicationFirewallPolicyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticApplicationGatewayWebApplicationFirewallPolicies", "applicationGatewayWebApplicationFirewallPolicies", "applicationGatewayWebApplicationFirewallPolicies"), + resourceids.UserSpecifiedSegment("applicationGatewayWebApplicationFirewallPolicyName", "applicationGatewayWebApplicationFirewallPolicyName"), + } +} + +// String returns a human-readable description of this Application Gateway Web Application Firewall Policy ID +func (id ApplicationGatewayWebApplicationFirewallPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Application Gateway Web Application Firewall Policy Name: %q", id.ApplicationGatewayWebApplicationFirewallPolicyName), + } + return fmt.Sprintf("Application Gateway Web Application Firewall Policy (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/id_applicationgatewaywebapplicationfirewallpolicy_test.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/id_applicationgatewaywebapplicationfirewallpolicy_test.go new file mode 100644 index 00000000000..205d73da565 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/id_applicationgatewaywebapplicationfirewallpolicy_test.go @@ -0,0 +1,282 @@ +package webapplicationfirewallpolicies + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ApplicationGatewayWebApplicationFirewallPolicyId{} + +func TestNewApplicationGatewayWebApplicationFirewallPolicyID(t *testing.T) { + id := NewApplicationGatewayWebApplicationFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayWebApplicationFirewallPolicyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ApplicationGatewayWebApplicationFirewallPolicyName != "applicationGatewayWebApplicationFirewallPolicyName" { + t.Fatalf("Expected %q but got %q for Segment 'ApplicationGatewayWebApplicationFirewallPolicyName'", id.ApplicationGatewayWebApplicationFirewallPolicyName, "applicationGatewayWebApplicationFirewallPolicyName") + } +} + +func TestFormatApplicationGatewayWebApplicationFirewallPolicyID(t *testing.T) { + actual := NewApplicationGatewayWebApplicationFirewallPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "applicationGatewayWebApplicationFirewallPolicyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/applicationGatewayWebApplicationFirewallPolicyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseApplicationGatewayWebApplicationFirewallPolicyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGatewayWebApplicationFirewallPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/applicationGatewayWebApplicationFirewallPolicyName", + Expected: &ApplicationGatewayWebApplicationFirewallPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGatewayWebApplicationFirewallPolicyName: "applicationGatewayWebApplicationFirewallPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/applicationGatewayWebApplicationFirewallPolicyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGatewayWebApplicationFirewallPolicyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGatewayWebApplicationFirewallPolicyName != v.Expected.ApplicationGatewayWebApplicationFirewallPolicyName { + t.Fatalf("Expected %q but got %q for ApplicationGatewayWebApplicationFirewallPolicyName", v.Expected.ApplicationGatewayWebApplicationFirewallPolicyName, actual.ApplicationGatewayWebApplicationFirewallPolicyName) + } + + } +} + +func TestParseApplicationGatewayWebApplicationFirewallPolicyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ApplicationGatewayWebApplicationFirewallPolicyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYwEbApPlIcAtIoNfIrEwAlLpOlIcIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/applicationGatewayWebApplicationFirewallPolicyName", + Expected: &ApplicationGatewayWebApplicationFirewallPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ApplicationGatewayWebApplicationFirewallPolicyName: "applicationGatewayWebApplicationFirewallPolicyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/applicationGatewayWebApplicationFirewallPolicyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYwEbApPlIcAtIoNfIrEwAlLpOlIcIeS/aPpLiCaTiOnGaTeWaYwEbApPlIcAtIoNfIrEwAlLpOlIcYnAmE", + Expected: &ApplicationGatewayWebApplicationFirewallPolicyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ApplicationGatewayWebApplicationFirewallPolicyName: "aPpLiCaTiOnGaTeWaYwEbApPlIcAtIoNfIrEwAlLpOlIcYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRk/aPpLiCaTiOnGaTeWaYwEbApPlIcAtIoNfIrEwAlLpOlIcIeS/aPpLiCaTiOnGaTeWaYwEbApPlIcAtIoNfIrEwAlLpOlIcYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseApplicationGatewayWebApplicationFirewallPolicyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ApplicationGatewayWebApplicationFirewallPolicyName != v.Expected.ApplicationGatewayWebApplicationFirewallPolicyName { + t.Fatalf("Expected %q but got %q for ApplicationGatewayWebApplicationFirewallPolicyName", v.Expected.ApplicationGatewayWebApplicationFirewallPolicyName, actual.ApplicationGatewayWebApplicationFirewallPolicyName) + } + + } +} + +func TestSegmentsForApplicationGatewayWebApplicationFirewallPolicyId(t *testing.T) { + segments := ApplicationGatewayWebApplicationFirewallPolicyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ApplicationGatewayWebApplicationFirewallPolicyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/method_createorupdate.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/method_createorupdate.go new file mode 100644 index 00000000000..556b406a3c2 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/method_createorupdate.go @@ -0,0 +1,58 @@ +package webapplicationfirewallpolicies + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebApplicationFirewallPolicy +} + +// CreateOrUpdate ... +func (c WebApplicationFirewallPoliciesClient) CreateOrUpdate(ctx context.Context, id ApplicationGatewayWebApplicationFirewallPolicyId, input WebApplicationFirewallPolicy) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WebApplicationFirewallPolicy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/method_delete.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/method_delete.go new file mode 100644 index 00000000000..c4547e95952 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/method_delete.go @@ -0,0 +1,71 @@ +package webapplicationfirewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c WebApplicationFirewallPoliciesClient) Delete(ctx context.Context, id ApplicationGatewayWebApplicationFirewallPolicyId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c WebApplicationFirewallPoliciesClient) DeleteThenPoll(ctx context.Context, id ApplicationGatewayWebApplicationFirewallPolicyId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/method_get.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/method_get.go new file mode 100644 index 00000000000..b34138178e0 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/method_get.go @@ -0,0 +1,53 @@ +package webapplicationfirewallpolicies + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebApplicationFirewallPolicy +} + +// Get ... +func (c WebApplicationFirewallPoliciesClient) Get(ctx context.Context, id ApplicationGatewayWebApplicationFirewallPolicyId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WebApplicationFirewallPolicy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/method_list.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/method_list.go new file mode 100644 index 00000000000..4a6b3abf31e --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/method_list.go @@ -0,0 +1,106 @@ +package webapplicationfirewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebApplicationFirewallPolicy +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebApplicationFirewallPolicy +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c WebApplicationFirewallPoliciesClient) List(ctx context.Context, id commonids.ResourceGroupId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WebApplicationFirewallPolicy `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c WebApplicationFirewallPoliciesClient) ListComplete(ctx context.Context, id commonids.ResourceGroupId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, WebApplicationFirewallPolicyOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebApplicationFirewallPoliciesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate WebApplicationFirewallPolicyOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WebApplicationFirewallPolicy, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/method_listall.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/method_listall.go new file mode 100644 index 00000000000..e3a633a2655 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/method_listall.go @@ -0,0 +1,106 @@ +package webapplicationfirewallpolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAllOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebApplicationFirewallPolicy +} + +type ListAllCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebApplicationFirewallPolicy +} + +type ListAllCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAllCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAll ... +func (c WebApplicationFirewallPoliciesClient) ListAll(ctx context.Context, id commonids.SubscriptionId) (result ListAllOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAllCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WebApplicationFirewallPolicy `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAllComplete retrieves all the results into a single object +func (c WebApplicationFirewallPoliciesClient) ListAllComplete(ctx context.Context, id commonids.SubscriptionId) (ListAllCompleteResult, error) { + return c.ListAllCompleteMatchingPredicate(ctx, id, WebApplicationFirewallPolicyOperationPredicate{}) +} + +// ListAllCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebApplicationFirewallPoliciesClient) ListAllCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate WebApplicationFirewallPolicyOperationPredicate) (result ListAllCompleteResult, err error) { + items := make([]WebApplicationFirewallPolicy, 0) + + resp, err := c.ListAll(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAllCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgateway.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgateway.go new file mode 100644 index 00000000000..69aa82140ea --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgateway.go @@ -0,0 +1,21 @@ +package webapplicationfirewallpolicies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayauthenticationcertificate.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayauthenticationcertificate.go new file mode 100644 index 00000000000..74175523bc1 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayauthenticationcertificate.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayAuthenticationCertificate struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayAuthenticationCertificatePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayauthenticationcertificatepropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayauthenticationcertificatepropertiesformat.go new file mode 100644 index 00000000000..7536ffa2439 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayauthenticationcertificatepropertiesformat.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayAuthenticationCertificatePropertiesFormat struct { + Data *string `json:"data,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayautoscaleconfiguration.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayautoscaleconfiguration.go new file mode 100644 index 00000000000..06e7df4e24e --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayautoscaleconfiguration.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayAutoscaleConfiguration struct { + MaxCapacity *int64 `json:"maxCapacity,omitempty"` + MinCapacity int64 `json:"minCapacity"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendaddress.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendaddress.go new file mode 100644 index 00000000000..dcc624a13aa --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendaddress.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddress struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendaddresspool.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendaddresspool.go new file mode 100644 index 00000000000..0f188b359ad --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendaddresspool.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..64a4ed2e836 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendaddresspoolpropertiesformat.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendAddressPoolPropertiesFormat struct { + BackendAddresses *[]ApplicationGatewayBackendAddress `json:"backendAddresses,omitempty"` + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendhttpsettings.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendhttpsettings.go new file mode 100644 index 00000000000..052f312d7b3 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendhttpsettings.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendHTTPSettings struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendHTTPSettingsPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendhttpsettingspropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendhttpsettingspropertiesformat.go new file mode 100644 index 00000000000..16305b5de81 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendhttpsettingspropertiesformat.go @@ -0,0 +1,21 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendHTTPSettingsPropertiesFormat struct { + AffinityCookieName *string `json:"affinityCookieName,omitempty"` + AuthenticationCertificates *[]SubResource `json:"authenticationCertificates,omitempty"` + ConnectionDraining *ApplicationGatewayConnectionDraining `json:"connectionDraining,omitempty"` + CookieBasedAffinity *ApplicationGatewayCookieBasedAffinity `json:"cookieBasedAffinity,omitempty"` + HostName *string `json:"hostName,omitempty"` + Path *string `json:"path,omitempty"` + PickHostNameFromBackendAddress *bool `json:"pickHostNameFromBackendAddress,omitempty"` + Port *int64 `json:"port,omitempty"` + Probe *SubResource `json:"probe,omitempty"` + ProbeEnabled *bool `json:"probeEnabled,omitempty"` + Protocol *ApplicationGatewayProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestTimeout *int64 `json:"requestTimeout,omitempty"` + TrustedRootCertificates *[]SubResource `json:"trustedRootCertificates,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendsettings.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendsettings.go new file mode 100644 index 00000000000..1bc8a5c5fe1 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendsettings.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendSettings struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayBackendSettingsPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendsettingspropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendsettingspropertiesformat.go new file mode 100644 index 00000000000..5d5f77f3c8d --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaybackendsettingspropertiesformat.go @@ -0,0 +1,15 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayBackendSettingsPropertiesFormat struct { + HostName *string `json:"hostName,omitempty"` + PickHostNameFromBackendAddress *bool `json:"pickHostNameFromBackendAddress,omitempty"` + Port *int64 `json:"port,omitempty"` + Probe *SubResource `json:"probe,omitempty"` + Protocol *ApplicationGatewayProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Timeout *int64 `json:"timeout,omitempty"` + TrustedRootCertificates *[]SubResource `json:"trustedRootCertificates,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayclientauthconfiguration.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayclientauthconfiguration.go new file mode 100644 index 00000000000..36e0f43021d --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayclientauthconfiguration.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayClientAuthConfiguration struct { + VerifyClientCertIssuerDN *bool `json:"verifyClientCertIssuerDN,omitempty"` + VerifyClientRevocation *ApplicationGatewayClientRevocationOptions `json:"verifyClientRevocation,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayconnectiondraining.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayconnectiondraining.go new file mode 100644 index 00000000000..369c8494e6f --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayconnectiondraining.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayConnectionDraining struct { + DrainTimeoutInSec int64 `json:"drainTimeoutInSec"` + Enabled bool `json:"enabled"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaycustomerror.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaycustomerror.go new file mode 100644 index 00000000000..b1f6dd22b0d --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaycustomerror.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayCustomError struct { + CustomErrorPageURL *string `json:"customErrorPageUrl,omitempty"` + StatusCode *ApplicationGatewayCustomErrorStatusCode `json:"statusCode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfirewalldisabledrulegroup.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfirewalldisabledrulegroup.go new file mode 100644 index 00000000000..c88a33b735c --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfirewalldisabledrulegroup.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFirewallDisabledRuleGroup struct { + RuleGroupName string `json:"ruleGroupName"` + Rules *[]int64 `json:"rules,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfirewallexclusion.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfirewallexclusion.go new file mode 100644 index 00000000000..541e5052e8f --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfirewallexclusion.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFirewallExclusion struct { + MatchVariable string `json:"matchVariable"` + Selector string `json:"selector"` + SelectorMatchOperator string `json:"selectorMatchOperator"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayforcontainersreferencedefinition.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayforcontainersreferencedefinition.go new file mode 100644 index 00000000000..2a18fd8a866 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayforcontainersreferencedefinition.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayForContainersReferenceDefinition struct { + Id string `json:"id"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfrontendipconfiguration.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfrontendipconfiguration.go new file mode 100644 index 00000000000..f5f9c5bebc7 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfrontendipconfiguration.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayFrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfrontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfrontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..1b61dc71c1d --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfrontendipconfigurationpropertiesformat.go @@ -0,0 +1,13 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFrontendIPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConfiguration *SubResource `json:"privateLinkConfiguration,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *SubResource `json:"publicIPAddress,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfrontendport.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfrontendport.go new file mode 100644 index 00000000000..dfcb5e52ee3 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfrontendport.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFrontendPort struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayFrontendPortPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfrontendportpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfrontendportpropertiesformat.go new file mode 100644 index 00000000000..d37b168d0aa --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayfrontendportpropertiesformat.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayFrontendPortPropertiesFormat struct { + Port *int64 `json:"port,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayglobalconfiguration.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayglobalconfiguration.go new file mode 100644 index 00000000000..b80dabed9a0 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayglobalconfiguration.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayGlobalConfiguration struct { + EnableRequestBuffering *bool `json:"enableRequestBuffering,omitempty"` + EnableResponseBuffering *bool `json:"enableResponseBuffering,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayheaderconfiguration.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayheaderconfiguration.go new file mode 100644 index 00000000000..7ffc4b3c8c8 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayheaderconfiguration.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayHeaderConfiguration struct { + HeaderName *string `json:"headerName,omitempty"` + HeaderValue *string `json:"headerValue,omitempty"` + HeaderValueMatcher *HeaderValueMatcher `json:"headerValueMatcher,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayhttplistener.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayhttplistener.go new file mode 100644 index 00000000000..0fd70bac201 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayhttplistener.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayHTTPListener struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayHTTPListenerPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayhttplistenerpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayhttplistenerpropertiesformat.go new file mode 100644 index 00000000000..9c4eb515f42 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayhttplistenerpropertiesformat.go @@ -0,0 +1,18 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayHTTPListenerPropertiesFormat struct { + CustomErrorConfigurations *[]ApplicationGatewayCustomError `json:"customErrorConfigurations,omitempty"` + FirewallPolicy *SubResource `json:"firewallPolicy,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *SubResource `json:"frontendPort,omitempty"` + HostName *string `json:"hostName,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + Protocol *ApplicationGatewayProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequireServerNameIndication *bool `json:"requireServerNameIndication,omitempty"` + SslCertificate *SubResource `json:"sslCertificate,omitempty"` + SslProfile *SubResource `json:"sslProfile,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayipconfiguration.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayipconfiguration.go new file mode 100644 index 00000000000..6ffd65f71c2 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayipconfiguration.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..e8482b21e60 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayipconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayIPConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaylistener.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaylistener.go new file mode 100644 index 00000000000..71fe702c98e --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaylistener.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayListener struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayListenerPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaylistenerpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaylistenerpropertiesformat.go new file mode 100644 index 00000000000..ceffb59e3b1 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaylistenerpropertiesformat.go @@ -0,0 +1,14 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayListenerPropertiesFormat struct { + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *SubResource `json:"frontendPort,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + Protocol *ApplicationGatewayProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SslCertificate *SubResource `json:"sslCertificate,omitempty"` + SslProfile *SubResource `json:"sslProfile,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayloaddistributionpolicy.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayloaddistributionpolicy.go new file mode 100644 index 00000000000..55e8713746c --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayloaddistributionpolicy.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayLoadDistributionPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayLoadDistributionPolicyPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayloaddistributionpolicypropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayloaddistributionpolicypropertiesformat.go new file mode 100644 index 00000000000..fe721166bf2 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayloaddistributionpolicypropertiesformat.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayLoadDistributionPolicyPropertiesFormat struct { + LoadDistributionAlgorithm *ApplicationGatewayLoadDistributionAlgorithm `json:"loadDistributionAlgorithm,omitempty"` + LoadDistributionTargets *[]ApplicationGatewayLoadDistributionTarget `json:"loadDistributionTargets,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayloaddistributiontarget.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayloaddistributiontarget.go new file mode 100644 index 00000000000..d361c4e3d97 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayloaddistributiontarget.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayLoadDistributionTarget struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayLoadDistributionTargetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayloaddistributiontargetpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayloaddistributiontargetpropertiesformat.go new file mode 100644 index 00000000000..6ba821b2e82 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayloaddistributiontargetpropertiesformat.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayLoadDistributionTargetPropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + WeightPerServer *int64 `json:"weightPerServer,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaypathrule.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaypathrule.go new file mode 100644 index 00000000000..992b948c558 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaypathrule.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPathRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayPathRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaypathrulepropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaypathrulepropertiesformat.go new file mode 100644 index 00000000000..5c8b00da085 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaypathrulepropertiesformat.go @@ -0,0 +1,15 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPathRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendHTTPSettings *SubResource `json:"backendHttpSettings,omitempty"` + FirewallPolicy *SubResource `json:"firewallPolicy,omitempty"` + LoadDistributionPolicy *SubResource `json:"loadDistributionPolicy,omitempty"` + Paths *[]string `json:"paths,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RedirectConfiguration *SubResource `json:"redirectConfiguration,omitempty"` + RewriteRuleSet *SubResource `json:"rewriteRuleSet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivateendpointconnection.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivateendpointconnection.go new file mode 100644 index 00000000000..5b45596cedc --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivateendpointconnection.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayPrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivateendpointconnectionproperties.go new file mode 100644 index 00000000000..c6a900feb31 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivatelinkconfiguration.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivatelinkconfiguration.go new file mode 100644 index 00000000000..73e8756981a --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivatelinkconfiguration.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateLinkConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayPrivateLinkConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivatelinkconfigurationproperties.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivatelinkconfigurationproperties.go new file mode 100644 index 00000000000..8855a67b9ce --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivatelinkconfigurationproperties.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateLinkConfigurationProperties struct { + IPConfigurations *[]ApplicationGatewayPrivateLinkIPConfiguration `json:"ipConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivatelinkipconfiguration.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivatelinkipconfiguration.go new file mode 100644 index 00000000000..ce8e67a68d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivatelinkipconfiguration.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateLinkIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayPrivateLinkIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivatelinkipconfigurationproperties.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivatelinkipconfigurationproperties.go new file mode 100644 index 00000000000..ff68d2052d7 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprivatelinkipconfigurationproperties.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPrivateLinkIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprobe.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprobe.go new file mode 100644 index 00000000000..9c935a9fbba --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprobe.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayProbe struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayProbePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprobehealthresponsematch.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprobehealthresponsematch.go new file mode 100644 index 00000000000..20c18109ec0 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprobehealthresponsematch.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayProbeHealthResponseMatch struct { + Body *string `json:"body,omitempty"` + StatusCodes *[]string `json:"statusCodes,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprobepropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprobepropertiesformat.go new file mode 100644 index 00000000000..b36845c57bf --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayprobepropertiesformat.go @@ -0,0 +1,19 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayProbePropertiesFormat struct { + Host *string `json:"host,omitempty"` + Interval *int64 `json:"interval,omitempty"` + Match *ApplicationGatewayProbeHealthResponseMatch `json:"match,omitempty"` + MinServers *int64 `json:"minServers,omitempty"` + Path *string `json:"path,omitempty"` + PickHostNameFromBackendHTTPSettings *bool `json:"pickHostNameFromBackendHttpSettings,omitempty"` + PickHostNameFromBackendSettings *bool `json:"pickHostNameFromBackendSettings,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *ApplicationGatewayProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Timeout *int64 `json:"timeout,omitempty"` + UnhealthyThreshold *int64 `json:"unhealthyThreshold,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaypropertiesformat.go new file mode 100644 index 00000000000..6cdbb059a1b --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaypropertiesformat.go @@ -0,0 +1,43 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayPropertiesFormat struct { + AuthenticationCertificates *[]ApplicationGatewayAuthenticationCertificate `json:"authenticationCertificates,omitempty"` + AutoscaleConfiguration *ApplicationGatewayAutoscaleConfiguration `json:"autoscaleConfiguration,omitempty"` + BackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"backendAddressPools,omitempty"` + BackendHTTPSettingsCollection *[]ApplicationGatewayBackendHTTPSettings `json:"backendHttpSettingsCollection,omitempty"` + BackendSettingsCollection *[]ApplicationGatewayBackendSettings `json:"backendSettingsCollection,omitempty"` + CustomErrorConfigurations *[]ApplicationGatewayCustomError `json:"customErrorConfigurations,omitempty"` + DefaultPredefinedSslPolicy *ApplicationGatewaySslPolicyName `json:"defaultPredefinedSslPolicy,omitempty"` + EnableFips *bool `json:"enableFips,omitempty"` + EnableHTTP2 *bool `json:"enableHttp2,omitempty"` + FirewallPolicy *SubResource `json:"firewallPolicy,omitempty"` + ForceFirewallPolicyAssociation *bool `json:"forceFirewallPolicyAssociation,omitempty"` + FrontendIPConfigurations *[]ApplicationGatewayFrontendIPConfiguration `json:"frontendIPConfigurations,omitempty"` + FrontendPorts *[]ApplicationGatewayFrontendPort `json:"frontendPorts,omitempty"` + GatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"gatewayIPConfigurations,omitempty"` + GlobalConfiguration *ApplicationGatewayGlobalConfiguration `json:"globalConfiguration,omitempty"` + HTTPListeners *[]ApplicationGatewayHTTPListener `json:"httpListeners,omitempty"` + Listeners *[]ApplicationGatewayListener `json:"listeners,omitempty"` + LoadDistributionPolicies *[]ApplicationGatewayLoadDistributionPolicy `json:"loadDistributionPolicies,omitempty"` + OperationalState *ApplicationGatewayOperationalState `json:"operationalState,omitempty"` + PrivateEndpointConnections *[]ApplicationGatewayPrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + PrivateLinkConfigurations *[]ApplicationGatewayPrivateLinkConfiguration `json:"privateLinkConfigurations,omitempty"` + Probes *[]ApplicationGatewayProbe `json:"probes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RedirectConfigurations *[]ApplicationGatewayRedirectConfiguration `json:"redirectConfigurations,omitempty"` + RequestRoutingRules *[]ApplicationGatewayRequestRoutingRule `json:"requestRoutingRules,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + RewriteRuleSets *[]ApplicationGatewayRewriteRuleSet `json:"rewriteRuleSets,omitempty"` + RoutingRules *[]ApplicationGatewayRoutingRule `json:"routingRules,omitempty"` + Sku *ApplicationGatewaySku `json:"sku,omitempty"` + SslCertificates *[]ApplicationGatewaySslCertificate `json:"sslCertificates,omitempty"` + SslPolicy *ApplicationGatewaySslPolicy `json:"sslPolicy,omitempty"` + SslProfiles *[]ApplicationGatewaySslProfile `json:"sslProfiles,omitempty"` + TrustedClientCertificates *[]ApplicationGatewayTrustedClientCertificate `json:"trustedClientCertificates,omitempty"` + TrustedRootCertificates *[]ApplicationGatewayTrustedRootCertificate `json:"trustedRootCertificates,omitempty"` + UrlPathMaps *[]ApplicationGatewayURLPathMap `json:"urlPathMaps,omitempty"` + WebApplicationFirewallConfiguration *ApplicationGatewayWebApplicationFirewallConfiguration `json:"webApplicationFirewallConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayredirectconfiguration.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayredirectconfiguration.go new file mode 100644 index 00000000000..85eed147eb2 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayredirectconfiguration.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRedirectConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayRedirectConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayredirectconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayredirectconfigurationpropertiesformat.go new file mode 100644 index 00000000000..6103c017cb4 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayredirectconfigurationpropertiesformat.go @@ -0,0 +1,15 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRedirectConfigurationPropertiesFormat struct { + IncludePath *bool `json:"includePath,omitempty"` + IncludeQueryString *bool `json:"includeQueryString,omitempty"` + PathRules *[]SubResource `json:"pathRules,omitempty"` + RedirectType *ApplicationGatewayRedirectType `json:"redirectType,omitempty"` + RequestRoutingRules *[]SubResource `json:"requestRoutingRules,omitempty"` + TargetListener *SubResource `json:"targetListener,omitempty"` + TargetURL *string `json:"targetUrl,omitempty"` + UrlPathMaps *[]SubResource `json:"urlPathMaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrequestroutingrule.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrequestroutingrule.go new file mode 100644 index 00000000000..9eb6ffe9c4a --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrequestroutingrule.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRequestRoutingRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayRequestRoutingRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrequestroutingrulepropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrequestroutingrulepropertiesformat.go new file mode 100644 index 00000000000..53dc9f99474 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrequestroutingrulepropertiesformat.go @@ -0,0 +1,17 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRequestRoutingRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendHTTPSettings *SubResource `json:"backendHttpSettings,omitempty"` + HTTPListener *SubResource `json:"httpListener,omitempty"` + LoadDistributionPolicy *SubResource `json:"loadDistributionPolicy,omitempty"` + Priority *int64 `json:"priority,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RedirectConfiguration *SubResource `json:"redirectConfiguration,omitempty"` + RewriteRuleSet *SubResource `json:"rewriteRuleSet,omitempty"` + RuleType *ApplicationGatewayRequestRoutingRuleType `json:"ruleType,omitempty"` + UrlPathMap *SubResource `json:"urlPathMap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrewriterule.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrewriterule.go new file mode 100644 index 00000000000..21ce81c5a24 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrewriterule.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRewriteRule struct { + ActionSet *ApplicationGatewayRewriteRuleActionSet `json:"actionSet,omitempty"` + Conditions *[]ApplicationGatewayRewriteRuleCondition `json:"conditions,omitempty"` + Name *string `json:"name,omitempty"` + RuleSequence *int64 `json:"ruleSequence,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrewriteruleactionset.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrewriteruleactionset.go new file mode 100644 index 00000000000..18cc34e55af --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrewriteruleactionset.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRewriteRuleActionSet struct { + RequestHeaderConfigurations *[]ApplicationGatewayHeaderConfiguration `json:"requestHeaderConfigurations,omitempty"` + ResponseHeaderConfigurations *[]ApplicationGatewayHeaderConfiguration `json:"responseHeaderConfigurations,omitempty"` + UrlConfiguration *ApplicationGatewayURLConfiguration `json:"urlConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrewriterulecondition.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrewriterulecondition.go new file mode 100644 index 00000000000..1e70a94ea80 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrewriterulecondition.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRewriteRuleCondition struct { + IgnoreCase *bool `json:"ignoreCase,omitempty"` + Negate *bool `json:"negate,omitempty"` + Pattern *string `json:"pattern,omitempty"` + Variable *string `json:"variable,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrewriteruleset.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrewriteruleset.go new file mode 100644 index 00000000000..a25c70e4a05 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrewriteruleset.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRewriteRuleSet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayRewriteRuleSetPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrewriterulesetpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrewriterulesetpropertiesformat.go new file mode 100644 index 00000000000..3a1e3374217 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayrewriterulesetpropertiesformat.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRewriteRuleSetPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RewriteRules *[]ApplicationGatewayRewriteRule `json:"rewriteRules,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayroutingrule.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayroutingrule.go new file mode 100644 index 00000000000..78053b23a9c --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayroutingrule.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRoutingRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayRoutingRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayroutingrulepropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayroutingrulepropertiesformat.go new file mode 100644 index 00000000000..05ed98ab597 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayroutingrulepropertiesformat.go @@ -0,0 +1,13 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayRoutingRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendSettings *SubResource `json:"backendSettings,omitempty"` + Listener *SubResource `json:"listener,omitempty"` + Priority int64 `json:"priority"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RuleType *ApplicationGatewayRequestRoutingRuleType `json:"ruleType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysku.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysku.go new file mode 100644 index 00000000000..af2d1c3c1e8 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysku.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewaySku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *ApplicationGatewaySkuFamily `json:"family,omitempty"` + Name *ApplicationGatewaySkuName `json:"name,omitempty"` + Tier *ApplicationGatewayTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysslcertificate.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysslcertificate.go new file mode 100644 index 00000000000..328f6a90d88 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysslcertificate.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewaySslCertificate struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewaySslCertificatePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysslcertificatepropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysslcertificatepropertiesformat.go new file mode 100644 index 00000000000..f087bfec9a8 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysslcertificatepropertiesformat.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewaySslCertificatePropertiesFormat struct { + Data *string `json:"data,omitempty"` + KeyVaultSecretId *string `json:"keyVaultSecretId,omitempty"` + Password *string `json:"password,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicCertData *string `json:"publicCertData,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysslpolicy.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysslpolicy.go new file mode 100644 index 00000000000..ae860f1460f --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysslpolicy.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewaySslPolicy struct { + CipherSuites *[]ApplicationGatewaySslCipherSuite `json:"cipherSuites,omitempty"` + DisabledSslProtocols *[]ApplicationGatewaySslProtocol `json:"disabledSslProtocols,omitempty"` + MinProtocolVersion *ApplicationGatewaySslProtocol `json:"minProtocolVersion,omitempty"` + PolicyName *ApplicationGatewaySslPolicyName `json:"policyName,omitempty"` + PolicyType *ApplicationGatewaySslPolicyType `json:"policyType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysslprofile.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysslprofile.go new file mode 100644 index 00000000000..8c1d0630c2f --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysslprofile.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewaySslProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewaySslProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysslprofilepropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysslprofilepropertiesformat.go new file mode 100644 index 00000000000..b89279b0c7f --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaysslprofilepropertiesformat.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewaySslProfilePropertiesFormat struct { + ClientAuthConfiguration *ApplicationGatewayClientAuthConfiguration `json:"clientAuthConfiguration,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SslPolicy *ApplicationGatewaySslPolicy `json:"sslPolicy,omitempty"` + TrustedClientCertificates *[]SubResource `json:"trustedClientCertificates,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaytrustedclientcertificate.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaytrustedclientcertificate.go new file mode 100644 index 00000000000..f2fb2244e71 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaytrustedclientcertificate.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayTrustedClientCertificate struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayTrustedClientCertificatePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaytrustedclientcertificatepropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaytrustedclientcertificatepropertiesformat.go new file mode 100644 index 00000000000..ac7454cb8f4 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaytrustedclientcertificatepropertiesformat.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayTrustedClientCertificatePropertiesFormat struct { + ClientCertIssuerDN *string `json:"clientCertIssuerDN,omitempty"` + Data *string `json:"data,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ValidatedCertData *string `json:"validatedCertData,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaytrustedrootcertificate.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaytrustedrootcertificate.go new file mode 100644 index 00000000000..9deacd55fe8 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaytrustedrootcertificate.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayTrustedRootCertificate struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayTrustedRootCertificatePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaytrustedrootcertificatepropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaytrustedrootcertificatepropertiesformat.go new file mode 100644 index 00000000000..f79bf663f76 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaytrustedrootcertificatepropertiesformat.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayTrustedRootCertificatePropertiesFormat struct { + Data *string `json:"data,omitempty"` + KeyVaultSecretId *string `json:"keyVaultSecretId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayurlconfiguration.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayurlconfiguration.go new file mode 100644 index 00000000000..c6de0fdbc1b --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayurlconfiguration.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayURLConfiguration struct { + ModifiedPath *string `json:"modifiedPath,omitempty"` + ModifiedQueryString *string `json:"modifiedQueryString,omitempty"` + Reroute *bool `json:"reroute,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayurlpathmap.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayurlpathmap.go new file mode 100644 index 00000000000..96a3dc6d985 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayurlpathmap.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayURLPathMap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationGatewayURLPathMapPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayurlpathmappropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayurlpathmappropertiesformat.go new file mode 100644 index 00000000000..e02847a3fd9 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewayurlpathmappropertiesformat.go @@ -0,0 +1,14 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayURLPathMapPropertiesFormat struct { + DefaultBackendAddressPool *SubResource `json:"defaultBackendAddressPool,omitempty"` + DefaultBackendHTTPSettings *SubResource `json:"defaultBackendHttpSettings,omitempty"` + DefaultLoadDistributionPolicy *SubResource `json:"defaultLoadDistributionPolicy,omitempty"` + DefaultRedirectConfiguration *SubResource `json:"defaultRedirectConfiguration,omitempty"` + DefaultRewriteRuleSet *SubResource `json:"defaultRewriteRuleSet,omitempty"` + PathRules *[]ApplicationGatewayPathRule `json:"pathRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaywebapplicationfirewallconfiguration.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaywebapplicationfirewallconfiguration.go new file mode 100644 index 00000000000..0ccb185da05 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationgatewaywebapplicationfirewallconfiguration.go @@ -0,0 +1,17 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationGatewayWebApplicationFirewallConfiguration struct { + DisabledRuleGroups *[]ApplicationGatewayFirewallDisabledRuleGroup `json:"disabledRuleGroups,omitempty"` + Enabled bool `json:"enabled"` + Exclusions *[]ApplicationGatewayFirewallExclusion `json:"exclusions,omitempty"` + FileUploadLimitInMb *int64 `json:"fileUploadLimitInMb,omitempty"` + FirewallMode ApplicationGatewayFirewallMode `json:"firewallMode"` + MaxRequestBodySize *int64 `json:"maxRequestBodySize,omitempty"` + MaxRequestBodySizeInKb *int64 `json:"maxRequestBodySizeInKb,omitempty"` + RequestBodyCheck *bool `json:"requestBodyCheck,omitempty"` + RuleSetType string `json:"ruleSetType"` + RuleSetVersion string `json:"ruleSetVersion"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationsecuritygroup.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationsecuritygroup.go new file mode 100644 index 00000000000..8dccd748428 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationsecuritygroup.go @@ -0,0 +1,14 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationsecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationsecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..2713b23e0a5 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_applicationsecuritygrouppropertiesformat.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationSecurityGroupPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_backendaddresspool.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_backendaddresspool.go new file mode 100644 index 00000000000..a5f3d1e0367 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_backendaddresspool.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPool struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackendAddressPoolPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_backendaddresspoolpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_backendaddresspoolpropertiesformat.go new file mode 100644 index 00000000000..ddf54b50116 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_backendaddresspoolpropertiesformat.go @@ -0,0 +1,19 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackendAddressPoolPropertiesFormat struct { + BackendIPConfigurations *[]NetworkInterfaceIPConfiguration `json:"backendIPConfigurations,omitempty"` + DrainPeriodInSeconds *int64 `json:"drainPeriodInSeconds,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancerBackendAddresses *[]LoadBalancerBackendAddress `json:"loadBalancerBackendAddresses,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + Location *string `json:"location,omitempty"` + OutboundRule *SubResource `json:"outboundRule,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SyncMode *SyncMode `json:"syncMode,omitempty"` + TunnelInterfaces *[]GatewayLoadBalancerTunnelInterface `json:"tunnelInterfaces,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_customdnsconfigpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_customdnsconfigpropertiesformat.go new file mode 100644 index 00000000000..e9022fbeb4f --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_customdnsconfigpropertiesformat.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsConfigPropertiesFormat struct { + Fqdn *string `json:"fqdn,omitempty"` + IPAddresses *[]string `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ddossettings.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ddossettings.go new file mode 100644 index 00000000000..4f7e1e20764 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ddossettings.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DdosSettings struct { + DdosProtectionPlan *SubResource `json:"ddosProtectionPlan,omitempty"` + ProtectionMode *DdosSettingsProtectionMode `json:"protectionMode,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_delegation.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_delegation.go new file mode 100644 index 00000000000..9a088e2a507 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_delegation.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Delegation struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceDelegationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_exceptionentry.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_exceptionentry.go new file mode 100644 index 00000000000..32ca8f8fa0a --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_exceptionentry.go @@ -0,0 +1,13 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExceptionEntry struct { + ExceptionManagedRuleSets *[]ExclusionManagedRuleSet `json:"exceptionManagedRuleSets,omitempty"` + MatchVariable ExceptionEntryMatchVariable `json:"matchVariable"` + Selector *string `json:"selector,omitempty"` + SelectorMatchOperator *ExceptionEntrySelectorMatchOperator `json:"selectorMatchOperator,omitempty"` + ValueMatchOperator ExceptionEntryValueMatchOperator `json:"valueMatchOperator"` + Values *[]string `json:"values,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_exclusionmanagedrule.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_exclusionmanagedrule.go new file mode 100644 index 00000000000..ffa39b22711 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_exclusionmanagedrule.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExclusionManagedRule struct { + RuleId string `json:"ruleId"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_exclusionmanagedrulegroup.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_exclusionmanagedrulegroup.go new file mode 100644 index 00000000000..29d30ef6bc1 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_exclusionmanagedrulegroup.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExclusionManagedRuleGroup struct { + RuleGroupName string `json:"ruleGroupName"` + Rules *[]ExclusionManagedRule `json:"rules,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_exclusionmanagedruleset.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_exclusionmanagedruleset.go new file mode 100644 index 00000000000..cb569797cec --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_exclusionmanagedruleset.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExclusionManagedRuleSet struct { + RuleGroups *[]ExclusionManagedRuleGroup `json:"ruleGroups,omitempty"` + RuleSetType string `json:"ruleSetType"` + RuleSetVersion string `json:"ruleSetVersion"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_flowlog.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_flowlog.go new file mode 100644 index 00000000000..e1c8c796363 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_flowlog.go @@ -0,0 +1,19 @@ +package webapplicationfirewallpolicies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLog struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FlowLogPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_flowlogformatparameters.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_flowlogformatparameters.go new file mode 100644 index 00000000000..8e97873a7c3 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_flowlogformatparameters.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogFormatParameters struct { + Type *FlowLogFormatType `json:"type,omitempty"` + Version *int64 `json:"version,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_flowlogpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_flowlogpropertiesformat.go new file mode 100644 index 00000000000..7afcaba37f9 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_flowlogpropertiesformat.go @@ -0,0 +1,16 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowLogPropertiesFormat struct { + Enabled *bool `json:"enabled,omitempty"` + EnabledFilteringCriteria *string `json:"enabledFilteringCriteria,omitempty"` + FlowAnalyticsConfiguration *TrafficAnalyticsProperties `json:"flowAnalyticsConfiguration,omitempty"` + Format *FlowLogFormatParameters `json:"format,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RetentionPolicy *RetentionPolicyParameters `json:"retentionPolicy,omitempty"` + StorageId string `json:"storageId"` + TargetResourceGuid *string `json:"targetResourceGuid,omitempty"` + TargetResourceId string `json:"targetResourceId"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_frontendipconfiguration.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_frontendipconfiguration.go new file mode 100644 index 00000000000..717217cc3a2 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_frontendipconfiguration.go @@ -0,0 +1,17 @@ +package webapplicationfirewallpolicies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FrontendIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_frontendipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_frontendipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..4f11b119df9 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_frontendipconfigurationpropertiesformat.go @@ -0,0 +1,19 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontendIPConfigurationPropertiesFormat struct { + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + InboundNatPools *[]SubResource `json:"inboundNatPools,omitempty"` + InboundNatRules *[]SubResource `json:"inboundNatRules,omitempty"` + LoadBalancingRules *[]SubResource `json:"loadBalancingRules,omitempty"` + OutboundRules *[]SubResource `json:"outboundRules,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_gatewayloadbalancertunnelinterface.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_gatewayloadbalancertunnelinterface.go new file mode 100644 index 00000000000..698c1c6a1b4 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_gatewayloadbalancertunnelinterface.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GatewayLoadBalancerTunnelInterface struct { + Identifier *int64 `json:"identifier,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *GatewayLoadBalancerTunnelProtocol `json:"protocol,omitempty"` + Type *GatewayLoadBalancerTunnelInterfaceType `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_groupbyusersession.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_groupbyusersession.go new file mode 100644 index 00000000000..5995831381a --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_groupbyusersession.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GroupByUserSession struct { + GroupByVariables []GroupByVariable `json:"groupByVariables"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_groupbyvariable.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_groupbyvariable.go new file mode 100644 index 00000000000..132602a8758 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_groupbyvariable.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GroupByVariable struct { + VariableName ApplicationGatewayFirewallUserSessionVariable `json:"variableName"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_headervaluematcher.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_headervaluematcher.go new file mode 100644 index 00000000000..d88a3a6eea0 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_headervaluematcher.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HeaderValueMatcher struct { + IgnoreCase *bool `json:"ignoreCase,omitempty"` + Negate *bool `json:"negate,omitempty"` + Pattern *string `json:"pattern,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_inboundnatrule.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_inboundnatrule.go new file mode 100644 index 00000000000..f9908a65135 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_inboundnatrule.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *InboundNatRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_inboundnatrulepropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_inboundnatrulepropertiesformat.go new file mode 100644 index 00000000000..2ed26d6a6d0 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_inboundnatrulepropertiesformat.go @@ -0,0 +1,19 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundNatRulePropertiesFormat struct { + BackendAddressPool *SubResource `json:"backendAddressPool,omitempty"` + BackendIPConfiguration *NetworkInterfaceIPConfiguration `json:"backendIPConfiguration,omitempty"` + BackendPort *int64 `json:"backendPort,omitempty"` + EnableFloatingIP *bool `json:"enableFloatingIP,omitempty"` + EnableTcpReset *bool `json:"enableTcpReset,omitempty"` + FrontendIPConfiguration *SubResource `json:"frontendIPConfiguration,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + FrontendPortRangeEnd *int64 `json:"frontendPortRangeEnd,omitempty"` + FrontendPortRangeStart *int64 `json:"frontendPortRangeStart,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + Protocol *TransportProtocol `json:"protocol,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipampoolprefixallocation.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipampoolprefixallocation.go new file mode 100644 index 00000000000..16f1eba5859 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipampoolprefixallocation.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocation struct { + AllocatedAddressPrefixes *[]string `json:"allocatedAddressPrefixes,omitempty"` + NumberOfIPAddresses *string `json:"numberOfIpAddresses,omitempty"` + Pool *IPamPoolPrefixAllocationPool `json:"pool,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipampoolprefixallocationpool.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipampoolprefixallocationpool.go new file mode 100644 index 00000000000..1d5d7e549f9 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipampoolprefixallocationpool.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPamPoolPrefixAllocationPool struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipconfiguration.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipconfiguration.go new file mode 100644 index 00000000000..ee1ee9f9ce3 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipconfiguration.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipconfigurationprofile.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipconfigurationprofile.go new file mode 100644 index 00000000000..4467a251182 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipconfigurationprofile.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfile struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IPConfigurationProfilePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipconfigurationprofilepropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipconfigurationprofilepropertiesformat.go new file mode 100644 index 00000000000..4746cb9a921 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipconfigurationprofilepropertiesformat.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationProfilePropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..6455af984df --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_ipconfigurationpropertiesformat.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPConfigurationPropertiesFormat struct { + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_iptag.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_iptag.go new file mode 100644 index 00000000000..da603122799 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_iptag.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_loadbalancerbackendaddress.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_loadbalancerbackendaddress.go new file mode 100644 index 00000000000..07977c08269 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_loadbalancerbackendaddress.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddress struct { + Name *string `json:"name,omitempty"` + Properties *LoadBalancerBackendAddressPropertiesFormat `json:"properties,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_loadbalancerbackendaddresspropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_loadbalancerbackendaddresspropertiesformat.go new file mode 100644 index 00000000000..ca60fdf8735 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_loadbalancerbackendaddresspropertiesformat.go @@ -0,0 +1,14 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerBackendAddressPropertiesFormat struct { + AdminState *LoadBalancerBackendAddressAdminState `json:"adminState,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + InboundNatRulesPortMapping *[]NatRulePortMapping `json:"inboundNatRulesPortMapping,omitempty"` + LoadBalancerFrontendIPConfiguration *SubResource `json:"loadBalancerFrontendIPConfiguration,omitempty"` + NetworkInterfaceIPConfiguration *SubResource `json:"networkInterfaceIPConfiguration,omitempty"` + Subnet *SubResource `json:"subnet,omitempty"` + VirtualNetwork *SubResource `json:"virtualNetwork,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_managedrulegroupoverride.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_managedrulegroupoverride.go new file mode 100644 index 00000000000..2810e8e0e4d --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_managedrulegroupoverride.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRuleGroupOverride struct { + RuleGroupName string `json:"ruleGroupName"` + Rules *[]ManagedRuleOverride `json:"rules,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_managedruleoverride.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_managedruleoverride.go new file mode 100644 index 00000000000..6e7f1e81153 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_managedruleoverride.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRuleOverride struct { + Action *ActionType `json:"action,omitempty"` + RuleId string `json:"ruleId"` + Sensitivity *SensitivityType `json:"sensitivity,omitempty"` + State *ManagedRuleEnabledState `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_managedrulesdefinition.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_managedrulesdefinition.go new file mode 100644 index 00000000000..a975ea21235 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_managedrulesdefinition.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRulesDefinition struct { + Exceptions *[]ExceptionEntry `json:"exceptions,omitempty"` + Exclusions *[]OwaspCrsExclusionEntry `json:"exclusions,omitempty"` + ManagedRuleSets []ManagedRuleSet `json:"managedRuleSets"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_managedruleset.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_managedruleset.go new file mode 100644 index 00000000000..9927c824c90 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_managedruleset.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRuleSet struct { + ComputedDisabledRules *[]ManagedRuleSetRuleGroup `json:"computedDisabledRules,omitempty"` + RuleGroupOverrides *[]ManagedRuleGroupOverride `json:"ruleGroupOverrides,omitempty"` + RuleSetType string `json:"ruleSetType"` + RuleSetVersion string `json:"ruleSetVersion"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_managedrulesetrulegroup.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_managedrulesetrulegroup.go new file mode 100644 index 00000000000..f967c9bc62f --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_managedrulesetrulegroup.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedRuleSetRuleGroup struct { + RuleGroupName string `json:"ruleGroupName"` + Rules *[]string `json:"rules,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_matchcondition.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_matchcondition.go new file mode 100644 index 00000000000..c8d3e722c75 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_matchcondition.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MatchCondition struct { + MatchValues []string `json:"matchValues"` + MatchVariables []MatchVariable `json:"matchVariables"` + NegationConditon *bool `json:"negationConditon,omitempty"` + Operator WebApplicationFirewallOperator `json:"operator"` + Transforms *[]WebApplicationFirewallTransform `json:"transforms,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_matchvariable.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_matchvariable.go new file mode 100644 index 00000000000..bd0473317b2 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_matchvariable.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MatchVariable struct { + Selector *string `json:"selector,omitempty"` + VariableName WebApplicationFirewallMatchVariable `json:"variableName"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_natgateway.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_natgateway.go new file mode 100644 index 00000000000..4a594a57232 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_natgateway.go @@ -0,0 +1,20 @@ +package webapplicationfirewallpolicies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGateway struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NatGatewayPropertiesFormat `json:"properties,omitempty"` + Sku *NatGatewaySku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_natgatewaypropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_natgatewaypropertiesformat.go new file mode 100644 index 00000000000..6b3df4f5118 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_natgatewaypropertiesformat.go @@ -0,0 +1,16 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewayPropertiesFormat struct { + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddresses *[]SubResource `json:"publicIpAddresses,omitempty"` + PublicIPAddressesV6 *[]SubResource `json:"publicIpAddressesV6,omitempty"` + PublicIPPrefixes *[]SubResource `json:"publicIpPrefixes,omitempty"` + PublicIPPrefixesV6 *[]SubResource `json:"publicIpPrefixesV6,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SourceVirtualNetwork *SubResource `json:"sourceVirtualNetwork,omitempty"` + Subnets *[]SubResource `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_natgatewaysku.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_natgatewaysku.go new file mode 100644 index 00000000000..01f9595dd47 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_natgatewaysku.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatGatewaySku struct { + Name *NatGatewaySkuName `json:"name,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_natruleportmapping.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_natruleportmapping.go new file mode 100644 index 00000000000..636fb66e30f --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_natruleportmapping.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NatRulePortMapping struct { + BackendPort *int64 `json:"backendPort,omitempty"` + FrontendPort *int64 `json:"frontendPort,omitempty"` + InboundNatRuleName *string `json:"inboundNatRuleName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterface.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterface.go new file mode 100644 index 00000000000..5f43f78eff1 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterface.go @@ -0,0 +1,19 @@ +package webapplicationfirewallpolicies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterface struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfacePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfacednssettings.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfacednssettings.go new file mode 100644 index 00000000000..2d9f1326e9a --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfacednssettings.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceDnsSettings struct { + AppliedDnsServers *[]string `json:"appliedDnsServers,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` + InternalDnsNameLabel *string `json:"internalDnsNameLabel,omitempty"` + InternalDomainNameSuffix *string `json:"internalDomainNameSuffix,omitempty"` + InternalFqdn *string `json:"internalFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfaceipconfiguration.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfaceipconfiguration.go new file mode 100644 index 00000000000..80650073a43 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfaceipconfiguration.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceIPConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go new file mode 100644 index 00000000000..ed9c49c6aa3 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfaceipconfigurationprivatelinkconnectionproperties.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties struct { + Fqdns *[]string `json:"fqdns,omitempty"` + GroupId *string `json:"groupId,omitempty"` + RequiredMemberName *string `json:"requiredMemberName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfaceipconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfaceipconfigurationpropertiesformat.go new file mode 100644 index 00000000000..db24b56da38 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfaceipconfigurationpropertiesformat.go @@ -0,0 +1,22 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceIPConfigurationPropertiesFormat struct { + ApplicationGatewayBackendAddressPools *[]ApplicationGatewayBackendAddressPool `json:"applicationGatewayBackendAddressPools,omitempty"` + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + GatewayLoadBalancer *SubResource `json:"gatewayLoadBalancer,omitempty"` + LoadBalancerBackendAddressPools *[]BackendAddressPool `json:"loadBalancerBackendAddressPools,omitempty"` + LoadBalancerInboundNatRules *[]InboundNatRule `json:"loadBalancerInboundNatRules,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressPrefixLength *int64 `json:"privateIPAddressPrefixLength,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + PrivateLinkConnectionProperties *NetworkInterfaceIPConfigurationPrivateLinkConnectionProperties `json:"privateLinkConnectionProperties,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddress *PublicIPAddress `json:"publicIPAddress,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` + VirtualNetworkTaps *[]VirtualNetworkTap `json:"virtualNetworkTaps,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfacepropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfacepropertiesformat.go new file mode 100644 index 00000000000..fc742511fd0 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfacepropertiesformat.go @@ -0,0 +1,30 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfacePropertiesFormat struct { + AuxiliaryMode *NetworkInterfaceAuxiliaryMode `json:"auxiliaryMode,omitempty"` + AuxiliarySku *NetworkInterfaceAuxiliarySku `json:"auxiliarySku,omitempty"` + DefaultOutboundConnectivityEnabled *bool `json:"defaultOutboundConnectivityEnabled,omitempty"` + DisableTcpStateTracking *bool `json:"disableTcpStateTracking,omitempty"` + DnsSettings *NetworkInterfaceDnsSettings `json:"dnsSettings,omitempty"` + DscpConfiguration *SubResource `json:"dscpConfiguration,omitempty"` + EnableAcceleratedNetworking *bool `json:"enableAcceleratedNetworking,omitempty"` + EnableIPForwarding *bool `json:"enableIPForwarding,omitempty"` + HostedWorkloads *[]string `json:"hostedWorkloads,omitempty"` + IPConfigurations *[]NetworkInterfaceIPConfiguration `json:"ipConfigurations,omitempty"` + MacAddress *string `json:"macAddress,omitempty"` + MigrationPhase *NetworkInterfaceMigrationPhase `json:"migrationPhase,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + NicType *NetworkInterfaceNicType `json:"nicType,omitempty"` + Primary *bool `json:"primary,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkService *PrivateLinkService `json:"privateLinkService,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + TapConfigurations *[]NetworkInterfaceTapConfiguration `json:"tapConfigurations,omitempty"` + VirtualMachine *SubResource `json:"virtualMachine,omitempty"` + VnetEncryptionSupported *bool `json:"vnetEncryptionSupported,omitempty"` + WorkloadType *string `json:"workloadType,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfacetapconfiguration.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfacetapconfiguration.go new file mode 100644 index 00000000000..559fab4512d --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfacetapconfiguration.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkInterfaceTapConfigurationPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfacetapconfigurationpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfacetapconfigurationpropertiesformat.go new file mode 100644 index 00000000000..d28ce56ff99 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networkinterfacetapconfigurationpropertiesformat.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkInterfaceTapConfigurationPropertiesFormat struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + VirtualNetworkTap *VirtualNetworkTap `json:"virtualNetworkTap,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networksecuritygroup.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networksecuritygroup.go new file mode 100644 index 00000000000..7edb20a30eb --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networksecuritygroup.go @@ -0,0 +1,14 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroup struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkSecurityGroupPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networksecuritygrouppropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networksecuritygrouppropertiesformat.go new file mode 100644 index 00000000000..63dfb0a3753 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_networksecuritygrouppropertiesformat.go @@ -0,0 +1,15 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkSecurityGroupPropertiesFormat struct { + DefaultSecurityRules *[]SecurityRule `json:"defaultSecurityRules,omitempty"` + FlowLogs *[]FlowLog `json:"flowLogs,omitempty"` + FlushConnection *bool `json:"flushConnection,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + SecurityRules *[]SecurityRule `json:"securityRules,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_owaspcrsexclusionentry.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_owaspcrsexclusionentry.go new file mode 100644 index 00000000000..447c5ce3185 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_owaspcrsexclusionentry.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OwaspCrsExclusionEntry struct { + ExclusionManagedRuleSets *[]ExclusionManagedRuleSet `json:"exclusionManagedRuleSets,omitempty"` + MatchVariable OwaspCrsExclusionEntryMatchVariable `json:"matchVariable"` + Selector string `json:"selector"` + SelectorMatchOperator OwaspCrsExclusionEntrySelectorMatchOperator `json:"selectorMatchOperator"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_policysettings.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_policysettings.go new file mode 100644 index 00000000000..a87e7c07bff --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_policysettings.go @@ -0,0 +1,19 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicySettings struct { + CustomBlockResponseBody *string `json:"customBlockResponseBody,omitempty"` + CustomBlockResponseStatusCode *int64 `json:"customBlockResponseStatusCode,omitempty"` + FileUploadEnforcement *bool `json:"fileUploadEnforcement,omitempty"` + FileUploadLimitInMb *int64 `json:"fileUploadLimitInMb,omitempty"` + JsChallengeCookieExpirationInMins *int64 `json:"jsChallengeCookieExpirationInMins,omitempty"` + LogScrubbing *PolicySettingsLogScrubbing `json:"logScrubbing,omitempty"` + MaxRequestBodySizeInKb *int64 `json:"maxRequestBodySizeInKb,omitempty"` + Mode *WebApplicationFirewallMode `json:"mode,omitempty"` + RequestBodyCheck *bool `json:"requestBodyCheck,omitempty"` + RequestBodyEnforcement *bool `json:"requestBodyEnforcement,omitempty"` + RequestBodyInspectLimitInKB *int64 `json:"requestBodyInspectLimitInKB,omitempty"` + State *WebApplicationFirewallEnabledState `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_policysettingslogscrubbing.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_policysettingslogscrubbing.go new file mode 100644 index 00000000000..a97418be867 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_policysettingslogscrubbing.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicySettingsLogScrubbing struct { + ScrubbingRules *[]WebApplicationFirewallScrubbingRules `json:"scrubbingRules,omitempty"` + State *WebApplicationFirewallScrubbingState `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpoint.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpoint.go new file mode 100644 index 00000000000..aabcb4ef384 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpoint.go @@ -0,0 +1,19 @@ +package webapplicationfirewallpolicies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpointconnection.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpointconnection.go new file mode 100644 index 00000000000..c66bc0045c7 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpointconnection.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpointconnectionproperties.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..dbd38c8e4ca --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpointconnectionproperties.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + LinkIdentifier *string `json:"linkIdentifier,omitempty"` + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpointLocation *string `json:"privateEndpointLocation,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpointipconfiguration.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpointipconfiguration.go new file mode 100644 index 00000000000..86f24c803d3 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpointipconfiguration.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpointipconfigurationproperties.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpointipconfigurationproperties.go new file mode 100644 index 00000000000..f40d8cf2be4 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpointipconfigurationproperties.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointIPConfigurationProperties struct { + GroupId *string `json:"groupId,omitempty"` + MemberName *string `json:"memberName,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpointproperties.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpointproperties.go new file mode 100644 index 00000000000..93cab138813 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privateendpointproperties.go @@ -0,0 +1,16 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointProperties struct { + ApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"applicationSecurityGroups,omitempty"` + CustomDnsConfigs *[]CustomDnsConfigPropertiesFormat `json:"customDnsConfigs,omitempty"` + CustomNetworkInterfaceName *string `json:"customNetworkInterfaceName,omitempty"` + IPConfigurations *[]PrivateEndpointIPConfiguration `json:"ipConfigurations,omitempty"` + ManualPrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"manualPrivateLinkServiceConnections,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateLinkServiceConnections *[]PrivateLinkServiceConnection `json:"privateLinkServiceConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkservice.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkservice.go new file mode 100644 index 00000000000..8b8ffdc399e --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkservice.go @@ -0,0 +1,19 @@ +package webapplicationfirewallpolicies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkService struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceconnection.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceconnection.go new file mode 100644 index 00000000000..ac293dace51 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceconnection.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnection struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceconnectionproperties.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceconnectionproperties.go new file mode 100644 index 00000000000..164ef869982 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceconnectionproperties.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceId *string `json:"privateLinkServiceId,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceconnectionstate.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..3ea66cb9940 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceipconfiguration.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceipconfiguration.go new file mode 100644 index 00000000000..7d17f466192 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceipconfiguration.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfiguration struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkServiceIPConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceipconfigurationproperties.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceipconfigurationproperties.go new file mode 100644 index 00000000000..814df952c03 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceipconfigurationproperties.go @@ -0,0 +1,13 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceIPConfigurationProperties struct { + Primary *bool `json:"primary,omitempty"` + PrivateIPAddress *string `json:"privateIPAddress,omitempty"` + PrivateIPAddressVersion *IPVersion `json:"privateIPAddressVersion,omitempty"` + PrivateIPAllocationMethod *IPAllocationMethod `json:"privateIPAllocationMethod,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Subnet *Subnet `json:"subnet,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceproperties.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceproperties.go new file mode 100644 index 00000000000..139f2159ef2 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_privatelinkserviceproperties.go @@ -0,0 +1,18 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceProperties struct { + Alias *string `json:"alias,omitempty"` + AutoApproval *ResourceSet `json:"autoApproval,omitempty"` + DestinationIPAddress *string `json:"destinationIPAddress,omitempty"` + EnableProxyProtocol *bool `json:"enableProxyProtocol,omitempty"` + Fqdns *[]string `json:"fqdns,omitempty"` + IPConfigurations *[]PrivateLinkServiceIPConfiguration `json:"ipConfigurations,omitempty"` + LoadBalancerFrontendIPConfigurations *[]FrontendIPConfiguration `json:"loadBalancerFrontendIpConfigurations,omitempty"` + NetworkInterfaces *[]NetworkInterface `json:"networkInterfaces,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Visibility *ResourceSet `json:"visibility,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_publicipaddress.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_publicipaddress.go new file mode 100644 index 00000000000..6f2116661f4 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_publicipaddress.go @@ -0,0 +1,22 @@ +package webapplicationfirewallpolicies + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddress struct { + Etag *string `json:"etag,omitempty"` + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicIPAddressPropertiesFormat `json:"properties,omitempty"` + Sku *PublicIPAddressSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_publicipaddressdnssettings.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_publicipaddressdnssettings.go new file mode 100644 index 00000000000..c122bbf9d00 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_publicipaddressdnssettings.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressDnsSettings struct { + DomainNameLabel *string `json:"domainNameLabel,omitempty"` + DomainNameLabelScope *PublicIPAddressDnsSettingsDomainNameLabelScope `json:"domainNameLabelScope,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + ReverseFqdn *string `json:"reverseFqdn,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_publicipaddresspropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_publicipaddresspropertiesformat.go new file mode 100644 index 00000000000..76e237783ef --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_publicipaddresspropertiesformat.go @@ -0,0 +1,23 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressPropertiesFormat struct { + DdosSettings *DdosSettings `json:"ddosSettings,omitempty"` + DeleteOption *DeleteOptions `json:"deleteOption,omitempty"` + DnsSettings *PublicIPAddressDnsSettings `json:"dnsSettings,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + IPConfiguration *IPConfiguration `json:"ipConfiguration,omitempty"` + IPTags *[]IPTag `json:"ipTags,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + LinkedPublicIPAddress *PublicIPAddress `json:"linkedPublicIPAddress,omitempty"` + MigrationPhase *PublicIPAddressMigrationPhase `json:"migrationPhase,omitempty"` + NatGateway *NatGateway `json:"natGateway,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicIPAddressVersion *IPVersion `json:"publicIPAddressVersion,omitempty"` + PublicIPAllocationMethod *IPAllocationMethod `json:"publicIPAllocationMethod,omitempty"` + PublicIPPrefix *SubResource `json:"publicIPPrefix,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServicePublicIPAddress *PublicIPAddress `json:"servicePublicIPAddress,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_publicipaddresssku.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_publicipaddresssku.go new file mode 100644 index 00000000000..1b8495a46b0 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_publicipaddresssku.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicIPAddressSku struct { + Name *PublicIPAddressSkuName `json:"name,omitempty"` + Tier *PublicIPAddressSkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_resourcenavigationlink.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_resourcenavigationlink.go new file mode 100644 index 00000000000..8cf0d6ae754 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_resourcenavigationlink.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceNavigationLinkFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_resourcenavigationlinkformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_resourcenavigationlinkformat.go new file mode 100644 index 00000000000..cfc65feb648 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_resourcenavigationlinkformat.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNavigationLinkFormat struct { + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_resourceset.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_resourceset.go new file mode 100644 index 00000000000..7bd3ff7ff53 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_resourceset.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSet struct { + Subscriptions *[]string `json:"subscriptions,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_retentionpolicyparameters.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_retentionpolicyparameters.go new file mode 100644 index 00000000000..700cf48fcef --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_retentionpolicyparameters.go @@ -0,0 +1,9 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetentionPolicyParameters struct { + Days *int64 `json:"days,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_route.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_route.go new file mode 100644 index 00000000000..854dbcba973 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_route.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RoutePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_routepropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_routepropertiesformat.go new file mode 100644 index 00000000000..65879ed15ad --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_routepropertiesformat.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoutePropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + HasBgpOverride *bool `json:"hasBgpOverride,omitempty"` + NextHopIPAddress *string `json:"nextHopIpAddress,omitempty"` + NextHopType RouteNextHopType `json:"nextHopType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_routetable.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_routetable.go new file mode 100644 index 00000000000..73fdbc844dc --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_routetable.go @@ -0,0 +1,14 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTable struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RouteTablePropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_routetablepropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_routetablepropertiesformat.go new file mode 100644 index 00000000000..f7082dd7d4a --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_routetablepropertiesformat.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RouteTablePropertiesFormat struct { + DisableBgpRoutePropagation *bool `json:"disableBgpRoutePropagation,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + Routes *[]Route `json:"routes,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_securityrule.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_securityrule.go new file mode 100644 index 00000000000..9a8c2e557c7 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_securityrule.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRule struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SecurityRulePropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_securityrulepropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_securityrulepropertiesformat.go new file mode 100644 index 00000000000..d40d084432c --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_securityrulepropertiesformat.go @@ -0,0 +1,23 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SecurityRulePropertiesFormat struct { + Access SecurityRuleAccess `json:"access"` + Description *string `json:"description,omitempty"` + DestinationAddressPrefix *string `json:"destinationAddressPrefix,omitempty"` + DestinationAddressPrefixes *[]string `json:"destinationAddressPrefixes,omitempty"` + DestinationApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"destinationApplicationSecurityGroups,omitempty"` + DestinationPortRange *string `json:"destinationPortRange,omitempty"` + DestinationPortRanges *[]string `json:"destinationPortRanges,omitempty"` + Direction SecurityRuleDirection `json:"direction"` + Priority int64 `json:"priority"` + Protocol SecurityRuleProtocol `json:"protocol"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + SourceAddressPrefix *string `json:"sourceAddressPrefix,omitempty"` + SourceAddressPrefixes *[]string `json:"sourceAddressPrefixes,omitempty"` + SourceApplicationSecurityGroups *[]ApplicationSecurityGroup `json:"sourceApplicationSecurityGroups,omitempty"` + SourcePortRange *string `json:"sourcePortRange,omitempty"` + SourcePortRanges *[]string `json:"sourcePortRanges,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceassociationlink.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceassociationlink.go new file mode 100644 index 00000000000..9f75aeaec5b --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceassociationlink.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLink struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceAssociationLinkPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceassociationlinkpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceassociationlinkpropertiesformat.go new file mode 100644 index 00000000000..abae149b764 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceassociationlinkpropertiesformat.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceAssociationLinkPropertiesFormat struct { + AllowDelete *bool `json:"allowDelete,omitempty"` + Link *string `json:"link,omitempty"` + LinkedResourceType *string `json:"linkedResourceType,omitempty"` + Locations *[]string `json:"locations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_servicedelegationpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_servicedelegationpropertiesformat.go new file mode 100644 index 00000000000..160d9aebc9f --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_servicedelegationpropertiesformat.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceDelegationPropertiesFormat struct { + Actions *[]string `json:"actions,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceendpointpolicy.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceendpointpolicy.go new file mode 100644 index 00000000000..ae5e0fd396a --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceendpointpolicy.go @@ -0,0 +1,15 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceendpointpolicydefinition.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceendpointpolicydefinition.go new file mode 100644 index 00000000000..ac60c21f09b --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceendpointpolicydefinition.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinition struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ServiceEndpointPolicyDefinitionPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceendpointpolicydefinitionpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceendpointpolicydefinitionpropertiesformat.go new file mode 100644 index 00000000000..34679603f3a --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceendpointpolicydefinitionpropertiesformat.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyDefinitionPropertiesFormat struct { + Description *string `json:"description,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` + ServiceResources *[]string `json:"serviceResources,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceendpointpolicypropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceendpointpolicypropertiesformat.go new file mode 100644 index 00000000000..aa5effcc158 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceendpointpolicypropertiesformat.go @@ -0,0 +1,13 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPolicyPropertiesFormat struct { + ContextualServiceEndpointPolicies *[]string `json:"contextualServiceEndpointPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` + ServiceAlias *string `json:"serviceAlias,omitempty"` + ServiceEndpointPolicyDefinitions *[]ServiceEndpointPolicyDefinition `json:"serviceEndpointPolicyDefinitions,omitempty"` + Subnets *[]Subnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceendpointpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceendpointpropertiesformat.go new file mode 100644 index 00000000000..4a37ea44fea --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_serviceendpointpropertiesformat.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceEndpointPropertiesFormat struct { + Locations *[]string `json:"locations,omitempty"` + NetworkIdentifier *SubResource `json:"networkIdentifier,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Service *string `json:"service,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_subnet.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_subnet.go new file mode 100644 index 00000000000..22ae6378be5 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_subnet.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Subnet struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SubnetPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_subnetpropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_subnetpropertiesformat.go new file mode 100644 index 00000000000..cbc01b70e9f --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_subnetpropertiesformat.go @@ -0,0 +1,29 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubnetPropertiesFormat struct { + AddressPrefix *string `json:"addressPrefix,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + ApplicationGatewayIPConfigurations *[]ApplicationGatewayIPConfiguration `json:"applicationGatewayIPConfigurations,omitempty"` + DefaultOutboundAccess *bool `json:"defaultOutboundAccess,omitempty"` + Delegations *[]Delegation `json:"delegations,omitempty"` + IPAllocations *[]SubResource `json:"ipAllocations,omitempty"` + IPConfigurationProfiles *[]IPConfigurationProfile `json:"ipConfigurationProfiles,omitempty"` + IPConfigurations *[]IPConfiguration `json:"ipConfigurations,omitempty"` + IPamPoolPrefixAllocations *[]IPamPoolPrefixAllocation `json:"ipamPoolPrefixAllocations,omitempty"` + NatGateway *SubResource `json:"natGateway,omitempty"` + NetworkSecurityGroup *NetworkSecurityGroup `json:"networkSecurityGroup,omitempty"` + PrivateEndpointNetworkPolicies *VirtualNetworkPrivateEndpointNetworkPolicies `json:"privateEndpointNetworkPolicies,omitempty"` + PrivateEndpoints *[]PrivateEndpoint `json:"privateEndpoints,omitempty"` + PrivateLinkServiceNetworkPolicies *VirtualNetworkPrivateLinkServiceNetworkPolicies `json:"privateLinkServiceNetworkPolicies,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Purpose *string `json:"purpose,omitempty"` + ResourceNavigationLinks *[]ResourceNavigationLink `json:"resourceNavigationLinks,omitempty"` + RouteTable *RouteTable `json:"routeTable,omitempty"` + ServiceAssociationLinks *[]ServiceAssociationLink `json:"serviceAssociationLinks,omitempty"` + ServiceEndpointPolicies *[]ServiceEndpointPolicy `json:"serviceEndpointPolicies,omitempty"` + ServiceEndpoints *[]ServiceEndpointPropertiesFormat `json:"serviceEndpoints,omitempty"` + SharingScope *SharingScope `json:"sharingScope,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_subresource.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_subresource.go new file mode 100644 index 00000000000..f80e970be83 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_subresource.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SubResource struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_trafficanalyticsconfigurationproperties.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_trafficanalyticsconfigurationproperties.go new file mode 100644 index 00000000000..fd4b0e7ec17 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_trafficanalyticsconfigurationproperties.go @@ -0,0 +1,12 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsConfigurationProperties struct { + Enabled *bool `json:"enabled,omitempty"` + TrafficAnalyticsInterval *int64 `json:"trafficAnalyticsInterval,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceRegion *string `json:"workspaceRegion,omitempty"` + WorkspaceResourceId *string `json:"workspaceResourceId,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_trafficanalyticsproperties.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_trafficanalyticsproperties.go new file mode 100644 index 00000000000..872500d56bf --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_trafficanalyticsproperties.go @@ -0,0 +1,8 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrafficAnalyticsProperties struct { + NetworkWatcherFlowAnalyticsConfiguration *TrafficAnalyticsConfigurationProperties `json:"networkWatcherFlowAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_virtualnetworktap.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_virtualnetworktap.go new file mode 100644 index 00000000000..e2de0ca881d --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_virtualnetworktap.go @@ -0,0 +1,14 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTap struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VirtualNetworkTapPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_virtualnetworktappropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_virtualnetworktappropertiesformat.go new file mode 100644 index 00000000000..418d09be371 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_virtualnetworktappropertiesformat.go @@ -0,0 +1,13 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkTapPropertiesFormat struct { + DestinationLoadBalancerFrontEndIPConfiguration *FrontendIPConfiguration `json:"destinationLoadBalancerFrontEndIPConfiguration,omitempty"` + DestinationNetworkInterfaceIPConfiguration *NetworkInterfaceIPConfiguration `json:"destinationNetworkInterfaceIPConfiguration,omitempty"` + DestinationPort *int64 `json:"destinationPort,omitempty"` + NetworkInterfaceTapConfigurations *[]NetworkInterfaceTapConfiguration `json:"networkInterfaceTapConfigurations,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_webapplicationfirewallcustomrule.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_webapplicationfirewallcustomrule.go new file mode 100644 index 00000000000..c66c1257253 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_webapplicationfirewallcustomrule.go @@ -0,0 +1,17 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebApplicationFirewallCustomRule struct { + Action WebApplicationFirewallAction `json:"action"` + Etag *string `json:"etag,omitempty"` + GroupByUserSession *[]GroupByUserSession `json:"groupByUserSession,omitempty"` + MatchConditions []MatchCondition `json:"matchConditions"` + Name *string `json:"name,omitempty"` + Priority int64 `json:"priority"` + RateLimitDuration *ApplicationGatewayFirewallRateLimitDuration `json:"rateLimitDuration,omitempty"` + RateLimitThreshold *int64 `json:"rateLimitThreshold,omitempty"` + RuleType WebApplicationFirewallRuleType `json:"ruleType"` + State *WebApplicationFirewallState `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_webapplicationfirewallpolicy.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_webapplicationfirewallpolicy.go new file mode 100644 index 00000000000..c79f926a28c --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_webapplicationfirewallpolicy.go @@ -0,0 +1,14 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebApplicationFirewallPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WebApplicationFirewallPolicyPropertiesFormat `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_webapplicationfirewallpolicypropertiesformat.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_webapplicationfirewallpolicypropertiesformat.go new file mode 100644 index 00000000000..6379e40c5de --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_webapplicationfirewallpolicypropertiesformat.go @@ -0,0 +1,16 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebApplicationFirewallPolicyPropertiesFormat struct { + ApplicationGatewayForContainers *[]ApplicationGatewayForContainersReferenceDefinition `json:"applicationGatewayForContainers,omitempty"` + ApplicationGateways *[]ApplicationGateway `json:"applicationGateways,omitempty"` + CustomRules *[]WebApplicationFirewallCustomRule `json:"customRules,omitempty"` + HTTPListeners *[]SubResource `json:"httpListeners,omitempty"` + ManagedRules ManagedRulesDefinition `json:"managedRules"` + PathBasedRules *[]SubResource `json:"pathBasedRules,omitempty"` + PolicySettings *PolicySettings `json:"policySettings,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceState *WebApplicationFirewallPolicyResourceState `json:"resourceState,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_webapplicationfirewallscrubbingrules.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_webapplicationfirewallscrubbingrules.go new file mode 100644 index 00000000000..b3d3f6dd209 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/model_webapplicationfirewallscrubbingrules.go @@ -0,0 +1,11 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebApplicationFirewallScrubbingRules struct { + MatchVariable ScrubbingRuleEntryMatchVariable `json:"matchVariable"` + Selector *string `json:"selector,omitempty"` + SelectorMatchOperator ScrubbingRuleEntryMatchOperator `json:"selectorMatchOperator"` + State *ScrubbingRuleEntryState `json:"state,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/predicates.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/predicates.go new file mode 100644 index 00000000000..a7973b0a14f --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/predicates.go @@ -0,0 +1,37 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebApplicationFirewallPolicyOperationPredicate struct { + Etag *string + Id *string + Location *string + Name *string + Type *string +} + +func (p WebApplicationFirewallPolicyOperationPredicate) Matches(input WebApplicationFirewallPolicy) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/version.go b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/version.go new file mode 100644 index 00000000000..9df6f41e664 --- /dev/null +++ b/resource-manager/network/2024-07-01/webapplicationfirewallpolicies/version.go @@ -0,0 +1,10 @@ +package webapplicationfirewallpolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/webapplicationfirewallpolicies/2024-07-01" +} diff --git a/resource-manager/network/2024-07-01/webcategories/README.md b/resource-manager/network/2024-07-01/webcategories/README.md new file mode 100644 index 00000000000..411d0b2b780 --- /dev/null +++ b/resource-manager/network/2024-07-01/webcategories/README.md @@ -0,0 +1,54 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/webcategories` Documentation + +The `webcategories` SDK allows for interaction with Azure Resource Manager `network` (API Version `2024-07-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/network/2024-07-01/webcategories" +``` + + +### Client Initialization + +```go +client := webcategories.NewWebCategoriesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WebCategoriesClient.Get` + +```go +ctx := context.TODO() +id := webcategories.NewAzureWebCategoryID("12345678-1234-9876-4563-123456789012", "azureWebCategoryName") + +read, err := client.Get(ctx, id, webcategories.DefaultGetOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebCategoriesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/network/2024-07-01/webcategories/client.go b/resource-manager/network/2024-07-01/webcategories/client.go new file mode 100644 index 00000000000..980ef726026 --- /dev/null +++ b/resource-manager/network/2024-07-01/webcategories/client.go @@ -0,0 +1,26 @@ +package webcategories + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebCategoriesClient struct { + Client *resourcemanager.Client +} + +func NewWebCategoriesClientWithBaseURI(sdkApi sdkEnv.Api) (*WebCategoriesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "webcategories", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WebCategoriesClient: %+v", err) + } + + return &WebCategoriesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/network/2024-07-01/webcategories/id_azurewebcategory.go b/resource-manager/network/2024-07-01/webcategories/id_azurewebcategory.go new file mode 100644 index 00000000000..9e7d76c94f2 --- /dev/null +++ b/resource-manager/network/2024-07-01/webcategories/id_azurewebcategory.go @@ -0,0 +1,121 @@ +package webcategories + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AzureWebCategoryId{}) +} + +var _ resourceids.ResourceId = &AzureWebCategoryId{} + +// AzureWebCategoryId is a struct representing the Resource ID for a Azure Web Category +type AzureWebCategoryId struct { + SubscriptionId string + AzureWebCategoryName string +} + +// NewAzureWebCategoryID returns a new AzureWebCategoryId struct +func NewAzureWebCategoryID(subscriptionId string, azureWebCategoryName string) AzureWebCategoryId { + return AzureWebCategoryId{ + SubscriptionId: subscriptionId, + AzureWebCategoryName: azureWebCategoryName, + } +} + +// ParseAzureWebCategoryID parses 'input' into a AzureWebCategoryId +func ParseAzureWebCategoryID(input string) (*AzureWebCategoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&AzureWebCategoryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AzureWebCategoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAzureWebCategoryIDInsensitively parses 'input' case-insensitively into a AzureWebCategoryId +// note: this method should only be used for API response data and not user input +func ParseAzureWebCategoryIDInsensitively(input string) (*AzureWebCategoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&AzureWebCategoryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AzureWebCategoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AzureWebCategoryId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.AzureWebCategoryName, ok = input.Parsed["azureWebCategoryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "azureWebCategoryName", input) + } + + return nil +} + +// ValidateAzureWebCategoryID checks that 'input' can be parsed as a Azure Web Category ID +func ValidateAzureWebCategoryID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseAzureWebCategoryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Azure Web Category ID +func (id AzureWebCategoryId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Network/azureWebCategories/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.AzureWebCategoryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Azure Web Category ID +func (id AzureWebCategoryId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), + resourceids.StaticSegment("staticAzureWebCategories", "azureWebCategories", "azureWebCategories"), + resourceids.UserSpecifiedSegment("azureWebCategoryName", "azureWebCategoryName"), + } +} + +// String returns a human-readable description of this Azure Web Category ID +func (id AzureWebCategoryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Azure Web Category Name: %q", id.AzureWebCategoryName), + } + return fmt.Sprintf("Azure Web Category (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/network/2024-07-01/webcategories/id_azurewebcategory_test.go b/resource-manager/network/2024-07-01/webcategories/id_azurewebcategory_test.go new file mode 100644 index 00000000000..08826593ed1 --- /dev/null +++ b/resource-manager/network/2024-07-01/webcategories/id_azurewebcategory_test.go @@ -0,0 +1,237 @@ +package webcategories + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AzureWebCategoryId{} + +func TestNewAzureWebCategoryID(t *testing.T) { + id := NewAzureWebCategoryID("12345678-1234-9876-4563-123456789012", "azureWebCategoryName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.AzureWebCategoryName != "azureWebCategoryName" { + t.Fatalf("Expected %q but got %q for Segment 'AzureWebCategoryName'", id.AzureWebCategoryName, "azureWebCategoryName") + } +} + +func TestFormatAzureWebCategoryID(t *testing.T) { + actual := NewAzureWebCategoryID("12345678-1234-9876-4563-123456789012", "azureWebCategoryName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/azureWebCategories/azureWebCategoryName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAzureWebCategoryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AzureWebCategoryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/azureWebCategories", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/azureWebCategories/azureWebCategoryName", + Expected: &AzureWebCategoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + AzureWebCategoryName: "azureWebCategoryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/azureWebCategories/azureWebCategoryName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAzureWebCategoryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.AzureWebCategoryName != v.Expected.AzureWebCategoryName { + t.Fatalf("Expected %q but got %q for AzureWebCategoryName", v.Expected.AzureWebCategoryName, actual.AzureWebCategoryName) + } + + } +} + +func TestParseAzureWebCategoryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AzureWebCategoryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/azureWebCategories", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/aZuReWeBcAtEgOrIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/azureWebCategories/azureWebCategoryName", + Expected: &AzureWebCategoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + AzureWebCategoryName: "azureWebCategoryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Network/azureWebCategories/azureWebCategoryName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/aZuReWeBcAtEgOrIeS/aZuReWeBcAtEgOrYnAmE", + Expected: &AzureWebCategoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + AzureWebCategoryName: "aZuReWeBcAtEgOrYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.nEtWoRk/aZuReWeBcAtEgOrIeS/aZuReWeBcAtEgOrYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAzureWebCategoryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.AzureWebCategoryName != v.Expected.AzureWebCategoryName { + t.Fatalf("Expected %q but got %q for AzureWebCategoryName", v.Expected.AzureWebCategoryName, actual.AzureWebCategoryName) + } + + } +} + +func TestSegmentsForAzureWebCategoryId(t *testing.T) { + segments := AzureWebCategoryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AzureWebCategoryId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/network/2024-07-01/webcategories/method_get.go b/resource-manager/network/2024-07-01/webcategories/method_get.go new file mode 100644 index 00000000000..bcebcf476db --- /dev/null +++ b/resource-manager/network/2024-07-01/webcategories/method_get.go @@ -0,0 +1,83 @@ +package webcategories + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureWebCategory +} + +type GetOperationOptions struct { + Expand *string +} + +func DefaultGetOperationOptions() GetOperationOptions { + return GetOperationOptions{} +} + +func (o GetOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Expand != nil { + out.Append("$expand", fmt.Sprintf("%v", *o.Expand)) + } + return &out +} + +// Get ... +func (c WebCategoriesClient) Get(ctx context.Context, id AzureWebCategoryId, options GetOperationOptions) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AzureWebCategory + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/network/2024-07-01/webcategories/method_listbysubscription.go b/resource-manager/network/2024-07-01/webcategories/method_listbysubscription.go new file mode 100644 index 00000000000..8e55ebdbf11 --- /dev/null +++ b/resource-manager/network/2024-07-01/webcategories/method_listbysubscription.go @@ -0,0 +1,106 @@ +package webcategories + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AzureWebCategory +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []AzureWebCategory +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c WebCategoriesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Network/azureWebCategories", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AzureWebCategory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c WebCategoriesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, AzureWebCategoryOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebCategoriesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AzureWebCategoryOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]AzureWebCategory, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/network/2024-07-01/webcategories/model_azurewebcategory.go b/resource-manager/network/2024-07-01/webcategories/model_azurewebcategory.go new file mode 100644 index 00000000000..81fe8aa1777 --- /dev/null +++ b/resource-manager/network/2024-07-01/webcategories/model_azurewebcategory.go @@ -0,0 +1,12 @@ +package webcategories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWebCategory struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AzureWebCategoryPropertiesFormat `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webcategories/model_azurewebcategorypropertiesformat.go b/resource-manager/network/2024-07-01/webcategories/model_azurewebcategorypropertiesformat.go new file mode 100644 index 00000000000..7e327867064 --- /dev/null +++ b/resource-manager/network/2024-07-01/webcategories/model_azurewebcategorypropertiesformat.go @@ -0,0 +1,8 @@ +package webcategories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWebCategoryPropertiesFormat struct { + Group *string `json:"group,omitempty"` +} diff --git a/resource-manager/network/2024-07-01/webcategories/predicates.go b/resource-manager/network/2024-07-01/webcategories/predicates.go new file mode 100644 index 00000000000..ab82b0c92b5 --- /dev/null +++ b/resource-manager/network/2024-07-01/webcategories/predicates.go @@ -0,0 +1,32 @@ +package webcategories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureWebCategoryOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p AzureWebCategoryOperationPredicate) Matches(input AzureWebCategory) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/network/2024-07-01/webcategories/version.go b/resource-manager/network/2024-07-01/webcategories/version.go new file mode 100644 index 00000000000..da870644079 --- /dev/null +++ b/resource-manager/network/2024-07-01/webcategories/version.go @@ -0,0 +1,10 @@ +package webcategories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-07-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/webcategories/2024-07-01" +} diff --git a/resource-manager/recoveryservicesbackup/2023-02-01/protecteditems/README.md b/resource-manager/recoveryservicesbackup/2023-02-01/protecteditems/README.md index cc08cd0bb90..dbcde74828b 100644 --- a/resource-manager/recoveryservicesbackup/2023-02-01/protecteditems/README.md +++ b/resource-manager/recoveryservicesbackup/2023-02-01/protecteditems/README.md @@ -31,13 +31,9 @@ payload := protecteditems.ProtectedItemResource{ } -read, err := client.CreateOrUpdate(ctx, id, payload) -if err != nil { +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { // handle the error } -if model := read.Model; model != nil { - // do something with the model/response object -} ``` @@ -47,13 +43,9 @@ if model := read.Model; model != nil { ctx := context.TODO() id := protecteditems.NewProtectedItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "vaultName", "backupFabricName", "protectionContainerName", "protectedItemName") -read, err := client.Delete(ctx, id) -if err != nil { +if err := client.DeleteThenPoll(ctx, id); err != nil { // handle the error } -if model := read.Model; model != nil { - // do something with the model/response object -} ``` diff --git a/resource-manager/recoveryservicesbackup/2023-02-01/protecteditems/method_createorupdate_autorest.go b/resource-manager/recoveryservicesbackup/2023-02-01/protecteditems/method_createorupdate_autorest.go index 22eeaf22b56..eca04019892 100644 --- a/resource-manager/recoveryservicesbackup/2023-02-01/protecteditems/method_createorupdate_autorest.go +++ b/resource-manager/recoveryservicesbackup/2023-02-01/protecteditems/method_createorupdate_autorest.go @@ -2,16 +2,19 @@ package protecteditems import ( "context" + "fmt" "net/http" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" ) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type CreateOrUpdateOperationResponse struct { + Poller polling.LongRunningPoller HttpResponse *http.Response Model *ProtectedItemResource } @@ -24,19 +27,27 @@ func (c ProtectedItemsClient) CreateOrUpdate(ctx context.Context, id ProtectedIt return } - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + result, err = c.senderForCreateOrUpdate(ctx, req) if err != nil { err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "CreateOrUpdate", result.HttpResponse, "Failure sending request") return } - result, err = c.responderForCreateOrUpdate(result.HttpResponse) + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ProtectedItemsClient) CreateOrUpdateThenPoll(ctx context.Context, id ProtectedItemId, input ProtectedItemResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) if err != nil { - err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "CreateOrUpdate", result.HttpResponse, "Failure responding to request") - return + return fmt.Errorf("performing CreateOrUpdate: %+v", err) } - return + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil } // preparerForCreateOrUpdate prepares the CreateOrUpdate request. @@ -55,15 +66,15 @@ func (c ProtectedItemsClient) preparerForCreateOrUpdate(ctx context.Context, id return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// responderForCreateOrUpdate handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (c ProtectedItemsClient) responderForCreateOrUpdate(resp *http.Response) (result CreateOrUpdateOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Model), - autorest.ByClosing()) - result.HttpResponse = resp +// senderForCreateOrUpdate sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (c ProtectedItemsClient) senderForCreateOrUpdate(ctx context.Context, req *http.Request) (future CreateOrUpdateOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) return } diff --git a/resource-manager/recoveryservicesbackup/2023-02-01/protecteditems/method_delete_autorest.go b/resource-manager/recoveryservicesbackup/2023-02-01/protecteditems/method_delete_autorest.go index ed0ba3ec7a7..2b31b31ca5b 100644 --- a/resource-manager/recoveryservicesbackup/2023-02-01/protecteditems/method_delete_autorest.go +++ b/resource-manager/recoveryservicesbackup/2023-02-01/protecteditems/method_delete_autorest.go @@ -2,16 +2,19 @@ package protecteditems import ( "context" + "fmt" "net/http" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure" + "github.com/hashicorp/go-azure-helpers/polling" ) // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type DeleteOperationResponse struct { + Poller polling.LongRunningPoller HttpResponse *http.Response } @@ -23,19 +26,27 @@ func (c ProtectedItemsClient) Delete(ctx context.Context, id ProtectedItemId) (r return } - result.HttpResponse, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + result, err = c.senderForDelete(ctx, req) if err != nil { err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "Delete", result.HttpResponse, "Failure sending request") return } - result, err = c.responderForDelete(result.HttpResponse) + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ProtectedItemsClient) DeleteThenPoll(ctx context.Context, id ProtectedItemId) error { + result, err := c.Delete(ctx, id) if err != nil { - err = autorest.NewErrorWithError(err, "protecteditems.ProtectedItemsClient", "Delete", result.HttpResponse, "Failure responding to request") - return + return fmt.Errorf("performing Delete: %+v", err) } - return + if err := result.Poller.PollUntilDone(); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil } // preparerForDelete prepares the Delete request. @@ -53,14 +64,15 @@ func (c ProtectedItemsClient) preparerForDelete(ctx context.Context, id Protecte return preparer.Prepare((&http.Request{}).WithContext(ctx)) } -// responderForDelete handles the response to the Delete request. The method always -// closes the http.Response Body. -func (c ProtectedItemsClient) responderForDelete(resp *http.Response) (result DeleteOperationResponse, err error) { - err = autorest.Respond( - resp, - azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusNoContent, http.StatusOK), - autorest.ByClosing()) - result.HttpResponse = resp +// senderForDelete sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (c ProtectedItemsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { + var resp *http.Response + resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) + if err != nil { + return + } + future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) return } diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/README.md b/resource-manager/web/2024-11-01/appservicecertificateorders/README.md new file mode 100644 index 00000000000..a7b8d369a6e --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/README.md @@ -0,0 +1,381 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/appservicecertificateorders` Documentation + +The `appservicecertificateorders` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/appservicecertificateorders" +``` + + +### Client Initialization + +```go +client := appservicecertificateorders.NewAppServiceCertificateOrdersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.AppServiceCertificateOrder{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.CreateOrUpdateCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "certificateName") + +payload := appservicecertificateorders.AppServiceCertificateResource{ + // ... +} + + +if err := client.CreateOrUpdateCertificateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Delete` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.DeleteCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "certificateName") + +read, err := client.DeleteCertificate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Get` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.GetCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "certificateName") + +read, err := client.GetCertificate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ListCertificates` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +// alternatively `client.ListCertificates(ctx, id)` can be used to do batched pagination +items, err := client.ListCertificatesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Reissue` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.ReissueCertificateOrderRequest{ + // ... +} + + +read, err := client.Reissue(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Renew` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.RenewCertificateOrderRequest{ + // ... +} + + +read, err := client.Renew(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ResendEmail` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +read, err := client.ResendEmail(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ResendRequestEmails` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.NameIdentifier{ + // ... +} + + +read, err := client.ResendRequestEmails(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.RetrieveCertificateActions` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +read, err := client.RetrieveCertificateActions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.RetrieveCertificateEmailHistory` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +read, err := client.RetrieveCertificateEmailHistory(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.RetrieveSiteSeal` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.SiteSealRequest{ + // ... +} + + +read, err := client.RetrieveSiteSeal(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.Update` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +payload := appservicecertificateorders.AppServiceCertificateOrderPatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.UpdateCertificate` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "certificateName") + +payload := appservicecertificateorders.AppServiceCertificatePatchResource{ + // ... +} + + +read, err := client.UpdateCertificate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.ValidatePurchaseInformation` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := appservicecertificateorders.AppServiceCertificateOrder{ + // ... +} + + +read, err := client.ValidatePurchaseInformation(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceCertificateOrdersClient.VerifyDomainOwnership` + +```go +ctx := context.TODO() +id := appservicecertificateorders.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +read, err := client.VerifyDomainOwnership(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/client.go b/resource-manager/web/2024-11-01/appservicecertificateorders/client.go new file mode 100644 index 00000000000..a4c0860883e --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/client.go @@ -0,0 +1,26 @@ +package appservicecertificateorders + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrdersClient struct { + Client *resourcemanager.Client +} + +func NewAppServiceCertificateOrdersClientWithBaseURI(sdkApi sdkEnv.Api) (*AppServiceCertificateOrdersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "appservicecertificateorders", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AppServiceCertificateOrdersClient: %+v", err) + } + + return &AppServiceCertificateOrdersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/constants.go b/resource-manager/web/2024-11-01/appservicecertificateorders/constants.go new file mode 100644 index 00000000000..7fd04266697 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/constants.go @@ -0,0 +1,355 @@ +package appservicecertificateorders + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOrderActionType string + +const ( + CertificateOrderActionTypeCertificateExpirationWarning CertificateOrderActionType = "CertificateExpirationWarning" + CertificateOrderActionTypeCertificateExpired CertificateOrderActionType = "CertificateExpired" + CertificateOrderActionTypeCertificateIssued CertificateOrderActionType = "CertificateIssued" + CertificateOrderActionTypeCertificateOrderCanceled CertificateOrderActionType = "CertificateOrderCanceled" + CertificateOrderActionTypeCertificateOrderCreated CertificateOrderActionType = "CertificateOrderCreated" + CertificateOrderActionTypeCertificateRevoked CertificateOrderActionType = "CertificateRevoked" + CertificateOrderActionTypeDomainValidationComplete CertificateOrderActionType = "DomainValidationComplete" + CertificateOrderActionTypeFraudCleared CertificateOrderActionType = "FraudCleared" + CertificateOrderActionTypeFraudDetected CertificateOrderActionType = "FraudDetected" + CertificateOrderActionTypeFraudDocumentationRequired CertificateOrderActionType = "FraudDocumentationRequired" + CertificateOrderActionTypeOrgNameChange CertificateOrderActionType = "OrgNameChange" + CertificateOrderActionTypeOrgValidationComplete CertificateOrderActionType = "OrgValidationComplete" + CertificateOrderActionTypeSanDrop CertificateOrderActionType = "SanDrop" + CertificateOrderActionTypeUnknown CertificateOrderActionType = "Unknown" +) + +func PossibleValuesForCertificateOrderActionType() []string { + return []string{ + string(CertificateOrderActionTypeCertificateExpirationWarning), + string(CertificateOrderActionTypeCertificateExpired), + string(CertificateOrderActionTypeCertificateIssued), + string(CertificateOrderActionTypeCertificateOrderCanceled), + string(CertificateOrderActionTypeCertificateOrderCreated), + string(CertificateOrderActionTypeCertificateRevoked), + string(CertificateOrderActionTypeDomainValidationComplete), + string(CertificateOrderActionTypeFraudCleared), + string(CertificateOrderActionTypeFraudDetected), + string(CertificateOrderActionTypeFraudDocumentationRequired), + string(CertificateOrderActionTypeOrgNameChange), + string(CertificateOrderActionTypeOrgValidationComplete), + string(CertificateOrderActionTypeSanDrop), + string(CertificateOrderActionTypeUnknown), + } +} + +func (s *CertificateOrderActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateOrderActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateOrderActionType(input string) (*CertificateOrderActionType, error) { + vals := map[string]CertificateOrderActionType{ + "certificateexpirationwarning": CertificateOrderActionTypeCertificateExpirationWarning, + "certificateexpired": CertificateOrderActionTypeCertificateExpired, + "certificateissued": CertificateOrderActionTypeCertificateIssued, + "certificateordercanceled": CertificateOrderActionTypeCertificateOrderCanceled, + "certificateordercreated": CertificateOrderActionTypeCertificateOrderCreated, + "certificaterevoked": CertificateOrderActionTypeCertificateRevoked, + "domainvalidationcomplete": CertificateOrderActionTypeDomainValidationComplete, + "fraudcleared": CertificateOrderActionTypeFraudCleared, + "frauddetected": CertificateOrderActionTypeFraudDetected, + "frauddocumentationrequired": CertificateOrderActionTypeFraudDocumentationRequired, + "orgnamechange": CertificateOrderActionTypeOrgNameChange, + "orgvalidationcomplete": CertificateOrderActionTypeOrgValidationComplete, + "sandrop": CertificateOrderActionTypeSanDrop, + "unknown": CertificateOrderActionTypeUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateOrderActionType(input) + return &out, nil +} + +type CertificateOrderStatus string + +const ( + CertificateOrderStatusCanceled CertificateOrderStatus = "Canceled" + CertificateOrderStatusDenied CertificateOrderStatus = "Denied" + CertificateOrderStatusExpired CertificateOrderStatus = "Expired" + CertificateOrderStatusIssued CertificateOrderStatus = "Issued" + CertificateOrderStatusNotSubmitted CertificateOrderStatus = "NotSubmitted" + CertificateOrderStatusPendingRekey CertificateOrderStatus = "PendingRekey" + CertificateOrderStatusPendingissuance CertificateOrderStatus = "Pendingissuance" + CertificateOrderStatusPendingrevocation CertificateOrderStatus = "Pendingrevocation" + CertificateOrderStatusRevoked CertificateOrderStatus = "Revoked" + CertificateOrderStatusUnused CertificateOrderStatus = "Unused" +) + +func PossibleValuesForCertificateOrderStatus() []string { + return []string{ + string(CertificateOrderStatusCanceled), + string(CertificateOrderStatusDenied), + string(CertificateOrderStatusExpired), + string(CertificateOrderStatusIssued), + string(CertificateOrderStatusNotSubmitted), + string(CertificateOrderStatusPendingRekey), + string(CertificateOrderStatusPendingissuance), + string(CertificateOrderStatusPendingrevocation), + string(CertificateOrderStatusRevoked), + string(CertificateOrderStatusUnused), + } +} + +func (s *CertificateOrderStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateOrderStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateOrderStatus(input string) (*CertificateOrderStatus, error) { + vals := map[string]CertificateOrderStatus{ + "canceled": CertificateOrderStatusCanceled, + "denied": CertificateOrderStatusDenied, + "expired": CertificateOrderStatusExpired, + "issued": CertificateOrderStatusIssued, + "notsubmitted": CertificateOrderStatusNotSubmitted, + "pendingrekey": CertificateOrderStatusPendingRekey, + "pendingissuance": CertificateOrderStatusPendingissuance, + "pendingrevocation": CertificateOrderStatusPendingrevocation, + "revoked": CertificateOrderStatusRevoked, + "unused": CertificateOrderStatusUnused, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateOrderStatus(input) + return &out, nil +} + +type CertificateProductType string + +const ( + CertificateProductTypeStandardDomainValidatedSsl CertificateProductType = "StandardDomainValidatedSsl" + CertificateProductTypeStandardDomainValidatedWildCardSsl CertificateProductType = "StandardDomainValidatedWildCardSsl" +) + +func PossibleValuesForCertificateProductType() []string { + return []string{ + string(CertificateProductTypeStandardDomainValidatedSsl), + string(CertificateProductTypeStandardDomainValidatedWildCardSsl), + } +} + +func (s *CertificateProductType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCertificateProductType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCertificateProductType(input string) (*CertificateProductType, error) { + vals := map[string]CertificateProductType{ + "standarddomainvalidatedssl": CertificateProductTypeStandardDomainValidatedSsl, + "standarddomainvalidatedwildcardssl": CertificateProductTypeStandardDomainValidatedWildCardSsl, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CertificateProductType(input) + return &out, nil +} + +type KeyVaultSecretStatus string + +const ( + KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault KeyVaultSecretStatus = "AzureServiceUnauthorizedToAccessKeyVault" + KeyVaultSecretStatusCertificateOrderFailed KeyVaultSecretStatus = "CertificateOrderFailed" + KeyVaultSecretStatusExternalPrivateKey KeyVaultSecretStatus = "ExternalPrivateKey" + KeyVaultSecretStatusInitialized KeyVaultSecretStatus = "Initialized" + KeyVaultSecretStatusKeyVaultDoesNotExist KeyVaultSecretStatus = "KeyVaultDoesNotExist" + KeyVaultSecretStatusKeyVaultSecretDoesNotExist KeyVaultSecretStatus = "KeyVaultSecretDoesNotExist" + KeyVaultSecretStatusOperationNotPermittedOnKeyVault KeyVaultSecretStatus = "OperationNotPermittedOnKeyVault" + KeyVaultSecretStatusSucceeded KeyVaultSecretStatus = "Succeeded" + KeyVaultSecretStatusUnknown KeyVaultSecretStatus = "Unknown" + KeyVaultSecretStatusUnknownError KeyVaultSecretStatus = "UnknownError" + KeyVaultSecretStatusWaitingOnCertificateOrder KeyVaultSecretStatus = "WaitingOnCertificateOrder" +) + +func PossibleValuesForKeyVaultSecretStatus() []string { + return []string{ + string(KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault), + string(KeyVaultSecretStatusCertificateOrderFailed), + string(KeyVaultSecretStatusExternalPrivateKey), + string(KeyVaultSecretStatusInitialized), + string(KeyVaultSecretStatusKeyVaultDoesNotExist), + string(KeyVaultSecretStatusKeyVaultSecretDoesNotExist), + string(KeyVaultSecretStatusOperationNotPermittedOnKeyVault), + string(KeyVaultSecretStatusSucceeded), + string(KeyVaultSecretStatusUnknown), + string(KeyVaultSecretStatusUnknownError), + string(KeyVaultSecretStatusWaitingOnCertificateOrder), + } +} + +func (s *KeyVaultSecretStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyVaultSecretStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyVaultSecretStatus(input string) (*KeyVaultSecretStatus, error) { + vals := map[string]KeyVaultSecretStatus{ + "azureserviceunauthorizedtoaccesskeyvault": KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault, + "certificateorderfailed": KeyVaultSecretStatusCertificateOrderFailed, + "externalprivatekey": KeyVaultSecretStatusExternalPrivateKey, + "initialized": KeyVaultSecretStatusInitialized, + "keyvaultdoesnotexist": KeyVaultSecretStatusKeyVaultDoesNotExist, + "keyvaultsecretdoesnotexist": KeyVaultSecretStatusKeyVaultSecretDoesNotExist, + "operationnotpermittedonkeyvault": KeyVaultSecretStatusOperationNotPermittedOnKeyVault, + "succeeded": KeyVaultSecretStatusSucceeded, + "unknown": KeyVaultSecretStatusUnknown, + "unknownerror": KeyVaultSecretStatusUnknownError, + "waitingoncertificateorder": KeyVaultSecretStatusWaitingOnCertificateOrder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyVaultSecretStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ResourceNotRenewableReason string + +const ( + ResourceNotRenewableReasonExpirationNotInRenewalTimeRange ResourceNotRenewableReason = "ExpirationNotInRenewalTimeRange" + ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal ResourceNotRenewableReason = "RegistrationStatusNotSupportedForRenewal" + ResourceNotRenewableReasonSubscriptionNotActive ResourceNotRenewableReason = "SubscriptionNotActive" +) + +func PossibleValuesForResourceNotRenewableReason() []string { + return []string{ + string(ResourceNotRenewableReasonExpirationNotInRenewalTimeRange), + string(ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal), + string(ResourceNotRenewableReasonSubscriptionNotActive), + } +} + +func (s *ResourceNotRenewableReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceNotRenewableReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceNotRenewableReason(input string) (*ResourceNotRenewableReason, error) { + vals := map[string]ResourceNotRenewableReason{ + "expirationnotinrenewaltimerange": ResourceNotRenewableReasonExpirationNotInRenewalTimeRange, + "registrationstatusnotsupportedforrenewal": ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal, + "subscriptionnotactive": ResourceNotRenewableReasonSubscriptionNotActive, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceNotRenewableReason(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/id_certificateorder.go b/resource-manager/web/2024-11-01/appservicecertificateorders/id_certificateorder.go new file mode 100644 index 00000000000..5b740005895 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/id_certificateorder.go @@ -0,0 +1,130 @@ +package appservicecertificateorders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CertificateOrderId{}) +} + +var _ resourceids.ResourceId = &CertificateOrderId{} + +// CertificateOrderId is a struct representing the Resource ID for a Certificate Order +type CertificateOrderId struct { + SubscriptionId string + ResourceGroupName string + CertificateOrderName string +} + +// NewCertificateOrderID returns a new CertificateOrderId struct +func NewCertificateOrderID(subscriptionId string, resourceGroupName string, certificateOrderName string) CertificateOrderId { + return CertificateOrderId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateOrderName: certificateOrderName, + } +} + +// ParseCertificateOrderID parses 'input' into a CertificateOrderId +func ParseCertificateOrderID(input string) (*CertificateOrderId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateOrderIDInsensitively parses 'input' case-insensitively into a CertificateOrderId +// note: this method should only be used for API response data and not user input +func ParseCertificateOrderIDInsensitively(input string) (*CertificateOrderId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateOrderId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CertificateOrderName, ok = input.Parsed["certificateOrderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateOrderName", input) + } + + return nil +} + +// ValidateCertificateOrderID checks that 'input' can be parsed as a Certificate Order ID +func ValidateCertificateOrderID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCertificateOrderID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate Order ID +func (id CertificateOrderId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate Order ID +func (id CertificateOrderId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCertificateRegistration", "Microsoft.CertificateRegistration", "Microsoft.CertificateRegistration"), + resourceids.StaticSegment("staticCertificateOrders", "certificateOrders", "certificateOrders"), + resourceids.UserSpecifiedSegment("certificateOrderName", "certificateOrderName"), + } +} + +// String returns a human-readable description of this Certificate Order ID +func (id CertificateOrderId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Order Name: %q", id.CertificateOrderName), + } + return fmt.Sprintf("Certificate Order (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/id_certificateorder_test.go b/resource-manager/web/2024-11-01/appservicecertificateorders/id_certificateorder_test.go new file mode 100644 index 00000000000..bdd7d952c00 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/id_certificateorder_test.go @@ -0,0 +1,282 @@ +package appservicecertificateorders + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CertificateOrderId{} + +func TestNewCertificateOrderID(t *testing.T) { + id := NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CertificateOrderName != "certificateOrderName" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateOrderName'", id.CertificateOrderName, "certificateOrderName") + } +} + +func TestFormatCertificateOrderID(t *testing.T) { + actual := NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateOrderID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + } +} + +func TestParseCertificateOrderIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CertificateOrderName: "cErTiFiCaTeOrDeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + } +} + +func TestSegmentsForCertificateOrderId(t *testing.T) { + segments := CertificateOrderId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateOrderId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/id_certificateordercertificate.go b/resource-manager/web/2024-11-01/appservicecertificateorders/id_certificateordercertificate.go new file mode 100644 index 00000000000..91835e730de --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/id_certificateordercertificate.go @@ -0,0 +1,139 @@ +package appservicecertificateorders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CertificateOrderCertificateId{}) +} + +var _ resourceids.ResourceId = &CertificateOrderCertificateId{} + +// CertificateOrderCertificateId is a struct representing the Resource ID for a Certificate Order Certificate +type CertificateOrderCertificateId struct { + SubscriptionId string + ResourceGroupName string + CertificateOrderName string + CertificateName string +} + +// NewCertificateOrderCertificateID returns a new CertificateOrderCertificateId struct +func NewCertificateOrderCertificateID(subscriptionId string, resourceGroupName string, certificateOrderName string, certificateName string) CertificateOrderCertificateId { + return CertificateOrderCertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateOrderName: certificateOrderName, + CertificateName: certificateName, + } +} + +// ParseCertificateOrderCertificateID parses 'input' into a CertificateOrderCertificateId +func ParseCertificateOrderCertificateID(input string) (*CertificateOrderCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderCertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderCertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateOrderCertificateIDInsensitively parses 'input' case-insensitively into a CertificateOrderCertificateId +// note: this method should only be used for API response data and not user input +func ParseCertificateOrderCertificateIDInsensitively(input string) (*CertificateOrderCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderCertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderCertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateOrderCertificateId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CertificateOrderName, ok = input.Parsed["certificateOrderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateOrderName", input) + } + + if id.CertificateName, ok = input.Parsed["certificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateName", input) + } + + return nil +} + +// ValidateCertificateOrderCertificateID checks that 'input' can be parsed as a Certificate Order Certificate ID +func ValidateCertificateOrderCertificateID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCertificateOrderCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate Order Certificate ID +func (id CertificateOrderCertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName, id.CertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate Order Certificate ID +func (id CertificateOrderCertificateId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCertificateRegistration", "Microsoft.CertificateRegistration", "Microsoft.CertificateRegistration"), + resourceids.StaticSegment("staticCertificateOrders", "certificateOrders", "certificateOrders"), + resourceids.UserSpecifiedSegment("certificateOrderName", "certificateOrderName"), + resourceids.StaticSegment("staticCertificates", "certificates", "certificates"), + resourceids.UserSpecifiedSegment("certificateName", "certificateName"), + } +} + +// String returns a human-readable description of this Certificate Order Certificate ID +func (id CertificateOrderCertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Order Name: %q", id.CertificateOrderName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Certificate Order Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/id_certificateordercertificate_test.go b/resource-manager/web/2024-11-01/appservicecertificateorders/id_certificateordercertificate_test.go new file mode 100644 index 00000000000..8b5bb4327c3 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/id_certificateordercertificate_test.go @@ -0,0 +1,327 @@ +package appservicecertificateorders + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CertificateOrderCertificateId{} + +func TestNewCertificateOrderCertificateID(t *testing.T) { + id := NewCertificateOrderCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "certificateName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CertificateOrderName != "certificateOrderName" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateOrderName'", id.CertificateOrderName, "certificateOrderName") + } + + if id.CertificateName != "certificateName" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateName'", id.CertificateName, "certificateName") + } +} + +func TestFormatCertificateOrderCertificateID(t *testing.T) { + actual := NewCertificateOrderCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "certificateName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/certificates/certificateName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateOrderCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderCertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/certificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/certificates/certificateName", + Expected: &CertificateOrderCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderName", + CertificateName: "certificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/certificates/certificateName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestParseCertificateOrderCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderCertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/certificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE/cErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/certificates/certificateName", + Expected: &CertificateOrderCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderName", + CertificateName: "certificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/certificates/certificateName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE/cErTiFiCaTeS/cErTiFiCaTeNaMe", + Expected: &CertificateOrderCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CertificateOrderName: "cErTiFiCaTeOrDeRnAmE", + CertificateName: "cErTiFiCaTeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE/cErTiFiCaTeS/cErTiFiCaTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestSegmentsForCertificateOrderCertificateId(t *testing.T) { + segments := CertificateOrderCertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateOrderCertificateId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_createorupdate.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_createorupdate.go new file mode 100644 index 00000000000..0ee50f71694 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_createorupdate.go @@ -0,0 +1,75 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateOrder +} + +// CreateOrUpdate ... +func (c AppServiceCertificateOrdersClient) CreateOrUpdate(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrder) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AppServiceCertificateOrdersClient) CreateOrUpdateThenPoll(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrder) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_createorupdatecertificate.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_createorupdatecertificate.go new file mode 100644 index 00000000000..013318e02e8 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_createorupdatecertificate.go @@ -0,0 +1,75 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateCertificateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateResource +} + +// CreateOrUpdateCertificate ... +func (c AppServiceCertificateOrdersClient) CreateOrUpdateCertificate(ctx context.Context, id CertificateOrderCertificateId, input AppServiceCertificateResource) (result CreateOrUpdateCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateCertificateThenPoll performs CreateOrUpdateCertificate then polls until it's completed +func (c AppServiceCertificateOrdersClient) CreateOrUpdateCertificateThenPoll(ctx context.Context, id CertificateOrderCertificateId, input AppServiceCertificateResource) error { + result, err := c.CreateOrUpdateCertificate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateCertificate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateCertificate: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_delete.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_delete.go new file mode 100644 index 00000000000..f8f40a08c11 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_delete.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c AppServiceCertificateOrdersClient) Delete(ctx context.Context, id CertificateOrderId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_deletecertificate.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_deletecertificate.go new file mode 100644 index 00000000000..98b4359fd23 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_deletecertificate.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteCertificate ... +func (c AppServiceCertificateOrdersClient) DeleteCertificate(ctx context.Context, id CertificateOrderCertificateId) (result DeleteCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_get.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_get.go new file mode 100644 index 00000000000..452a170346a --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_get.go @@ -0,0 +1,53 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateOrder +} + +// Get ... +func (c AppServiceCertificateOrdersClient) Get(ctx context.Context, id CertificateOrderId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServiceCertificateOrder + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_getcertificate.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_getcertificate.go new file mode 100644 index 00000000000..712789271ae --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_getcertificate.go @@ -0,0 +1,53 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateResource +} + +// GetCertificate ... +func (c AppServiceCertificateOrdersClient) GetCertificate(ctx context.Context, id CertificateOrderCertificateId) (result GetCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServiceCertificateResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_list.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_list.go new file mode 100644 index 00000000000..dc2a1437f6d --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_list.go @@ -0,0 +1,106 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceCertificateOrder +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceCertificateOrder +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c AppServiceCertificateOrdersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/certificateOrders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServiceCertificateOrder `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AppServiceCertificateOrdersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AppServiceCertificateOrderOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AppServiceCertificateOrderOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AppServiceCertificateOrder, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_listbyresourcegroup.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_listbyresourcegroup.go new file mode 100644 index 00000000000..e800bd4359e --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceCertificateOrder +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceCertificateOrder +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c AppServiceCertificateOrdersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/certificateOrders", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServiceCertificateOrder `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AppServiceCertificateOrdersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AppServiceCertificateOrderOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AppServiceCertificateOrderOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AppServiceCertificateOrder, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_listcertificates.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_listcertificates.go new file mode 100644 index 00000000000..04a478191c0 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_listcertificates.go @@ -0,0 +1,105 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListCertificatesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceCertificateResource +} + +type ListCertificatesCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceCertificateResource +} + +type ListCertificatesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCertificatesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListCertificates ... +func (c AppServiceCertificateOrdersClient) ListCertificates(ctx context.Context, id CertificateOrderId) (result ListCertificatesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCertificatesCustomPager{}, + Path: fmt.Sprintf("%s/certificates", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServiceCertificateResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListCertificatesComplete retrieves all the results into a single object +func (c AppServiceCertificateOrdersClient) ListCertificatesComplete(ctx context.Context, id CertificateOrderId) (ListCertificatesCompleteResult, error) { + return c.ListCertificatesCompleteMatchingPredicate(ctx, id, AppServiceCertificateResourceOperationPredicate{}) +} + +// ListCertificatesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceCertificateOrdersClient) ListCertificatesCompleteMatchingPredicate(ctx context.Context, id CertificateOrderId, predicate AppServiceCertificateResourceOperationPredicate) (result ListCertificatesCompleteResult, err error) { + items := make([]AppServiceCertificateResource, 0) + + resp, err := c.ListCertificates(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCertificatesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_reissue.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_reissue.go new file mode 100644 index 00000000000..91b863f81f7 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_reissue.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReissueOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Reissue ... +func (c AppServiceCertificateOrdersClient) Reissue(ctx context.Context, id CertificateOrderId, input ReissueCertificateOrderRequest) (result ReissueOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reissue", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_renew.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_renew.go new file mode 100644 index 00000000000..0d15451ed17 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_renew.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Renew ... +func (c AppServiceCertificateOrdersClient) Renew(ctx context.Context, id CertificateOrderId, input RenewCertificateOrderRequest) (result RenewOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/renew", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_resendemail.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_resendemail.go new file mode 100644 index 00000000000..49de4389c59 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_resendemail.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResendEmailOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResendEmail ... +func (c AppServiceCertificateOrdersClient) ResendEmail(ctx context.Context, id CertificateOrderId) (result ResendEmailOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resendEmail", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_resendrequestemails.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_resendrequestemails.go new file mode 100644 index 00000000000..e758b4dd706 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_resendrequestemails.go @@ -0,0 +1,51 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResendRequestEmailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResendRequestEmails ... +func (c AppServiceCertificateOrdersClient) ResendRequestEmails(ctx context.Context, id CertificateOrderId, input NameIdentifier) (result ResendRequestEmailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resendRequestEmails", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_retrievecertificateactions.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_retrievecertificateactions.go new file mode 100644 index 00000000000..51a8af70e7f --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_retrievecertificateactions.go @@ -0,0 +1,54 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetrieveCertificateActionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CertificateOrderAction +} + +// RetrieveCertificateActions ... +func (c AppServiceCertificateOrdersClient) RetrieveCertificateActions(ctx context.Context, id CertificateOrderId) (result RetrieveCertificateActionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveCertificateActions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []CertificateOrderAction + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_retrievecertificateemailhistory.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_retrievecertificateemailhistory.go new file mode 100644 index 00000000000..84feccdb804 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_retrievecertificateemailhistory.go @@ -0,0 +1,54 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetrieveCertificateEmailHistoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CertificateEmail +} + +// RetrieveCertificateEmailHistory ... +func (c AppServiceCertificateOrdersClient) RetrieveCertificateEmailHistory(ctx context.Context, id CertificateOrderId) (result RetrieveCertificateEmailHistoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveEmailHistory", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []CertificateEmail + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_retrievesiteseal.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_retrievesiteseal.go new file mode 100644 index 00000000000..160d1b5010b --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_retrievesiteseal.go @@ -0,0 +1,58 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetrieveSiteSealOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSeal +} + +// RetrieveSiteSeal ... +func (c AppServiceCertificateOrdersClient) RetrieveSiteSeal(ctx context.Context, id CertificateOrderId, input SiteSealRequest) (result RetrieveSiteSealOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/retrieveSiteSeal", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteSeal + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_update.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_update.go new file mode 100644 index 00000000000..cebc44fbccc --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_update.go @@ -0,0 +1,57 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateOrder +} + +// Update ... +func (c AppServiceCertificateOrdersClient) Update(ctx context.Context, id CertificateOrderId, input AppServiceCertificateOrderPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServiceCertificateOrder + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_updatecertificate.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_updatecertificate.go new file mode 100644 index 00000000000..dbb5136b153 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_updatecertificate.go @@ -0,0 +1,57 @@ +package appservicecertificateorders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceCertificateResource +} + +// UpdateCertificate ... +func (c AppServiceCertificateOrdersClient) UpdateCertificate(ctx context.Context, id CertificateOrderCertificateId, input AppServiceCertificatePatchResource) (result UpdateCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServiceCertificateResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_validatepurchaseinformation.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_validatepurchaseinformation.go new file mode 100644 index 00000000000..1a4c9a08f69 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_validatepurchaseinformation.go @@ -0,0 +1,52 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidatePurchaseInformationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ValidatePurchaseInformation ... +func (c AppServiceCertificateOrdersClient) ValidatePurchaseInformation(ctx context.Context, id commonids.SubscriptionId, input AppServiceCertificateOrder) (result ValidatePurchaseInformationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.CertificateRegistration/validateCertificateRegistrationInformation", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/method_verifydomainownership.go b/resource-manager/web/2024-11-01/appservicecertificateorders/method_verifydomainownership.go new file mode 100644 index 00000000000..413d5008994 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/method_verifydomainownership.go @@ -0,0 +1,47 @@ +package appservicecertificateorders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VerifyDomainOwnershipOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// VerifyDomainOwnership ... +func (c AppServiceCertificateOrdersClient) VerifyDomainOwnership(ctx context.Context, id CertificateOrderId) (result VerifyDomainOwnershipOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/verifyDomainOwnership", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificate.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificate.go new file mode 100644 index 00000000000..5572932e257 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificate.go @@ -0,0 +1,10 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificate struct { + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultSecretName *string `json:"keyVaultSecretName,omitempty"` + ProvisioningState *KeyVaultSecretStatus `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificateorder.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificateorder.go new file mode 100644 index 00000000000..3f171abb6db --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificateorder.go @@ -0,0 +1,14 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrder struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificateOrderProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go new file mode 100644 index 00000000000..f0b6b7d477d --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificateorderpatchresource.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrderPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificateOrderPatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go new file mode 100644 index 00000000000..4657e81b440 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificateorderpatchresourceproperties.go @@ -0,0 +1,69 @@ +package appservicecertificateorders + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrderPatchResourceProperties struct { + AppServiceCertificateNotRenewableReasons *[]ResourceNotRenewableReason `json:"appServiceCertificateNotRenewableReasons,omitempty"` + AutoRenew *bool `json:"autoRenew,omitempty"` + Certificates *map[string]AppServiceCertificate `json:"certificates,omitempty"` + Contact *CertificateOrderContact `json:"contact,omitempty"` + Csr *string `json:"csr,omitempty"` + DistinguishedName *string `json:"distinguishedName,omitempty"` + DomainVerificationToken *string `json:"domainVerificationToken,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + Intermediate *CertificateDetails `json:"intermediate,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` + LastCertificateIssuanceTime *string `json:"lastCertificateIssuanceTime,omitempty"` + NextAutoRenewalTimeStamp *string `json:"nextAutoRenewalTimeStamp,omitempty"` + ProductType CertificateProductType `json:"productType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Root *CertificateDetails `json:"root,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SignedCertificate *CertificateDetails `json:"signedCertificate,omitempty"` + Status *CertificateOrderStatus `json:"status,omitempty"` + ValidityInYears *int64 `json:"validityInYears,omitempty"` +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) GetLastCertificateIssuanceTimeAsTime() (*time.Time, error) { + if o.LastCertificateIssuanceTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastCertificateIssuanceTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) SetLastCertificateIssuanceTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastCertificateIssuanceTime = &formatted +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) GetNextAutoRenewalTimeStampAsTime() (*time.Time, error) { + if o.NextAutoRenewalTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextAutoRenewalTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderPatchResourceProperties) SetNextAutoRenewalTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextAutoRenewalTimeStamp = &formatted +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificateorderproperties.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificateorderproperties.go new file mode 100644 index 00000000000..9b30d4ae973 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificateorderproperties.go @@ -0,0 +1,69 @@ +package appservicecertificateorders + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrderProperties struct { + AppServiceCertificateNotRenewableReasons *[]ResourceNotRenewableReason `json:"appServiceCertificateNotRenewableReasons,omitempty"` + AutoRenew *bool `json:"autoRenew,omitempty"` + Certificates *map[string]AppServiceCertificate `json:"certificates,omitempty"` + Contact *CertificateOrderContact `json:"contact,omitempty"` + Csr *string `json:"csr,omitempty"` + DistinguishedName *string `json:"distinguishedName,omitempty"` + DomainVerificationToken *string `json:"domainVerificationToken,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + Intermediate *CertificateDetails `json:"intermediate,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` + LastCertificateIssuanceTime *string `json:"lastCertificateIssuanceTime,omitempty"` + NextAutoRenewalTimeStamp *string `json:"nextAutoRenewalTimeStamp,omitempty"` + ProductType CertificateProductType `json:"productType"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Root *CertificateDetails `json:"root,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SignedCertificate *CertificateDetails `json:"signedCertificate,omitempty"` + Status *CertificateOrderStatus `json:"status,omitempty"` + ValidityInYears *int64 `json:"validityInYears,omitempty"` +} + +func (o *AppServiceCertificateOrderProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *AppServiceCertificateOrderProperties) GetLastCertificateIssuanceTimeAsTime() (*time.Time, error) { + if o.LastCertificateIssuanceTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastCertificateIssuanceTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderProperties) SetLastCertificateIssuanceTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastCertificateIssuanceTime = &formatted +} + +func (o *AppServiceCertificateOrderProperties) GetNextAutoRenewalTimeStampAsTime() (*time.Time, error) { + if o.NextAutoRenewalTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextAutoRenewalTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServiceCertificateOrderProperties) SetNextAutoRenewalTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextAutoRenewalTimeStamp = &formatted +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificatepatchresource.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificatepatchresource.go new file mode 100644 index 00000000000..8f8d91b6c87 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificatepatchresource.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificatePatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificate `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificateresource.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificateresource.go new file mode 100644 index 00000000000..7cd601e38f7 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_appservicecertificateresource.go @@ -0,0 +1,14 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServiceCertificate `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_certificatedetails.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_certificatedetails.go new file mode 100644 index 00000000000..6905351a7c5 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_certificatedetails.go @@ -0,0 +1,46 @@ +package appservicecertificateorders + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateDetails struct { + Issuer *string `json:"issuer,omitempty"` + NotAfter *string `json:"notAfter,omitempty"` + NotBefore *string `json:"notBefore,omitempty"` + RawData *string `json:"rawData,omitempty"` + SerialNumber *string `json:"serialNumber,omitempty"` + SignatureAlgorithm *string `json:"signatureAlgorithm,omitempty"` + Subject *string `json:"subject,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Version *int64 `json:"version,omitempty"` +} + +func (o *CertificateDetails) GetNotAfterAsTime() (*time.Time, error) { + if o.NotAfter == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NotAfter, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateDetails) SetNotAfterAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NotAfter = &formatted +} + +func (o *CertificateDetails) GetNotBeforeAsTime() (*time.Time, error) { + if o.NotBefore == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NotBefore, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateDetails) SetNotBeforeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NotBefore = &formatted +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_certificateemail.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_certificateemail.go new file mode 100644 index 00000000000..27ec4e4d6f2 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_certificateemail.go @@ -0,0 +1,27 @@ +package appservicecertificateorders + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateEmail struct { + EmailId *string `json:"emailId,omitempty"` + TimeStamp *string `json:"timeStamp,omitempty"` +} + +func (o *CertificateEmail) GetTimeStampAsTime() (*time.Time, error) { + if o.TimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateEmail) SetTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeStamp = &formatted +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_certificateorderaction.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_certificateorderaction.go new file mode 100644 index 00000000000..5a7f75ca664 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_certificateorderaction.go @@ -0,0 +1,27 @@ +package appservicecertificateorders + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOrderAction struct { + ActionType *CertificateOrderActionType `json:"actionType,omitempty"` + CreatedAt *string `json:"createdAt,omitempty"` +} + +func (o *CertificateOrderAction) GetCreatedAtAsTime() (*time.Time, error) { + if o.CreatedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateOrderAction) SetCreatedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedAt = &formatted +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_certificateordercontact.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_certificateordercontact.go new file mode 100644 index 00000000000..65e867d2102 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_certificateordercontact.go @@ -0,0 +1,11 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOrderContact struct { + Email *string `json:"email,omitempty"` + NameFirst *string `json:"nameFirst,omitempty"` + NameLast *string `json:"nameLast,omitempty"` + Phone *string `json:"phone,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_nameidentifier.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_nameidentifier.go new file mode 100644 index 00000000000..72477ac557d --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_nameidentifier.go @@ -0,0 +1,8 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameIdentifier struct { + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_reissuecertificateorderrequest.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_reissuecertificateorderrequest.go new file mode 100644 index 00000000000..15d4fec9572 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_reissuecertificateorderrequest.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReissueCertificateOrderRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ReissueCertificateOrderRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go new file mode 100644 index 00000000000..edcc06283c9 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_reissuecertificateorderrequestproperties.go @@ -0,0 +1,11 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ReissueCertificateOrderRequestProperties struct { + Csr *string `json:"csr,omitempty"` + DelayExistingRevokeInHours *int64 `json:"delayExistingRevokeInHours,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_renewcertificateorderrequest.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_renewcertificateorderrequest.go new file mode 100644 index 00000000000..cacc0bada97 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_renewcertificateorderrequest.go @@ -0,0 +1,12 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateOrderRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RenewCertificateOrderRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go new file mode 100644 index 00000000000..161c783b54e --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_renewcertificateorderrequestproperties.go @@ -0,0 +1,10 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewCertificateOrderRequestProperties struct { + Csr *string `json:"csr,omitempty"` + IsPrivateKeyExternal *bool `json:"isPrivateKeyExternal,omitempty"` + KeySize *int64 `json:"keySize,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_siteseal.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_siteseal.go new file mode 100644 index 00000000000..64f302c54e8 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_siteseal.go @@ -0,0 +1,8 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteSeal struct { + Html string `json:"html"` +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/model_sitesealrequest.go b/resource-manager/web/2024-11-01/appservicecertificateorders/model_sitesealrequest.go new file mode 100644 index 00000000000..ed81319016d --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/model_sitesealrequest.go @@ -0,0 +1,9 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteSealRequest struct { + LightTheme *bool `json:"lightTheme,omitempty"` + Locale *string `json:"locale,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/predicates.go b/resource-manager/web/2024-11-01/appservicecertificateorders/predicates.go new file mode 100644 index 00000000000..e7457040d0b --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/predicates.go @@ -0,0 +1,70 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceCertificateOrderOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServiceCertificateOrderOperationPredicate) Matches(input AppServiceCertificateOrder) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type AppServiceCertificateResourceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServiceCertificateResourceOperationPredicate) Matches(input AppServiceCertificateResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/appservicecertificateorders/version.go b/resource-manager/web/2024-11-01/appservicecertificateorders/version.go new file mode 100644 index 00000000000..7a1364a2a64 --- /dev/null +++ b/resource-manager/web/2024-11-01/appservicecertificateorders/version.go @@ -0,0 +1,10 @@ +package appservicecertificateorders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/appservicecertificateorders/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/README.md b/resource-manager/web/2024-11-01/appserviceenvironments/README.md new file mode 100644 index 00000000000..491f7b3a041 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/README.md @@ -0,0 +1,833 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/appserviceenvironments` Documentation + +The `appserviceenvironments` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/appserviceenvironments" +``` + + +### Client Initialization + +```go +client := appserviceenvironments.NewAppServiceEnvironmentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ApproveOrRejectPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewHostingEnvironmentPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "privateEndpointConnectionName") + +payload := appserviceenvironments.RemotePrivateEndpointConnectionARMResource{ + // ... +} + + +if err := client.ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ChangeVnet` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +payload := appserviceenvironments.VirtualNetworkProfile{ + // ... +} + + +// alternatively `client.ChangeVnet(ctx, id, payload)` can be used to do batched pagination +items, err := client.ChangeVnetComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +payload := appserviceenvironments.AppServiceEnvironmentResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.CreateOrUpdateMultiRolePool` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +payload := appserviceenvironments.WorkerPoolResource{ + // ... +} + + +if err := client.CreateOrUpdateMultiRolePoolThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.CreateOrUpdateWorkerPool` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName") + +payload := appserviceenvironments.WorkerPoolResource{ + // ... +} + + +if err := client.CreateOrUpdateWorkerPoolThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +if err := client.DeleteThenPoll(ctx, id, appserviceenvironments.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.DeleteAseCustomDnsSuffixConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.DeleteAseCustomDnsSuffixConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.DeletePrivateEndpointConnection` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewHostingEnvironmentPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "privateEndpointConnectionName") + +if err := client.DeletePrivateEndpointConnectionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetAseCustomDnsSuffixConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.GetAseCustomDnsSuffixConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetAseV3NetworkingConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.GetAseV3NetworkingConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetDiagnosticsItem` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewHostingEnvironmentDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "diagnosticName") + +read, err := client.GetDiagnosticsItem(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetInboundNetworkDependenciesEndpoints` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.GetInboundNetworkDependenciesEndpoints(ctx, id)` can be used to do batched pagination +items, err := client.GetInboundNetworkDependenciesEndpointsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetMultiRolePool` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.GetMultiRolePool(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetOutboundNetworkDependenciesEndpoints` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.GetOutboundNetworkDependenciesEndpoints(ctx, id)` can be used to do batched pagination +items, err := client.GetOutboundNetworkDependenciesEndpointsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewHostingEnvironmentPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "privateEndpointConnectionName") + +read, err := client.GetPrivateEndpointConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetPrivateEndpointConnectionList` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.GetPrivateEndpointConnectionList(ctx, id)` can be used to do batched pagination +items, err := client.GetPrivateEndpointConnectionListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetPrivateLinkResources` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.GetPrivateLinkResources(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetVipInfo` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.GetVipInfo(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.GetWorkerPool` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName") + +read, err := client.GetWorkerPool(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListAppServicePlans` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListAppServicePlans(ctx, id)` can be used to do batched pagination +items, err := client.ListAppServicePlansComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListCapacities` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListCapacities(ctx, id)` can be used to do batched pagination +items, err := client.ListCapacitiesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListDiagnostics` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.ListDiagnostics(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListMultiRoleMetricDefinitions` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListMultiRoleMetricDefinitions(ctx, id)` can be used to do batched pagination +items, err := client.ListMultiRoleMetricDefinitionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListMultiRolePoolInstanceMetricDefinitions` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewDefaultInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "instanceName") + +// alternatively `client.ListMultiRolePoolInstanceMetricDefinitions(ctx, id)` can be used to do batched pagination +items, err := client.ListMultiRolePoolInstanceMetricDefinitionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListMultiRolePoolSkus` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListMultiRolePoolSkus(ctx, id)` can be used to do batched pagination +items, err := client.ListMultiRolePoolSkusComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListMultiRolePools` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListMultiRolePools(ctx, id)` can be used to do batched pagination +items, err := client.ListMultiRolePoolsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListMultiRoleUsages` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListMultiRoleUsages(ctx, id)` can be used to do batched pagination +items, err := client.ListMultiRoleUsagesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListOperations` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.ListOperations(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListUsages` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListUsages(ctx, id, appserviceenvironments.DefaultListUsagesOperationOptions())` can be used to do batched pagination +items, err := client.ListUsagesComplete(ctx, id, appserviceenvironments.DefaultListUsagesOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWebApps` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListWebApps(ctx, id, appserviceenvironments.DefaultListWebAppsOperationOptions())` can be used to do batched pagination +items, err := client.ListWebAppsComplete(ctx, id, appserviceenvironments.DefaultListWebAppsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWebWorkerMetricDefinitions` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName") + +// alternatively `client.ListWebWorkerMetricDefinitions(ctx, id)` can be used to do batched pagination +items, err := client.ListWebWorkerMetricDefinitionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWebWorkerUsages` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName") + +// alternatively `client.ListWebWorkerUsages(ctx, id)` can be used to do batched pagination +items, err := client.ListWebWorkerUsagesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWorkerPoolInstanceMetricDefinitions` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName", "instanceName") + +// alternatively `client.ListWorkerPoolInstanceMetricDefinitions(ctx, id)` can be used to do batched pagination +items, err := client.ListWorkerPoolInstanceMetricDefinitionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWorkerPoolSkus` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName") + +// alternatively `client.ListWorkerPoolSkus(ctx, id)` can be used to do batched pagination +items, err := client.ListWorkerPoolSkusComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.ListWorkerPools` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListWorkerPools(ctx, id)` can be used to do batched pagination +items, err := client.ListWorkerPoolsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Reboot` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.Reboot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Resume` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.Resume(ctx, id)` can be used to do batched pagination +items, err := client.ResumeComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Suspend` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.Suspend(ctx, id)` can be used to do batched pagination +items, err := client.SuspendComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.TestUpgradeAvailableNotification` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.TestUpgradeAvailableNotification(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Update` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +payload := appserviceenvironments.AppServiceEnvironmentPatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.UpdateAseCustomDnsSuffixConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +payload := appserviceenvironments.CustomDnsSuffixConfiguration{ + // ... +} + + +read, err := client.UpdateAseCustomDnsSuffixConfiguration(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.UpdateAseNetworkingConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +payload := appserviceenvironments.AseV3NetworkingConfiguration{ + // ... +} + + +read, err := client.UpdateAseNetworkingConfiguration(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.UpdateMultiRolePool` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +payload := appserviceenvironments.WorkerPoolResource{ + // ... +} + + +read, err := client.UpdateMultiRolePool(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.UpdateWorkerPool` + +```go +ctx := context.TODO() +id := appserviceenvironments.NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName") + +payload := appserviceenvironments.WorkerPoolResource{ + // ... +} + + +read, err := client.UpdateWorkerPool(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServiceEnvironmentsClient.Upgrade` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +if err := client.UpgradeThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/client.go b/resource-manager/web/2024-11-01/appserviceenvironments/client.go new file mode 100644 index 00000000000..706ca7d556d --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/client.go @@ -0,0 +1,26 @@ +package appserviceenvironments + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceEnvironmentsClient struct { + Client *resourcemanager.Client +} + +func NewAppServiceEnvironmentsClientWithBaseURI(sdkApi sdkEnv.Api) (*AppServiceEnvironmentsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "appserviceenvironments", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AppServiceEnvironmentsClient: %+v", err) + } + + return &AppServiceEnvironmentsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/constants.go b/resource-manager/web/2024-11-01/appserviceenvironments/constants.go new file mode 100644 index 00000000000..bd1d791b853 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/constants.go @@ -0,0 +1,1715 @@ +package appserviceenvironments + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthenticationType string + +const ( + AuthenticationTypeStorageAccountConnectionString AuthenticationType = "StorageAccountConnectionString" + AuthenticationTypeSystemAssignedIdentity AuthenticationType = "SystemAssignedIdentity" + AuthenticationTypeUserAssignedIdentity AuthenticationType = "UserAssignedIdentity" +) + +func PossibleValuesForAuthenticationType() []string { + return []string{ + string(AuthenticationTypeStorageAccountConnectionString), + string(AuthenticationTypeSystemAssignedIdentity), + string(AuthenticationTypeUserAssignedIdentity), + } +} + +func (s *AuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationType(input string) (*AuthenticationType, error) { + vals := map[string]AuthenticationType{ + "storageaccountconnectionstring": AuthenticationTypeStorageAccountConnectionString, + "systemassignedidentity": AuthenticationTypeSystemAssignedIdentity, + "userassignedidentity": AuthenticationTypeUserAssignedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationType(input) + return &out, nil +} + +type AutoGeneratedDomainNameLabelScope string + +const ( + AutoGeneratedDomainNameLabelScopeNoReuse AutoGeneratedDomainNameLabelScope = "NoReuse" + AutoGeneratedDomainNameLabelScopeResourceGroupReuse AutoGeneratedDomainNameLabelScope = "ResourceGroupReuse" + AutoGeneratedDomainNameLabelScopeSubscriptionReuse AutoGeneratedDomainNameLabelScope = "SubscriptionReuse" + AutoGeneratedDomainNameLabelScopeTenantReuse AutoGeneratedDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForAutoGeneratedDomainNameLabelScope() []string { + return []string{ + string(AutoGeneratedDomainNameLabelScopeNoReuse), + string(AutoGeneratedDomainNameLabelScopeResourceGroupReuse), + string(AutoGeneratedDomainNameLabelScopeSubscriptionReuse), + string(AutoGeneratedDomainNameLabelScopeTenantReuse), + } +} + +func (s *AutoGeneratedDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoGeneratedDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoGeneratedDomainNameLabelScope(input string) (*AutoGeneratedDomainNameLabelScope, error) { + vals := map[string]AutoGeneratedDomainNameLabelScope{ + "noreuse": AutoGeneratedDomainNameLabelScopeNoReuse, + "resourcegroupreuse": AutoGeneratedDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": AutoGeneratedDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": AutoGeneratedDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoGeneratedDomainNameLabelScope(input) + return &out, nil +} + +type AutoHealActionType string + +const ( + AutoHealActionTypeCustomAction AutoHealActionType = "CustomAction" + AutoHealActionTypeLogEvent AutoHealActionType = "LogEvent" + AutoHealActionTypeRecycle AutoHealActionType = "Recycle" +) + +func PossibleValuesForAutoHealActionType() []string { + return []string{ + string(AutoHealActionTypeCustomAction), + string(AutoHealActionTypeLogEvent), + string(AutoHealActionTypeRecycle), + } +} + +func (s *AutoHealActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoHealActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoHealActionType(input string) (*AutoHealActionType, error) { + vals := map[string]AutoHealActionType{ + "customaction": AutoHealActionTypeCustomAction, + "logevent": AutoHealActionTypeLogEvent, + "recycle": AutoHealActionTypeRecycle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoHealActionType(input) + return &out, nil +} + +type AzureStorageProtocol string + +const ( + AzureStorageProtocolHTTP AzureStorageProtocol = "Http" + AzureStorageProtocolNfs AzureStorageProtocol = "Nfs" + AzureStorageProtocolSmb AzureStorageProtocol = "Smb" +) + +func PossibleValuesForAzureStorageProtocol() []string { + return []string{ + string(AzureStorageProtocolHTTP), + string(AzureStorageProtocolNfs), + string(AzureStorageProtocolSmb), + } +} + +func (s *AzureStorageProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageProtocol(input string) (*AzureStorageProtocol, error) { + vals := map[string]AzureStorageProtocol{ + "http": AzureStorageProtocolHTTP, + "nfs": AzureStorageProtocolNfs, + "smb": AzureStorageProtocolSmb, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageProtocol(input) + return &out, nil +} + +type AzureStorageState string + +const ( + AzureStorageStateInvalidCredentials AzureStorageState = "InvalidCredentials" + AzureStorageStateInvalidShare AzureStorageState = "InvalidShare" + AzureStorageStateNotValidated AzureStorageState = "NotValidated" + AzureStorageStateOk AzureStorageState = "Ok" +) + +func PossibleValuesForAzureStorageState() []string { + return []string{ + string(AzureStorageStateInvalidCredentials), + string(AzureStorageStateInvalidShare), + string(AzureStorageStateNotValidated), + string(AzureStorageStateOk), + } +} + +func (s *AzureStorageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageState(input string) (*AzureStorageState, error) { + vals := map[string]AzureStorageState{ + "invalidcredentials": AzureStorageStateInvalidCredentials, + "invalidshare": AzureStorageStateInvalidShare, + "notvalidated": AzureStorageStateNotValidated, + "ok": AzureStorageStateOk, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageState(input) + return &out, nil +} + +type AzureStorageType string + +const ( + AzureStorageTypeAzureBlob AzureStorageType = "AzureBlob" + AzureStorageTypeAzureFiles AzureStorageType = "AzureFiles" +) + +func PossibleValuesForAzureStorageType() []string { + return []string{ + string(AzureStorageTypeAzureBlob), + string(AzureStorageTypeAzureFiles), + } +} + +func (s *AzureStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageType(input string) (*AzureStorageType, error) { + vals := map[string]AzureStorageType{ + "azureblob": AzureStorageTypeAzureBlob, + "azurefiles": AzureStorageTypeAzureFiles, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageType(input) + return &out, nil +} + +type ClientCertMode string + +const ( + ClientCertModeOptional ClientCertMode = "Optional" + ClientCertModeOptionalInteractiveUser ClientCertMode = "OptionalInteractiveUser" + ClientCertModeRequired ClientCertMode = "Required" +) + +func PossibleValuesForClientCertMode() []string { + return []string{ + string(ClientCertModeOptional), + string(ClientCertModeOptionalInteractiveUser), + string(ClientCertModeRequired), + } +} + +func (s *ClientCertMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientCertMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClientCertMode(input string) (*ClientCertMode, error) { + vals := map[string]ClientCertMode{ + "optional": ClientCertModeOptional, + "optionalinteractiveuser": ClientCertModeOptionalInteractiveUser, + "required": ClientCertModeRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClientCertMode(input) + return &out, nil +} + +type ComputeModeOptions string + +const ( + ComputeModeOptionsDedicated ComputeModeOptions = "Dedicated" + ComputeModeOptionsDynamic ComputeModeOptions = "Dynamic" + ComputeModeOptionsShared ComputeModeOptions = "Shared" +) + +func PossibleValuesForComputeModeOptions() []string { + return []string{ + string(ComputeModeOptionsDedicated), + string(ComputeModeOptionsDynamic), + string(ComputeModeOptionsShared), + } +} + +func (s *ComputeModeOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeModeOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeModeOptions(input string) (*ComputeModeOptions, error) { + vals := map[string]ComputeModeOptions{ + "dedicated": ComputeModeOptionsDedicated, + "dynamic": ComputeModeOptionsDynamic, + "shared": ComputeModeOptionsShared, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeModeOptions(input) + return &out, nil +} + +type ConnectionStringType string + +const ( + ConnectionStringTypeApiHub ConnectionStringType = "ApiHub" + ConnectionStringTypeCustom ConnectionStringType = "Custom" + ConnectionStringTypeDocDb ConnectionStringType = "DocDb" + ConnectionStringTypeEventHub ConnectionStringType = "EventHub" + ConnectionStringTypeMySql ConnectionStringType = "MySql" + ConnectionStringTypeNotificationHub ConnectionStringType = "NotificationHub" + ConnectionStringTypePostgreSQL ConnectionStringType = "PostgreSQL" + ConnectionStringTypeRedisCache ConnectionStringType = "RedisCache" + ConnectionStringTypeSQLAzure ConnectionStringType = "SQLAzure" + ConnectionStringTypeSQLServer ConnectionStringType = "SQLServer" + ConnectionStringTypeServiceBus ConnectionStringType = "ServiceBus" +) + +func PossibleValuesForConnectionStringType() []string { + return []string{ + string(ConnectionStringTypeApiHub), + string(ConnectionStringTypeCustom), + string(ConnectionStringTypeDocDb), + string(ConnectionStringTypeEventHub), + string(ConnectionStringTypeMySql), + string(ConnectionStringTypeNotificationHub), + string(ConnectionStringTypePostgreSQL), + string(ConnectionStringTypeRedisCache), + string(ConnectionStringTypeSQLAzure), + string(ConnectionStringTypeSQLServer), + string(ConnectionStringTypeServiceBus), + } +} + +func (s *ConnectionStringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionStringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionStringType(input string) (*ConnectionStringType, error) { + vals := map[string]ConnectionStringType{ + "apihub": ConnectionStringTypeApiHub, + "custom": ConnectionStringTypeCustom, + "docdb": ConnectionStringTypeDocDb, + "eventhub": ConnectionStringTypeEventHub, + "mysql": ConnectionStringTypeMySql, + "notificationhub": ConnectionStringTypeNotificationHub, + "postgresql": ConnectionStringTypePostgreSQL, + "rediscache": ConnectionStringTypeRedisCache, + "sqlazure": ConnectionStringTypeSQLAzure, + "sqlserver": ConnectionStringTypeSQLServer, + "servicebus": ConnectionStringTypeServiceBus, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionStringType(input) + return &out, nil +} + +type CustomDnsSuffixProvisioningState string + +const ( + CustomDnsSuffixProvisioningStateDegraded CustomDnsSuffixProvisioningState = "Degraded" + CustomDnsSuffixProvisioningStateFailed CustomDnsSuffixProvisioningState = "Failed" + CustomDnsSuffixProvisioningStateInProgress CustomDnsSuffixProvisioningState = "InProgress" + CustomDnsSuffixProvisioningStateSucceeded CustomDnsSuffixProvisioningState = "Succeeded" +) + +func PossibleValuesForCustomDnsSuffixProvisioningState() []string { + return []string{ + string(CustomDnsSuffixProvisioningStateDegraded), + string(CustomDnsSuffixProvisioningStateFailed), + string(CustomDnsSuffixProvisioningStateInProgress), + string(CustomDnsSuffixProvisioningStateSucceeded), + } +} + +func (s *CustomDnsSuffixProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomDnsSuffixProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomDnsSuffixProvisioningState(input string) (*CustomDnsSuffixProvisioningState, error) { + vals := map[string]CustomDnsSuffixProvisioningState{ + "degraded": CustomDnsSuffixProvisioningStateDegraded, + "failed": CustomDnsSuffixProvisioningStateFailed, + "inprogress": CustomDnsSuffixProvisioningStateInProgress, + "succeeded": CustomDnsSuffixProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomDnsSuffixProvisioningState(input) + return &out, nil +} + +type DaprLogLevel string + +const ( + DaprLogLevelDebug DaprLogLevel = "debug" + DaprLogLevelError DaprLogLevel = "error" + DaprLogLevelInfo DaprLogLevel = "info" + DaprLogLevelWarn DaprLogLevel = "warn" +) + +func PossibleValuesForDaprLogLevel() []string { + return []string{ + string(DaprLogLevelDebug), + string(DaprLogLevelError), + string(DaprLogLevelInfo), + string(DaprLogLevelWarn), + } +} + +func (s *DaprLogLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDaprLogLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDaprLogLevel(input string) (*DaprLogLevel, error) { + vals := map[string]DaprLogLevel{ + "debug": DaprLogLevelDebug, + "error": DaprLogLevelError, + "info": DaprLogLevelInfo, + "warn": DaprLogLevelWarn, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DaprLogLevel(input) + return &out, nil +} + +type DefaultAction string + +const ( + DefaultActionAllow DefaultAction = "Allow" + DefaultActionDeny DefaultAction = "Deny" +) + +func PossibleValuesForDefaultAction() []string { + return []string{ + string(DefaultActionAllow), + string(DefaultActionDeny), + } +} + +func (s *DefaultAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDefaultAction(input string) (*DefaultAction, error) { + vals := map[string]DefaultAction{ + "allow": DefaultActionAllow, + "deny": DefaultActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DefaultAction(input) + return &out, nil +} + +type FtpsState string + +const ( + FtpsStateAllAllowed FtpsState = "AllAllowed" + FtpsStateDisabled FtpsState = "Disabled" + FtpsStateFtpsOnly FtpsState = "FtpsOnly" +) + +func PossibleValuesForFtpsState() []string { + return []string{ + string(FtpsStateAllAllowed), + string(FtpsStateDisabled), + string(FtpsStateFtpsOnly), + } +} + +func (s *FtpsState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFtpsState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFtpsState(input string) (*FtpsState, error) { + vals := map[string]FtpsState{ + "allallowed": FtpsStateAllAllowed, + "disabled": FtpsStateDisabled, + "ftpsonly": FtpsStateFtpsOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FtpsState(input) + return &out, nil +} + +type FunctionsDeploymentStorageType string + +const ( + FunctionsDeploymentStorageTypeBlobContainer FunctionsDeploymentStorageType = "blobContainer" +) + +func PossibleValuesForFunctionsDeploymentStorageType() []string { + return []string{ + string(FunctionsDeploymentStorageTypeBlobContainer), + } +} + +func (s *FunctionsDeploymentStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFunctionsDeploymentStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFunctionsDeploymentStorageType(input string) (*FunctionsDeploymentStorageType, error) { + vals := map[string]FunctionsDeploymentStorageType{ + "blobcontainer": FunctionsDeploymentStorageTypeBlobContainer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FunctionsDeploymentStorageType(input) + return &out, nil +} + +type HostType string + +const ( + HostTypeRepository HostType = "Repository" + HostTypeStandard HostType = "Standard" +) + +func PossibleValuesForHostType() []string { + return []string{ + string(HostTypeRepository), + string(HostTypeStandard), + } +} + +func (s *HostType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostType(input string) (*HostType, error) { + vals := map[string]HostType{ + "repository": HostTypeRepository, + "standard": HostTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostType(input) + return &out, nil +} + +type HostingEnvironmentStatus string + +const ( + HostingEnvironmentStatusDeleting HostingEnvironmentStatus = "Deleting" + HostingEnvironmentStatusPreparing HostingEnvironmentStatus = "Preparing" + HostingEnvironmentStatusReady HostingEnvironmentStatus = "Ready" + HostingEnvironmentStatusScaling HostingEnvironmentStatus = "Scaling" +) + +func PossibleValuesForHostingEnvironmentStatus() []string { + return []string{ + string(HostingEnvironmentStatusDeleting), + string(HostingEnvironmentStatusPreparing), + string(HostingEnvironmentStatusReady), + string(HostingEnvironmentStatusScaling), + } +} + +func (s *HostingEnvironmentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostingEnvironmentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostingEnvironmentStatus(input string) (*HostingEnvironmentStatus, error) { + vals := map[string]HostingEnvironmentStatus{ + "deleting": HostingEnvironmentStatusDeleting, + "preparing": HostingEnvironmentStatusPreparing, + "ready": HostingEnvironmentStatusReady, + "scaling": HostingEnvironmentStatusScaling, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostingEnvironmentStatus(input) + return &out, nil +} + +type IPFilterTag string + +const ( + IPFilterTagDefault IPFilterTag = "Default" + IPFilterTagServiceTag IPFilterTag = "ServiceTag" + IPFilterTagXffProxy IPFilterTag = "XffProxy" +) + +func PossibleValuesForIPFilterTag() []string { + return []string{ + string(IPFilterTagDefault), + string(IPFilterTagServiceTag), + string(IPFilterTagXffProxy), + } +} + +func (s *IPFilterTag) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFilterTag(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPFilterTag(input string) (*IPFilterTag, error) { + vals := map[string]IPFilterTag{ + "default": IPFilterTagDefault, + "servicetag": IPFilterTagServiceTag, + "xffproxy": IPFilterTagXffProxy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPFilterTag(input) + return &out, nil +} + +type IPMode string + +const ( + IPModeIPvFour IPMode = "IPv4" + IPModeIPvFourAndIPvSix IPMode = "IPv4AndIPv6" + IPModeIPvSix IPMode = "IPv6" +) + +func PossibleValuesForIPMode() []string { + return []string{ + string(IPModeIPvFour), + string(IPModeIPvFourAndIPvSix), + string(IPModeIPvSix), + } +} + +func (s *IPMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPMode(input string) (*IPMode, error) { + vals := map[string]IPMode{ + "ipv4": IPModeIPvFour, + "ipv4andipv6": IPModeIPvFourAndIPvSix, + "ipv6": IPModeIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPMode(input) + return &out, nil +} + +type LoadBalancingMode string + +const ( + LoadBalancingModeNone LoadBalancingMode = "None" + LoadBalancingModePublishing LoadBalancingMode = "Publishing" + LoadBalancingModeWeb LoadBalancingMode = "Web" + LoadBalancingModeWebPublishing LoadBalancingMode = "Web, Publishing" +) + +func PossibleValuesForLoadBalancingMode() []string { + return []string{ + string(LoadBalancingModeNone), + string(LoadBalancingModePublishing), + string(LoadBalancingModeWeb), + string(LoadBalancingModeWebPublishing), + } +} + +func (s *LoadBalancingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancingMode(input string) (*LoadBalancingMode, error) { + vals := map[string]LoadBalancingMode{ + "none": LoadBalancingModeNone, + "publishing": LoadBalancingModePublishing, + "web": LoadBalancingModeWeb, + "web, publishing": LoadBalancingModeWebPublishing, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancingMode(input) + return &out, nil +} + +type ManagedPipelineMode string + +const ( + ManagedPipelineModeClassic ManagedPipelineMode = "Classic" + ManagedPipelineModeIntegrated ManagedPipelineMode = "Integrated" +) + +func PossibleValuesForManagedPipelineMode() []string { + return []string{ + string(ManagedPipelineModeClassic), + string(ManagedPipelineModeIntegrated), + } +} + +func (s *ManagedPipelineMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedPipelineMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedPipelineMode(input string) (*ManagedPipelineMode, error) { + vals := map[string]ManagedPipelineMode{ + "classic": ManagedPipelineModeClassic, + "integrated": ManagedPipelineModeIntegrated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedPipelineMode(input) + return &out, nil +} + +type OperationStatus string + +const ( + OperationStatusCreated OperationStatus = "Created" + OperationStatusFailed OperationStatus = "Failed" + OperationStatusInProgress OperationStatus = "InProgress" + OperationStatusSucceeded OperationStatus = "Succeeded" + OperationStatusTimedOut OperationStatus = "TimedOut" +) + +func PossibleValuesForOperationStatus() []string { + return []string{ + string(OperationStatusCreated), + string(OperationStatusFailed), + string(OperationStatusInProgress), + string(OperationStatusSucceeded), + string(OperationStatusTimedOut), + } +} + +func (s *OperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperationStatus(input string) (*OperationStatus, error) { + vals := map[string]OperationStatus{ + "created": OperationStatusCreated, + "failed": OperationStatusFailed, + "inprogress": OperationStatusInProgress, + "succeeded": OperationStatusSucceeded, + "timedout": OperationStatusTimedOut, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type RedundancyMode string + +const ( + RedundancyModeActiveActive RedundancyMode = "ActiveActive" + RedundancyModeFailover RedundancyMode = "Failover" + RedundancyModeGeoRedundant RedundancyMode = "GeoRedundant" + RedundancyModeManual RedundancyMode = "Manual" + RedundancyModeNone RedundancyMode = "None" +) + +func PossibleValuesForRedundancyMode() []string { + return []string{ + string(RedundancyModeActiveActive), + string(RedundancyModeFailover), + string(RedundancyModeGeoRedundant), + string(RedundancyModeManual), + string(RedundancyModeNone), + } +} + +func (s *RedundancyMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRedundancyMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRedundancyMode(input string) (*RedundancyMode, error) { + vals := map[string]RedundancyMode{ + "activeactive": RedundancyModeActiveActive, + "failover": RedundancyModeFailover, + "georedundant": RedundancyModeGeoRedundant, + "manual": RedundancyModeManual, + "none": RedundancyModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RedundancyMode(input) + return &out, nil +} + +type RuntimeName string + +const ( + RuntimeNameCustom RuntimeName = "custom" + RuntimeNameDotnetNegativeisolated RuntimeName = "dotnet-isolated" + RuntimeNameJava RuntimeName = "java" + RuntimeNameNode RuntimeName = "node" + RuntimeNamePowershell RuntimeName = "powershell" + RuntimeNamePython RuntimeName = "python" +) + +func PossibleValuesForRuntimeName() []string { + return []string{ + string(RuntimeNameCustom), + string(RuntimeNameDotnetNegativeisolated), + string(RuntimeNameJava), + string(RuntimeNameNode), + string(RuntimeNamePowershell), + string(RuntimeNamePython), + } +} + +func (s *RuntimeName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuntimeName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuntimeName(input string) (*RuntimeName, error) { + vals := map[string]RuntimeName{ + "custom": RuntimeNameCustom, + "dotnet-isolated": RuntimeNameDotnetNegativeisolated, + "java": RuntimeNameJava, + "node": RuntimeNameNode, + "powershell": RuntimeNamePowershell, + "python": RuntimeNamePython, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuntimeName(input) + return &out, nil +} + +type ScmType string + +const ( + ScmTypeBitbucketGit ScmType = "BitbucketGit" + ScmTypeBitbucketHg ScmType = "BitbucketHg" + ScmTypeCodePlexGit ScmType = "CodePlexGit" + ScmTypeCodePlexHg ScmType = "CodePlexHg" + ScmTypeDropbox ScmType = "Dropbox" + ScmTypeExternalGit ScmType = "ExternalGit" + ScmTypeExternalHg ScmType = "ExternalHg" + ScmTypeGitHub ScmType = "GitHub" + ScmTypeLocalGit ScmType = "LocalGit" + ScmTypeNone ScmType = "None" + ScmTypeOneDrive ScmType = "OneDrive" + ScmTypeTfs ScmType = "Tfs" + ScmTypeVSO ScmType = "VSO" + ScmTypeVSTSRM ScmType = "VSTSRM" +) + +func PossibleValuesForScmType() []string { + return []string{ + string(ScmTypeBitbucketGit), + string(ScmTypeBitbucketHg), + string(ScmTypeCodePlexGit), + string(ScmTypeCodePlexHg), + string(ScmTypeDropbox), + string(ScmTypeExternalGit), + string(ScmTypeExternalHg), + string(ScmTypeGitHub), + string(ScmTypeLocalGit), + string(ScmTypeNone), + string(ScmTypeOneDrive), + string(ScmTypeTfs), + string(ScmTypeVSO), + string(ScmTypeVSTSRM), + } +} + +func (s *ScmType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScmType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScmType(input string) (*ScmType, error) { + vals := map[string]ScmType{ + "bitbucketgit": ScmTypeBitbucketGit, + "bitbuckethg": ScmTypeBitbucketHg, + "codeplexgit": ScmTypeCodePlexGit, + "codeplexhg": ScmTypeCodePlexHg, + "dropbox": ScmTypeDropbox, + "externalgit": ScmTypeExternalGit, + "externalhg": ScmTypeExternalHg, + "github": ScmTypeGitHub, + "localgit": ScmTypeLocalGit, + "none": ScmTypeNone, + "onedrive": ScmTypeOneDrive, + "tfs": ScmTypeTfs, + "vso": ScmTypeVSO, + "vstsrm": ScmTypeVSTSRM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScmType(input) + return &out, nil +} + +type SiteAvailabilityState string + +const ( + SiteAvailabilityStateDisasterRecoveryMode SiteAvailabilityState = "DisasterRecoveryMode" + SiteAvailabilityStateLimited SiteAvailabilityState = "Limited" + SiteAvailabilityStateNormal SiteAvailabilityState = "Normal" +) + +func PossibleValuesForSiteAvailabilityState() []string { + return []string{ + string(SiteAvailabilityStateDisasterRecoveryMode), + string(SiteAvailabilityStateLimited), + string(SiteAvailabilityStateNormal), + } +} + +func (s *SiteAvailabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteAvailabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteAvailabilityState(input string) (*SiteAvailabilityState, error) { + vals := map[string]SiteAvailabilityState{ + "disasterrecoverymode": SiteAvailabilityStateDisasterRecoveryMode, + "limited": SiteAvailabilityStateLimited, + "normal": SiteAvailabilityStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteAvailabilityState(input) + return &out, nil +} + +type SiteLoadBalancing string + +const ( + SiteLoadBalancingLeastRequests SiteLoadBalancing = "LeastRequests" + SiteLoadBalancingLeastRequestsWithTieBreaker SiteLoadBalancing = "LeastRequestsWithTieBreaker" + SiteLoadBalancingLeastResponseTime SiteLoadBalancing = "LeastResponseTime" + SiteLoadBalancingPerSiteRoundRobin SiteLoadBalancing = "PerSiteRoundRobin" + SiteLoadBalancingRequestHash SiteLoadBalancing = "RequestHash" + SiteLoadBalancingWeightedRoundRobin SiteLoadBalancing = "WeightedRoundRobin" + SiteLoadBalancingWeightedTotalTraffic SiteLoadBalancing = "WeightedTotalTraffic" +) + +func PossibleValuesForSiteLoadBalancing() []string { + return []string{ + string(SiteLoadBalancingLeastRequests), + string(SiteLoadBalancingLeastRequestsWithTieBreaker), + string(SiteLoadBalancingLeastResponseTime), + string(SiteLoadBalancingPerSiteRoundRobin), + string(SiteLoadBalancingRequestHash), + string(SiteLoadBalancingWeightedRoundRobin), + string(SiteLoadBalancingWeightedTotalTraffic), + } +} + +func (s *SiteLoadBalancing) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteLoadBalancing(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteLoadBalancing(input string) (*SiteLoadBalancing, error) { + vals := map[string]SiteLoadBalancing{ + "leastrequests": SiteLoadBalancingLeastRequests, + "leastrequestswithtiebreaker": SiteLoadBalancingLeastRequestsWithTieBreaker, + "leastresponsetime": SiteLoadBalancingLeastResponseTime, + "persiteroundrobin": SiteLoadBalancingPerSiteRoundRobin, + "requesthash": SiteLoadBalancingRequestHash, + "weightedroundrobin": SiteLoadBalancingWeightedRoundRobin, + "weightedtotaltraffic": SiteLoadBalancingWeightedTotalTraffic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteLoadBalancing(input) + return &out, nil +} + +type SslState string + +const ( + SslStateDisabled SslState = "Disabled" + SslStateIPBasedEnabled SslState = "IpBasedEnabled" + SslStateSniEnabled SslState = "SniEnabled" +) + +func PossibleValuesForSslState() []string { + return []string{ + string(SslStateDisabled), + string(SslStateIPBasedEnabled), + string(SslStateSniEnabled), + } +} + +func (s *SslState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSslState(input string) (*SslState, error) { + vals := map[string]SslState{ + "disabled": SslStateDisabled, + "ipbasedenabled": SslStateIPBasedEnabled, + "snienabled": SslStateSniEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SslState(input) + return &out, nil +} + +type StatusOptions string + +const ( + StatusOptionsCreating StatusOptions = "Creating" + StatusOptionsPending StatusOptions = "Pending" + StatusOptionsReady StatusOptions = "Ready" +) + +func PossibleValuesForStatusOptions() []string { + return []string{ + string(StatusOptionsCreating), + string(StatusOptionsPending), + string(StatusOptionsReady), + } +} + +func (s *StatusOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatusOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatusOptions(input string) (*StatusOptions, error) { + vals := map[string]StatusOptions{ + "creating": StatusOptionsCreating, + "pending": StatusOptionsPending, + "ready": StatusOptionsReady, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StatusOptions(input) + return &out, nil +} + +type SupportedTlsVersions string + +const ( + SupportedTlsVersionsOnePointOne SupportedTlsVersions = "1.1" + SupportedTlsVersionsOnePointThree SupportedTlsVersions = "1.3" + SupportedTlsVersionsOnePointTwo SupportedTlsVersions = "1.2" + SupportedTlsVersionsOnePointZero SupportedTlsVersions = "1.0" +) + +func PossibleValuesForSupportedTlsVersions() []string { + return []string{ + string(SupportedTlsVersionsOnePointOne), + string(SupportedTlsVersionsOnePointThree), + string(SupportedTlsVersionsOnePointTwo), + string(SupportedTlsVersionsOnePointZero), + } +} + +func (s *SupportedTlsVersions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSupportedTlsVersions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSupportedTlsVersions(input string) (*SupportedTlsVersions, error) { + vals := map[string]SupportedTlsVersions{ + "1.1": SupportedTlsVersionsOnePointOne, + "1.3": SupportedTlsVersionsOnePointThree, + "1.2": SupportedTlsVersionsOnePointTwo, + "1.0": SupportedTlsVersionsOnePointZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SupportedTlsVersions(input) + return &out, nil +} + +type TlsCipherSuites string + +const ( + TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_AES_128_GCM_SHA256" + TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_RSA_WITH_AES_256_GCM_SHA384" +) + +func PossibleValuesForTlsCipherSuites() []string { + return []string{ + string(TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + } +} + +func (s *TlsCipherSuites) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTlsCipherSuites(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTlsCipherSuites(input string) (*TlsCipherSuites, error) { + vals := map[string]TlsCipherSuites{ + "tls_aes_128_gcm_sha256": TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix, + "tls_aes_256_gcm_sha384": TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_ecdsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA, + "tls_ecdhe_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA, + "tls_ecdhe_rsa_with_aes_256_cbc_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA, + "tls_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA, + "tls_rsa_with_aes_256_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix, + "tls_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TlsCipherSuites(input) + return &out, nil +} + +type UpgradeAvailability string + +const ( + UpgradeAvailabilityNone UpgradeAvailability = "None" + UpgradeAvailabilityReady UpgradeAvailability = "Ready" +) + +func PossibleValuesForUpgradeAvailability() []string { + return []string{ + string(UpgradeAvailabilityNone), + string(UpgradeAvailabilityReady), + } +} + +func (s *UpgradeAvailability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradeAvailability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpgradeAvailability(input string) (*UpgradeAvailability, error) { + vals := map[string]UpgradeAvailability{ + "none": UpgradeAvailabilityNone, + "ready": UpgradeAvailabilityReady, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpgradeAvailability(input) + return &out, nil +} + +type UpgradePreference string + +const ( + UpgradePreferenceEarly UpgradePreference = "Early" + UpgradePreferenceLate UpgradePreference = "Late" + UpgradePreferenceManual UpgradePreference = "Manual" + UpgradePreferenceNone UpgradePreference = "None" +) + +func PossibleValuesForUpgradePreference() []string { + return []string{ + string(UpgradePreferenceEarly), + string(UpgradePreferenceLate), + string(UpgradePreferenceManual), + string(UpgradePreferenceNone), + } +} + +func (s *UpgradePreference) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradePreference(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpgradePreference(input string) (*UpgradePreference, error) { + vals := map[string]UpgradePreference{ + "early": UpgradePreferenceEarly, + "late": UpgradePreferenceLate, + "manual": UpgradePreferenceManual, + "none": UpgradePreferenceNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpgradePreference(input) + return &out, nil +} + +type UsageState string + +const ( + UsageStateExceeded UsageState = "Exceeded" + UsageStateNormal UsageState = "Normal" +) + +func PossibleValuesForUsageState() []string { + return []string{ + string(UsageStateExceeded), + string(UsageStateNormal), + } +} + +func (s *UsageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsageState(input string) (*UsageState, error) { + vals := map[string]UsageState{ + "exceeded": UsageStateExceeded, + "normal": UsageStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsageState(input) + return &out, nil +} + +type WorkerSizeOptions string + +const ( + WorkerSizeOptionsDOne WorkerSizeOptions = "D1" + WorkerSizeOptionsDThree WorkerSizeOptions = "D3" + WorkerSizeOptionsDTwo WorkerSizeOptions = "D2" + WorkerSizeOptionsDefault WorkerSizeOptions = "Default" + WorkerSizeOptionsLarge WorkerSizeOptions = "Large" + WorkerSizeOptionsLargeVThree WorkerSizeOptions = "LargeV3" + WorkerSizeOptionsMedium WorkerSizeOptions = "Medium" + WorkerSizeOptionsMediumVThree WorkerSizeOptions = "MediumV3" + WorkerSizeOptionsNestedSmall WorkerSizeOptions = "NestedSmall" + WorkerSizeOptionsNestedSmallLinux WorkerSizeOptions = "NestedSmallLinux" + WorkerSizeOptionsSmall WorkerSizeOptions = "Small" + WorkerSizeOptionsSmallVThree WorkerSizeOptions = "SmallV3" +) + +func PossibleValuesForWorkerSizeOptions() []string { + return []string{ + string(WorkerSizeOptionsDOne), + string(WorkerSizeOptionsDThree), + string(WorkerSizeOptionsDTwo), + string(WorkerSizeOptionsDefault), + string(WorkerSizeOptionsLarge), + string(WorkerSizeOptionsLargeVThree), + string(WorkerSizeOptionsMedium), + string(WorkerSizeOptionsMediumVThree), + string(WorkerSizeOptionsNestedSmall), + string(WorkerSizeOptionsNestedSmallLinux), + string(WorkerSizeOptionsSmall), + string(WorkerSizeOptionsSmallVThree), + } +} + +func (s *WorkerSizeOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkerSizeOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkerSizeOptions(input string) (*WorkerSizeOptions, error) { + vals := map[string]WorkerSizeOptions{ + "d1": WorkerSizeOptionsDOne, + "d3": WorkerSizeOptionsDThree, + "d2": WorkerSizeOptionsDTwo, + "default": WorkerSizeOptionsDefault, + "large": WorkerSizeOptionsLarge, + "largev3": WorkerSizeOptionsLargeVThree, + "medium": WorkerSizeOptionsMedium, + "mediumv3": WorkerSizeOptionsMediumVThree, + "nestedsmall": WorkerSizeOptionsNestedSmall, + "nestedsmalllinux": WorkerSizeOptionsNestedSmallLinux, + "small": WorkerSizeOptionsSmall, + "smallv3": WorkerSizeOptionsSmallVThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkerSizeOptions(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/id_defaultinstance.go b/resource-manager/web/2024-11-01/appserviceenvironments/id_defaultinstance.go new file mode 100644 index 00000000000..88c10f8ab90 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/id_defaultinstance.go @@ -0,0 +1,141 @@ +package appserviceenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DefaultInstanceId{}) +} + +var _ resourceids.ResourceId = &DefaultInstanceId{} + +// DefaultInstanceId is a struct representing the Resource ID for a Default Instance +type DefaultInstanceId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + InstanceName string +} + +// NewDefaultInstanceID returns a new DefaultInstanceId struct +func NewDefaultInstanceID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, instanceName string) DefaultInstanceId { + return DefaultInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + InstanceName: instanceName, + } +} + +// ParseDefaultInstanceID parses 'input' into a DefaultInstanceId +func ParseDefaultInstanceID(input string) (*DefaultInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&DefaultInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DefaultInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDefaultInstanceIDInsensitively parses 'input' case-insensitively into a DefaultInstanceId +// note: this method should only be used for API response data and not user input +func ParseDefaultInstanceIDInsensitively(input string) (*DefaultInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&DefaultInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DefaultInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DefaultInstanceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.InstanceName, ok = input.Parsed["instanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceName", input) + } + + return nil +} + +// ValidateDefaultInstanceID checks that 'input' can be parsed as a Default Instance ID +func ValidateDefaultInstanceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDefaultInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Default Instance ID +func (id DefaultInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/multiRolePools/default/instances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.InstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Default Instance ID +func (id DefaultInstanceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentName"), + resourceids.StaticSegment("staticMultiRolePools", "multiRolePools", "multiRolePools"), + resourceids.StaticSegment("staticDefault", "default", "default"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceName", "instanceName"), + } +} + +// String returns a human-readable description of this Default Instance ID +func (id DefaultInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Instance Name: %q", id.InstanceName), + } + return fmt.Sprintf("Default Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/id_defaultinstance_test.go b/resource-manager/web/2024-11-01/appserviceenvironments/id_defaultinstance_test.go new file mode 100644 index 00000000000..a260dfe3401 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/id_defaultinstance_test.go @@ -0,0 +1,357 @@ +package appserviceenvironments + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DefaultInstanceId{} + +func TestNewDefaultInstanceID(t *testing.T) { + id := NewDefaultInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "instanceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostingEnvironmentName != "hostingEnvironmentName" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentName") + } + + if id.InstanceName != "instanceName" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceName'", id.InstanceName, "instanceName") + } +} + +func TestFormatDefaultInstanceID(t *testing.T) { + actual := NewDefaultInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "instanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default/instances/instanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDefaultInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DefaultInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default/instances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default/instances/instanceName", + Expected: &DefaultInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + InstanceName: "instanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default/instances/instanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDefaultInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.InstanceName != v.Expected.InstanceName { + t.Fatalf("Expected %q but got %q for InstanceName", v.Expected.InstanceName, actual.InstanceName) + } + + } +} + +func TestParseDefaultInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DefaultInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/mUlTiRoLePoOlS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/mUlTiRoLePoOlS/dEfAuLt", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/mUlTiRoLePoOlS/dEfAuLt/iNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default/instances/instanceName", + Expected: &DefaultInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + InstanceName: "instanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/multiRolePools/default/instances/instanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/mUlTiRoLePoOlS/dEfAuLt/iNsTaNcEs/iNsTaNcEnAmE", + Expected: &DefaultInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTnAmE", + InstanceName: "iNsTaNcEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/mUlTiRoLePoOlS/dEfAuLt/iNsTaNcEs/iNsTaNcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDefaultInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.InstanceName != v.Expected.InstanceName { + t.Fatalf("Expected %q but got %q for InstanceName", v.Expected.InstanceName, actual.InstanceName) + } + + } +} + +func TestSegmentsForDefaultInstanceId(t *testing.T) { + segments := DefaultInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DefaultInstanceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/id_hostingenvironmentdiagnostic.go b/resource-manager/web/2024-11-01/appserviceenvironments/id_hostingenvironmentdiagnostic.go new file mode 100644 index 00000000000..9c0321e3f7a --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/id_hostingenvironmentdiagnostic.go @@ -0,0 +1,139 @@ +package appserviceenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostingEnvironmentDiagnosticId{}) +} + +var _ resourceids.ResourceId = &HostingEnvironmentDiagnosticId{} + +// HostingEnvironmentDiagnosticId is a struct representing the Resource ID for a Hosting Environment Diagnostic +type HostingEnvironmentDiagnosticId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + DiagnosticName string +} + +// NewHostingEnvironmentDiagnosticID returns a new HostingEnvironmentDiagnosticId struct +func NewHostingEnvironmentDiagnosticID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, diagnosticName string) HostingEnvironmentDiagnosticId { + return HostingEnvironmentDiagnosticId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + DiagnosticName: diagnosticName, + } +} + +// ParseHostingEnvironmentDiagnosticID parses 'input' into a HostingEnvironmentDiagnosticId +func ParseHostingEnvironmentDiagnosticID(input string) (*HostingEnvironmentDiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentDiagnosticId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentDiagnosticId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostingEnvironmentDiagnosticIDInsensitively parses 'input' case-insensitively into a HostingEnvironmentDiagnosticId +// note: this method should only be used for API response data and not user input +func ParseHostingEnvironmentDiagnosticIDInsensitively(input string) (*HostingEnvironmentDiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentDiagnosticId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentDiagnosticId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostingEnvironmentDiagnosticId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + return nil +} + +// ValidateHostingEnvironmentDiagnosticID checks that 'input' can be parsed as a Hosting Environment Diagnostic ID +func ValidateHostingEnvironmentDiagnosticID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostingEnvironmentDiagnosticID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hosting Environment Diagnostic ID +func (id HostingEnvironmentDiagnosticId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/diagnostics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.DiagnosticName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hosting Environment Diagnostic ID +func (id HostingEnvironmentDiagnosticId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentName"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticName"), + } +} + +// String returns a human-readable description of this Hosting Environment Diagnostic ID +func (id HostingEnvironmentDiagnosticId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + } + return fmt.Sprintf("Hosting Environment Diagnostic (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/id_hostingenvironmentdiagnostic_test.go b/resource-manager/web/2024-11-01/appserviceenvironments/id_hostingenvironmentdiagnostic_test.go new file mode 100644 index 00000000000..e998d9bcef1 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/id_hostingenvironmentdiagnostic_test.go @@ -0,0 +1,327 @@ +package appserviceenvironments + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostingEnvironmentDiagnosticId{} + +func TestNewHostingEnvironmentDiagnosticID(t *testing.T) { + id := NewHostingEnvironmentDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "diagnosticName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostingEnvironmentName != "hostingEnvironmentName" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentName") + } + + if id.DiagnosticName != "diagnosticName" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticName") + } +} + +func TestFormatHostingEnvironmentDiagnosticID(t *testing.T) { + actual := NewHostingEnvironmentDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "diagnosticName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/diagnostics/diagnosticName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostingEnvironmentDiagnosticID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentDiagnosticId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/diagnostics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/diagnostics/diagnosticName", + Expected: &HostingEnvironmentDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + DiagnosticName: "diagnosticName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/diagnostics/diagnosticName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentDiagnosticID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestParseHostingEnvironmentDiagnosticIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentDiagnosticId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/dIaGnOsTiCs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/diagnostics/diagnosticName", + Expected: &HostingEnvironmentDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + DiagnosticName: "diagnosticName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/diagnostics/diagnosticName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE", + Expected: &HostingEnvironmentDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTnAmE", + DiagnosticName: "dIaGnOsTiCnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentDiagnosticIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestSegmentsForHostingEnvironmentDiagnosticId(t *testing.T) { + segments := HostingEnvironmentDiagnosticId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostingEnvironmentDiagnosticId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection.go b/resource-manager/web/2024-11-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection.go new file mode 100644 index 00000000000..415a31bdc7e --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection.go @@ -0,0 +1,139 @@ +package appserviceenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostingEnvironmentPrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &HostingEnvironmentPrivateEndpointConnectionId{} + +// HostingEnvironmentPrivateEndpointConnectionId is a struct representing the Resource ID for a Hosting Environment Private Endpoint Connection +type HostingEnvironmentPrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + PrivateEndpointConnectionName string +} + +// NewHostingEnvironmentPrivateEndpointConnectionID returns a new HostingEnvironmentPrivateEndpointConnectionId struct +func NewHostingEnvironmentPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, privateEndpointConnectionName string) HostingEnvironmentPrivateEndpointConnectionId { + return HostingEnvironmentPrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParseHostingEnvironmentPrivateEndpointConnectionID parses 'input' into a HostingEnvironmentPrivateEndpointConnectionId +func ParseHostingEnvironmentPrivateEndpointConnectionID(input string) (*HostingEnvironmentPrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentPrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentPrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostingEnvironmentPrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a HostingEnvironmentPrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParseHostingEnvironmentPrivateEndpointConnectionIDInsensitively(input string) (*HostingEnvironmentPrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentPrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentPrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostingEnvironmentPrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidateHostingEnvironmentPrivateEndpointConnectionID checks that 'input' can be parsed as a Hosting Environment Private Endpoint Connection ID +func ValidateHostingEnvironmentPrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostingEnvironmentPrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hosting Environment Private Endpoint Connection ID +func (id HostingEnvironmentPrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hosting Environment Private Endpoint Connection ID +func (id HostingEnvironmentPrivateEndpointConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Hosting Environment Private Endpoint Connection ID +func (id HostingEnvironmentPrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Hosting Environment Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection_test.go b/resource-manager/web/2024-11-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection_test.go new file mode 100644 index 00000000000..f343f7258e6 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/id_hostingenvironmentprivateendpointconnection_test.go @@ -0,0 +1,327 @@ +package appserviceenvironments + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostingEnvironmentPrivateEndpointConnectionId{} + +func TestNewHostingEnvironmentPrivateEndpointConnectionID(t *testing.T) { + id := NewHostingEnvironmentPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "privateEndpointConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostingEnvironmentName != "hostingEnvironmentName" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatHostingEnvironmentPrivateEndpointConnectionID(t *testing.T) { + actual := NewHostingEnvironmentPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostingEnvironmentPrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentPrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &HostingEnvironmentPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentPrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParseHostingEnvironmentPrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentPrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &HostingEnvironmentPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &HostingEnvironmentPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTnAmE", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentPrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForHostingEnvironmentPrivateEndpointConnectionId(t *testing.T) { + segments := HostingEnvironmentPrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostingEnvironmentPrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/id_workerpool.go b/resource-manager/web/2024-11-01/appserviceenvironments/id_workerpool.go new file mode 100644 index 00000000000..dd10e8ad690 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/id_workerpool.go @@ -0,0 +1,139 @@ +package appserviceenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkerPoolId{}) +} + +var _ resourceids.ResourceId = &WorkerPoolId{} + +// WorkerPoolId is a struct representing the Resource ID for a Worker Pool +type WorkerPoolId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + WorkerPoolName string +} + +// NewWorkerPoolID returns a new WorkerPoolId struct +func NewWorkerPoolID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, workerPoolName string) WorkerPoolId { + return WorkerPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + WorkerPoolName: workerPoolName, + } +} + +// ParseWorkerPoolID parses 'input' into a WorkerPoolId +func ParseWorkerPoolID(input string) (*WorkerPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkerPoolIDInsensitively parses 'input' case-insensitively into a WorkerPoolId +// note: this method should only be used for API response data and not user input +func ParseWorkerPoolIDInsensitively(input string) (*WorkerPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerPoolId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkerPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.WorkerPoolName, ok = input.Parsed["workerPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workerPoolName", input) + } + + return nil +} + +// ValidateWorkerPoolID checks that 'input' can be parsed as a Worker Pool ID +func ValidateWorkerPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkerPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Worker Pool ID +func (id WorkerPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/workerPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.WorkerPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Worker Pool ID +func (id WorkerPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentName"), + resourceids.StaticSegment("staticWorkerPools", "workerPools", "workerPools"), + resourceids.UserSpecifiedSegment("workerPoolName", "workerPoolName"), + } +} + +// String returns a human-readable description of this Worker Pool ID +func (id WorkerPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Worker Pool Name: %q", id.WorkerPoolName), + } + return fmt.Sprintf("Worker Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/id_workerpool_test.go b/resource-manager/web/2024-11-01/appserviceenvironments/id_workerpool_test.go new file mode 100644 index 00000000000..df611010d06 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/id_workerpool_test.go @@ -0,0 +1,327 @@ +package appserviceenvironments + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkerPoolId{} + +func TestNewWorkerPoolID(t *testing.T) { + id := NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostingEnvironmentName != "hostingEnvironmentName" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentName") + } + + if id.WorkerPoolName != "workerPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkerPoolName'", id.WorkerPoolName, "workerPoolName") + } +} + +func TestFormatWorkerPoolID(t *testing.T) { + actual := NewWorkerPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkerPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName", + Expected: &WorkerPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + WorkerPoolName: "workerPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.WorkerPoolName != v.Expected.WorkerPoolName { + t.Fatalf("Expected %q but got %q for WorkerPoolName", v.Expected.WorkerPoolName, actual.WorkerPoolName) + } + + } +} + +func TestParseWorkerPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/wOrKeRpOoLs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName", + Expected: &WorkerPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + WorkerPoolName: "workerPoolName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/wOrKeRpOoLs/wOrKeRpOoLnAmE", + Expected: &WorkerPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTnAmE", + WorkerPoolName: "wOrKeRpOoLnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/wOrKeRpOoLs/wOrKeRpOoLnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.WorkerPoolName != v.Expected.WorkerPoolName { + t.Fatalf("Expected %q but got %q for WorkerPoolName", v.Expected.WorkerPoolName, actual.WorkerPoolName) + } + + } +} + +func TestSegmentsForWorkerPoolId(t *testing.T) { + segments := WorkerPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkerPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/id_workerpoolinstance.go b/resource-manager/web/2024-11-01/appserviceenvironments/id_workerpoolinstance.go new file mode 100644 index 00000000000..50a42965552 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/id_workerpoolinstance.go @@ -0,0 +1,148 @@ +package appserviceenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkerPoolInstanceId{}) +} + +var _ resourceids.ResourceId = &WorkerPoolInstanceId{} + +// WorkerPoolInstanceId is a struct representing the Resource ID for a Worker Pool Instance +type WorkerPoolInstanceId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + WorkerPoolName string + InstanceName string +} + +// NewWorkerPoolInstanceID returns a new WorkerPoolInstanceId struct +func NewWorkerPoolInstanceID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, workerPoolName string, instanceName string) WorkerPoolInstanceId { + return WorkerPoolInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + WorkerPoolName: workerPoolName, + InstanceName: instanceName, + } +} + +// ParseWorkerPoolInstanceID parses 'input' into a WorkerPoolInstanceId +func ParseWorkerPoolInstanceID(input string) (*WorkerPoolInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerPoolInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerPoolInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkerPoolInstanceIDInsensitively parses 'input' case-insensitively into a WorkerPoolInstanceId +// note: this method should only be used for API response data and not user input +func ParseWorkerPoolInstanceIDInsensitively(input string) (*WorkerPoolInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerPoolInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerPoolInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkerPoolInstanceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.WorkerPoolName, ok = input.Parsed["workerPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workerPoolName", input) + } + + if id.InstanceName, ok = input.Parsed["instanceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceName", input) + } + + return nil +} + +// ValidateWorkerPoolInstanceID checks that 'input' can be parsed as a Worker Pool Instance ID +func ValidateWorkerPoolInstanceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkerPoolInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Worker Pool Instance ID +func (id WorkerPoolInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/workerPools/%s/instances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.WorkerPoolName, id.InstanceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Worker Pool Instance ID +func (id WorkerPoolInstanceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentName"), + resourceids.StaticSegment("staticWorkerPools", "workerPools", "workerPools"), + resourceids.UserSpecifiedSegment("workerPoolName", "workerPoolName"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceName", "instanceName"), + } +} + +// String returns a human-readable description of this Worker Pool Instance ID +func (id WorkerPoolInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Worker Pool Name: %q", id.WorkerPoolName), + fmt.Sprintf("Instance Name: %q", id.InstanceName), + } + return fmt.Sprintf("Worker Pool Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/id_workerpoolinstance_test.go b/resource-manager/web/2024-11-01/appserviceenvironments/id_workerpoolinstance_test.go new file mode 100644 index 00000000000..b23611ebd58 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/id_workerpoolinstance_test.go @@ -0,0 +1,372 @@ +package appserviceenvironments + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkerPoolInstanceId{} + +func TestNewWorkerPoolInstanceID(t *testing.T) { + id := NewWorkerPoolInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName", "instanceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostingEnvironmentName != "hostingEnvironmentName" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentName") + } + + if id.WorkerPoolName != "workerPoolName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkerPoolName'", id.WorkerPoolName, "workerPoolName") + } + + if id.InstanceName != "instanceName" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceName'", id.InstanceName, "instanceName") + } +} + +func TestFormatWorkerPoolInstanceID(t *testing.T) { + actual := NewWorkerPoolInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "workerPoolName", "instanceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/instances/instanceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkerPoolInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerPoolInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/instances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/instances/instanceName", + Expected: &WorkerPoolInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + WorkerPoolName: "workerPoolName", + InstanceName: "instanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/instances/instanceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerPoolInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.WorkerPoolName != v.Expected.WorkerPoolName { + t.Fatalf("Expected %q but got %q for WorkerPoolName", v.Expected.WorkerPoolName, actual.WorkerPoolName) + } + + if actual.InstanceName != v.Expected.InstanceName { + t.Fatalf("Expected %q but got %q for InstanceName", v.Expected.InstanceName, actual.InstanceName) + } + + } +} + +func TestParseWorkerPoolInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerPoolInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/wOrKeRpOoLs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/wOrKeRpOoLs/wOrKeRpOoLnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/wOrKeRpOoLs/wOrKeRpOoLnAmE/iNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/instances/instanceName", + Expected: &WorkerPoolInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + WorkerPoolName: "workerPoolName", + InstanceName: "instanceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/workerPools/workerPoolName/instances/instanceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/wOrKeRpOoLs/wOrKeRpOoLnAmE/iNsTaNcEs/iNsTaNcEnAmE", + Expected: &WorkerPoolInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTnAmE", + WorkerPoolName: "wOrKeRpOoLnAmE", + InstanceName: "iNsTaNcEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/wOrKeRpOoLs/wOrKeRpOoLnAmE/iNsTaNcEs/iNsTaNcEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerPoolInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.WorkerPoolName != v.Expected.WorkerPoolName { + t.Fatalf("Expected %q but got %q for WorkerPoolName", v.Expected.WorkerPoolName, actual.WorkerPoolName) + } + + if actual.InstanceName != v.Expected.InstanceName { + t.Fatalf("Expected %q but got %q for InstanceName", v.Expected.InstanceName, actual.InstanceName) + } + + } +} + +func TestSegmentsForWorkerPoolInstanceId(t *testing.T) { + segments := WorkerPoolInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkerPoolInstanceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_approveorrejectprivateendpointconnection.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_approveorrejectprivateendpointconnection.go new file mode 100644 index 00000000000..5bd10a90134 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_approveorrejectprivateendpointconnection.go @@ -0,0 +1,75 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApproveOrRejectPrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// ApproveOrRejectPrivateEndpointConnection ... +func (c AppServiceEnvironmentsClient) ApproveOrRejectPrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) (result ApproveOrRejectPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ApproveOrRejectPrivateEndpointConnectionThenPoll performs ApproveOrRejectPrivateEndpointConnection then polls until it's completed +func (c AppServiceEnvironmentsClient) ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) error { + result, err := c.ApproveOrRejectPrivateEndpointConnection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_changevnet.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_changevnet.go new file mode 100644 index 00000000000..6bf6156af62 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_changevnet.go @@ -0,0 +1,94 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ChangeVnetOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ChangeVnetCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type ChangeVnetCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ChangeVnetCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ChangeVnet ... +func (c AppServiceEnvironmentsClient) ChangeVnet(ctx context.Context, id commonids.AppServiceEnvironmentId, input VirtualNetworkProfile) (result ChangeVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ChangeVnetCustomPager{}, + Path: fmt.Sprintf("%s/changeVirtualNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ChangeVnetThenPoll performs ChangeVnet then polls until it's completed +func (c AppServiceEnvironmentsClient) ChangeVnetThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId, input VirtualNetworkProfile) error { + result, err := c.ChangeVnet(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ChangeVnet: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ChangeVnet: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_createorupdate.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_createorupdate.go new file mode 100644 index 00000000000..0e325049b7f --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_createorupdate.go @@ -0,0 +1,77 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceEnvironmentResource +} + +// CreateOrUpdate ... +func (c AppServiceEnvironmentsClient) CreateOrUpdate(ctx context.Context, id commonids.AppServiceEnvironmentId, input AppServiceEnvironmentResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AppServiceEnvironmentsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId, input AppServiceEnvironmentResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_createorupdatemultirolepool.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_createorupdatemultirolepool.go new file mode 100644 index 00000000000..680b38261e5 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_createorupdatemultirolepool.go @@ -0,0 +1,76 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateMultiRolePoolOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// CreateOrUpdateMultiRolePool ... +func (c AppServiceEnvironmentsClient) CreateOrUpdateMultiRolePool(ctx context.Context, id commonids.AppServiceEnvironmentId, input WorkerPoolResource) (result CreateOrUpdateMultiRolePoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/multiRolePools/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateMultiRolePoolThenPoll performs CreateOrUpdateMultiRolePool then polls until it's completed +func (c AppServiceEnvironmentsClient) CreateOrUpdateMultiRolePoolThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId, input WorkerPoolResource) error { + result, err := c.CreateOrUpdateMultiRolePool(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateMultiRolePool: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateMultiRolePool: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_createorupdateworkerpool.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_createorupdateworkerpool.go new file mode 100644 index 00000000000..a3cb8c751fd --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_createorupdateworkerpool.go @@ -0,0 +1,75 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateWorkerPoolOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// CreateOrUpdateWorkerPool ... +func (c AppServiceEnvironmentsClient) CreateOrUpdateWorkerPool(ctx context.Context, id WorkerPoolId, input WorkerPoolResource) (result CreateOrUpdateWorkerPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateWorkerPoolThenPoll performs CreateOrUpdateWorkerPool then polls until it's completed +func (c AppServiceEnvironmentsClient) CreateOrUpdateWorkerPoolThenPoll(ctx context.Context, id WorkerPoolId, input WorkerPoolResource) error { + result, err := c.CreateOrUpdateWorkerPool(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateWorkerPool: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateWorkerPool: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_delete.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_delete.go new file mode 100644 index 00000000000..f8fb37d265b --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_delete.go @@ -0,0 +1,100 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + ForceDelete *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ForceDelete != nil { + out.Append("forceDelete", fmt.Sprintf("%v", *o.ForceDelete)) + } + return &out +} + +// Delete ... +func (c AppServiceEnvironmentsClient) Delete(ctx context.Context, id commonids.AppServiceEnvironmentId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c AppServiceEnvironmentsClient) DeleteThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_deleteasecustomdnssuffixconfiguration.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_deleteasecustomdnssuffixconfiguration.go new file mode 100644 index 00000000000..c5871258555 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_deleteasecustomdnssuffixconfiguration.go @@ -0,0 +1,56 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteAseCustomDnsSuffixConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// DeleteAseCustomDnsSuffixConfiguration ... +func (c AppServiceEnvironmentsClient) DeleteAseCustomDnsSuffixConfiguration(ctx context.Context, id commonids.AppServiceEnvironmentId) (result DeleteAseCustomDnsSuffixConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/configurations/customdnssuffix", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model interface{} + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_deleteprivateendpointconnection.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_deleteprivateendpointconnection.go new file mode 100644 index 00000000000..f15f2fafc23 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_deleteprivateendpointconnection.go @@ -0,0 +1,72 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletePrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// DeletePrivateEndpointConnection ... +func (c AppServiceEnvironmentsClient) DeletePrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed +func (c AppServiceEnvironmentsClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnection(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_get.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_get.go new file mode 100644 index 00000000000..19b2bdb044f --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_get.go @@ -0,0 +1,54 @@ +package appserviceenvironments + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceEnvironmentResource +} + +// Get ... +func (c AppServiceEnvironmentsClient) Get(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServiceEnvironmentResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_getasecustomdnssuffixconfiguration.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_getasecustomdnssuffixconfiguration.go new file mode 100644 index 00000000000..01f38db8a6e --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_getasecustomdnssuffixconfiguration.go @@ -0,0 +1,55 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAseCustomDnsSuffixConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomDnsSuffixConfiguration +} + +// GetAseCustomDnsSuffixConfiguration ... +func (c AppServiceEnvironmentsClient) GetAseCustomDnsSuffixConfiguration(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetAseCustomDnsSuffixConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/configurations/customdnssuffix", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CustomDnsSuffixConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_getasev3networkingconfiguration.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_getasev3networkingconfiguration.go new file mode 100644 index 00000000000..3815d5e3c5e --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_getasev3networkingconfiguration.go @@ -0,0 +1,55 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAseV3NetworkingConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AseV3NetworkingConfiguration +} + +// GetAseV3NetworkingConfiguration ... +func (c AppServiceEnvironmentsClient) GetAseV3NetworkingConfiguration(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetAseV3NetworkingConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/configurations/networking", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AseV3NetworkingConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_getdiagnosticsitem.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_getdiagnosticsitem.go new file mode 100644 index 00000000000..681cc63213c --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_getdiagnosticsitem.go @@ -0,0 +1,53 @@ +package appserviceenvironments + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetDiagnosticsItemOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostingEnvironmentDiagnostics +} + +// GetDiagnosticsItem ... +func (c AppServiceEnvironmentsClient) GetDiagnosticsItem(ctx context.Context, id HostingEnvironmentDiagnosticId) (result GetDiagnosticsItemOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HostingEnvironmentDiagnostics + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_getinboundnetworkdependenciesendpoints.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_getinboundnetworkdependenciesendpoints.go new file mode 100644 index 00000000000..0ba5559383d --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_getinboundnetworkdependenciesendpoints.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetInboundNetworkDependenciesEndpointsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]InboundEnvironmentEndpoint +} + +type GetInboundNetworkDependenciesEndpointsCompleteResult struct { + LatestHttpResponse *http.Response + Items []InboundEnvironmentEndpoint +} + +type GetInboundNetworkDependenciesEndpointsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetInboundNetworkDependenciesEndpointsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetInboundNetworkDependenciesEndpoints ... +func (c AppServiceEnvironmentsClient) GetInboundNetworkDependenciesEndpoints(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetInboundNetworkDependenciesEndpointsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetInboundNetworkDependenciesEndpointsCustomPager{}, + Path: fmt.Sprintf("%s/inboundNetworkDependenciesEndpoints", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]InboundEnvironmentEndpoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetInboundNetworkDependenciesEndpointsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) GetInboundNetworkDependenciesEndpointsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (GetInboundNetworkDependenciesEndpointsCompleteResult, error) { + return c.GetInboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx, id, InboundEnvironmentEndpointOperationPredicate{}) +} + +// GetInboundNetworkDependenciesEndpointsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) GetInboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate InboundEnvironmentEndpointOperationPredicate) (result GetInboundNetworkDependenciesEndpointsCompleteResult, err error) { + items := make([]InboundEnvironmentEndpoint, 0) + + resp, err := c.GetInboundNetworkDependenciesEndpoints(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetInboundNetworkDependenciesEndpointsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_getmultirolepool.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_getmultirolepool.go new file mode 100644 index 00000000000..7cbd25047b9 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_getmultirolepool.go @@ -0,0 +1,55 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetMultiRolePoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// GetMultiRolePool ... +func (c AppServiceEnvironmentsClient) GetMultiRolePool(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetMultiRolePoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/multiRolePools/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkerPoolResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_getoutboundnetworkdependenciesendpoints.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_getoutboundnetworkdependenciesendpoints.go new file mode 100644 index 00000000000..0e457723e3d --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_getoutboundnetworkdependenciesendpoints.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOutboundNetworkDependenciesEndpointsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OutboundEnvironmentEndpoint +} + +type GetOutboundNetworkDependenciesEndpointsCompleteResult struct { + LatestHttpResponse *http.Response + Items []OutboundEnvironmentEndpoint +} + +type GetOutboundNetworkDependenciesEndpointsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetOutboundNetworkDependenciesEndpointsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetOutboundNetworkDependenciesEndpoints ... +func (c AppServiceEnvironmentsClient) GetOutboundNetworkDependenciesEndpoints(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetOutboundNetworkDependenciesEndpointsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetOutboundNetworkDependenciesEndpointsCustomPager{}, + Path: fmt.Sprintf("%s/outboundNetworkDependenciesEndpoints", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]OutboundEnvironmentEndpoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetOutboundNetworkDependenciesEndpointsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) GetOutboundNetworkDependenciesEndpointsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (GetOutboundNetworkDependenciesEndpointsCompleteResult, error) { + return c.GetOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx, id, OutboundEnvironmentEndpointOperationPredicate{}) +} + +// GetOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) GetOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate OutboundEnvironmentEndpointOperationPredicate) (result GetOutboundNetworkDependenciesEndpointsCompleteResult, err error) { + items := make([]OutboundEnvironmentEndpoint, 0) + + resp, err := c.GetOutboundNetworkDependenciesEndpoints(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetOutboundNetworkDependenciesEndpointsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_getprivateendpointconnection.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_getprivateendpointconnection.go new file mode 100644 index 00000000000..714c1276f69 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_getprivateendpointconnection.go @@ -0,0 +1,53 @@ +package appserviceenvironments + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPrivateEndpointConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnection ... +func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnection(ctx context.Context, id HostingEnvironmentPrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RemotePrivateEndpointConnectionARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_getprivateendpointconnectionlist.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_getprivateendpointconnectionlist.go new file mode 100644 index 00000000000..c4ecbd05aaf --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_getprivateendpointconnectionlist.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPrivateEndpointConnectionListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetPrivateEndpointConnectionListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetPrivateEndpointConnectionList ... +func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnectionList(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetPrivateEndpointConnectionListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetPrivateEndpointConnectionListCustomPager{}, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RemotePrivateEndpointConnectionARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetPrivateEndpointConnectionListComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnectionListComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (GetPrivateEndpointConnectionListCompleteResult, error) { + return c.GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) +} + +// GetPrivateEndpointConnectionListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (result GetPrivateEndpointConnectionListCompleteResult, err error) { + items := make([]RemotePrivateEndpointConnectionARMResource, 0) + + resp, err := c.GetPrivateEndpointConnectionList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetPrivateEndpointConnectionListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_getprivatelinkresources.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_getprivatelinkresources.go new file mode 100644 index 00000000000..ecd193a3901 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_getprivatelinkresources.go @@ -0,0 +1,55 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesWrapper +} + +// GetPrivateLinkResources ... +func (c AppServiceEnvironmentsClient) GetPrivateLinkResources(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateLinkResourcesWrapper + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_getvipinfo.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_getvipinfo.go new file mode 100644 index 00000000000..ef0c4a7c970 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_getvipinfo.go @@ -0,0 +1,55 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetVipInfoOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AddressResponse +} + +// GetVipInfo ... +func (c AppServiceEnvironmentsClient) GetVipInfo(ctx context.Context, id commonids.AppServiceEnvironmentId) (result GetVipInfoOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/capacities/virtualip", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AddressResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_getworkerpool.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_getworkerpool.go new file mode 100644 index 00000000000..f18c4334f8a --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_getworkerpool.go @@ -0,0 +1,53 @@ +package appserviceenvironments + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetWorkerPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// GetWorkerPool ... +func (c AppServiceEnvironmentsClient) GetWorkerPool(ctx context.Context, id WorkerPoolId) (result GetWorkerPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkerPoolResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_list.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_list.go new file mode 100644 index 00000000000..b29d1ea041b --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_list.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceEnvironmentResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceEnvironmentResource +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c AppServiceEnvironmentsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/hostingEnvironments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServiceEnvironmentResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AppServiceEnvironmentResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AppServiceEnvironmentResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AppServiceEnvironmentResource, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_listappserviceplans.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_listappserviceplans.go new file mode 100644 index 00000000000..26d1f005a45 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_listappserviceplans.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAppServicePlansOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServicePlan +} + +type ListAppServicePlansCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServicePlan +} + +type ListAppServicePlansCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAppServicePlansCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAppServicePlans ... +func (c AppServiceEnvironmentsClient) ListAppServicePlans(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListAppServicePlansOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAppServicePlansCustomPager{}, + Path: fmt.Sprintf("%s/serverFarms", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServicePlan `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAppServicePlansComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListAppServicePlansComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListAppServicePlansCompleteResult, error) { + return c.ListAppServicePlansCompleteMatchingPredicate(ctx, id, AppServicePlanOperationPredicate{}) +} + +// ListAppServicePlansCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListAppServicePlansCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate AppServicePlanOperationPredicate) (result ListAppServicePlansCompleteResult, err error) { + items := make([]AppServicePlan, 0) + + resp, err := c.ListAppServicePlans(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAppServicePlansCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_listbyresourcegroup.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_listbyresourcegroup.go new file mode 100644 index 00000000000..3d45ec03742 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServiceEnvironmentResource +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServiceEnvironmentResource +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c AppServiceEnvironmentsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/hostingEnvironments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServiceEnvironmentResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AppServiceEnvironmentResourceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AppServiceEnvironmentResourceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AppServiceEnvironmentResource, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_listcapacities.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_listcapacities.go new file mode 100644 index 00000000000..b524c9ea8d6 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_listcapacities.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListCapacitiesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StampCapacity +} + +type ListCapacitiesCompleteResult struct { + LatestHttpResponse *http.Response + Items []StampCapacity +} + +type ListCapacitiesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCapacitiesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListCapacities ... +func (c AppServiceEnvironmentsClient) ListCapacities(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListCapacitiesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCapacitiesCustomPager{}, + Path: fmt.Sprintf("%s/capacities/compute", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StampCapacity `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListCapacitiesComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListCapacitiesComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListCapacitiesCompleteResult, error) { + return c.ListCapacitiesCompleteMatchingPredicate(ctx, id, StampCapacityOperationPredicate{}) +} + +// ListCapacitiesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListCapacitiesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate StampCapacityOperationPredicate) (result ListCapacitiesCompleteResult, err error) { + items := make([]StampCapacity, 0) + + resp, err := c.ListCapacities(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCapacitiesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_listdiagnostics.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_listdiagnostics.go new file mode 100644 index 00000000000..0b07c6c4a90 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_listdiagnostics.go @@ -0,0 +1,55 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListDiagnosticsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HostingEnvironmentDiagnostics +} + +// ListDiagnostics ... +func (c AppServiceEnvironmentsClient) ListDiagnostics(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListDiagnosticsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/diagnostics", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []HostingEnvironmentDiagnostics + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_listmultirolemetricdefinitions.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_listmultirolemetricdefinitions.go new file mode 100644 index 00000000000..703092408d6 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_listmultirolemetricdefinitions.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListMultiRoleMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceMetricDefinition +} + +type ListMultiRoleMetricDefinitionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceMetricDefinition +} + +type ListMultiRoleMetricDefinitionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListMultiRoleMetricDefinitionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListMultiRoleMetricDefinitions ... +func (c AppServiceEnvironmentsClient) ListMultiRoleMetricDefinitions(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListMultiRoleMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListMultiRoleMetricDefinitionsCustomPager{}, + Path: fmt.Sprintf("%s/multiRolePools/default/metricdefinitions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceMetricDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRoleMetricDefinitionsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRoleMetricDefinitionsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListMultiRoleMetricDefinitionsCompleteResult, error) { + return c.ListMultiRoleMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) +} + +// ListMultiRoleMetricDefinitionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRoleMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate ResourceMetricDefinitionOperationPredicate) (result ListMultiRoleMetricDefinitionsCompleteResult, err error) { + items := make([]ResourceMetricDefinition, 0) + + resp, err := c.ListMultiRoleMetricDefinitions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListMultiRoleMetricDefinitionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_listmultirolepoolinstancemetricdefinitions.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_listmultirolepoolinstancemetricdefinitions.go new file mode 100644 index 00000000000..b0c259db50e --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_listmultirolepoolinstancemetricdefinitions.go @@ -0,0 +1,105 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListMultiRolePoolInstanceMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceMetricDefinition +} + +type ListMultiRolePoolInstanceMetricDefinitionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceMetricDefinition +} + +type ListMultiRolePoolInstanceMetricDefinitionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListMultiRolePoolInstanceMetricDefinitionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListMultiRolePoolInstanceMetricDefinitions ... +func (c AppServiceEnvironmentsClient) ListMultiRolePoolInstanceMetricDefinitions(ctx context.Context, id DefaultInstanceId) (result ListMultiRolePoolInstanceMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListMultiRolePoolInstanceMetricDefinitionsCustomPager{}, + Path: fmt.Sprintf("%s/metricdefinitions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceMetricDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRolePoolInstanceMetricDefinitionsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRolePoolInstanceMetricDefinitionsComplete(ctx context.Context, id DefaultInstanceId) (ListMultiRolePoolInstanceMetricDefinitionsCompleteResult, error) { + return c.ListMultiRolePoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) +} + +// ListMultiRolePoolInstanceMetricDefinitionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRolePoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id DefaultInstanceId, predicate ResourceMetricDefinitionOperationPredicate) (result ListMultiRolePoolInstanceMetricDefinitionsCompleteResult, err error) { + items := make([]ResourceMetricDefinition, 0) + + resp, err := c.ListMultiRolePoolInstanceMetricDefinitions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListMultiRolePoolInstanceMetricDefinitionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_listmultirolepools.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_listmultirolepools.go new file mode 100644 index 00000000000..2fff5186ba4 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_listmultirolepools.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListMultiRolePoolsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkerPoolResource +} + +type ListMultiRolePoolsCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkerPoolResource +} + +type ListMultiRolePoolsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListMultiRolePoolsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListMultiRolePools ... +func (c AppServiceEnvironmentsClient) ListMultiRolePools(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListMultiRolePoolsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListMultiRolePoolsCustomPager{}, + Path: fmt.Sprintf("%s/multiRolePools", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkerPoolResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRolePoolsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRolePoolsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListMultiRolePoolsCompleteResult, error) { + return c.ListMultiRolePoolsCompleteMatchingPredicate(ctx, id, WorkerPoolResourceOperationPredicate{}) +} + +// ListMultiRolePoolsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRolePoolsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate WorkerPoolResourceOperationPredicate) (result ListMultiRolePoolsCompleteResult, err error) { + items := make([]WorkerPoolResource, 0) + + resp, err := c.ListMultiRolePools(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListMultiRolePoolsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_listmultirolepoolskus.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_listmultirolepoolskus.go new file mode 100644 index 00000000000..68df6ce4b5d --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_listmultirolepoolskus.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListMultiRolePoolSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SkuInfo +} + +type ListMultiRolePoolSkusCompleteResult struct { + LatestHttpResponse *http.Response + Items []SkuInfo +} + +type ListMultiRolePoolSkusCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListMultiRolePoolSkusCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListMultiRolePoolSkus ... +func (c AppServiceEnvironmentsClient) ListMultiRolePoolSkus(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListMultiRolePoolSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListMultiRolePoolSkusCustomPager{}, + Path: fmt.Sprintf("%s/multiRolePools/default/skus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SkuInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRolePoolSkusComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRolePoolSkusComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListMultiRolePoolSkusCompleteResult, error) { + return c.ListMultiRolePoolSkusCompleteMatchingPredicate(ctx, id, SkuInfoOperationPredicate{}) +} + +// ListMultiRolePoolSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRolePoolSkusCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate SkuInfoOperationPredicate) (result ListMultiRolePoolSkusCompleteResult, err error) { + items := make([]SkuInfo, 0) + + resp, err := c.ListMultiRolePoolSkus(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListMultiRolePoolSkusCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_listmultiroleusages.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_listmultiroleusages.go new file mode 100644 index 00000000000..a835e6f4109 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_listmultiroleusages.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListMultiRoleUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Usage +} + +type ListMultiRoleUsagesCompleteResult struct { + LatestHttpResponse *http.Response + Items []Usage +} + +type ListMultiRoleUsagesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListMultiRoleUsagesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListMultiRoleUsages ... +func (c AppServiceEnvironmentsClient) ListMultiRoleUsages(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListMultiRoleUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListMultiRoleUsagesCustomPager{}, + Path: fmt.Sprintf("%s/multiRolePools/default/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Usage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMultiRoleUsagesComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListMultiRoleUsagesComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListMultiRoleUsagesCompleteResult, error) { + return c.ListMultiRoleUsagesCompleteMatchingPredicate(ctx, id, UsageOperationPredicate{}) +} + +// ListMultiRoleUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListMultiRoleUsagesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate UsageOperationPredicate) (result ListMultiRoleUsagesCompleteResult, err error) { + items := make([]Usage, 0) + + resp, err := c.ListMultiRoleUsages(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListMultiRoleUsagesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_listoperations.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_listoperations.go new file mode 100644 index 00000000000..cc96adc214e --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_listoperations.go @@ -0,0 +1,55 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Operation +} + +// ListOperations ... +func (c AppServiceEnvironmentsClient) ListOperations(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListOperationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/operations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []Operation + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_listusages.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_listusages.go new file mode 100644 index 00000000000..2fdba17a92e --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_listusages.go @@ -0,0 +1,135 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type ListUsagesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmUsageQuota +} + +type ListUsagesOperationOptions struct { + Filter *string +} + +func DefaultListUsagesOperationOptions() ListUsagesOperationOptions { + return ListUsagesOperationOptions{} +} + +func (o ListUsagesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListUsagesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListUsagesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListUsagesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListUsagesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListUsages ... +func (c AppServiceEnvironmentsClient) ListUsages(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListUsagesOperationOptions) (result ListUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListUsagesCustomPager{}, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListUsagesComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListUsagesComplete(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListUsagesOperationOptions) (ListUsagesCompleteResult, error) { + return c.ListUsagesCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) +} + +// ListUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListUsagesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListUsagesOperationOptions, predicate CsmUsageQuotaOperationPredicate) (result ListUsagesCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.ListUsages(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListUsagesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_listwebapps.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_listwebapps.go new file mode 100644 index 00000000000..2c63e81b80b --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_listwebapps.go @@ -0,0 +1,135 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListWebAppsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListWebAppsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type ListWebAppsOperationOptions struct { + PropertiesToInclude *string +} + +func DefaultListWebAppsOperationOptions() ListWebAppsOperationOptions { + return ListWebAppsOperationOptions{} +} + +func (o ListWebAppsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListWebAppsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListWebAppsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.PropertiesToInclude != nil { + out.Append("propertiesToInclude", fmt.Sprintf("%v", *o.PropertiesToInclude)) + } + return &out +} + +type ListWebAppsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWebAppsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWebApps ... +func (c AppServiceEnvironmentsClient) ListWebApps(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListWebAppsOperationOptions) (result ListWebAppsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListWebAppsCustomPager{}, + Path: fmt.Sprintf("%s/sites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebAppsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWebAppsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListWebAppsOperationOptions) (ListWebAppsCompleteResult, error) { + return c.ListWebAppsCompleteMatchingPredicate(ctx, id, options, SiteOperationPredicate{}) +} + +// ListWebAppsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWebAppsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListWebAppsOperationOptions, predicate SiteOperationPredicate) (result ListWebAppsCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.ListWebApps(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWebAppsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_listwebworkermetricdefinitions.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_listwebworkermetricdefinitions.go new file mode 100644 index 00000000000..0d83ccdd738 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_listwebworkermetricdefinitions.go @@ -0,0 +1,105 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListWebWorkerMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceMetricDefinition +} + +type ListWebWorkerMetricDefinitionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceMetricDefinition +} + +type ListWebWorkerMetricDefinitionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWebWorkerMetricDefinitionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWebWorkerMetricDefinitions ... +func (c AppServiceEnvironmentsClient) ListWebWorkerMetricDefinitions(ctx context.Context, id WorkerPoolId) (result ListWebWorkerMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWebWorkerMetricDefinitionsCustomPager{}, + Path: fmt.Sprintf("%s/metricdefinitions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceMetricDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebWorkerMetricDefinitionsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWebWorkerMetricDefinitionsComplete(ctx context.Context, id WorkerPoolId) (ListWebWorkerMetricDefinitionsCompleteResult, error) { + return c.ListWebWorkerMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) +} + +// ListWebWorkerMetricDefinitionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWebWorkerMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id WorkerPoolId, predicate ResourceMetricDefinitionOperationPredicate) (result ListWebWorkerMetricDefinitionsCompleteResult, err error) { + items := make([]ResourceMetricDefinition, 0) + + resp, err := c.ListWebWorkerMetricDefinitions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWebWorkerMetricDefinitionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_listwebworkerusages.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_listwebworkerusages.go new file mode 100644 index 00000000000..380989d1a8d --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_listwebworkerusages.go @@ -0,0 +1,105 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListWebWorkerUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Usage +} + +type ListWebWorkerUsagesCompleteResult struct { + LatestHttpResponse *http.Response + Items []Usage +} + +type ListWebWorkerUsagesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWebWorkerUsagesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWebWorkerUsages ... +func (c AppServiceEnvironmentsClient) ListWebWorkerUsages(ctx context.Context, id WorkerPoolId) (result ListWebWorkerUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWebWorkerUsagesCustomPager{}, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Usage `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebWorkerUsagesComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWebWorkerUsagesComplete(ctx context.Context, id WorkerPoolId) (ListWebWorkerUsagesCompleteResult, error) { + return c.ListWebWorkerUsagesCompleteMatchingPredicate(ctx, id, UsageOperationPredicate{}) +} + +// ListWebWorkerUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWebWorkerUsagesCompleteMatchingPredicate(ctx context.Context, id WorkerPoolId, predicate UsageOperationPredicate) (result ListWebWorkerUsagesCompleteResult, err error) { + items := make([]Usage, 0) + + resp, err := c.ListWebWorkerUsages(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWebWorkerUsagesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_listworkerpoolinstancemetricdefinitions.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_listworkerpoolinstancemetricdefinitions.go new file mode 100644 index 00000000000..283907aee09 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_listworkerpoolinstancemetricdefinitions.go @@ -0,0 +1,105 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListWorkerPoolInstanceMetricDefinitionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceMetricDefinition +} + +type ListWorkerPoolInstanceMetricDefinitionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceMetricDefinition +} + +type ListWorkerPoolInstanceMetricDefinitionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWorkerPoolInstanceMetricDefinitionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWorkerPoolInstanceMetricDefinitions ... +func (c AppServiceEnvironmentsClient) ListWorkerPoolInstanceMetricDefinitions(ctx context.Context, id WorkerPoolInstanceId) (result ListWorkerPoolInstanceMetricDefinitionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWorkerPoolInstanceMetricDefinitionsCustomPager{}, + Path: fmt.Sprintf("%s/metricdefinitions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceMetricDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWorkerPoolInstanceMetricDefinitionsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWorkerPoolInstanceMetricDefinitionsComplete(ctx context.Context, id WorkerPoolInstanceId) (ListWorkerPoolInstanceMetricDefinitionsCompleteResult, error) { + return c.ListWorkerPoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx, id, ResourceMetricDefinitionOperationPredicate{}) +} + +// ListWorkerPoolInstanceMetricDefinitionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWorkerPoolInstanceMetricDefinitionsCompleteMatchingPredicate(ctx context.Context, id WorkerPoolInstanceId, predicate ResourceMetricDefinitionOperationPredicate) (result ListWorkerPoolInstanceMetricDefinitionsCompleteResult, err error) { + items := make([]ResourceMetricDefinition, 0) + + resp, err := c.ListWorkerPoolInstanceMetricDefinitions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWorkerPoolInstanceMetricDefinitionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_listworkerpools.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_listworkerpools.go new file mode 100644 index 00000000000..ec25afdb033 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_listworkerpools.go @@ -0,0 +1,106 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListWorkerPoolsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkerPoolResource +} + +type ListWorkerPoolsCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkerPoolResource +} + +type ListWorkerPoolsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWorkerPoolsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWorkerPools ... +func (c AppServiceEnvironmentsClient) ListWorkerPools(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListWorkerPoolsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWorkerPoolsCustomPager{}, + Path: fmt.Sprintf("%s/workerPools", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkerPoolResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWorkerPoolsComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWorkerPoolsComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListWorkerPoolsCompleteResult, error) { + return c.ListWorkerPoolsCompleteMatchingPredicate(ctx, id, WorkerPoolResourceOperationPredicate{}) +} + +// ListWorkerPoolsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWorkerPoolsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate WorkerPoolResourceOperationPredicate) (result ListWorkerPoolsCompleteResult, err error) { + items := make([]WorkerPoolResource, 0) + + resp, err := c.ListWorkerPools(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWorkerPoolsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_listworkerpoolskus.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_listworkerpoolskus.go new file mode 100644 index 00000000000..74192d0c7ec --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_listworkerpoolskus.go @@ -0,0 +1,105 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListWorkerPoolSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SkuInfo +} + +type ListWorkerPoolSkusCompleteResult struct { + LatestHttpResponse *http.Response + Items []SkuInfo +} + +type ListWorkerPoolSkusCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWorkerPoolSkusCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWorkerPoolSkus ... +func (c AppServiceEnvironmentsClient) ListWorkerPoolSkus(ctx context.Context, id WorkerPoolId) (result ListWorkerPoolSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWorkerPoolSkusCustomPager{}, + Path: fmt.Sprintf("%s/skus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SkuInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWorkerPoolSkusComplete retrieves all the results into a single object +func (c AppServiceEnvironmentsClient) ListWorkerPoolSkusComplete(ctx context.Context, id WorkerPoolId) (ListWorkerPoolSkusCompleteResult, error) { + return c.ListWorkerPoolSkusCompleteMatchingPredicate(ctx, id, SkuInfoOperationPredicate{}) +} + +// ListWorkerPoolSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServiceEnvironmentsClient) ListWorkerPoolSkusCompleteMatchingPredicate(ctx context.Context, id WorkerPoolId, predicate SkuInfoOperationPredicate) (result ListWorkerPoolSkusCompleteResult, err error) { + items := make([]SkuInfo, 0) + + resp, err := c.ListWorkerPoolSkus(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWorkerPoolSkusCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_reboot.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_reboot.go new file mode 100644 index 00000000000..da6ac719365 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_reboot.go @@ -0,0 +1,48 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RebootOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Reboot ... +func (c AppServiceEnvironmentsClient) Reboot(ctx context.Context, id commonids.AppServiceEnvironmentId) (result RebootOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reboot", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_resume.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_resume.go new file mode 100644 index 00000000000..9cafc62c013 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_resume.go @@ -0,0 +1,90 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResumeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ResumeCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type ResumeCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ResumeCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// Resume ... +func (c AppServiceEnvironmentsClient) Resume(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ResumeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ResumeCustomPager{}, + Path: fmt.Sprintf("%s/resume", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResumeThenPoll performs Resume then polls until it's completed +func (c AppServiceEnvironmentsClient) ResumeThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId) error { + result, err := c.Resume(ctx, id) + if err != nil { + return fmt.Errorf("performing Resume: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Resume: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_suspend.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_suspend.go new file mode 100644 index 00000000000..e6c388ed071 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_suspend.go @@ -0,0 +1,90 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SuspendOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type SuspendCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type SuspendCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *SuspendCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// Suspend ... +func (c AppServiceEnvironmentsClient) Suspend(ctx context.Context, id commonids.AppServiceEnvironmentId) (result SuspendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &SuspendCustomPager{}, + Path: fmt.Sprintf("%s/suspend", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SuspendThenPoll performs Suspend then polls until it's completed +func (c AppServiceEnvironmentsClient) SuspendThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId) error { + result, err := c.Suspend(ctx, id) + if err != nil { + return fmt.Errorf("performing Suspend: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Suspend: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_testupgradeavailablenotification.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_testupgradeavailablenotification.go new file mode 100644 index 00000000000..3c1081f9144 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_testupgradeavailablenotification.go @@ -0,0 +1,48 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TestUpgradeAvailableNotificationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// TestUpgradeAvailableNotification ... +func (c AppServiceEnvironmentsClient) TestUpgradeAvailableNotification(ctx context.Context, id commonids.AppServiceEnvironmentId) (result TestUpgradeAvailableNotificationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/testUpgradeAvailableNotification", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_update.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_update.go new file mode 100644 index 00000000000..eeba2343384 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_update.go @@ -0,0 +1,60 @@ +package appserviceenvironments + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServiceEnvironmentResource +} + +// Update ... +func (c AppServiceEnvironmentsClient) Update(ctx context.Context, id commonids.AppServiceEnvironmentId, input AppServiceEnvironmentPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServiceEnvironmentResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_updateasecustomdnssuffixconfiguration.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_updateasecustomdnssuffixconfiguration.go new file mode 100644 index 00000000000..84b44271ed7 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_updateasecustomdnssuffixconfiguration.go @@ -0,0 +1,59 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateAseCustomDnsSuffixConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomDnsSuffixConfiguration +} + +// UpdateAseCustomDnsSuffixConfiguration ... +func (c AppServiceEnvironmentsClient) UpdateAseCustomDnsSuffixConfiguration(ctx context.Context, id commonids.AppServiceEnvironmentId, input CustomDnsSuffixConfiguration) (result UpdateAseCustomDnsSuffixConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/configurations/customdnssuffix", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CustomDnsSuffixConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_updateasenetworkingconfiguration.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_updateasenetworkingconfiguration.go new file mode 100644 index 00000000000..d215f8021fa --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_updateasenetworkingconfiguration.go @@ -0,0 +1,59 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateAseNetworkingConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AseV3NetworkingConfiguration +} + +// UpdateAseNetworkingConfiguration ... +func (c AppServiceEnvironmentsClient) UpdateAseNetworkingConfiguration(ctx context.Context, id commonids.AppServiceEnvironmentId, input AseV3NetworkingConfiguration) (result UpdateAseNetworkingConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/configurations/networking", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AseV3NetworkingConfiguration + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_updatemultirolepool.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_updatemultirolepool.go new file mode 100644 index 00000000000..22ee8b00991 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_updatemultirolepool.go @@ -0,0 +1,60 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateMultiRolePoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// UpdateMultiRolePool ... +func (c AppServiceEnvironmentsClient) UpdateMultiRolePool(ctx context.Context, id commonids.AppServiceEnvironmentId, input WorkerPoolResource) (result UpdateMultiRolePoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/multiRolePools/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkerPoolResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_updateworkerpool.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_updateworkerpool.go new file mode 100644 index 00000000000..42b61ccc4f7 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_updateworkerpool.go @@ -0,0 +1,58 @@ +package appserviceenvironments + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateWorkerPoolOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkerPoolResource +} + +// UpdateWorkerPool ... +func (c AppServiceEnvironmentsClient) UpdateWorkerPool(ctx context.Context, id WorkerPoolId, input WorkerPoolResource) (result UpdateWorkerPoolOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkerPoolResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/method_upgrade.go b/resource-manager/web/2024-11-01/appserviceenvironments/method_upgrade.go new file mode 100644 index 00000000000..36584682ac1 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/method_upgrade.go @@ -0,0 +1,70 @@ +package appserviceenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpgradeOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Upgrade ... +func (c AppServiceEnvironmentsClient) Upgrade(ctx context.Context, id commonids.AppServiceEnvironmentId) (result UpgradeOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/upgrade", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpgradeThenPoll performs Upgrade then polls until it's completed +func (c AppServiceEnvironmentsClient) UpgradeThenPoll(ctx context.Context, id commonids.AppServiceEnvironmentId) error { + result, err := c.Upgrade(ctx, id) + if err != nil { + return fmt.Errorf("performing Upgrade: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Upgrade: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_addressresponse.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_addressresponse.go new file mode 100644 index 00000000000..5949ada3aeb --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_addressresponse.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressResponse struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AddressResponseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_addressresponseproperties.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_addressresponseproperties.go new file mode 100644 index 00000000000..22241e69975 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_addressresponseproperties.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddressResponseProperties struct { + InternalIPAddress *string `json:"internalIpAddress,omitempty"` + OutboundIPAddresses *[]string `json:"outboundIpAddresses,omitempty"` + ServiceIPAddress *string `json:"serviceIpAddress,omitempty"` + VipMappings *[]VirtualIPMapping `json:"vipMappings,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_apidefinitioninfo.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_apidefinitioninfo.go new file mode 100644 index 00000000000..b29b3fb28ec --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_apidefinitioninfo.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiDefinitionInfo struct { + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_apimanagementconfig.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_apimanagementconfig.go new file mode 100644 index 00000000000..eca6e5d45b9 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_apimanagementconfig.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiManagementConfig struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_appserviceenvironment.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_appserviceenvironment.go new file mode 100644 index 00000000000..7e868462756 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_appserviceenvironment.go @@ -0,0 +1,27 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceEnvironment struct { + ClusterSettings *[]NameValuePair `json:"clusterSettings,omitempty"` + CustomDnsSuffixConfiguration *CustomDnsSuffixConfiguration `json:"customDnsSuffixConfiguration,omitempty"` + DedicatedHostCount *int64 `json:"dedicatedHostCount,omitempty"` + DnsSuffix *string `json:"dnsSuffix,omitempty"` + FrontEndScaleFactor *int64 `json:"frontEndScaleFactor,omitempty"` + HasLinuxWorkers *bool `json:"hasLinuxWorkers,omitempty"` + IPsslAddressCount *int64 `json:"ipsslAddressCount,omitempty"` + InternalLoadBalancingMode *LoadBalancingMode `json:"internalLoadBalancingMode,omitempty"` + MaximumNumberOfMachines *int64 `json:"maximumNumberOfMachines,omitempty"` + MultiRoleCount *int64 `json:"multiRoleCount,omitempty"` + MultiSize *string `json:"multiSize,omitempty"` + NetworkingConfiguration *AseV3NetworkingConfiguration `json:"networkingConfiguration,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Status *HostingEnvironmentStatus `json:"status,omitempty"` + Suspended *bool `json:"suspended,omitempty"` + UpgradeAvailability *UpgradeAvailability `json:"upgradeAvailability,omitempty"` + UpgradePreference *UpgradePreference `json:"upgradePreference,omitempty"` + UserWhitelistedIPRanges *[]string `json:"userWhitelistedIpRanges,omitempty"` + VirtualNetwork VirtualNetworkProfile `json:"virtualNetwork"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_appserviceenvironmentpatchresource.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_appserviceenvironmentpatchresource.go new file mode 100644 index 00000000000..594e57510dd --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_appserviceenvironmentpatchresource.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceEnvironmentPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AppServiceEnvironment `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_appserviceenvironmentresource.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_appserviceenvironmentresource.go new file mode 100644 index 00000000000..31263ba6394 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_appserviceenvironmentresource.go @@ -0,0 +1,14 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceEnvironmentResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServiceEnvironment `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_appserviceplan.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_appserviceplan.go new file mode 100644 index 00000000000..499328be215 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_appserviceplan.go @@ -0,0 +1,16 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServicePlan struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServicePlanProperties `json:"properties,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_appserviceplanproperties.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_appserviceplanproperties.go new file mode 100644 index 00000000000..fd5c38c25d2 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_appserviceplanproperties.go @@ -0,0 +1,61 @@ +package appserviceenvironments + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServicePlanProperties struct { + AsyncScalingEnabled *bool `json:"asyncScalingEnabled,omitempty"` + ElasticScaleEnabled *bool `json:"elasticScaleEnabled,omitempty"` + FreeOfferExpirationTime *string `json:"freeOfferExpirationTime,omitempty"` + GeoRegion *string `json:"geoRegion,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + IsSpot *bool `json:"isSpot,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KubeEnvironmentProfile *KubeEnvironmentProfile `json:"kubeEnvironmentProfile,omitempty"` + MaximumElasticWorkerCount *int64 `json:"maximumElasticWorkerCount,omitempty"` + MaximumNumberOfWorkers *int64 `json:"maximumNumberOfWorkers,omitempty"` + NumberOfSites *int64 `json:"numberOfSites,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PerSiteScaling *bool `json:"perSiteScaling,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + SpotExpirationTime *string `json:"spotExpirationTime,omitempty"` + Status *StatusOptions `json:"status,omitempty"` + Subscription *string `json:"subscription,omitempty"` + TargetWorkerCount *int64 `json:"targetWorkerCount,omitempty"` + TargetWorkerSizeId *int64 `json:"targetWorkerSizeId,omitempty"` + WorkerTierName *string `json:"workerTierName,omitempty"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} + +func (o *AppServicePlanProperties) GetFreeOfferExpirationTimeAsTime() (*time.Time, error) { + if o.FreeOfferExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.FreeOfferExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanProperties) SetFreeOfferExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.FreeOfferExpirationTime = &formatted +} + +func (o *AppServicePlanProperties) GetSpotExpirationTimeAsTime() (*time.Time, error) { + if o.SpotExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SpotExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanProperties) SetSpotExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SpotExpirationTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_armidwrapper.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_armidwrapper.go new file mode 100644 index 00000000000..23291cc1624 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_armidwrapper.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArmIdWrapper struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_asev3networkingconfiguration.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_asev3networkingconfiguration.go new file mode 100644 index 00000000000..dd9c6b64a48 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_asev3networkingconfiguration.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseV3NetworkingConfiguration struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AseV3NetworkingConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_asev3networkingconfigurationproperties.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_asev3networkingconfigurationproperties.go new file mode 100644 index 00000000000..82c8e80d94e --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_asev3networkingconfigurationproperties.go @@ -0,0 +1,15 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseV3NetworkingConfigurationProperties struct { + AllowNewPrivateEndpointConnections *bool `json:"allowNewPrivateEndpointConnections,omitempty"` + ExternalInboundIPAddresses *[]string `json:"externalInboundIpAddresses,omitempty"` + FtpEnabled *bool `json:"ftpEnabled,omitempty"` + InboundIPAddressOverride *string `json:"inboundIpAddressOverride,omitempty"` + InternalInboundIPAddresses *[]string `json:"internalInboundIpAddresses,omitempty"` + LinuxOutboundIPAddresses *[]string `json:"linuxOutboundIpAddresses,omitempty"` + RemoteDebugEnabled *bool `json:"remoteDebugEnabled,omitempty"` + WindowsOutboundIPAddresses *[]string `json:"windowsOutboundIpAddresses,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_autohealactions.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_autohealactions.go new file mode 100644 index 00000000000..a53db3433d9 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_autohealactions.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealActions struct { + ActionType *AutoHealActionType `json:"actionType,omitempty"` + CustomAction *AutoHealCustomAction `json:"customAction,omitempty"` + MinProcessExecutionTime *string `json:"minProcessExecutionTime,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_autohealcustomaction.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_autohealcustomaction.go new file mode 100644 index 00000000000..b4979e90b7a --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_autohealcustomaction.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealCustomAction struct { + Exe *string `json:"exe,omitempty"` + Parameters *string `json:"parameters,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_autohealrules.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_autohealrules.go new file mode 100644 index 00000000000..cd835879fe2 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_autohealrules.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealRules struct { + Actions *AutoHealActions `json:"actions,omitempty"` + Triggers *AutoHealTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_autohealtriggers.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_autohealtriggers.go new file mode 100644 index 00000000000..2d6842a3f7d --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_autohealtriggers.go @@ -0,0 +1,13 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealTriggers struct { + PrivateBytesInKB *int64 `json:"privateBytesInKB,omitempty"` + Requests *RequestsBasedTrigger `json:"requests,omitempty"` + SlowRequests *SlowRequestsBasedTrigger `json:"slowRequests,omitempty"` + SlowRequestsWithPath *[]SlowRequestsBasedTrigger `json:"slowRequestsWithPath,omitempty"` + StatusCodes *[]StatusCodesBasedTrigger `json:"statusCodes,omitempty"` + StatusCodesRange *[]StatusCodesRangeBasedTrigger `json:"statusCodesRange,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_azurestorageinfovalue.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_azurestorageinfovalue.go new file mode 100644 index 00000000000..57e32f54dc0 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_azurestorageinfovalue.go @@ -0,0 +1,14 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageInfoValue struct { + AccessKey *string `json:"accessKey,omitempty"` + AccountName *string `json:"accountName,omitempty"` + MountPath *string `json:"mountPath,omitempty"` + Protocol *AzureStorageProtocol `json:"protocol,omitempty"` + ShareName *string `json:"shareName,omitempty"` + State *AzureStorageState `json:"state,omitempty"` + Type *AzureStorageType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_capability.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_capability.go new file mode 100644 index 00000000000..6b07c220bef --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_capability.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Capability struct { + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_cloninginfo.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_cloninginfo.go new file mode 100644 index 00000000000..f9505ee3c37 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_cloninginfo.go @@ -0,0 +1,18 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloningInfo struct { + AppSettingsOverrides *map[string]string `json:"appSettingsOverrides,omitempty"` + CloneCustomHostNames *bool `json:"cloneCustomHostNames,omitempty"` + CloneSourceControl *bool `json:"cloneSourceControl,omitempty"` + ConfigureLoadBalancing *bool `json:"configureLoadBalancing,omitempty"` + CorrelationId *string `json:"correlationId,omitempty"` + HostingEnvironment *string `json:"hostingEnvironment,omitempty"` + Overwrite *bool `json:"overwrite,omitempty"` + SourceWebAppId string `json:"sourceWebAppId"` + SourceWebAppLocation *string `json:"sourceWebAppLocation,omitempty"` + TrafficManagerProfileId *string `json:"trafficManagerProfileId,omitempty"` + TrafficManagerProfileName *string `json:"trafficManagerProfileName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_connstringinfo.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_connstringinfo.go new file mode 100644 index 00000000000..a4172f89872 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_connstringinfo.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnStringInfo struct { + ConnectionString *string `json:"connectionString,omitempty"` + Name *string `json:"name,omitempty"` + Type *ConnectionStringType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_corssettings.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_corssettings.go new file mode 100644 index 00000000000..24390a28726 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_corssettings.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CorsSettings struct { + AllowedOrigins *[]string `json:"allowedOrigins,omitempty"` + SupportCredentials *bool `json:"supportCredentials,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_csmusagequota.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_csmusagequota.go new file mode 100644 index 00000000000..0ba4a1dd059 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_csmusagequota.go @@ -0,0 +1,30 @@ +package appserviceenvironments + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmUsageQuota struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *LocalizableString `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +func (o *CsmUsageQuota) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CsmUsageQuota) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_customdnssuffixconfiguration.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_customdnssuffixconfiguration.go new file mode 100644 index 00000000000..ed5fdcd1b9a --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_customdnssuffixconfiguration.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsSuffixConfiguration struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CustomDnsSuffixConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_customdnssuffixconfigurationproperties.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_customdnssuffixconfigurationproperties.go new file mode 100644 index 00000000000..54d57c9d118 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_customdnssuffixconfigurationproperties.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsSuffixConfigurationProperties struct { + CertificateURL *string `json:"certificateUrl,omitempty"` + DnsSuffix *string `json:"dnsSuffix,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + ProvisioningDetails *string `json:"provisioningDetails,omitempty"` + ProvisioningState *CustomDnsSuffixProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_daprconfig.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_daprconfig.go new file mode 100644 index 00000000000..9268fd62dc0 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_daprconfig.go @@ -0,0 +1,14 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprConfig struct { + AppId *string `json:"appId,omitempty"` + AppPort *int64 `json:"appPort,omitempty"` + EnableApiLogging *bool `json:"enableApiLogging,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + HTTPMaxRequestSize *int64 `json:"httpMaxRequestSize,omitempty"` + HTTPReadBufferSize *int64 `json:"httpReadBufferSize,omitempty"` + LogLevel *DaprLogLevel `json:"logLevel,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_endpointdependency.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_endpointdependency.go new file mode 100644 index 00000000000..9840103ce20 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_endpointdependency.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointDependency struct { + DomainName *string `json:"domainName,omitempty"` + EndpointDetails *[]EndpointDetail `json:"endpointDetails,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_endpointdetail.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_endpointdetail.go new file mode 100644 index 00000000000..d738ebeb260 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_endpointdetail.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointDetail struct { + IPAddress *string `json:"ipAddress,omitempty"` + IsAccessible *bool `json:"isAccessible,omitempty"` + Latency *float64 `json:"latency,omitempty"` + Port *int64 `json:"port,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_errorentity.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_errorentity.go new file mode 100644 index 00000000000..8125008a5d2 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_errorentity.go @@ -0,0 +1,15 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorEntity struct { + Code *string `json:"code,omitempty"` + Details *[]ErrorEntity `json:"details,omitempty"` + ExtendedCode *string `json:"extendedCode,omitempty"` + InnerErrors *[]ErrorEntity `json:"innerErrors,omitempty"` + Message *string `json:"message,omitempty"` + MessageTemplate *string `json:"messageTemplate,omitempty"` + Parameters *[]string `json:"parameters,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_experiments.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_experiments.go new file mode 100644 index 00000000000..9bd9653d59f --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_experiments.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Experiments struct { + RampUpRules *[]RampUpRule `json:"rampUpRules,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_extendedlocation.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_extendedlocation.go new file mode 100644 index 00000000000..b24df8493f9 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_extendedlocation.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_functionappconfig.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionappconfig.go new file mode 100644 index 00000000000..e3733b6a7c4 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionappconfig.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppConfig struct { + Deployment *FunctionsDeployment `json:"deployment,omitempty"` + Runtime *FunctionsRuntime `json:"runtime,omitempty"` + ScaleAndConcurrency *FunctionsScaleAndConcurrency `json:"scaleAndConcurrency,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsalwaysreadyconfig.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsalwaysreadyconfig.go new file mode 100644 index 00000000000..7034ed11de4 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsalwaysreadyconfig.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsAlwaysReadyConfig struct { + InstanceCount *int64 `json:"instanceCount,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsdeployment.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsdeployment.go new file mode 100644 index 00000000000..4b819404793 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsdeployment.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeployment struct { + Storage *FunctionsDeploymentStorage `json:"storage,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsdeploymentstorage.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsdeploymentstorage.go new file mode 100644 index 00000000000..de4f6231617 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsdeploymentstorage.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorage struct { + Authentication *FunctionsDeploymentStorageAuthentication `json:"authentication,omitempty"` + Type *FunctionsDeploymentStorageType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsdeploymentstorageauthentication.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsdeploymentstorageauthentication.go new file mode 100644 index 00000000000..deebac5deb3 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsdeploymentstorageauthentication.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorageAuthentication struct { + StorageAccountConnectionStringName *string `json:"storageAccountConnectionStringName,omitempty"` + Type *AuthenticationType `json:"type,omitempty"` + UserAssignedIdentityResourceId *string `json:"userAssignedIdentityResourceId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsruntime.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsruntime.go new file mode 100644 index 00000000000..b0fc099b28b --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsruntime.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsRuntime struct { + Name *RuntimeName `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsscaleandconcurrency.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsscaleandconcurrency.go new file mode 100644 index 00000000000..98d876cc3d9 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsscaleandconcurrency.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrency struct { + AlwaysReady *[]FunctionsAlwaysReadyConfig `json:"alwaysReady,omitempty"` + InstanceMemoryMB *int64 `json:"instanceMemoryMB,omitempty"` + MaximumInstanceCount *int64 `json:"maximumInstanceCount,omitempty"` + Triggers *FunctionsScaleAndConcurrencyTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsscaleandconcurrencytriggers.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsscaleandconcurrencytriggers.go new file mode 100644 index 00000000000..28d4106d6fb --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsscaleandconcurrencytriggers.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggers struct { + HTTP *FunctionsScaleAndConcurrencyTriggersHTTP `json:"http,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsscaleandconcurrencytriggershttp.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsscaleandconcurrencytriggershttp.go new file mode 100644 index 00000000000..06c763b2e79 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_functionsscaleandconcurrencytriggershttp.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggersHTTP struct { + PerInstanceConcurrency *int64 `json:"perInstanceConcurrency,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_handlermapping.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_handlermapping.go new file mode 100644 index 00000000000..add89600372 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_handlermapping.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HandlerMapping struct { + Arguments *string `json:"arguments,omitempty"` + Extension *string `json:"extension,omitempty"` + ScriptProcessor *string `json:"scriptProcessor,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_hostingenvironmentdiagnostics.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_hostingenvironmentdiagnostics.go new file mode 100644 index 00000000000..1d298e705f6 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_hostingenvironmentdiagnostics.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentDiagnostics struct { + DiagnosticsOutput *string `json:"diagnosticsOutput,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_hostingenvironmentprofile.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_hostingenvironmentprofile.go new file mode 100644 index 00000000000..e67fbad99e5 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_hostingenvironmentprofile.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_hostnamesslstate.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_hostnamesslstate.go new file mode 100644 index 00000000000..b60ed2b41ef --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_hostnamesslstate.go @@ -0,0 +1,13 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostNameSslState struct { + HostType *HostType `json:"hostType,omitempty"` + Name *string `json:"name,omitempty"` + SslState *SslState `json:"sslState,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + ToUpdate *bool `json:"toUpdate,omitempty"` + VirtualIP *string `json:"virtualIP,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_inboundenvironmentendpoint.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_inboundenvironmentendpoint.go new file mode 100644 index 00000000000..83dea79b75b --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_inboundenvironmentendpoint.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InboundEnvironmentEndpoint struct { + Description *string `json:"description,omitempty"` + Endpoints *[]string `json:"endpoints,omitempty"` + Ports *[]string `json:"ports,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_ipsecurityrestriction.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_ipsecurityrestriction.go new file mode 100644 index 00000000000..cce3b7521d2 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_ipsecurityrestriction.go @@ -0,0 +1,18 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPSecurityRestriction struct { + Action *string `json:"action,omitempty"` + Description *string `json:"description,omitempty"` + Headers *map[string][]string `json:"headers,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + SubnetMask *string `json:"subnetMask,omitempty"` + SubnetTrafficTag *int64 `json:"subnetTrafficTag,omitempty"` + Tag *IPFilterTag `json:"tag,omitempty"` + VnetSubnetResourceId *string `json:"vnetSubnetResourceId,omitempty"` + VnetTrafficTag *int64 `json:"vnetTrafficTag,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_kubeenvironmentprofile.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_kubeenvironmentprofile.go new file mode 100644 index 00000000000..1ad013915fa --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_kubeenvironmentprofile.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_localizablestring.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_localizablestring.go new file mode 100644 index 00000000000..5974acdfb1a --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_localizablestring.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalizableString struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_namevaluepair.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_namevaluepair.go new file mode 100644 index 00000000000..ac9cb553c36 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_namevaluepair.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameValuePair struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_operation.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_operation.go new file mode 100644 index 00000000000..e226cf16987 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_operation.go @@ -0,0 +1,57 @@ +package appserviceenvironments + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Operation struct { + CreatedTime *string `json:"createdTime,omitempty"` + Errors *[]ErrorEntity `json:"errors,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + GeoMasterOperationId *string `json:"geoMasterOperationId,omitempty"` + Id *string `json:"id,omitempty"` + ModifiedTime *string `json:"modifiedTime,omitempty"` + Name *string `json:"name,omitempty"` + Status *OperationStatus `json:"status,omitempty"` +} + +func (o *Operation) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *Operation) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *Operation) GetModifiedTimeAsTime() (*time.Time, error) { + if o.ModifiedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetModifiedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_outboundenvironmentendpoint.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_outboundenvironmentendpoint.go new file mode 100644 index 00000000000..04928bef582 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_outboundenvironmentendpoint.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundEnvironmentEndpoint struct { + Category *string `json:"category,omitempty"` + Endpoints *[]EndpointDependency `json:"endpoints,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_outboundvnetrouting.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_outboundvnetrouting.go new file mode 100644 index 00000000000..fd9c076fc68 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_outboundvnetrouting.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundVnetRouting struct { + AllTraffic *bool `json:"allTraffic,omitempty"` + ApplicationTraffic *bool `json:"applicationTraffic,omitempty"` + BackupRestoreTraffic *bool `json:"backupRestoreTraffic,omitempty"` + ContentShareTraffic *bool `json:"contentShareTraffic,omitempty"` + ImagePullTraffic *bool `json:"imagePullTraffic,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_privatelinkconnectionstate.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_privatelinkconnectionstate.go new file mode 100644 index 00000000000..86ca1b14e24 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_privatelinkconnectionstate.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_privatelinkresource.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_privatelinkresource.go new file mode 100644 index 00000000000..1b58321d272 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_privatelinkresource.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id string `json:"id"` + Name string `json:"name"` + Properties PrivateLinkResourceProperties `json:"properties"` + Type string `json:"type"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_privatelinkresourceproperties.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..ecd58509b6f --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_privatelinkresourceswrapper.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_privatelinkresourceswrapper.go new file mode 100644 index 00000000000..40cc8c0e8b1 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_privatelinkresourceswrapper.go @@ -0,0 +1,8 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesWrapper struct { + Value []PrivateLinkResource `json:"value"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_pushsettings.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_pushsettings.go new file mode 100644 index 00000000000..addca78ae4d --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_pushsettings.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettings struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PushSettingsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_pushsettingsproperties.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_pushsettingsproperties.go new file mode 100644 index 00000000000..6c80542248a --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_pushsettingsproperties.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettingsProperties struct { + DynamicTagsJson *string `json:"dynamicTagsJson,omitempty"` + IsPushEnabled bool `json:"isPushEnabled"` + TagWhitelistJson *string `json:"tagWhitelistJson,omitempty"` + TagsRequiringAuth *string `json:"tagsRequiringAuth,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_rampuprule.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_rampuprule.go new file mode 100644 index 00000000000..0db6bb0db58 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_rampuprule.go @@ -0,0 +1,15 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RampUpRule struct { + ActionHostName *string `json:"actionHostName,omitempty"` + ChangeDecisionCallbackURL *string `json:"changeDecisionCallbackUrl,omitempty"` + ChangeIntervalInMinutes *int64 `json:"changeIntervalInMinutes,omitempty"` + ChangeStep *float64 `json:"changeStep,omitempty"` + MaxReroutePercentage *float64 `json:"maxReroutePercentage,omitempty"` + MinReroutePercentage *float64 `json:"minReroutePercentage,omitempty"` + Name *string `json:"name,omitempty"` + ReroutePercentage *float64 `json:"reroutePercentage,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresource.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresource.go new file mode 100644 index 00000000000..314760728b6 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresource.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RemotePrivateEndpointConnectionARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresourceproperties.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresourceproperties.go new file mode 100644 index 00000000000..a96786cf386 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_remoteprivateendpointconnectionarmresourceproperties.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResourceProperties struct { + IPAddresses *[]string `json:"ipAddresses,omitempty"` + PrivateEndpoint *ArmIdWrapper `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_requestsbasedtrigger.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_requestsbasedtrigger.go new file mode 100644 index 00000000000..57351c32612 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_requestsbasedtrigger.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_resourceconfig.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_resourceconfig.go new file mode 100644 index 00000000000..d6f6c721d3c --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_resourceconfig.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceConfig struct { + Cpu *float64 `json:"cpu,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_resourcemetricavailability.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_resourcemetricavailability.go new file mode 100644 index 00000000000..2688445beaa --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_resourcemetricavailability.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceMetricAvailability struct { + Retention *string `json:"retention,omitempty"` + TimeGrain *string `json:"timeGrain,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_resourcemetricdefinition.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_resourcemetricdefinition.go new file mode 100644 index 00000000000..8645bb913f3 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_resourcemetricdefinition.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceMetricDefinition struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceMetricDefinitionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_resourcemetricdefinitionproperties.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_resourcemetricdefinitionproperties.go new file mode 100644 index 00000000000..d1d6856879a --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_resourcemetricdefinitionproperties.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceMetricDefinitionProperties struct { + MetricAvailabilities *[]ResourceMetricAvailability `json:"metricAvailabilities,omitempty"` + PrimaryAggregationType *string `json:"primaryAggregationType,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ResourceUri *string `json:"resourceUri,omitempty"` + Unit *string `json:"unit,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_site.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_site.go new file mode 100644 index 00000000000..a09cdcffac4 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_site.go @@ -0,0 +1,20 @@ +package appserviceenvironments + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Site struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SiteProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_siteconfig.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_siteconfig.go new file mode 100644 index 00000000000..75d99b4664e --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_siteconfig.go @@ -0,0 +1,98 @@ +package appserviceenvironments + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteConfig struct { + AcrUseManagedIdentityCreds *bool `json:"acrUseManagedIdentityCreds,omitempty"` + AcrUserManagedIdentityID *string `json:"acrUserManagedIdentityID,omitempty"` + AlwaysOn *bool `json:"alwaysOn,omitempty"` + ApiDefinition *ApiDefinitionInfo `json:"apiDefinition,omitempty"` + ApiManagementConfig *ApiManagementConfig `json:"apiManagementConfig,omitempty"` + AppCommandLine *string `json:"appCommandLine,omitempty"` + AppSettings *[]NameValuePair `json:"appSettings,omitempty"` + AutoHealEnabled *bool `json:"autoHealEnabled,omitempty"` + AutoHealRules *AutoHealRules `json:"autoHealRules,omitempty"` + AutoSwapSlotName *string `json:"autoSwapSlotName,omitempty"` + AzureStorageAccounts *map[string]AzureStorageInfoValue `json:"azureStorageAccounts,omitempty"` + ConnectionStrings *[]ConnStringInfo `json:"connectionStrings,omitempty"` + Cors *CorsSettings `json:"cors,omitempty"` + DefaultDocuments *[]string `json:"defaultDocuments,omitempty"` + DetailedErrorLoggingEnabled *bool `json:"detailedErrorLoggingEnabled,omitempty"` + DocumentRoot *string `json:"documentRoot,omitempty"` + ElasticWebAppScaleLimit *int64 `json:"elasticWebAppScaleLimit,omitempty"` + Experiments *Experiments `json:"experiments,omitempty"` + FtpsState *FtpsState `json:"ftpsState,omitempty"` + FunctionAppScaleLimit *int64 `json:"functionAppScaleLimit,omitempty"` + FunctionsRuntimeScaleMonitoringEnabled *bool `json:"functionsRuntimeScaleMonitoringEnabled,omitempty"` + HTTP20Enabled *bool `json:"http20Enabled,omitempty"` + HTTP20ProxyFlag *int64 `json:"http20ProxyFlag,omitempty"` + HTTPLoggingEnabled *bool `json:"httpLoggingEnabled,omitempty"` + HandlerMappings *[]HandlerMapping `json:"handlerMappings,omitempty"` + HealthCheckPath *string `json:"healthCheckPath,omitempty"` + IPSecurityRestrictions *[]IPSecurityRestriction `json:"ipSecurityRestrictions,omitempty"` + IPSecurityRestrictionsDefaultAction *DefaultAction `json:"ipSecurityRestrictionsDefaultAction,omitempty"` + JavaContainer *string `json:"javaContainer,omitempty"` + JavaContainerVersion *string `json:"javaContainerVersion,omitempty"` + JavaVersion *string `json:"javaVersion,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + Limits *SiteLimits `json:"limits,omitempty"` + LinuxFxVersion *string `json:"linuxFxVersion,omitempty"` + LoadBalancing *SiteLoadBalancing `json:"loadBalancing,omitempty"` + LocalMySqlEnabled *bool `json:"localMySqlEnabled,omitempty"` + LogsDirectorySizeLimit *int64 `json:"logsDirectorySizeLimit,omitempty"` + MachineKey *SiteMachineKey `json:"machineKey,omitempty"` + ManagedPipelineMode *ManagedPipelineMode `json:"managedPipelineMode,omitempty"` + ManagedServiceIdentityId *int64 `json:"managedServiceIdentityId,omitempty"` + Metadata *[]NameValuePair `json:"metadata,omitempty"` + MinTlsCipherSuite *TlsCipherSuites `json:"minTlsCipherSuite,omitempty"` + MinTlsVersion *SupportedTlsVersions `json:"minTlsVersion,omitempty"` + MinimumElasticInstanceCount *int64 `json:"minimumElasticInstanceCount,omitempty"` + NetFrameworkVersion *string `json:"netFrameworkVersion,omitempty"` + NodeVersion *string `json:"nodeVersion,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PhpVersion *string `json:"phpVersion,omitempty"` + PowerShellVersion *string `json:"powerShellVersion,omitempty"` + PreWarmedInstanceCount *int64 `json:"preWarmedInstanceCount,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + PublishingUsername *string `json:"publishingUsername,omitempty"` + Push *PushSettings `json:"push,omitempty"` + PythonVersion *string `json:"pythonVersion,omitempty"` + RemoteDebuggingEnabled *bool `json:"remoteDebuggingEnabled,omitempty"` + RemoteDebuggingVersion *string `json:"remoteDebuggingVersion,omitempty"` + RequestTracingEnabled *bool `json:"requestTracingEnabled,omitempty"` + RequestTracingExpirationTime *string `json:"requestTracingExpirationTime,omitempty"` + ScmIPSecurityRestrictions *[]IPSecurityRestriction `json:"scmIpSecurityRestrictions,omitempty"` + ScmIPSecurityRestrictionsDefaultAction *DefaultAction `json:"scmIpSecurityRestrictionsDefaultAction,omitempty"` + ScmIPSecurityRestrictionsUseMain *bool `json:"scmIpSecurityRestrictionsUseMain,omitempty"` + ScmMinTlsVersion *SupportedTlsVersions `json:"scmMinTlsVersion,omitempty"` + ScmType *ScmType `json:"scmType,omitempty"` + TracingOptions *string `json:"tracingOptions,omitempty"` + Use32BitWorkerProcess *bool `json:"use32BitWorkerProcess,omitempty"` + VirtualApplications *[]VirtualApplication `json:"virtualApplications,omitempty"` + VnetName *string `json:"vnetName,omitempty"` + VnetPrivatePortsCount *int64 `json:"vnetPrivatePortsCount,omitempty"` + VnetRouteAllEnabled *bool `json:"vnetRouteAllEnabled,omitempty"` + WebSocketsEnabled *bool `json:"webSocketsEnabled,omitempty"` + WebsiteTimeZone *string `json:"websiteTimeZone,omitempty"` + WindowsFxVersion *string `json:"windowsFxVersion,omitempty"` + XManagedServiceIdentityId *int64 `json:"xManagedServiceIdentityId,omitempty"` +} + +func (o *SiteConfig) GetRequestTracingExpirationTimeAsTime() (*time.Time, error) { + if o.RequestTracingExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RequestTracingExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteConfig) SetRequestTracingExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RequestTracingExpirationTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_sitednsconfig.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_sitednsconfig.go new file mode 100644 index 00000000000..4b4479a9c71 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_sitednsconfig.go @@ -0,0 +1,13 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteDnsConfig struct { + DnsAltServer *string `json:"dnsAltServer,omitempty"` + DnsLegacySortOrder *bool `json:"dnsLegacySortOrder,omitempty"` + DnsMaxCacheTimeout *int64 `json:"dnsMaxCacheTimeout,omitempty"` + DnsRetryAttemptCount *int64 `json:"dnsRetryAttemptCount,omitempty"` + DnsRetryAttemptTimeout *int64 `json:"dnsRetryAttemptTimeout,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_sitelimits.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_sitelimits.go new file mode 100644 index 00000000000..b3130e580f6 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_sitelimits.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteLimits struct { + MaxDiskSizeInMb *int64 `json:"maxDiskSizeInMb,omitempty"` + MaxMemoryInMb *int64 `json:"maxMemoryInMb,omitempty"` + MaxPercentageCPU *float64 `json:"maxPercentageCpu,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_sitemachinekey.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_sitemachinekey.go new file mode 100644 index 00000000000..267ce523b14 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_sitemachinekey.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteMachineKey struct { + Decryption *string `json:"decryption,omitempty"` + DecryptionKey *string `json:"decryptionKey,omitempty"` + Validation *string `json:"validation,omitempty"` + ValidationKey *string `json:"validationKey,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_siteproperties.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_siteproperties.go new file mode 100644 index 00000000000..d8302cc5670 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_siteproperties.go @@ -0,0 +1,93 @@ +package appserviceenvironments + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteProperties struct { + AutoGeneratedDomainNameLabelScope *AutoGeneratedDomainNameLabelScope `json:"autoGeneratedDomainNameLabelScope,omitempty"` + AvailabilityState *SiteAvailabilityState `json:"availabilityState,omitempty"` + ClientAffinityEnabled *bool `json:"clientAffinityEnabled,omitempty"` + ClientAffinityPartitioningEnabled *bool `json:"clientAffinityPartitioningEnabled,omitempty"` + ClientAffinityProxyEnabled *bool `json:"clientAffinityProxyEnabled,omitempty"` + ClientCertEnabled *bool `json:"clientCertEnabled,omitempty"` + ClientCertExclusionPaths *string `json:"clientCertExclusionPaths,omitempty"` + ClientCertMode *ClientCertMode `json:"clientCertMode,omitempty"` + CloningInfo *CloningInfo `json:"cloningInfo,omitempty"` + ContainerSize *int64 `json:"containerSize,omitempty"` + CustomDomainVerificationId *string `json:"customDomainVerificationId,omitempty"` + DailyMemoryTimeQuota *int64 `json:"dailyMemoryTimeQuota,omitempty"` + DaprConfig *DaprConfig `json:"daprConfig,omitempty"` + DefaultHostName *string `json:"defaultHostName,omitempty"` + DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + EndToEndEncryptionEnabled *bool `json:"endToEndEncryptionEnabled,omitempty"` + FunctionAppConfig *FunctionAppConfig `json:"functionAppConfig,omitempty"` + HTTPSOnly *bool `json:"httpsOnly,omitempty"` + HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostNamesDisabled *bool `json:"hostNamesDisabled,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + IPMode *IPMode `json:"ipMode,omitempty"` + InProgressOperationId *string `json:"inProgressOperationId,omitempty"` + IsDefaultContainer *bool `json:"isDefaultContainer,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + LastModifiedTimeUtc *string `json:"lastModifiedTimeUtc,omitempty"` + ManagedEnvironmentId *string `json:"managedEnvironmentId,omitempty"` + MaxNumberOfWorkers *int64 `json:"maxNumberOfWorkers,omitempty"` + OutboundIPAddresses *string `json:"outboundIpAddresses,omitempty"` + OutboundVnetRouting *OutboundVnetRouting `json:"outboundVnetRouting,omitempty"` + PossibleOutboundIPAddresses *string `json:"possibleOutboundIpAddresses,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + RedundancyMode *RedundancyMode `json:"redundancyMode,omitempty"` + RepositorySiteName *string `json:"repositorySiteName,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceConfig *ResourceConfig `json:"resourceConfig,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ScmSiteAlsoStopped *bool `json:"scmSiteAlsoStopped,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteConfig *SiteConfig `json:"siteConfig,omitempty"` + Sku *string `json:"sku,omitempty"` + SlotSwapStatus *SlotSwapStatus `json:"slotSwapStatus,omitempty"` + SshEnabled *bool `json:"sshEnabled,omitempty"` + State *string `json:"state,omitempty"` + StorageAccountRequired *bool `json:"storageAccountRequired,omitempty"` + SuspendedTill *string `json:"suspendedTill,omitempty"` + TargetSwapSlot *string `json:"targetSwapSlot,omitempty"` + TrafficManagerHostNames *[]string `json:"trafficManagerHostNames,omitempty"` + UsageState *UsageState `json:"usageState,omitempty"` + VirtualNetworkSubnetId *string `json:"virtualNetworkSubnetId,omitempty"` + WorkloadProfileName *string `json:"workloadProfileName,omitempty"` +} + +func (o *SiteProperties) GetLastModifiedTimeUtcAsTime() (*time.Time, error) { + if o.LastModifiedTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetLastModifiedTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTimeUtc = &formatted +} + +func (o *SiteProperties) GetSuspendedTillAsTime() (*time.Time, error) { + if o.SuspendedTill == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SuspendedTill, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetSuspendedTillAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SuspendedTill = &formatted +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_skucapacity.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_skucapacity.go new file mode 100644 index 00000000000..2e04c5df978 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_skucapacity.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuCapacity struct { + Default *int64 `json:"default,omitempty"` + ElasticMaximum *int64 `json:"elasticMaximum,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` + Minimum *int64 `json:"minimum,omitempty"` + ScaleType *string `json:"scaleType,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_skudescription.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_skudescription.go new file mode 100644 index 00000000000..47f1a308d34 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_skudescription.go @@ -0,0 +1,15 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuDescription struct { + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Locations *[]string `json:"locations,omitempty"` + Name *string `json:"name,omitempty"` + Size *string `json:"size,omitempty"` + SkuCapacity *SkuCapacity `json:"skuCapacity,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_skuinfo.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_skuinfo.go new file mode 100644 index 00000000000..9faba036b8a --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_skuinfo.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuInfo struct { + Capacity *SkuCapacity `json:"capacity,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_slotswapstatus.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_slotswapstatus.go new file mode 100644 index 00000000000..ae1901b782c --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_slotswapstatus.go @@ -0,0 +1,28 @@ +package appserviceenvironments + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlotSwapStatus struct { + DestinationSlotName *string `json:"destinationSlotName,omitempty"` + SourceSlotName *string `json:"sourceSlotName,omitempty"` + TimestampUtc *string `json:"timestampUtc,omitempty"` +} + +func (o *SlotSwapStatus) GetTimestampUtcAsTime() (*time.Time, error) { + if o.TimestampUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimestampUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SlotSwapStatus) SetTimestampUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimestampUtc = &formatted +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_slowrequestsbasedtrigger.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_slowrequestsbasedtrigger.go new file mode 100644 index 00000000000..ef74f6f556b --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_slowrequestsbasedtrigger.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlowRequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + TimeTaken *string `json:"timeTaken,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_stampcapacity.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_stampcapacity.go new file mode 100644 index 00000000000..138ebe09348 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_stampcapacity.go @@ -0,0 +1,18 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StampCapacity struct { + AvailableCapacity *int64 `json:"availableCapacity,omitempty"` + ComputeMode *ComputeModeOptions `json:"computeMode,omitempty"` + ExcludeFromCapacityAllocation *bool `json:"excludeFromCapacityAllocation,omitempty"` + IsApplicableForAllComputeModes *bool `json:"isApplicableForAllComputeModes,omitempty"` + IsLinux *bool `json:"isLinux,omitempty"` + Name *string `json:"name,omitempty"` + SiteMode *string `json:"siteMode,omitempty"` + TotalCapacity *int64 `json:"totalCapacity,omitempty"` + Unit *string `json:"unit,omitempty"` + WorkerSize *WorkerSizeOptions `json:"workerSize,omitempty"` + WorkerSizeId *int64 `json:"workerSizeId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_statuscodesbasedtrigger.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_statuscodesbasedtrigger.go new file mode 100644 index 00000000000..633cfec8a5e --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_statuscodesbasedtrigger.go @@ -0,0 +1,13 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + Status *int64 `json:"status,omitempty"` + SubStatus *int64 `json:"subStatus,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + Win32Status *int64 `json:"win32Status,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_statuscodesrangebasedtrigger.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_statuscodesrangebasedtrigger.go new file mode 100644 index 00000000000..ccbeced17af --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_statuscodesrangebasedtrigger.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesRangeBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + StatusCodes *string `json:"statusCodes,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_usage.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_usage.go new file mode 100644 index 00000000000..7e9e07f4502 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_usage.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Usage struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *UsageProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_usageproperties.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_usageproperties.go new file mode 100644 index 00000000000..8b0f3272bdf --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_usageproperties.go @@ -0,0 +1,33 @@ +package appserviceenvironments + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UsageProperties struct { + ComputeMode *ComputeModeOptions `json:"computeMode,omitempty"` + CurrentValue *int64 `json:"currentValue,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Limit *int64 `json:"limit,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + ResourceName *string `json:"resourceName,omitempty"` + SiteMode *string `json:"siteMode,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +func (o *UsageProperties) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *UsageProperties) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_virtualapplication.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_virtualapplication.go new file mode 100644 index 00000000000..bdac22a3474 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_virtualapplication.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplication struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + PreloadEnabled *bool `json:"preloadEnabled,omitempty"` + VirtualDirectories *[]VirtualDirectory `json:"virtualDirectories,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_virtualdirectory.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_virtualdirectory.go new file mode 100644 index 00000000000..f4c38830a4c --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_virtualdirectory.go @@ -0,0 +1,9 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualDirectory struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_virtualipmapping.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_virtualipmapping.go new file mode 100644 index 00000000000..dc88e33ecba --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_virtualipmapping.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualIPMapping struct { + InUse *bool `json:"inUse,omitempty"` + InternalHTTPPort *int64 `json:"internalHttpPort,omitempty"` + InternalHTTPSPort *int64 `json:"internalHttpsPort,omitempty"` + ServiceName *string `json:"serviceName,omitempty"` + VirtualIP *string `json:"virtualIP,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_virtualnetworkprofile.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_virtualnetworkprofile.go new file mode 100644 index 00000000000..d01868e107b --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_virtualnetworkprofile.go @@ -0,0 +1,11 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkProfile struct { + Id string `json:"id"` + Name *string `json:"name,omitempty"` + Subnet *string `json:"subnet,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_workerpool.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_workerpool.go new file mode 100644 index 00000000000..fbb7707c437 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_workerpool.go @@ -0,0 +1,12 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkerPool struct { + ComputeMode *ComputeModeOptions `json:"computeMode,omitempty"` + InstanceNames *[]string `json:"instanceNames,omitempty"` + WorkerCount *int64 `json:"workerCount,omitempty"` + WorkerSize *string `json:"workerSize,omitempty"` + WorkerSizeId *int64 `json:"workerSizeId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/model_workerpoolresource.go b/resource-manager/web/2024-11-01/appserviceenvironments/model_workerpoolresource.go new file mode 100644 index 00000000000..6a4150ac46d --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/model_workerpoolresource.go @@ -0,0 +1,13 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkerPoolResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkerPool `json:"properties,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/predicates.go b/resource-manager/web/2024-11-01/appserviceenvironments/predicates.go new file mode 100644 index 00000000000..96a5324bde9 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/predicates.go @@ -0,0 +1,335 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceEnvironmentResourceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServiceEnvironmentResourceOperationPredicate) Matches(input AppServiceEnvironmentResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type AppServicePlanOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServicePlanOperationPredicate) Matches(input AppServicePlan) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type CsmUsageQuotaOperationPredicate struct { + CurrentValue *int64 + Limit *int64 + NextResetTime *string + Unit *string +} + +func (p CsmUsageQuotaOperationPredicate) Matches(input CsmUsageQuota) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.NextResetTime != nil && (input.NextResetTime == nil || *p.NextResetTime != *input.NextResetTime) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} + +type InboundEnvironmentEndpointOperationPredicate struct { + Description *string +} + +func (p InboundEnvironmentEndpointOperationPredicate) Matches(input InboundEnvironmentEndpoint) bool { + + if p.Description != nil && (input.Description == nil || *p.Description != *input.Description) { + return false + } + + return true +} + +type OutboundEnvironmentEndpointOperationPredicate struct { + Category *string +} + +func (p OutboundEnvironmentEndpointOperationPredicate) Matches(input OutboundEnvironmentEndpoint) bool { + + if p.Category != nil && (input.Category == nil || *p.Category != *input.Category) { + return false + } + + return true +} + +type RemotePrivateEndpointConnectionARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p RemotePrivateEndpointConnectionARMResourceOperationPredicate) Matches(input RemotePrivateEndpointConnectionARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type ResourceMetricDefinitionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ResourceMetricDefinitionOperationPredicate) Matches(input ResourceMetricDefinition) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SiteOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p SiteOperationPredicate) Matches(input Site) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SkuInfoOperationPredicate struct { + ResourceType *string +} + +func (p SkuInfoOperationPredicate) Matches(input SkuInfo) bool { + + if p.ResourceType != nil && (input.ResourceType == nil || *p.ResourceType != *input.ResourceType) { + return false + } + + return true +} + +type StampCapacityOperationPredicate struct { + AvailableCapacity *int64 + ExcludeFromCapacityAllocation *bool + IsApplicableForAllComputeModes *bool + IsLinux *bool + Name *string + SiteMode *string + TotalCapacity *int64 + Unit *string + WorkerSizeId *int64 +} + +func (p StampCapacityOperationPredicate) Matches(input StampCapacity) bool { + + if p.AvailableCapacity != nil && (input.AvailableCapacity == nil || *p.AvailableCapacity != *input.AvailableCapacity) { + return false + } + + if p.ExcludeFromCapacityAllocation != nil && (input.ExcludeFromCapacityAllocation == nil || *p.ExcludeFromCapacityAllocation != *input.ExcludeFromCapacityAllocation) { + return false + } + + if p.IsApplicableForAllComputeModes != nil && (input.IsApplicableForAllComputeModes == nil || *p.IsApplicableForAllComputeModes != *input.IsApplicableForAllComputeModes) { + return false + } + + if p.IsLinux != nil && (input.IsLinux == nil || *p.IsLinux != *input.IsLinux) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.SiteMode != nil && (input.SiteMode == nil || *p.SiteMode != *input.SiteMode) { + return false + } + + if p.TotalCapacity != nil && (input.TotalCapacity == nil || *p.TotalCapacity != *input.TotalCapacity) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + if p.WorkerSizeId != nil && (input.WorkerSizeId == nil || *p.WorkerSizeId != *input.WorkerSizeId) { + return false + } + + return true +} + +type UsageOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p UsageOperationPredicate) Matches(input Usage) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type WorkerPoolResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p WorkerPoolResourceOperationPredicate) Matches(input WorkerPoolResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/appserviceenvironments/version.go b/resource-manager/web/2024-11-01/appserviceenvironments/version.go new file mode 100644 index 00000000000..071147bc509 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceenvironments/version.go @@ -0,0 +1,10 @@ +package appserviceenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/appserviceenvironments/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/README.md b/resource-manager/web/2024-11-01/appserviceplans/README.md new file mode 100644 index 00000000000..30c5525f792 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/README.md @@ -0,0 +1,480 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/appserviceplans` Documentation + +The `appserviceplans` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/appserviceplans" +``` + + +### Client Initialization + +```go +client := appserviceplans.NewAppServicePlansClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AppServicePlansClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +payload := appserviceplans.AppServicePlan{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AppServicePlansClient.CreateOrUpdateVnetRoute` + +```go +ctx := context.TODO() +id := appserviceplans.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "routeName") + +payload := appserviceplans.VnetRoute{ + // ... +} + + +read, err := client.CreateOrUpdateVnetRoute(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.DeleteHybridConnection` + +```go +ctx := context.TODO() +id := appserviceplans.NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "hybridConnectionNamespaceName", "relayName") + +read, err := client.DeleteHybridConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.DeleteVnetRoute` + +```go +ctx := context.TODO() +id := appserviceplans.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "routeName") + +read, err := client.DeleteVnetRoute(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.GetHybridConnection` + +```go +ctx := context.TODO() +id := appserviceplans.NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "hybridConnectionNamespaceName", "relayName") + +read, err := client.GetHybridConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.GetHybridConnectionPlanLimit` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +read, err := client.GetHybridConnectionPlanLimit(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.GetRouteForVnet` + +```go +ctx := context.TODO() +id := appserviceplans.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "routeName") + +read, err := client.GetRouteForVnet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.GetServerFarmSkus` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +read, err := client.GetServerFarmSkus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.GetVnetFromServerFarm` + +```go +ctx := context.TODO() +id := appserviceplans.NewServerFarmVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName") + +read, err := client.GetVnetFromServerFarm(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.GetVnetGateway` + +```go +ctx := context.TODO() +id := appserviceplans.NewVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "gatewayName") + +read, err := client.GetVnetGateway(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, appserviceplans.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, appserviceplans.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.ListCapabilities` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +read, err := client.ListCapabilities(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.ListHybridConnectionKeys` + +```go +ctx := context.TODO() +id := appserviceplans.NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "hybridConnectionNamespaceName", "relayName") + +read, err := client.ListHybridConnectionKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.ListHybridConnections` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +// alternatively `client.ListHybridConnections(ctx, id)` can be used to do batched pagination +items, err := client.ListHybridConnectionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.ListRoutesForVnet` + +```go +ctx := context.TODO() +id := appserviceplans.NewServerFarmVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName") + +read, err := client.ListRoutesForVnet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.ListUsages` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +// alternatively `client.ListUsages(ctx, id, appserviceplans.DefaultListUsagesOperationOptions())` can be used to do batched pagination +items, err := client.ListUsagesComplete(ctx, id, appserviceplans.DefaultListUsagesOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.ListVnets` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +read, err := client.ListVnets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.ListWebApps` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +// alternatively `client.ListWebApps(ctx, id, appserviceplans.DefaultListWebAppsOperationOptions())` can be used to do batched pagination +items, err := client.ListWebAppsComplete(ctx, id, appserviceplans.DefaultListWebAppsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.ListWebAppsByHybridConnection` + +```go +ctx := context.TODO() +id := appserviceplans.NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "hybridConnectionNamespaceName", "relayName") + +// alternatively `client.ListWebAppsByHybridConnection(ctx, id)` can be used to do batched pagination +items, err := client.ListWebAppsByHybridConnectionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AppServicePlansClient.RebootWorker` + +```go +ctx := context.TODO() +id := appserviceplans.NewWorkerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "workerName") + +read, err := client.RebootWorker(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.RestartWebApps` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +read, err := client.RestartWebApps(ctx, id, appserviceplans.DefaultRestartWebAppsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.Update` + +```go +ctx := context.TODO() +id := commonids.NewAppServicePlanID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName") + +payload := appserviceplans.AppServicePlanPatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.UpdateVnetGateway` + +```go +ctx := context.TODO() +id := appserviceplans.NewVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "gatewayName") + +payload := appserviceplans.VnetGateway{ + // ... +} + + +read, err := client.UpdateVnetGateway(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AppServicePlansClient.UpdateVnetRoute` + +```go +ctx := context.TODO() +id := appserviceplans.NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "routeName") + +payload := appserviceplans.VnetRoute{ + // ... +} + + +read, err := client.UpdateVnetRoute(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-11-01/appserviceplans/client.go b/resource-manager/web/2024-11-01/appserviceplans/client.go new file mode 100644 index 00000000000..9afc7d23899 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/client.go @@ -0,0 +1,26 @@ +package appserviceplans + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServicePlansClient struct { + Client *resourcemanager.Client +} + +func NewAppServicePlansClientWithBaseURI(sdkApi sdkEnv.Api) (*AppServicePlansClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "appserviceplans", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AppServicePlansClient: %+v", err) + } + + return &AppServicePlansClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/constants.go b/resource-manager/web/2024-11-01/appserviceplans/constants.go new file mode 100644 index 00000000000..2a92bf77d55 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/constants.go @@ -0,0 +1,1365 @@ +package appserviceplans + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthenticationType string + +const ( + AuthenticationTypeStorageAccountConnectionString AuthenticationType = "StorageAccountConnectionString" + AuthenticationTypeSystemAssignedIdentity AuthenticationType = "SystemAssignedIdentity" + AuthenticationTypeUserAssignedIdentity AuthenticationType = "UserAssignedIdentity" +) + +func PossibleValuesForAuthenticationType() []string { + return []string{ + string(AuthenticationTypeStorageAccountConnectionString), + string(AuthenticationTypeSystemAssignedIdentity), + string(AuthenticationTypeUserAssignedIdentity), + } +} + +func (s *AuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationType(input string) (*AuthenticationType, error) { + vals := map[string]AuthenticationType{ + "storageaccountconnectionstring": AuthenticationTypeStorageAccountConnectionString, + "systemassignedidentity": AuthenticationTypeSystemAssignedIdentity, + "userassignedidentity": AuthenticationTypeUserAssignedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationType(input) + return &out, nil +} + +type AutoGeneratedDomainNameLabelScope string + +const ( + AutoGeneratedDomainNameLabelScopeNoReuse AutoGeneratedDomainNameLabelScope = "NoReuse" + AutoGeneratedDomainNameLabelScopeResourceGroupReuse AutoGeneratedDomainNameLabelScope = "ResourceGroupReuse" + AutoGeneratedDomainNameLabelScopeSubscriptionReuse AutoGeneratedDomainNameLabelScope = "SubscriptionReuse" + AutoGeneratedDomainNameLabelScopeTenantReuse AutoGeneratedDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForAutoGeneratedDomainNameLabelScope() []string { + return []string{ + string(AutoGeneratedDomainNameLabelScopeNoReuse), + string(AutoGeneratedDomainNameLabelScopeResourceGroupReuse), + string(AutoGeneratedDomainNameLabelScopeSubscriptionReuse), + string(AutoGeneratedDomainNameLabelScopeTenantReuse), + } +} + +func (s *AutoGeneratedDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoGeneratedDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoGeneratedDomainNameLabelScope(input string) (*AutoGeneratedDomainNameLabelScope, error) { + vals := map[string]AutoGeneratedDomainNameLabelScope{ + "noreuse": AutoGeneratedDomainNameLabelScopeNoReuse, + "resourcegroupreuse": AutoGeneratedDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": AutoGeneratedDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": AutoGeneratedDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoGeneratedDomainNameLabelScope(input) + return &out, nil +} + +type AutoHealActionType string + +const ( + AutoHealActionTypeCustomAction AutoHealActionType = "CustomAction" + AutoHealActionTypeLogEvent AutoHealActionType = "LogEvent" + AutoHealActionTypeRecycle AutoHealActionType = "Recycle" +) + +func PossibleValuesForAutoHealActionType() []string { + return []string{ + string(AutoHealActionTypeCustomAction), + string(AutoHealActionTypeLogEvent), + string(AutoHealActionTypeRecycle), + } +} + +func (s *AutoHealActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoHealActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoHealActionType(input string) (*AutoHealActionType, error) { + vals := map[string]AutoHealActionType{ + "customaction": AutoHealActionTypeCustomAction, + "logevent": AutoHealActionTypeLogEvent, + "recycle": AutoHealActionTypeRecycle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoHealActionType(input) + return &out, nil +} + +type AzureStorageProtocol string + +const ( + AzureStorageProtocolHTTP AzureStorageProtocol = "Http" + AzureStorageProtocolNfs AzureStorageProtocol = "Nfs" + AzureStorageProtocolSmb AzureStorageProtocol = "Smb" +) + +func PossibleValuesForAzureStorageProtocol() []string { + return []string{ + string(AzureStorageProtocolHTTP), + string(AzureStorageProtocolNfs), + string(AzureStorageProtocolSmb), + } +} + +func (s *AzureStorageProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageProtocol(input string) (*AzureStorageProtocol, error) { + vals := map[string]AzureStorageProtocol{ + "http": AzureStorageProtocolHTTP, + "nfs": AzureStorageProtocolNfs, + "smb": AzureStorageProtocolSmb, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageProtocol(input) + return &out, nil +} + +type AzureStorageState string + +const ( + AzureStorageStateInvalidCredentials AzureStorageState = "InvalidCredentials" + AzureStorageStateInvalidShare AzureStorageState = "InvalidShare" + AzureStorageStateNotValidated AzureStorageState = "NotValidated" + AzureStorageStateOk AzureStorageState = "Ok" +) + +func PossibleValuesForAzureStorageState() []string { + return []string{ + string(AzureStorageStateInvalidCredentials), + string(AzureStorageStateInvalidShare), + string(AzureStorageStateNotValidated), + string(AzureStorageStateOk), + } +} + +func (s *AzureStorageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageState(input string) (*AzureStorageState, error) { + vals := map[string]AzureStorageState{ + "invalidcredentials": AzureStorageStateInvalidCredentials, + "invalidshare": AzureStorageStateInvalidShare, + "notvalidated": AzureStorageStateNotValidated, + "ok": AzureStorageStateOk, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageState(input) + return &out, nil +} + +type AzureStorageType string + +const ( + AzureStorageTypeAzureBlob AzureStorageType = "AzureBlob" + AzureStorageTypeAzureFiles AzureStorageType = "AzureFiles" +) + +func PossibleValuesForAzureStorageType() []string { + return []string{ + string(AzureStorageTypeAzureBlob), + string(AzureStorageTypeAzureFiles), + } +} + +func (s *AzureStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageType(input string) (*AzureStorageType, error) { + vals := map[string]AzureStorageType{ + "azureblob": AzureStorageTypeAzureBlob, + "azurefiles": AzureStorageTypeAzureFiles, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageType(input) + return &out, nil +} + +type ClientCertMode string + +const ( + ClientCertModeOptional ClientCertMode = "Optional" + ClientCertModeOptionalInteractiveUser ClientCertMode = "OptionalInteractiveUser" + ClientCertModeRequired ClientCertMode = "Required" +) + +func PossibleValuesForClientCertMode() []string { + return []string{ + string(ClientCertModeOptional), + string(ClientCertModeOptionalInteractiveUser), + string(ClientCertModeRequired), + } +} + +func (s *ClientCertMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientCertMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClientCertMode(input string) (*ClientCertMode, error) { + vals := map[string]ClientCertMode{ + "optional": ClientCertModeOptional, + "optionalinteractiveuser": ClientCertModeOptionalInteractiveUser, + "required": ClientCertModeRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClientCertMode(input) + return &out, nil +} + +type ConnectionStringType string + +const ( + ConnectionStringTypeApiHub ConnectionStringType = "ApiHub" + ConnectionStringTypeCustom ConnectionStringType = "Custom" + ConnectionStringTypeDocDb ConnectionStringType = "DocDb" + ConnectionStringTypeEventHub ConnectionStringType = "EventHub" + ConnectionStringTypeMySql ConnectionStringType = "MySql" + ConnectionStringTypeNotificationHub ConnectionStringType = "NotificationHub" + ConnectionStringTypePostgreSQL ConnectionStringType = "PostgreSQL" + ConnectionStringTypeRedisCache ConnectionStringType = "RedisCache" + ConnectionStringTypeSQLAzure ConnectionStringType = "SQLAzure" + ConnectionStringTypeSQLServer ConnectionStringType = "SQLServer" + ConnectionStringTypeServiceBus ConnectionStringType = "ServiceBus" +) + +func PossibleValuesForConnectionStringType() []string { + return []string{ + string(ConnectionStringTypeApiHub), + string(ConnectionStringTypeCustom), + string(ConnectionStringTypeDocDb), + string(ConnectionStringTypeEventHub), + string(ConnectionStringTypeMySql), + string(ConnectionStringTypeNotificationHub), + string(ConnectionStringTypePostgreSQL), + string(ConnectionStringTypeRedisCache), + string(ConnectionStringTypeSQLAzure), + string(ConnectionStringTypeSQLServer), + string(ConnectionStringTypeServiceBus), + } +} + +func (s *ConnectionStringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionStringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionStringType(input string) (*ConnectionStringType, error) { + vals := map[string]ConnectionStringType{ + "apihub": ConnectionStringTypeApiHub, + "custom": ConnectionStringTypeCustom, + "docdb": ConnectionStringTypeDocDb, + "eventhub": ConnectionStringTypeEventHub, + "mysql": ConnectionStringTypeMySql, + "notificationhub": ConnectionStringTypeNotificationHub, + "postgresql": ConnectionStringTypePostgreSQL, + "rediscache": ConnectionStringTypeRedisCache, + "sqlazure": ConnectionStringTypeSQLAzure, + "sqlserver": ConnectionStringTypeSQLServer, + "servicebus": ConnectionStringTypeServiceBus, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionStringType(input) + return &out, nil +} + +type DaprLogLevel string + +const ( + DaprLogLevelDebug DaprLogLevel = "debug" + DaprLogLevelError DaprLogLevel = "error" + DaprLogLevelInfo DaprLogLevel = "info" + DaprLogLevelWarn DaprLogLevel = "warn" +) + +func PossibleValuesForDaprLogLevel() []string { + return []string{ + string(DaprLogLevelDebug), + string(DaprLogLevelError), + string(DaprLogLevelInfo), + string(DaprLogLevelWarn), + } +} + +func (s *DaprLogLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDaprLogLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDaprLogLevel(input string) (*DaprLogLevel, error) { + vals := map[string]DaprLogLevel{ + "debug": DaprLogLevelDebug, + "error": DaprLogLevelError, + "info": DaprLogLevelInfo, + "warn": DaprLogLevelWarn, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DaprLogLevel(input) + return &out, nil +} + +type DefaultAction string + +const ( + DefaultActionAllow DefaultAction = "Allow" + DefaultActionDeny DefaultAction = "Deny" +) + +func PossibleValuesForDefaultAction() []string { + return []string{ + string(DefaultActionAllow), + string(DefaultActionDeny), + } +} + +func (s *DefaultAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDefaultAction(input string) (*DefaultAction, error) { + vals := map[string]DefaultAction{ + "allow": DefaultActionAllow, + "deny": DefaultActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DefaultAction(input) + return &out, nil +} + +type FtpsState string + +const ( + FtpsStateAllAllowed FtpsState = "AllAllowed" + FtpsStateDisabled FtpsState = "Disabled" + FtpsStateFtpsOnly FtpsState = "FtpsOnly" +) + +func PossibleValuesForFtpsState() []string { + return []string{ + string(FtpsStateAllAllowed), + string(FtpsStateDisabled), + string(FtpsStateFtpsOnly), + } +} + +func (s *FtpsState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFtpsState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFtpsState(input string) (*FtpsState, error) { + vals := map[string]FtpsState{ + "allallowed": FtpsStateAllAllowed, + "disabled": FtpsStateDisabled, + "ftpsonly": FtpsStateFtpsOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FtpsState(input) + return &out, nil +} + +type FunctionsDeploymentStorageType string + +const ( + FunctionsDeploymentStorageTypeBlobContainer FunctionsDeploymentStorageType = "blobContainer" +) + +func PossibleValuesForFunctionsDeploymentStorageType() []string { + return []string{ + string(FunctionsDeploymentStorageTypeBlobContainer), + } +} + +func (s *FunctionsDeploymentStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFunctionsDeploymentStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFunctionsDeploymentStorageType(input string) (*FunctionsDeploymentStorageType, error) { + vals := map[string]FunctionsDeploymentStorageType{ + "blobcontainer": FunctionsDeploymentStorageTypeBlobContainer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FunctionsDeploymentStorageType(input) + return &out, nil +} + +type HostType string + +const ( + HostTypeRepository HostType = "Repository" + HostTypeStandard HostType = "Standard" +) + +func PossibleValuesForHostType() []string { + return []string{ + string(HostTypeRepository), + string(HostTypeStandard), + } +} + +func (s *HostType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostType(input string) (*HostType, error) { + vals := map[string]HostType{ + "repository": HostTypeRepository, + "standard": HostTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostType(input) + return &out, nil +} + +type IPFilterTag string + +const ( + IPFilterTagDefault IPFilterTag = "Default" + IPFilterTagServiceTag IPFilterTag = "ServiceTag" + IPFilterTagXffProxy IPFilterTag = "XffProxy" +) + +func PossibleValuesForIPFilterTag() []string { + return []string{ + string(IPFilterTagDefault), + string(IPFilterTagServiceTag), + string(IPFilterTagXffProxy), + } +} + +func (s *IPFilterTag) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFilterTag(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPFilterTag(input string) (*IPFilterTag, error) { + vals := map[string]IPFilterTag{ + "default": IPFilterTagDefault, + "servicetag": IPFilterTagServiceTag, + "xffproxy": IPFilterTagXffProxy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPFilterTag(input) + return &out, nil +} + +type IPMode string + +const ( + IPModeIPvFour IPMode = "IPv4" + IPModeIPvFourAndIPvSix IPMode = "IPv4AndIPv6" + IPModeIPvSix IPMode = "IPv6" +) + +func PossibleValuesForIPMode() []string { + return []string{ + string(IPModeIPvFour), + string(IPModeIPvFourAndIPvSix), + string(IPModeIPvSix), + } +} + +func (s *IPMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPMode(input string) (*IPMode, error) { + vals := map[string]IPMode{ + "ipv4": IPModeIPvFour, + "ipv4andipv6": IPModeIPvFourAndIPvSix, + "ipv6": IPModeIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPMode(input) + return &out, nil +} + +type ManagedPipelineMode string + +const ( + ManagedPipelineModeClassic ManagedPipelineMode = "Classic" + ManagedPipelineModeIntegrated ManagedPipelineMode = "Integrated" +) + +func PossibleValuesForManagedPipelineMode() []string { + return []string{ + string(ManagedPipelineModeClassic), + string(ManagedPipelineModeIntegrated), + } +} + +func (s *ManagedPipelineMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedPipelineMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedPipelineMode(input string) (*ManagedPipelineMode, error) { + vals := map[string]ManagedPipelineMode{ + "classic": ManagedPipelineModeClassic, + "integrated": ManagedPipelineModeIntegrated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedPipelineMode(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type RedundancyMode string + +const ( + RedundancyModeActiveActive RedundancyMode = "ActiveActive" + RedundancyModeFailover RedundancyMode = "Failover" + RedundancyModeGeoRedundant RedundancyMode = "GeoRedundant" + RedundancyModeManual RedundancyMode = "Manual" + RedundancyModeNone RedundancyMode = "None" +) + +func PossibleValuesForRedundancyMode() []string { + return []string{ + string(RedundancyModeActiveActive), + string(RedundancyModeFailover), + string(RedundancyModeGeoRedundant), + string(RedundancyModeManual), + string(RedundancyModeNone), + } +} + +func (s *RedundancyMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRedundancyMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRedundancyMode(input string) (*RedundancyMode, error) { + vals := map[string]RedundancyMode{ + "activeactive": RedundancyModeActiveActive, + "failover": RedundancyModeFailover, + "georedundant": RedundancyModeGeoRedundant, + "manual": RedundancyModeManual, + "none": RedundancyModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RedundancyMode(input) + return &out, nil +} + +type RouteType string + +const ( + RouteTypeDefault RouteType = "DEFAULT" + RouteTypeINHERITED RouteType = "INHERITED" + RouteTypeSTATIC RouteType = "STATIC" +) + +func PossibleValuesForRouteType() []string { + return []string{ + string(RouteTypeDefault), + string(RouteTypeINHERITED), + string(RouteTypeSTATIC), + } +} + +func (s *RouteType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteType(input string) (*RouteType, error) { + vals := map[string]RouteType{ + "default": RouteTypeDefault, + "inherited": RouteTypeINHERITED, + "static": RouteTypeSTATIC, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteType(input) + return &out, nil +} + +type RuntimeName string + +const ( + RuntimeNameCustom RuntimeName = "custom" + RuntimeNameDotnetNegativeisolated RuntimeName = "dotnet-isolated" + RuntimeNameJava RuntimeName = "java" + RuntimeNameNode RuntimeName = "node" + RuntimeNamePowershell RuntimeName = "powershell" + RuntimeNamePython RuntimeName = "python" +) + +func PossibleValuesForRuntimeName() []string { + return []string{ + string(RuntimeNameCustom), + string(RuntimeNameDotnetNegativeisolated), + string(RuntimeNameJava), + string(RuntimeNameNode), + string(RuntimeNamePowershell), + string(RuntimeNamePython), + } +} + +func (s *RuntimeName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuntimeName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuntimeName(input string) (*RuntimeName, error) { + vals := map[string]RuntimeName{ + "custom": RuntimeNameCustom, + "dotnet-isolated": RuntimeNameDotnetNegativeisolated, + "java": RuntimeNameJava, + "node": RuntimeNameNode, + "powershell": RuntimeNamePowershell, + "python": RuntimeNamePython, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuntimeName(input) + return &out, nil +} + +type ScmType string + +const ( + ScmTypeBitbucketGit ScmType = "BitbucketGit" + ScmTypeBitbucketHg ScmType = "BitbucketHg" + ScmTypeCodePlexGit ScmType = "CodePlexGit" + ScmTypeCodePlexHg ScmType = "CodePlexHg" + ScmTypeDropbox ScmType = "Dropbox" + ScmTypeExternalGit ScmType = "ExternalGit" + ScmTypeExternalHg ScmType = "ExternalHg" + ScmTypeGitHub ScmType = "GitHub" + ScmTypeLocalGit ScmType = "LocalGit" + ScmTypeNone ScmType = "None" + ScmTypeOneDrive ScmType = "OneDrive" + ScmTypeTfs ScmType = "Tfs" + ScmTypeVSO ScmType = "VSO" + ScmTypeVSTSRM ScmType = "VSTSRM" +) + +func PossibleValuesForScmType() []string { + return []string{ + string(ScmTypeBitbucketGit), + string(ScmTypeBitbucketHg), + string(ScmTypeCodePlexGit), + string(ScmTypeCodePlexHg), + string(ScmTypeDropbox), + string(ScmTypeExternalGit), + string(ScmTypeExternalHg), + string(ScmTypeGitHub), + string(ScmTypeLocalGit), + string(ScmTypeNone), + string(ScmTypeOneDrive), + string(ScmTypeTfs), + string(ScmTypeVSO), + string(ScmTypeVSTSRM), + } +} + +func (s *ScmType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScmType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScmType(input string) (*ScmType, error) { + vals := map[string]ScmType{ + "bitbucketgit": ScmTypeBitbucketGit, + "bitbuckethg": ScmTypeBitbucketHg, + "codeplexgit": ScmTypeCodePlexGit, + "codeplexhg": ScmTypeCodePlexHg, + "dropbox": ScmTypeDropbox, + "externalgit": ScmTypeExternalGit, + "externalhg": ScmTypeExternalHg, + "github": ScmTypeGitHub, + "localgit": ScmTypeLocalGit, + "none": ScmTypeNone, + "onedrive": ScmTypeOneDrive, + "tfs": ScmTypeTfs, + "vso": ScmTypeVSO, + "vstsrm": ScmTypeVSTSRM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScmType(input) + return &out, nil +} + +type SiteAvailabilityState string + +const ( + SiteAvailabilityStateDisasterRecoveryMode SiteAvailabilityState = "DisasterRecoveryMode" + SiteAvailabilityStateLimited SiteAvailabilityState = "Limited" + SiteAvailabilityStateNormal SiteAvailabilityState = "Normal" +) + +func PossibleValuesForSiteAvailabilityState() []string { + return []string{ + string(SiteAvailabilityStateDisasterRecoveryMode), + string(SiteAvailabilityStateLimited), + string(SiteAvailabilityStateNormal), + } +} + +func (s *SiteAvailabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteAvailabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteAvailabilityState(input string) (*SiteAvailabilityState, error) { + vals := map[string]SiteAvailabilityState{ + "disasterrecoverymode": SiteAvailabilityStateDisasterRecoveryMode, + "limited": SiteAvailabilityStateLimited, + "normal": SiteAvailabilityStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteAvailabilityState(input) + return &out, nil +} + +type SiteLoadBalancing string + +const ( + SiteLoadBalancingLeastRequests SiteLoadBalancing = "LeastRequests" + SiteLoadBalancingLeastRequestsWithTieBreaker SiteLoadBalancing = "LeastRequestsWithTieBreaker" + SiteLoadBalancingLeastResponseTime SiteLoadBalancing = "LeastResponseTime" + SiteLoadBalancingPerSiteRoundRobin SiteLoadBalancing = "PerSiteRoundRobin" + SiteLoadBalancingRequestHash SiteLoadBalancing = "RequestHash" + SiteLoadBalancingWeightedRoundRobin SiteLoadBalancing = "WeightedRoundRobin" + SiteLoadBalancingWeightedTotalTraffic SiteLoadBalancing = "WeightedTotalTraffic" +) + +func PossibleValuesForSiteLoadBalancing() []string { + return []string{ + string(SiteLoadBalancingLeastRequests), + string(SiteLoadBalancingLeastRequestsWithTieBreaker), + string(SiteLoadBalancingLeastResponseTime), + string(SiteLoadBalancingPerSiteRoundRobin), + string(SiteLoadBalancingRequestHash), + string(SiteLoadBalancingWeightedRoundRobin), + string(SiteLoadBalancingWeightedTotalTraffic), + } +} + +func (s *SiteLoadBalancing) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteLoadBalancing(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteLoadBalancing(input string) (*SiteLoadBalancing, error) { + vals := map[string]SiteLoadBalancing{ + "leastrequests": SiteLoadBalancingLeastRequests, + "leastrequestswithtiebreaker": SiteLoadBalancingLeastRequestsWithTieBreaker, + "leastresponsetime": SiteLoadBalancingLeastResponseTime, + "persiteroundrobin": SiteLoadBalancingPerSiteRoundRobin, + "requesthash": SiteLoadBalancingRequestHash, + "weightedroundrobin": SiteLoadBalancingWeightedRoundRobin, + "weightedtotaltraffic": SiteLoadBalancingWeightedTotalTraffic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteLoadBalancing(input) + return &out, nil +} + +type SslState string + +const ( + SslStateDisabled SslState = "Disabled" + SslStateIPBasedEnabled SslState = "IpBasedEnabled" + SslStateSniEnabled SslState = "SniEnabled" +) + +func PossibleValuesForSslState() []string { + return []string{ + string(SslStateDisabled), + string(SslStateIPBasedEnabled), + string(SslStateSniEnabled), + } +} + +func (s *SslState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSslState(input string) (*SslState, error) { + vals := map[string]SslState{ + "disabled": SslStateDisabled, + "ipbasedenabled": SslStateIPBasedEnabled, + "snienabled": SslStateSniEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SslState(input) + return &out, nil +} + +type StatusOptions string + +const ( + StatusOptionsCreating StatusOptions = "Creating" + StatusOptionsPending StatusOptions = "Pending" + StatusOptionsReady StatusOptions = "Ready" +) + +func PossibleValuesForStatusOptions() []string { + return []string{ + string(StatusOptionsCreating), + string(StatusOptionsPending), + string(StatusOptionsReady), + } +} + +func (s *StatusOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatusOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatusOptions(input string) (*StatusOptions, error) { + vals := map[string]StatusOptions{ + "creating": StatusOptionsCreating, + "pending": StatusOptionsPending, + "ready": StatusOptionsReady, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StatusOptions(input) + return &out, nil +} + +type SupportedTlsVersions string + +const ( + SupportedTlsVersionsOnePointOne SupportedTlsVersions = "1.1" + SupportedTlsVersionsOnePointThree SupportedTlsVersions = "1.3" + SupportedTlsVersionsOnePointTwo SupportedTlsVersions = "1.2" + SupportedTlsVersionsOnePointZero SupportedTlsVersions = "1.0" +) + +func PossibleValuesForSupportedTlsVersions() []string { + return []string{ + string(SupportedTlsVersionsOnePointOne), + string(SupportedTlsVersionsOnePointThree), + string(SupportedTlsVersionsOnePointTwo), + string(SupportedTlsVersionsOnePointZero), + } +} + +func (s *SupportedTlsVersions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSupportedTlsVersions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSupportedTlsVersions(input string) (*SupportedTlsVersions, error) { + vals := map[string]SupportedTlsVersions{ + "1.1": SupportedTlsVersionsOnePointOne, + "1.3": SupportedTlsVersionsOnePointThree, + "1.2": SupportedTlsVersionsOnePointTwo, + "1.0": SupportedTlsVersionsOnePointZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SupportedTlsVersions(input) + return &out, nil +} + +type TlsCipherSuites string + +const ( + TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_AES_128_GCM_SHA256" + TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_RSA_WITH_AES_256_GCM_SHA384" +) + +func PossibleValuesForTlsCipherSuites() []string { + return []string{ + string(TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + } +} + +func (s *TlsCipherSuites) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTlsCipherSuites(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTlsCipherSuites(input string) (*TlsCipherSuites, error) { + vals := map[string]TlsCipherSuites{ + "tls_aes_128_gcm_sha256": TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix, + "tls_aes_256_gcm_sha384": TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_ecdsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA, + "tls_ecdhe_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA, + "tls_ecdhe_rsa_with_aes_256_cbc_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA, + "tls_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA, + "tls_rsa_with_aes_256_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix, + "tls_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TlsCipherSuites(input) + return &out, nil +} + +type UsageState string + +const ( + UsageStateExceeded UsageState = "Exceeded" + UsageStateNormal UsageState = "Normal" +) + +func PossibleValuesForUsageState() []string { + return []string{ + string(UsageStateExceeded), + string(UsageStateNormal), + } +} + +func (s *UsageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsageState(input string) (*UsageState, error) { + vals := map[string]UsageState{ + "exceeded": UsageStateExceeded, + "normal": UsageStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsageState(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/id_hybridconnectionnamespacerelay.go b/resource-manager/web/2024-11-01/appserviceplans/id_hybridconnectionnamespacerelay.go new file mode 100644 index 00000000000..31cf0010bc4 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/id_hybridconnectionnamespacerelay.go @@ -0,0 +1,148 @@ +package appserviceplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HybridConnectionNamespaceRelayId{}) +} + +var _ resourceids.ResourceId = &HybridConnectionNamespaceRelayId{} + +// HybridConnectionNamespaceRelayId is a struct representing the Resource ID for a Hybrid Connection Namespace Relay +type HybridConnectionNamespaceRelayId struct { + SubscriptionId string + ResourceGroupName string + ServerFarmName string + HybridConnectionNamespaceName string + RelayName string +} + +// NewHybridConnectionNamespaceRelayID returns a new HybridConnectionNamespaceRelayId struct +func NewHybridConnectionNamespaceRelayID(subscriptionId string, resourceGroupName string, serverFarmName string, hybridConnectionNamespaceName string, relayName string) HybridConnectionNamespaceRelayId { + return HybridConnectionNamespaceRelayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServerFarmName: serverFarmName, + HybridConnectionNamespaceName: hybridConnectionNamespaceName, + RelayName: relayName, + } +} + +// ParseHybridConnectionNamespaceRelayID parses 'input' into a HybridConnectionNamespaceRelayId +func ParseHybridConnectionNamespaceRelayID(input string) (*HybridConnectionNamespaceRelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&HybridConnectionNamespaceRelayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HybridConnectionNamespaceRelayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHybridConnectionNamespaceRelayIDInsensitively parses 'input' case-insensitively into a HybridConnectionNamespaceRelayId +// note: this method should only be used for API response data and not user input +func ParseHybridConnectionNamespaceRelayIDInsensitively(input string) (*HybridConnectionNamespaceRelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&HybridConnectionNamespaceRelayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HybridConnectionNamespaceRelayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HybridConnectionNamespaceRelayId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ServerFarmName, ok = input.Parsed["serverFarmName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serverFarmName", input) + } + + if id.HybridConnectionNamespaceName, ok = input.Parsed["hybridConnectionNamespaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hybridConnectionNamespaceName", input) + } + + if id.RelayName, ok = input.Parsed["relayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "relayName", input) + } + + return nil +} + +// ValidateHybridConnectionNamespaceRelayID checks that 'input' can be parsed as a Hybrid Connection Namespace Relay ID +func ValidateHybridConnectionNamespaceRelayID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHybridConnectionNamespaceRelayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hybrid Connection Namespace Relay ID +func (id HybridConnectionNamespaceRelayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/serverFarms/%s/hybridConnectionNamespaces/%s/relays/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServerFarmName, id.HybridConnectionNamespaceName, id.RelayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hybrid Connection Namespace Relay ID +func (id HybridConnectionNamespaceRelayId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticServerFarms", "serverFarms", "serverFarms"), + resourceids.UserSpecifiedSegment("serverFarmName", "serverFarmName"), + resourceids.StaticSegment("staticHybridConnectionNamespaces", "hybridConnectionNamespaces", "hybridConnectionNamespaces"), + resourceids.UserSpecifiedSegment("hybridConnectionNamespaceName", "hybridConnectionNamespaceName"), + resourceids.StaticSegment("staticRelays", "relays", "relays"), + resourceids.UserSpecifiedSegment("relayName", "relayName"), + } +} + +// String returns a human-readable description of this Hybrid Connection Namespace Relay ID +func (id HybridConnectionNamespaceRelayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Server Farm Name: %q", id.ServerFarmName), + fmt.Sprintf("Hybrid Connection Namespace Name: %q", id.HybridConnectionNamespaceName), + fmt.Sprintf("Relay Name: %q", id.RelayName), + } + return fmt.Sprintf("Hybrid Connection Namespace Relay (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/id_hybridconnectionnamespacerelay_test.go b/resource-manager/web/2024-11-01/appserviceplans/id_hybridconnectionnamespacerelay_test.go new file mode 100644 index 00000000000..ca8a17b9536 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/id_hybridconnectionnamespacerelay_test.go @@ -0,0 +1,372 @@ +package appserviceplans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HybridConnectionNamespaceRelayId{} + +func TestNewHybridConnectionNamespaceRelayID(t *testing.T) { + id := NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "hybridConnectionNamespaceName", "relayName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ServerFarmName != "serverFarmName" { + t.Fatalf("Expected %q but got %q for Segment 'ServerFarmName'", id.ServerFarmName, "serverFarmName") + } + + if id.HybridConnectionNamespaceName != "hybridConnectionNamespaceName" { + t.Fatalf("Expected %q but got %q for Segment 'HybridConnectionNamespaceName'", id.HybridConnectionNamespaceName, "hybridConnectionNamespaceName") + } + + if id.RelayName != "relayName" { + t.Fatalf("Expected %q but got %q for Segment 'RelayName'", id.RelayName, "relayName") + } +} + +func TestFormatHybridConnectionNamespaceRelayID(t *testing.T) { + actual := NewHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "hybridConnectionNamespaceName", "relayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHybridConnectionNamespaceRelayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HybridConnectionNamespaceRelayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName", + Expected: &HybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + HybridConnectionNamespaceName: "hybridConnectionNamespaceName", + RelayName: "relayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHybridConnectionNamespaceRelayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestParseHybridConnectionNamespaceRelayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HybridConnectionNamespaceRelayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName", + Expected: &HybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + HybridConnectionNamespaceName: "hybridConnectionNamespaceName", + RelayName: "relayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS/rElAyNaMe", + Expected: &HybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServerFarmName: "sErVeRfArMnAmE", + HybridConnectionNamespaceName: "hYbRiDcOnNeCtIoNnAmEsPaCeNaMe", + RelayName: "rElAyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS/rElAyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHybridConnectionNamespaceRelayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestSegmentsForHybridConnectionNamespaceRelayId(t *testing.T) { + segments := HybridConnectionNamespaceRelayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HybridConnectionNamespaceRelayId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/id_route.go b/resource-manager/web/2024-11-01/appserviceplans/id_route.go new file mode 100644 index 00000000000..4368f47c094 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/id_route.go @@ -0,0 +1,148 @@ +package appserviceplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RouteId{}) +} + +var _ resourceids.ResourceId = &RouteId{} + +// RouteId is a struct representing the Resource ID for a Route +type RouteId struct { + SubscriptionId string + ResourceGroupName string + ServerFarmName string + VirtualNetworkConnectionName string + RouteName string +} + +// NewRouteID returns a new RouteId struct +func NewRouteID(subscriptionId string, resourceGroupName string, serverFarmName string, virtualNetworkConnectionName string, routeName string) RouteId { + return RouteId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServerFarmName: serverFarmName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + RouteName: routeName, + } +} + +// ParseRouteID parses 'input' into a RouteId +func ParseRouteID(input string) (*RouteId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRouteIDInsensitively parses 'input' case-insensitively into a RouteId +// note: this method should only be used for API response data and not user input +func ParseRouteIDInsensitively(input string) (*RouteId, error) { + parser := resourceids.NewParserFromResourceIdType(&RouteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RouteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RouteId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ServerFarmName, ok = input.Parsed["serverFarmName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serverFarmName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + if id.RouteName, ok = input.Parsed["routeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "routeName", input) + } + + return nil +} + +// ValidateRouteID checks that 'input' can be parsed as a Route ID +func ValidateRouteID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRouteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Route ID +func (id RouteId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/serverFarms/%s/virtualNetworkConnections/%s/routes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServerFarmName, id.VirtualNetworkConnectionName, id.RouteName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Route ID +func (id RouteId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticServerFarms", "serverFarms", "serverFarms"), + resourceids.UserSpecifiedSegment("serverFarmName", "serverFarmName"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionName"), + resourceids.StaticSegment("staticRoutes", "routes", "routes"), + resourceids.UserSpecifiedSegment("routeName", "routeName"), + } +} + +// String returns a human-readable description of this Route ID +func (id RouteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Server Farm Name: %q", id.ServerFarmName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + fmt.Sprintf("Route Name: %q", id.RouteName), + } + return fmt.Sprintf("Route (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/id_route_test.go b/resource-manager/web/2024-11-01/appserviceplans/id_route_test.go new file mode 100644 index 00000000000..ec524514b68 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/id_route_test.go @@ -0,0 +1,372 @@ +package appserviceplans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RouteId{} + +func TestNewRouteID(t *testing.T) { + id := NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "routeName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ServerFarmName != "serverFarmName" { + t.Fatalf("Expected %q but got %q for Segment 'ServerFarmName'", id.ServerFarmName, "serverFarmName") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionName") + } + + if id.RouteName != "routeName" { + t.Fatalf("Expected %q but got %q for Segment 'RouteName'", id.RouteName, "routeName") + } +} + +func TestFormatRouteID(t *testing.T) { + actual := NewRouteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "routeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/routes/routeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRouteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/routes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/routes/routeName", + Expected: &RouteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + RouteName: "routeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/routes/routeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.RouteName != v.Expected.RouteName { + t.Fatalf("Expected %q but got %q for RouteName", v.Expected.RouteName, actual.RouteName) + } + + } +} + +func TestParseRouteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RouteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/routes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/rOuTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/routes/routeName", + Expected: &RouteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + RouteName: "routeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/routes/routeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/rOuTeS/rOuTeNaMe", + Expected: &RouteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServerFarmName: "sErVeRfArMnAmE", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + RouteName: "rOuTeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/rOuTeS/rOuTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRouteIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.RouteName != v.Expected.RouteName { + t.Fatalf("Expected %q but got %q for RouteName", v.Expected.RouteName, actual.RouteName) + } + + } +} + +func TestSegmentsForRouteId(t *testing.T) { + segments := RouteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RouteId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/id_serverfarmvirtualnetworkconnection.go b/resource-manager/web/2024-11-01/appserviceplans/id_serverfarmvirtualnetworkconnection.go new file mode 100644 index 00000000000..5d43668ff23 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/id_serverfarmvirtualnetworkconnection.go @@ -0,0 +1,139 @@ +package appserviceplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ServerFarmVirtualNetworkConnectionId{}) +} + +var _ resourceids.ResourceId = &ServerFarmVirtualNetworkConnectionId{} + +// ServerFarmVirtualNetworkConnectionId is a struct representing the Resource ID for a Server Farm Virtual Network Connection +type ServerFarmVirtualNetworkConnectionId struct { + SubscriptionId string + ResourceGroupName string + ServerFarmName string + VirtualNetworkConnectionName string +} + +// NewServerFarmVirtualNetworkConnectionID returns a new ServerFarmVirtualNetworkConnectionId struct +func NewServerFarmVirtualNetworkConnectionID(subscriptionId string, resourceGroupName string, serverFarmName string, virtualNetworkConnectionName string) ServerFarmVirtualNetworkConnectionId { + return ServerFarmVirtualNetworkConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServerFarmName: serverFarmName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + } +} + +// ParseServerFarmVirtualNetworkConnectionID parses 'input' into a ServerFarmVirtualNetworkConnectionId +func ParseServerFarmVirtualNetworkConnectionID(input string) (*ServerFarmVirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServerFarmVirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServerFarmVirtualNetworkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseServerFarmVirtualNetworkConnectionIDInsensitively parses 'input' case-insensitively into a ServerFarmVirtualNetworkConnectionId +// note: this method should only be used for API response data and not user input +func ParseServerFarmVirtualNetworkConnectionIDInsensitively(input string) (*ServerFarmVirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServerFarmVirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServerFarmVirtualNetworkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ServerFarmVirtualNetworkConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ServerFarmName, ok = input.Parsed["serverFarmName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serverFarmName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + return nil +} + +// ValidateServerFarmVirtualNetworkConnectionID checks that 'input' can be parsed as a Server Farm Virtual Network Connection ID +func ValidateServerFarmVirtualNetworkConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseServerFarmVirtualNetworkConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Server Farm Virtual Network Connection ID +func (id ServerFarmVirtualNetworkConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/serverFarms/%s/virtualNetworkConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServerFarmName, id.VirtualNetworkConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Server Farm Virtual Network Connection ID +func (id ServerFarmVirtualNetworkConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticServerFarms", "serverFarms", "serverFarms"), + resourceids.UserSpecifiedSegment("serverFarmName", "serverFarmName"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionName"), + } +} + +// String returns a human-readable description of this Server Farm Virtual Network Connection ID +func (id ServerFarmVirtualNetworkConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Server Farm Name: %q", id.ServerFarmName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + } + return fmt.Sprintf("Server Farm Virtual Network Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/id_serverfarmvirtualnetworkconnection_test.go b/resource-manager/web/2024-11-01/appserviceplans/id_serverfarmvirtualnetworkconnection_test.go new file mode 100644 index 00000000000..5601db88695 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/id_serverfarmvirtualnetworkconnection_test.go @@ -0,0 +1,327 @@ +package appserviceplans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ServerFarmVirtualNetworkConnectionId{} + +func TestNewServerFarmVirtualNetworkConnectionID(t *testing.T) { + id := NewServerFarmVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ServerFarmName != "serverFarmName" { + t.Fatalf("Expected %q but got %q for Segment 'ServerFarmName'", id.ServerFarmName, "serverFarmName") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionName") + } +} + +func TestFormatServerFarmVirtualNetworkConnectionID(t *testing.T) { + actual := NewServerFarmVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServerFarmVirtualNetworkConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServerFarmVirtualNetworkConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName", + Expected: &ServerFarmVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServerFarmVirtualNetworkConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestParseServerFarmVirtualNetworkConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServerFarmVirtualNetworkConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName", + Expected: &ServerFarmVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + Expected: &ServerFarmVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServerFarmName: "sErVeRfArMnAmE", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServerFarmVirtualNetworkConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestSegmentsForServerFarmVirtualNetworkConnectionId(t *testing.T) { + segments := ServerFarmVirtualNetworkConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServerFarmVirtualNetworkConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/id_virtualnetworkconnectiongateway.go b/resource-manager/web/2024-11-01/appserviceplans/id_virtualnetworkconnectiongateway.go new file mode 100644 index 00000000000..4ccedb2d7ce --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/id_virtualnetworkconnectiongateway.go @@ -0,0 +1,148 @@ +package appserviceplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualNetworkConnectionGatewayId{}) +} + +var _ resourceids.ResourceId = &VirtualNetworkConnectionGatewayId{} + +// VirtualNetworkConnectionGatewayId is a struct representing the Resource ID for a Virtual Network Connection Gateway +type VirtualNetworkConnectionGatewayId struct { + SubscriptionId string + ResourceGroupName string + ServerFarmName string + VirtualNetworkConnectionName string + GatewayName string +} + +// NewVirtualNetworkConnectionGatewayID returns a new VirtualNetworkConnectionGatewayId struct +func NewVirtualNetworkConnectionGatewayID(subscriptionId string, resourceGroupName string, serverFarmName string, virtualNetworkConnectionName string, gatewayName string) VirtualNetworkConnectionGatewayId { + return VirtualNetworkConnectionGatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServerFarmName: serverFarmName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + GatewayName: gatewayName, + } +} + +// ParseVirtualNetworkConnectionGatewayID parses 'input' into a VirtualNetworkConnectionGatewayId +func ParseVirtualNetworkConnectionGatewayID(input string) (*VirtualNetworkConnectionGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkConnectionGatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkConnectionGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualNetworkConnectionGatewayIDInsensitively parses 'input' case-insensitively into a VirtualNetworkConnectionGatewayId +// note: this method should only be used for API response data and not user input +func ParseVirtualNetworkConnectionGatewayIDInsensitively(input string) (*VirtualNetworkConnectionGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkConnectionGatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkConnectionGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualNetworkConnectionGatewayId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ServerFarmName, ok = input.Parsed["serverFarmName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serverFarmName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + if id.GatewayName, ok = input.Parsed["gatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "gatewayName", input) + } + + return nil +} + +// ValidateVirtualNetworkConnectionGatewayID checks that 'input' can be parsed as a Virtual Network Connection Gateway ID +func ValidateVirtualNetworkConnectionGatewayID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVirtualNetworkConnectionGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Network Connection Gateway ID +func (id VirtualNetworkConnectionGatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/serverFarms/%s/virtualNetworkConnections/%s/gateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServerFarmName, id.VirtualNetworkConnectionName, id.GatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Network Connection Gateway ID +func (id VirtualNetworkConnectionGatewayId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticServerFarms", "serverFarms", "serverFarms"), + resourceids.UserSpecifiedSegment("serverFarmName", "serverFarmName"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionName"), + resourceids.StaticSegment("staticGateways", "gateways", "gateways"), + resourceids.UserSpecifiedSegment("gatewayName", "gatewayName"), + } +} + +// String returns a human-readable description of this Virtual Network Connection Gateway ID +func (id VirtualNetworkConnectionGatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Server Farm Name: %q", id.ServerFarmName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + fmt.Sprintf("Gateway Name: %q", id.GatewayName), + } + return fmt.Sprintf("Virtual Network Connection Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/id_virtualnetworkconnectiongateway_test.go b/resource-manager/web/2024-11-01/appserviceplans/id_virtualnetworkconnectiongateway_test.go new file mode 100644 index 00000000000..d542242e414 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/id_virtualnetworkconnectiongateway_test.go @@ -0,0 +1,372 @@ +package appserviceplans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualNetworkConnectionGatewayId{} + +func TestNewVirtualNetworkConnectionGatewayID(t *testing.T) { + id := NewVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "gatewayName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ServerFarmName != "serverFarmName" { + t.Fatalf("Expected %q but got %q for Segment 'ServerFarmName'", id.ServerFarmName, "serverFarmName") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionName") + } + + if id.GatewayName != "gatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'GatewayName'", id.GatewayName, "gatewayName") + } +} + +func TestFormatVirtualNetworkConnectionGatewayID(t *testing.T) { + actual := NewVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "virtualNetworkConnectionName", "gatewayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualNetworkConnectionGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkConnectionGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/gateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName", + Expected: &VirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + GatewayName: "gatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkConnectionGatewayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestParseVirtualNetworkConnectionGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkConnectionGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/gateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName", + Expected: &VirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + GatewayName: "gatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS/gAtEwAyNaMe", + Expected: &VirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServerFarmName: "sErVeRfArMnAmE", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + GatewayName: "gAtEwAyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS/gAtEwAyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkConnectionGatewayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestSegmentsForVirtualNetworkConnectionGatewayId(t *testing.T) { + segments := VirtualNetworkConnectionGatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualNetworkConnectionGatewayId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/id_worker.go b/resource-manager/web/2024-11-01/appserviceplans/id_worker.go new file mode 100644 index 00000000000..31d71dbd008 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/id_worker.go @@ -0,0 +1,139 @@ +package appserviceplans + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkerId{}) +} + +var _ resourceids.ResourceId = &WorkerId{} + +// WorkerId is a struct representing the Resource ID for a Worker +type WorkerId struct { + SubscriptionId string + ResourceGroupName string + ServerFarmName string + WorkerName string +} + +// NewWorkerID returns a new WorkerId struct +func NewWorkerID(subscriptionId string, resourceGroupName string, serverFarmName string, workerName string) WorkerId { + return WorkerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ServerFarmName: serverFarmName, + WorkerName: workerName, + } +} + +// ParseWorkerID parses 'input' into a WorkerId +func ParseWorkerID(input string) (*WorkerId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkerIDInsensitively parses 'input' case-insensitively into a WorkerId +// note: this method should only be used for API response data and not user input +func ParseWorkerIDInsensitively(input string) (*WorkerId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ServerFarmName, ok = input.Parsed["serverFarmName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serverFarmName", input) + } + + if id.WorkerName, ok = input.Parsed["workerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workerName", input) + } + + return nil +} + +// ValidateWorkerID checks that 'input' can be parsed as a Worker ID +func ValidateWorkerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Worker ID +func (id WorkerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/serverFarms/%s/workers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ServerFarmName, id.WorkerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Worker ID +func (id WorkerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticServerFarms", "serverFarms", "serverFarms"), + resourceids.UserSpecifiedSegment("serverFarmName", "serverFarmName"), + resourceids.StaticSegment("staticWorkers", "workers", "workers"), + resourceids.UserSpecifiedSegment("workerName", "workerName"), + } +} + +// String returns a human-readable description of this Worker ID +func (id WorkerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Server Farm Name: %q", id.ServerFarmName), + fmt.Sprintf("Worker Name: %q", id.WorkerName), + } + return fmt.Sprintf("Worker (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/id_worker_test.go b/resource-manager/web/2024-11-01/appserviceplans/id_worker_test.go new file mode 100644 index 00000000000..9113edebceb --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/id_worker_test.go @@ -0,0 +1,327 @@ +package appserviceplans + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkerId{} + +func TestNewWorkerID(t *testing.T) { + id := NewWorkerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "workerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ServerFarmName != "serverFarmName" { + t.Fatalf("Expected %q but got %q for Segment 'ServerFarmName'", id.ServerFarmName, "serverFarmName") + } + + if id.WorkerName != "workerName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkerName'", id.WorkerName, "workerName") + } +} + +func TestFormatWorkerID(t *testing.T) { + actual := NewWorkerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serverFarmName", "workerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/workers/workerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/workers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/workers/workerName", + Expected: &WorkerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + WorkerName: "workerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/workers/workerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.WorkerName != v.Expected.WorkerName { + t.Fatalf("Expected %q but got %q for WorkerName", v.Expected.WorkerName, actual.WorkerName) + } + + } +} + +func TestParseWorkerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/workers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/wOrKeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/workers/workerName", + Expected: &WorkerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ServerFarmName: "serverFarmName", + WorkerName: "workerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/serverFarms/serverFarmName/workers/workerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/wOrKeRs/wOrKeRnAmE", + Expected: &WorkerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ServerFarmName: "sErVeRfArMnAmE", + WorkerName: "wOrKeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sErVeRfArMs/sErVeRfArMnAmE/wOrKeRs/wOrKeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ServerFarmName != v.Expected.ServerFarmName { + t.Fatalf("Expected %q but got %q for ServerFarmName", v.Expected.ServerFarmName, actual.ServerFarmName) + } + + if actual.WorkerName != v.Expected.WorkerName { + t.Fatalf("Expected %q but got %q for WorkerName", v.Expected.WorkerName, actual.WorkerName) + } + + } +} + +func TestSegmentsForWorkerId(t *testing.T) { + segments := WorkerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_createorupdate.go b/resource-manager/web/2024-11-01/appserviceplans/method_createorupdate.go new file mode 100644 index 00000000000..130e220ffb1 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_createorupdate.go @@ -0,0 +1,76 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AppServicePlan +} + +// CreateOrUpdate ... +func (c AppServicePlansClient) CreateOrUpdate(ctx context.Context, id commonids.AppServicePlanId, input AppServicePlan) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AppServicePlansClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.AppServicePlanId, input AppServicePlan) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_createorupdatevnetroute.go b/resource-manager/web/2024-11-01/appserviceplans/method_createorupdatevnetroute.go new file mode 100644 index 00000000000..a25c348ca80 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_createorupdatevnetroute.go @@ -0,0 +1,57 @@ +package appserviceplans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateVnetRouteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetRoute +} + +// CreateOrUpdateVnetRoute ... +func (c AppServicePlansClient) CreateOrUpdateVnetRoute(ctx context.Context, id RouteId, input VnetRoute) (result CreateOrUpdateVnetRouteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetRoute + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_delete.go b/resource-manager/web/2024-11-01/appserviceplans/method_delete.go new file mode 100644 index 00000000000..4d95de15002 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_delete.go @@ -0,0 +1,48 @@ +package appserviceplans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c AppServicePlansClient) Delete(ctx context.Context, id commonids.AppServicePlanId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_deletehybridconnection.go b/resource-manager/web/2024-11-01/appserviceplans/method_deletehybridconnection.go new file mode 100644 index 00000000000..e886d4067bc --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_deletehybridconnection.go @@ -0,0 +1,47 @@ +package appserviceplans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHybridConnection ... +func (c AppServicePlansClient) DeleteHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (result DeleteHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_deletevnetroute.go b/resource-manager/web/2024-11-01/appserviceplans/method_deletevnetroute.go new file mode 100644 index 00000000000..ad025ea00a2 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_deletevnetroute.go @@ -0,0 +1,46 @@ +package appserviceplans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteVnetRouteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteVnetRoute ... +func (c AppServicePlansClient) DeleteVnetRoute(ctx context.Context, id RouteId) (result DeleteVnetRouteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_get.go b/resource-manager/web/2024-11-01/appserviceplans/method_get.go new file mode 100644 index 00000000000..e8c9fc7e49c --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_get.go @@ -0,0 +1,54 @@ +package appserviceplans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServicePlan +} + +// Get ... +func (c AppServicePlansClient) Get(ctx context.Context, id commonids.AppServicePlanId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServicePlan + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_gethybridconnection.go b/resource-manager/web/2024-11-01/appserviceplans/method_gethybridconnection.go new file mode 100644 index 00000000000..76d08712a13 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_gethybridconnection.go @@ -0,0 +1,53 @@ +package appserviceplans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// GetHybridConnection ... +func (c AppServicePlansClient) GetHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (result GetHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_gethybridconnectionplanlimit.go b/resource-manager/web/2024-11-01/appserviceplans/method_gethybridconnectionplanlimit.go new file mode 100644 index 00000000000..5fdd323b80c --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_gethybridconnectionplanlimit.go @@ -0,0 +1,55 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetHybridConnectionPlanLimitOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnectionLimits +} + +// GetHybridConnectionPlanLimit ... +func (c AppServicePlansClient) GetHybridConnectionPlanLimit(ctx context.Context, id commonids.AppServicePlanId) (result GetHybridConnectionPlanLimitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnectionPlanLimits/limit", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnectionLimits + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_getrouteforvnet.go b/resource-manager/web/2024-11-01/appserviceplans/method_getrouteforvnet.go new file mode 100644 index 00000000000..43c608e9890 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_getrouteforvnet.go @@ -0,0 +1,53 @@ +package appserviceplans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetRouteForVnetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetRoute +} + +// GetRouteForVnet ... +func (c AppServicePlansClient) GetRouteForVnet(ctx context.Context, id RouteId) (result GetRouteForVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []VnetRoute + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_getserverfarmskus.go b/resource-manager/web/2024-11-01/appserviceplans/method_getserverfarmskus.go new file mode 100644 index 00000000000..bbd1499852a --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_getserverfarmskus.go @@ -0,0 +1,55 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetServerFarmSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// GetServerFarmSkus ... +func (c AppServicePlansClient) GetServerFarmSkus(ctx context.Context, id commonids.AppServicePlanId) (result GetServerFarmSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/skus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model interface{} + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_getvnetfromserverfarm.go b/resource-manager/web/2024-11-01/appserviceplans/method_getvnetfromserverfarm.go new file mode 100644 index 00000000000..650f8a3926f --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_getvnetfromserverfarm.go @@ -0,0 +1,53 @@ +package appserviceplans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetVnetFromServerFarmOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// GetVnetFromServerFarm ... +func (c AppServicePlansClient) GetVnetFromServerFarm(ctx context.Context, id ServerFarmVirtualNetworkConnectionId) (result GetVnetFromServerFarmOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_getvnetgateway.go b/resource-manager/web/2024-11-01/appserviceplans/method_getvnetgateway.go new file mode 100644 index 00000000000..f1892454285 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_getvnetgateway.go @@ -0,0 +1,53 @@ +package appserviceplans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetVnetGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// GetVnetGateway ... +func (c AppServicePlansClient) GetVnetGateway(ctx context.Context, id VirtualNetworkConnectionGatewayId) (result GetVnetGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_list.go b/resource-manager/web/2024-11-01/appserviceplans/method_list.go new file mode 100644 index 00000000000..6487ac4dcb4 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_list.go @@ -0,0 +1,135 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServicePlan +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServicePlan +} + +type ListOperationOptions struct { + Detailed *bool +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Detailed != nil { + out.Append("detailed", fmt.Sprintf("%v", *o.Detailed)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c AppServicePlansClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/serverFarms", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServicePlan `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, AppServicePlanOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate AppServicePlanOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AppServicePlan, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_listbyresourcegroup.go b/resource-manager/web/2024-11-01/appserviceplans/method_listbyresourcegroup.go new file mode 100644 index 00000000000..8a92a8bb9a4 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AppServicePlan +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []AppServicePlan +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c AppServicePlansClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/serverFarms", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AppServicePlan `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, AppServicePlanOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate AppServicePlanOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]AppServicePlan, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_listcapabilities.go b/resource-manager/web/2024-11-01/appserviceplans/method_listcapabilities.go new file mode 100644 index 00000000000..2c65ef4aae9 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_listcapabilities.go @@ -0,0 +1,55 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListCapabilitiesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Capability +} + +// ListCapabilities ... +func (c AppServicePlansClient) ListCapabilities(ctx context.Context, id commonids.AppServicePlanId) (result ListCapabilitiesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/capabilities", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []Capability + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_listhybridconnectionkeys.go b/resource-manager/web/2024-11-01/appserviceplans/method_listhybridconnectionkeys.go new file mode 100644 index 00000000000..78f4e16f7b6 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_listhybridconnectionkeys.go @@ -0,0 +1,54 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListHybridConnectionKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnectionKey +} + +// ListHybridConnectionKeys ... +func (c AppServicePlansClient) ListHybridConnectionKeys(ctx context.Context, id HybridConnectionNamespaceRelayId) (result ListHybridConnectionKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnectionKey + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_listhybridconnections.go b/resource-manager/web/2024-11-01/appserviceplans/method_listhybridconnections.go new file mode 100644 index 00000000000..397cbb6929c --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_listhybridconnections.go @@ -0,0 +1,106 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListHybridConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HybridConnection +} + +type ListHybridConnectionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []HybridConnection +} + +type ListHybridConnectionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListHybridConnectionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListHybridConnections ... +func (c AppServicePlansClient) ListHybridConnections(ctx context.Context, id commonids.AppServicePlanId) (result ListHybridConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListHybridConnectionsCustomPager{}, + Path: fmt.Sprintf("%s/hybridConnectionRelays", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]HybridConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHybridConnectionsComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListHybridConnectionsComplete(ctx context.Context, id commonids.AppServicePlanId) (ListHybridConnectionsCompleteResult, error) { + return c.ListHybridConnectionsCompleteMatchingPredicate(ctx, id, HybridConnectionOperationPredicate{}) +} + +// ListHybridConnectionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListHybridConnectionsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServicePlanId, predicate HybridConnectionOperationPredicate) (result ListHybridConnectionsCompleteResult, err error) { + items := make([]HybridConnection, 0) + + resp, err := c.ListHybridConnections(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListHybridConnectionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_listroutesforvnet.go b/resource-manager/web/2024-11-01/appserviceplans/method_listroutesforvnet.go new file mode 100644 index 00000000000..cea1ee3b594 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_listroutesforvnet.go @@ -0,0 +1,54 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListRoutesForVnetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetRoute +} + +// ListRoutesForVnet ... +func (c AppServicePlansClient) ListRoutesForVnet(ctx context.Context, id ServerFarmVirtualNetworkConnectionId) (result ListRoutesForVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/routes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []VnetRoute + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_listusages.go b/resource-manager/web/2024-11-01/appserviceplans/method_listusages.go new file mode 100644 index 00000000000..11927a25518 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_listusages.go @@ -0,0 +1,135 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type ListUsagesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmUsageQuota +} + +type ListUsagesOperationOptions struct { + Filter *string +} + +func DefaultListUsagesOperationOptions() ListUsagesOperationOptions { + return ListUsagesOperationOptions{} +} + +func (o ListUsagesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListUsagesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListUsagesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListUsagesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListUsagesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListUsages ... +func (c AppServicePlansClient) ListUsages(ctx context.Context, id commonids.AppServicePlanId, options ListUsagesOperationOptions) (result ListUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListUsagesCustomPager{}, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListUsagesComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListUsagesComplete(ctx context.Context, id commonids.AppServicePlanId, options ListUsagesOperationOptions) (ListUsagesCompleteResult, error) { + return c.ListUsagesCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) +} + +// ListUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListUsagesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServicePlanId, options ListUsagesOperationOptions, predicate CsmUsageQuotaOperationPredicate) (result ListUsagesCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.ListUsages(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListUsagesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_listvnets.go b/resource-manager/web/2024-11-01/appserviceplans/method_listvnets.go new file mode 100644 index 00000000000..1779fca1033 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_listvnets.go @@ -0,0 +1,55 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListVnetsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetInfoResource +} + +// ListVnets ... +func (c AppServicePlansClient) ListVnets(ctx context.Context, id commonids.AppServicePlanId) (result ListVnetsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/virtualNetworkConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_listwebapps.go b/resource-manager/web/2024-11-01/appserviceplans/method_listwebapps.go new file mode 100644 index 00000000000..112b9dd14f8 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_listwebapps.go @@ -0,0 +1,139 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListWebAppsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListWebAppsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type ListWebAppsOperationOptions struct { + Filter *string + Top *string +} + +func DefaultListWebAppsOperationOptions() ListWebAppsOperationOptions { + return ListWebAppsOperationOptions{} +} + +func (o ListWebAppsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListWebAppsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListWebAppsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListWebAppsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWebAppsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWebApps ... +func (c AppServicePlansClient) ListWebApps(ctx context.Context, id commonids.AppServicePlanId, options ListWebAppsOperationOptions) (result ListWebAppsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListWebAppsCustomPager{}, + Path: fmt.Sprintf("%s/sites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebAppsComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListWebAppsComplete(ctx context.Context, id commonids.AppServicePlanId, options ListWebAppsOperationOptions) (ListWebAppsCompleteResult, error) { + return c.ListWebAppsCompleteMatchingPredicate(ctx, id, options, SiteOperationPredicate{}) +} + +// ListWebAppsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AppServicePlansClient) ListWebAppsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServicePlanId, options ListWebAppsOperationOptions, predicate SiteOperationPredicate) (result ListWebAppsCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.ListWebApps(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWebAppsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_listwebappsbyhybridconnection.go b/resource-manager/web/2024-11-01/appserviceplans/method_listwebappsbyhybridconnection.go new file mode 100644 index 00000000000..84d13849999 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_listwebappsbyhybridconnection.go @@ -0,0 +1,98 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListWebAppsByHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]string +} + +type ListWebAppsByHybridConnectionCompleteResult struct { + LatestHttpResponse *http.Response + Items []string +} + +type ListWebAppsByHybridConnectionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWebAppsByHybridConnectionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWebAppsByHybridConnection ... +func (c AppServicePlansClient) ListWebAppsByHybridConnection(ctx context.Context, id HybridConnectionNamespaceRelayId) (result ListWebAppsByHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWebAppsByHybridConnectionCustomPager{}, + Path: fmt.Sprintf("%s/sites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]string `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebAppsByHybridConnectionComplete retrieves all the results into a single object +func (c AppServicePlansClient) ListWebAppsByHybridConnectionComplete(ctx context.Context, id HybridConnectionNamespaceRelayId) (result ListWebAppsByHybridConnectionCompleteResult, err error) { + items := make([]string, 0) + + resp, err := c.ListWebAppsByHybridConnection(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + items = append(items, v) + } + } + + result = ListWebAppsByHybridConnectionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_rebootworker.go b/resource-manager/web/2024-11-01/appserviceplans/method_rebootworker.go new file mode 100644 index 00000000000..b1e54e3cffe --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_rebootworker.go @@ -0,0 +1,47 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RebootWorkerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RebootWorker ... +func (c AppServicePlansClient) RebootWorker(ctx context.Context, id WorkerId) (result RebootWorkerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/reboot", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_restartwebapps.go b/resource-manager/web/2024-11-01/appserviceplans/method_restartwebapps.go new file mode 100644 index 00000000000..e6b604d940c --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_restartwebapps.go @@ -0,0 +1,77 @@ +package appserviceplans + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestartWebAppsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type RestartWebAppsOperationOptions struct { + SoftRestart *bool +} + +func DefaultRestartWebAppsOperationOptions() RestartWebAppsOperationOptions { + return RestartWebAppsOperationOptions{} +} + +func (o RestartWebAppsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestartWebAppsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RestartWebAppsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SoftRestart != nil { + out.Append("softRestart", fmt.Sprintf("%v", *o.SoftRestart)) + } + return &out +} + +// RestartWebApps ... +func (c AppServicePlansClient) RestartWebApps(ctx context.Context, id commonids.AppServicePlanId, options RestartWebAppsOperationOptions) (result RestartWebAppsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/restartSites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_update.go b/resource-manager/web/2024-11-01/appserviceplans/method_update.go new file mode 100644 index 00000000000..cc2bebbb8cc --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_update.go @@ -0,0 +1,59 @@ +package appserviceplans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AppServicePlan +} + +// Update ... +func (c AppServicePlansClient) Update(ctx context.Context, id commonids.AppServicePlanId, input AppServicePlanPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AppServicePlan + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_updatevnetgateway.go b/resource-manager/web/2024-11-01/appserviceplans/method_updatevnetgateway.go new file mode 100644 index 00000000000..084885def91 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_updatevnetgateway.go @@ -0,0 +1,57 @@ +package appserviceplans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateVnetGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// UpdateVnetGateway ... +func (c AppServicePlansClient) UpdateVnetGateway(ctx context.Context, id VirtualNetworkConnectionGatewayId, input VnetGateway) (result UpdateVnetGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/method_updatevnetroute.go b/resource-manager/web/2024-11-01/appserviceplans/method_updatevnetroute.go new file mode 100644 index 00000000000..0d8db289b93 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/method_updatevnetroute.go @@ -0,0 +1,57 @@ +package appserviceplans + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateVnetRouteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetRoute +} + +// UpdateVnetRoute ... +func (c AppServicePlansClient) UpdateVnetRoute(ctx context.Context, id RouteId, input VnetRoute) (result UpdateVnetRouteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetRoute + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_apidefinitioninfo.go b/resource-manager/web/2024-11-01/appserviceplans/model_apidefinitioninfo.go new file mode 100644 index 00000000000..2ac5fa81cba --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_apidefinitioninfo.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiDefinitionInfo struct { + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_apimanagementconfig.go b/resource-manager/web/2024-11-01/appserviceplans/model_apimanagementconfig.go new file mode 100644 index 00000000000..dab0ea80e65 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_apimanagementconfig.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiManagementConfig struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_appserviceplan.go b/resource-manager/web/2024-11-01/appserviceplans/model_appserviceplan.go new file mode 100644 index 00000000000..939499f257a --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_appserviceplan.go @@ -0,0 +1,16 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServicePlan struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AppServicePlanProperties `json:"properties,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_appserviceplanpatchresource.go b/resource-manager/web/2024-11-01/appserviceplans/model_appserviceplanpatchresource.go new file mode 100644 index 00000000000..e2e21fc04a7 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_appserviceplanpatchresource.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServicePlanPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AppServicePlanPatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_appserviceplanpatchresourceproperties.go b/resource-manager/web/2024-11-01/appserviceplans/model_appserviceplanpatchresourceproperties.go new file mode 100644 index 00000000000..efdb53cdcff --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_appserviceplanpatchresourceproperties.go @@ -0,0 +1,60 @@ +package appserviceplans + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServicePlanPatchResourceProperties struct { + ElasticScaleEnabled *bool `json:"elasticScaleEnabled,omitempty"` + FreeOfferExpirationTime *string `json:"freeOfferExpirationTime,omitempty"` + GeoRegion *string `json:"geoRegion,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + IsSpot *bool `json:"isSpot,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KubeEnvironmentProfile *KubeEnvironmentProfile `json:"kubeEnvironmentProfile,omitempty"` + MaximumElasticWorkerCount *int64 `json:"maximumElasticWorkerCount,omitempty"` + MaximumNumberOfWorkers *int64 `json:"maximumNumberOfWorkers,omitempty"` + NumberOfSites *int64 `json:"numberOfSites,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PerSiteScaling *bool `json:"perSiteScaling,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + SpotExpirationTime *string `json:"spotExpirationTime,omitempty"` + Status *StatusOptions `json:"status,omitempty"` + Subscription *string `json:"subscription,omitempty"` + TargetWorkerCount *int64 `json:"targetWorkerCount,omitempty"` + TargetWorkerSizeId *int64 `json:"targetWorkerSizeId,omitempty"` + WorkerTierName *string `json:"workerTierName,omitempty"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} + +func (o *AppServicePlanPatchResourceProperties) GetFreeOfferExpirationTimeAsTime() (*time.Time, error) { + if o.FreeOfferExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.FreeOfferExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanPatchResourceProperties) SetFreeOfferExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.FreeOfferExpirationTime = &formatted +} + +func (o *AppServicePlanPatchResourceProperties) GetSpotExpirationTimeAsTime() (*time.Time, error) { + if o.SpotExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SpotExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanPatchResourceProperties) SetSpotExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SpotExpirationTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_appserviceplanproperties.go b/resource-manager/web/2024-11-01/appserviceplans/model_appserviceplanproperties.go new file mode 100644 index 00000000000..16fa5bfc6a9 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_appserviceplanproperties.go @@ -0,0 +1,61 @@ +package appserviceplans + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServicePlanProperties struct { + AsyncScalingEnabled *bool `json:"asyncScalingEnabled,omitempty"` + ElasticScaleEnabled *bool `json:"elasticScaleEnabled,omitempty"` + FreeOfferExpirationTime *string `json:"freeOfferExpirationTime,omitempty"` + GeoRegion *string `json:"geoRegion,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + IsSpot *bool `json:"isSpot,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KubeEnvironmentProfile *KubeEnvironmentProfile `json:"kubeEnvironmentProfile,omitempty"` + MaximumElasticWorkerCount *int64 `json:"maximumElasticWorkerCount,omitempty"` + MaximumNumberOfWorkers *int64 `json:"maximumNumberOfWorkers,omitempty"` + NumberOfSites *int64 `json:"numberOfSites,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PerSiteScaling *bool `json:"perSiteScaling,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + SpotExpirationTime *string `json:"spotExpirationTime,omitempty"` + Status *StatusOptions `json:"status,omitempty"` + Subscription *string `json:"subscription,omitempty"` + TargetWorkerCount *int64 `json:"targetWorkerCount,omitempty"` + TargetWorkerSizeId *int64 `json:"targetWorkerSizeId,omitempty"` + WorkerTierName *string `json:"workerTierName,omitempty"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} + +func (o *AppServicePlanProperties) GetFreeOfferExpirationTimeAsTime() (*time.Time, error) { + if o.FreeOfferExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.FreeOfferExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanProperties) SetFreeOfferExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.FreeOfferExpirationTime = &formatted +} + +func (o *AppServicePlanProperties) GetSpotExpirationTimeAsTime() (*time.Time, error) { + if o.SpotExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SpotExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AppServicePlanProperties) SetSpotExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SpotExpirationTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_autohealactions.go b/resource-manager/web/2024-11-01/appserviceplans/model_autohealactions.go new file mode 100644 index 00000000000..e32290fd78e --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_autohealactions.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealActions struct { + ActionType *AutoHealActionType `json:"actionType,omitempty"` + CustomAction *AutoHealCustomAction `json:"customAction,omitempty"` + MinProcessExecutionTime *string `json:"minProcessExecutionTime,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_autohealcustomaction.go b/resource-manager/web/2024-11-01/appserviceplans/model_autohealcustomaction.go new file mode 100644 index 00000000000..2b7e2af847d --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_autohealcustomaction.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealCustomAction struct { + Exe *string `json:"exe,omitempty"` + Parameters *string `json:"parameters,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_autohealrules.go b/resource-manager/web/2024-11-01/appserviceplans/model_autohealrules.go new file mode 100644 index 00000000000..6da2d1028df --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_autohealrules.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealRules struct { + Actions *AutoHealActions `json:"actions,omitempty"` + Triggers *AutoHealTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_autohealtriggers.go b/resource-manager/web/2024-11-01/appserviceplans/model_autohealtriggers.go new file mode 100644 index 00000000000..a3c3a7fe781 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_autohealtriggers.go @@ -0,0 +1,13 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealTriggers struct { + PrivateBytesInKB *int64 `json:"privateBytesInKB,omitempty"` + Requests *RequestsBasedTrigger `json:"requests,omitempty"` + SlowRequests *SlowRequestsBasedTrigger `json:"slowRequests,omitempty"` + SlowRequestsWithPath *[]SlowRequestsBasedTrigger `json:"slowRequestsWithPath,omitempty"` + StatusCodes *[]StatusCodesBasedTrigger `json:"statusCodes,omitempty"` + StatusCodesRange *[]StatusCodesRangeBasedTrigger `json:"statusCodesRange,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_azurestorageinfovalue.go b/resource-manager/web/2024-11-01/appserviceplans/model_azurestorageinfovalue.go new file mode 100644 index 00000000000..0c62698b97b --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_azurestorageinfovalue.go @@ -0,0 +1,14 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageInfoValue struct { + AccessKey *string `json:"accessKey,omitempty"` + AccountName *string `json:"accountName,omitempty"` + MountPath *string `json:"mountPath,omitempty"` + Protocol *AzureStorageProtocol `json:"protocol,omitempty"` + ShareName *string `json:"shareName,omitempty"` + State *AzureStorageState `json:"state,omitempty"` + Type *AzureStorageType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_capability.go b/resource-manager/web/2024-11-01/appserviceplans/model_capability.go new file mode 100644 index 00000000000..0cfebd66ae9 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_capability.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Capability struct { + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_cloninginfo.go b/resource-manager/web/2024-11-01/appserviceplans/model_cloninginfo.go new file mode 100644 index 00000000000..5d297b188da --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_cloninginfo.go @@ -0,0 +1,18 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloningInfo struct { + AppSettingsOverrides *map[string]string `json:"appSettingsOverrides,omitempty"` + CloneCustomHostNames *bool `json:"cloneCustomHostNames,omitempty"` + CloneSourceControl *bool `json:"cloneSourceControl,omitempty"` + ConfigureLoadBalancing *bool `json:"configureLoadBalancing,omitempty"` + CorrelationId *string `json:"correlationId,omitempty"` + HostingEnvironment *string `json:"hostingEnvironment,omitempty"` + Overwrite *bool `json:"overwrite,omitempty"` + SourceWebAppId string `json:"sourceWebAppId"` + SourceWebAppLocation *string `json:"sourceWebAppLocation,omitempty"` + TrafficManagerProfileId *string `json:"trafficManagerProfileId,omitempty"` + TrafficManagerProfileName *string `json:"trafficManagerProfileName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_connstringinfo.go b/resource-manager/web/2024-11-01/appserviceplans/model_connstringinfo.go new file mode 100644 index 00000000000..367ae1ac201 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_connstringinfo.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnStringInfo struct { + ConnectionString *string `json:"connectionString,omitempty"` + Name *string `json:"name,omitempty"` + Type *ConnectionStringType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_corssettings.go b/resource-manager/web/2024-11-01/appserviceplans/model_corssettings.go new file mode 100644 index 00000000000..ec523b9ae12 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_corssettings.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CorsSettings struct { + AllowedOrigins *[]string `json:"allowedOrigins,omitempty"` + SupportCredentials *bool `json:"supportCredentials,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_csmusagequota.go b/resource-manager/web/2024-11-01/appserviceplans/model_csmusagequota.go new file mode 100644 index 00000000000..24ec9c595c0 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_csmusagequota.go @@ -0,0 +1,30 @@ +package appserviceplans + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmUsageQuota struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *LocalizableString `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +func (o *CsmUsageQuota) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CsmUsageQuota) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_daprconfig.go b/resource-manager/web/2024-11-01/appserviceplans/model_daprconfig.go new file mode 100644 index 00000000000..bd07c41dcc8 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_daprconfig.go @@ -0,0 +1,14 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprConfig struct { + AppId *string `json:"appId,omitempty"` + AppPort *int64 `json:"appPort,omitempty"` + EnableApiLogging *bool `json:"enableApiLogging,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + HTTPMaxRequestSize *int64 `json:"httpMaxRequestSize,omitempty"` + HTTPReadBufferSize *int64 `json:"httpReadBufferSize,omitempty"` + LogLevel *DaprLogLevel `json:"logLevel,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_experiments.go b/resource-manager/web/2024-11-01/appserviceplans/model_experiments.go new file mode 100644 index 00000000000..c10e0c96da0 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_experiments.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Experiments struct { + RampUpRules *[]RampUpRule `json:"rampUpRules,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_extendedlocation.go b/resource-manager/web/2024-11-01/appserviceplans/model_extendedlocation.go new file mode 100644 index 00000000000..9e237794a1d --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_extendedlocation.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_functionappconfig.go b/resource-manager/web/2024-11-01/appserviceplans/model_functionappconfig.go new file mode 100644 index 00000000000..5eb3b499888 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_functionappconfig.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppConfig struct { + Deployment *FunctionsDeployment `json:"deployment,omitempty"` + Runtime *FunctionsRuntime `json:"runtime,omitempty"` + ScaleAndConcurrency *FunctionsScaleAndConcurrency `json:"scaleAndConcurrency,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_functionsalwaysreadyconfig.go b/resource-manager/web/2024-11-01/appserviceplans/model_functionsalwaysreadyconfig.go new file mode 100644 index 00000000000..bfd0d3eab01 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_functionsalwaysreadyconfig.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsAlwaysReadyConfig struct { + InstanceCount *int64 `json:"instanceCount,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_functionsdeployment.go b/resource-manager/web/2024-11-01/appserviceplans/model_functionsdeployment.go new file mode 100644 index 00000000000..41f4213a7c6 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_functionsdeployment.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeployment struct { + Storage *FunctionsDeploymentStorage `json:"storage,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_functionsdeploymentstorage.go b/resource-manager/web/2024-11-01/appserviceplans/model_functionsdeploymentstorage.go new file mode 100644 index 00000000000..49254f5989c --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_functionsdeploymentstorage.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorage struct { + Authentication *FunctionsDeploymentStorageAuthentication `json:"authentication,omitempty"` + Type *FunctionsDeploymentStorageType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_functionsdeploymentstorageauthentication.go b/resource-manager/web/2024-11-01/appserviceplans/model_functionsdeploymentstorageauthentication.go new file mode 100644 index 00000000000..e194eb9b172 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_functionsdeploymentstorageauthentication.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorageAuthentication struct { + StorageAccountConnectionStringName *string `json:"storageAccountConnectionStringName,omitempty"` + Type *AuthenticationType `json:"type,omitempty"` + UserAssignedIdentityResourceId *string `json:"userAssignedIdentityResourceId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_functionsruntime.go b/resource-manager/web/2024-11-01/appserviceplans/model_functionsruntime.go new file mode 100644 index 00000000000..d04994cdbd0 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_functionsruntime.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsRuntime struct { + Name *RuntimeName `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_functionsscaleandconcurrency.go b/resource-manager/web/2024-11-01/appserviceplans/model_functionsscaleandconcurrency.go new file mode 100644 index 00000000000..048b6d942a7 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_functionsscaleandconcurrency.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrency struct { + AlwaysReady *[]FunctionsAlwaysReadyConfig `json:"alwaysReady,omitempty"` + InstanceMemoryMB *int64 `json:"instanceMemoryMB,omitempty"` + MaximumInstanceCount *int64 `json:"maximumInstanceCount,omitempty"` + Triggers *FunctionsScaleAndConcurrencyTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_functionsscaleandconcurrencytriggers.go b/resource-manager/web/2024-11-01/appserviceplans/model_functionsscaleandconcurrencytriggers.go new file mode 100644 index 00000000000..9a87d6ba0f2 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_functionsscaleandconcurrencytriggers.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggers struct { + HTTP *FunctionsScaleAndConcurrencyTriggersHTTP `json:"http,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_functionsscaleandconcurrencytriggershttp.go b/resource-manager/web/2024-11-01/appserviceplans/model_functionsscaleandconcurrencytriggershttp.go new file mode 100644 index 00000000000..d547bd4d367 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_functionsscaleandconcurrencytriggershttp.go @@ -0,0 +1,8 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggersHTTP struct { + PerInstanceConcurrency *int64 `json:"perInstanceConcurrency,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_handlermapping.go b/resource-manager/web/2024-11-01/appserviceplans/model_handlermapping.go new file mode 100644 index 00000000000..2b0fd51c628 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_handlermapping.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HandlerMapping struct { + Arguments *string `json:"arguments,omitempty"` + Extension *string `json:"extension,omitempty"` + ScriptProcessor *string `json:"scriptProcessor,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_hostingenvironmentprofile.go b/resource-manager/web/2024-11-01/appserviceplans/model_hostingenvironmentprofile.go new file mode 100644 index 00000000000..3e6d1e245c0 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_hostingenvironmentprofile.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_hostnamesslstate.go b/resource-manager/web/2024-11-01/appserviceplans/model_hostnamesslstate.go new file mode 100644 index 00000000000..eb49e879dbe --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_hostnamesslstate.go @@ -0,0 +1,13 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostNameSslState struct { + HostType *HostType `json:"hostType,omitempty"` + Name *string `json:"name,omitempty"` + SslState *SslState `json:"sslState,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + ToUpdate *bool `json:"toUpdate,omitempty"` + VirtualIP *string `json:"virtualIP,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnection.go b/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnection.go new file mode 100644 index 00000000000..92deac554e2 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnection.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnection struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HybridConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnectionkey.go b/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnectionkey.go new file mode 100644 index 00000000000..95cbaf8d9c6 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnectionkey.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionKey struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HybridConnectionKeyProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnectionkeyproperties.go b/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnectionkeyproperties.go new file mode 100644 index 00000000000..b9d55a5c698 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnectionkeyproperties.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionKeyProperties struct { + SendKeyName *string `json:"sendKeyName,omitempty"` + SendKeyValue *string `json:"sendKeyValue,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnectionlimits.go b/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnectionlimits.go new file mode 100644 index 00000000000..1463d5e4dbf --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnectionlimits.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionLimits struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HybridConnectionLimitsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnectionlimitsproperties.go b/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnectionlimitsproperties.go new file mode 100644 index 00000000000..a462d888655 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnectionlimitsproperties.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionLimitsProperties struct { + Current *int64 `json:"current,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnectionproperties.go b/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnectionproperties.go new file mode 100644 index 00000000000..93e6f70afd6 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_hybridconnectionproperties.go @@ -0,0 +1,15 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionProperties struct { + Hostname *string `json:"hostname,omitempty"` + Port *int64 `json:"port,omitempty"` + RelayArmUri *string `json:"relayArmUri,omitempty"` + RelayName *string `json:"relayName,omitempty"` + SendKeyName *string `json:"sendKeyName,omitempty"` + SendKeyValue *string `json:"sendKeyValue,omitempty"` + ServiceBusNamespace *string `json:"serviceBusNamespace,omitempty"` + ServiceBusSuffix *string `json:"serviceBusSuffix,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_ipsecurityrestriction.go b/resource-manager/web/2024-11-01/appserviceplans/model_ipsecurityrestriction.go new file mode 100644 index 00000000000..d1bf7483ffc --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_ipsecurityrestriction.go @@ -0,0 +1,18 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPSecurityRestriction struct { + Action *string `json:"action,omitempty"` + Description *string `json:"description,omitempty"` + Headers *map[string][]string `json:"headers,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + SubnetMask *string `json:"subnetMask,omitempty"` + SubnetTrafficTag *int64 `json:"subnetTrafficTag,omitempty"` + Tag *IPFilterTag `json:"tag,omitempty"` + VnetSubnetResourceId *string `json:"vnetSubnetResourceId,omitempty"` + VnetTrafficTag *int64 `json:"vnetTrafficTag,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_kubeenvironmentprofile.go b/resource-manager/web/2024-11-01/appserviceplans/model_kubeenvironmentprofile.go new file mode 100644 index 00000000000..a8c2c586a76 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_kubeenvironmentprofile.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_localizablestring.go b/resource-manager/web/2024-11-01/appserviceplans/model_localizablestring.go new file mode 100644 index 00000000000..3f1e149630e --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_localizablestring.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalizableString struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_namevaluepair.go b/resource-manager/web/2024-11-01/appserviceplans/model_namevaluepair.go new file mode 100644 index 00000000000..8810fa8f3de --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_namevaluepair.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameValuePair struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_outboundvnetrouting.go b/resource-manager/web/2024-11-01/appserviceplans/model_outboundvnetrouting.go new file mode 100644 index 00000000000..e6a301ba71d --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_outboundvnetrouting.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundVnetRouting struct { + AllTraffic *bool `json:"allTraffic,omitempty"` + ApplicationTraffic *bool `json:"applicationTraffic,omitempty"` + BackupRestoreTraffic *bool `json:"backupRestoreTraffic,omitempty"` + ContentShareTraffic *bool `json:"contentShareTraffic,omitempty"` + ImagePullTraffic *bool `json:"imagePullTraffic,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_pushsettings.go b/resource-manager/web/2024-11-01/appserviceplans/model_pushsettings.go new file mode 100644 index 00000000000..4dc8d4fea82 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_pushsettings.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettings struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PushSettingsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_pushsettingsproperties.go b/resource-manager/web/2024-11-01/appserviceplans/model_pushsettingsproperties.go new file mode 100644 index 00000000000..beae479c519 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_pushsettingsproperties.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettingsProperties struct { + DynamicTagsJson *string `json:"dynamicTagsJson,omitempty"` + IsPushEnabled bool `json:"isPushEnabled"` + TagWhitelistJson *string `json:"tagWhitelistJson,omitempty"` + TagsRequiringAuth *string `json:"tagsRequiringAuth,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_rampuprule.go b/resource-manager/web/2024-11-01/appserviceplans/model_rampuprule.go new file mode 100644 index 00000000000..424344dba00 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_rampuprule.go @@ -0,0 +1,15 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RampUpRule struct { + ActionHostName *string `json:"actionHostName,omitempty"` + ChangeDecisionCallbackURL *string `json:"changeDecisionCallbackUrl,omitempty"` + ChangeIntervalInMinutes *int64 `json:"changeIntervalInMinutes,omitempty"` + ChangeStep *float64 `json:"changeStep,omitempty"` + MaxReroutePercentage *float64 `json:"maxReroutePercentage,omitempty"` + MinReroutePercentage *float64 `json:"minReroutePercentage,omitempty"` + Name *string `json:"name,omitempty"` + ReroutePercentage *float64 `json:"reroutePercentage,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_requestsbasedtrigger.go b/resource-manager/web/2024-11-01/appserviceplans/model_requestsbasedtrigger.go new file mode 100644 index 00000000000..3858f02d387 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_requestsbasedtrigger.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_resourceconfig.go b/resource-manager/web/2024-11-01/appserviceplans/model_resourceconfig.go new file mode 100644 index 00000000000..3998b6a1a11 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_resourceconfig.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceConfig struct { + Cpu *float64 `json:"cpu,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_site.go b/resource-manager/web/2024-11-01/appserviceplans/model_site.go new file mode 100644 index 00000000000..f0199b22e0b --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_site.go @@ -0,0 +1,20 @@ +package appserviceplans + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Site struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SiteProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_siteconfig.go b/resource-manager/web/2024-11-01/appserviceplans/model_siteconfig.go new file mode 100644 index 00000000000..62bed8fb614 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_siteconfig.go @@ -0,0 +1,98 @@ +package appserviceplans + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteConfig struct { + AcrUseManagedIdentityCreds *bool `json:"acrUseManagedIdentityCreds,omitempty"` + AcrUserManagedIdentityID *string `json:"acrUserManagedIdentityID,omitempty"` + AlwaysOn *bool `json:"alwaysOn,omitempty"` + ApiDefinition *ApiDefinitionInfo `json:"apiDefinition,omitempty"` + ApiManagementConfig *ApiManagementConfig `json:"apiManagementConfig,omitempty"` + AppCommandLine *string `json:"appCommandLine,omitempty"` + AppSettings *[]NameValuePair `json:"appSettings,omitempty"` + AutoHealEnabled *bool `json:"autoHealEnabled,omitempty"` + AutoHealRules *AutoHealRules `json:"autoHealRules,omitempty"` + AutoSwapSlotName *string `json:"autoSwapSlotName,omitempty"` + AzureStorageAccounts *map[string]AzureStorageInfoValue `json:"azureStorageAccounts,omitempty"` + ConnectionStrings *[]ConnStringInfo `json:"connectionStrings,omitempty"` + Cors *CorsSettings `json:"cors,omitempty"` + DefaultDocuments *[]string `json:"defaultDocuments,omitempty"` + DetailedErrorLoggingEnabled *bool `json:"detailedErrorLoggingEnabled,omitempty"` + DocumentRoot *string `json:"documentRoot,omitempty"` + ElasticWebAppScaleLimit *int64 `json:"elasticWebAppScaleLimit,omitempty"` + Experiments *Experiments `json:"experiments,omitempty"` + FtpsState *FtpsState `json:"ftpsState,omitempty"` + FunctionAppScaleLimit *int64 `json:"functionAppScaleLimit,omitempty"` + FunctionsRuntimeScaleMonitoringEnabled *bool `json:"functionsRuntimeScaleMonitoringEnabled,omitempty"` + HTTP20Enabled *bool `json:"http20Enabled,omitempty"` + HTTP20ProxyFlag *int64 `json:"http20ProxyFlag,omitempty"` + HTTPLoggingEnabled *bool `json:"httpLoggingEnabled,omitempty"` + HandlerMappings *[]HandlerMapping `json:"handlerMappings,omitempty"` + HealthCheckPath *string `json:"healthCheckPath,omitempty"` + IPSecurityRestrictions *[]IPSecurityRestriction `json:"ipSecurityRestrictions,omitempty"` + IPSecurityRestrictionsDefaultAction *DefaultAction `json:"ipSecurityRestrictionsDefaultAction,omitempty"` + JavaContainer *string `json:"javaContainer,omitempty"` + JavaContainerVersion *string `json:"javaContainerVersion,omitempty"` + JavaVersion *string `json:"javaVersion,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + Limits *SiteLimits `json:"limits,omitempty"` + LinuxFxVersion *string `json:"linuxFxVersion,omitempty"` + LoadBalancing *SiteLoadBalancing `json:"loadBalancing,omitempty"` + LocalMySqlEnabled *bool `json:"localMySqlEnabled,omitempty"` + LogsDirectorySizeLimit *int64 `json:"logsDirectorySizeLimit,omitempty"` + MachineKey *SiteMachineKey `json:"machineKey,omitempty"` + ManagedPipelineMode *ManagedPipelineMode `json:"managedPipelineMode,omitempty"` + ManagedServiceIdentityId *int64 `json:"managedServiceIdentityId,omitempty"` + Metadata *[]NameValuePair `json:"metadata,omitempty"` + MinTlsCipherSuite *TlsCipherSuites `json:"minTlsCipherSuite,omitempty"` + MinTlsVersion *SupportedTlsVersions `json:"minTlsVersion,omitempty"` + MinimumElasticInstanceCount *int64 `json:"minimumElasticInstanceCount,omitempty"` + NetFrameworkVersion *string `json:"netFrameworkVersion,omitempty"` + NodeVersion *string `json:"nodeVersion,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PhpVersion *string `json:"phpVersion,omitempty"` + PowerShellVersion *string `json:"powerShellVersion,omitempty"` + PreWarmedInstanceCount *int64 `json:"preWarmedInstanceCount,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + PublishingUsername *string `json:"publishingUsername,omitempty"` + Push *PushSettings `json:"push,omitempty"` + PythonVersion *string `json:"pythonVersion,omitempty"` + RemoteDebuggingEnabled *bool `json:"remoteDebuggingEnabled,omitempty"` + RemoteDebuggingVersion *string `json:"remoteDebuggingVersion,omitempty"` + RequestTracingEnabled *bool `json:"requestTracingEnabled,omitempty"` + RequestTracingExpirationTime *string `json:"requestTracingExpirationTime,omitempty"` + ScmIPSecurityRestrictions *[]IPSecurityRestriction `json:"scmIpSecurityRestrictions,omitempty"` + ScmIPSecurityRestrictionsDefaultAction *DefaultAction `json:"scmIpSecurityRestrictionsDefaultAction,omitempty"` + ScmIPSecurityRestrictionsUseMain *bool `json:"scmIpSecurityRestrictionsUseMain,omitempty"` + ScmMinTlsVersion *SupportedTlsVersions `json:"scmMinTlsVersion,omitempty"` + ScmType *ScmType `json:"scmType,omitempty"` + TracingOptions *string `json:"tracingOptions,omitempty"` + Use32BitWorkerProcess *bool `json:"use32BitWorkerProcess,omitempty"` + VirtualApplications *[]VirtualApplication `json:"virtualApplications,omitempty"` + VnetName *string `json:"vnetName,omitempty"` + VnetPrivatePortsCount *int64 `json:"vnetPrivatePortsCount,omitempty"` + VnetRouteAllEnabled *bool `json:"vnetRouteAllEnabled,omitempty"` + WebSocketsEnabled *bool `json:"webSocketsEnabled,omitempty"` + WebsiteTimeZone *string `json:"websiteTimeZone,omitempty"` + WindowsFxVersion *string `json:"windowsFxVersion,omitempty"` + XManagedServiceIdentityId *int64 `json:"xManagedServiceIdentityId,omitempty"` +} + +func (o *SiteConfig) GetRequestTracingExpirationTimeAsTime() (*time.Time, error) { + if o.RequestTracingExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RequestTracingExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteConfig) SetRequestTracingExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RequestTracingExpirationTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_sitednsconfig.go b/resource-manager/web/2024-11-01/appserviceplans/model_sitednsconfig.go new file mode 100644 index 00000000000..58beab17a2d --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_sitednsconfig.go @@ -0,0 +1,13 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteDnsConfig struct { + DnsAltServer *string `json:"dnsAltServer,omitempty"` + DnsLegacySortOrder *bool `json:"dnsLegacySortOrder,omitempty"` + DnsMaxCacheTimeout *int64 `json:"dnsMaxCacheTimeout,omitempty"` + DnsRetryAttemptCount *int64 `json:"dnsRetryAttemptCount,omitempty"` + DnsRetryAttemptTimeout *int64 `json:"dnsRetryAttemptTimeout,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_sitelimits.go b/resource-manager/web/2024-11-01/appserviceplans/model_sitelimits.go new file mode 100644 index 00000000000..1036a87d597 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_sitelimits.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteLimits struct { + MaxDiskSizeInMb *int64 `json:"maxDiskSizeInMb,omitempty"` + MaxMemoryInMb *int64 `json:"maxMemoryInMb,omitempty"` + MaxPercentageCPU *float64 `json:"maxPercentageCpu,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_sitemachinekey.go b/resource-manager/web/2024-11-01/appserviceplans/model_sitemachinekey.go new file mode 100644 index 00000000000..17855ad5e8c --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_sitemachinekey.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteMachineKey struct { + Decryption *string `json:"decryption,omitempty"` + DecryptionKey *string `json:"decryptionKey,omitempty"` + Validation *string `json:"validation,omitempty"` + ValidationKey *string `json:"validationKey,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_siteproperties.go b/resource-manager/web/2024-11-01/appserviceplans/model_siteproperties.go new file mode 100644 index 00000000000..5c2d75ae761 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_siteproperties.go @@ -0,0 +1,93 @@ +package appserviceplans + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteProperties struct { + AutoGeneratedDomainNameLabelScope *AutoGeneratedDomainNameLabelScope `json:"autoGeneratedDomainNameLabelScope,omitempty"` + AvailabilityState *SiteAvailabilityState `json:"availabilityState,omitempty"` + ClientAffinityEnabled *bool `json:"clientAffinityEnabled,omitempty"` + ClientAffinityPartitioningEnabled *bool `json:"clientAffinityPartitioningEnabled,omitempty"` + ClientAffinityProxyEnabled *bool `json:"clientAffinityProxyEnabled,omitempty"` + ClientCertEnabled *bool `json:"clientCertEnabled,omitempty"` + ClientCertExclusionPaths *string `json:"clientCertExclusionPaths,omitempty"` + ClientCertMode *ClientCertMode `json:"clientCertMode,omitempty"` + CloningInfo *CloningInfo `json:"cloningInfo,omitempty"` + ContainerSize *int64 `json:"containerSize,omitempty"` + CustomDomainVerificationId *string `json:"customDomainVerificationId,omitempty"` + DailyMemoryTimeQuota *int64 `json:"dailyMemoryTimeQuota,omitempty"` + DaprConfig *DaprConfig `json:"daprConfig,omitempty"` + DefaultHostName *string `json:"defaultHostName,omitempty"` + DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + EndToEndEncryptionEnabled *bool `json:"endToEndEncryptionEnabled,omitempty"` + FunctionAppConfig *FunctionAppConfig `json:"functionAppConfig,omitempty"` + HTTPSOnly *bool `json:"httpsOnly,omitempty"` + HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostNamesDisabled *bool `json:"hostNamesDisabled,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + IPMode *IPMode `json:"ipMode,omitempty"` + InProgressOperationId *string `json:"inProgressOperationId,omitempty"` + IsDefaultContainer *bool `json:"isDefaultContainer,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + LastModifiedTimeUtc *string `json:"lastModifiedTimeUtc,omitempty"` + ManagedEnvironmentId *string `json:"managedEnvironmentId,omitempty"` + MaxNumberOfWorkers *int64 `json:"maxNumberOfWorkers,omitempty"` + OutboundIPAddresses *string `json:"outboundIpAddresses,omitempty"` + OutboundVnetRouting *OutboundVnetRouting `json:"outboundVnetRouting,omitempty"` + PossibleOutboundIPAddresses *string `json:"possibleOutboundIpAddresses,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + RedundancyMode *RedundancyMode `json:"redundancyMode,omitempty"` + RepositorySiteName *string `json:"repositorySiteName,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceConfig *ResourceConfig `json:"resourceConfig,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ScmSiteAlsoStopped *bool `json:"scmSiteAlsoStopped,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteConfig *SiteConfig `json:"siteConfig,omitempty"` + Sku *string `json:"sku,omitempty"` + SlotSwapStatus *SlotSwapStatus `json:"slotSwapStatus,omitempty"` + SshEnabled *bool `json:"sshEnabled,omitempty"` + State *string `json:"state,omitempty"` + StorageAccountRequired *bool `json:"storageAccountRequired,omitempty"` + SuspendedTill *string `json:"suspendedTill,omitempty"` + TargetSwapSlot *string `json:"targetSwapSlot,omitempty"` + TrafficManagerHostNames *[]string `json:"trafficManagerHostNames,omitempty"` + UsageState *UsageState `json:"usageState,omitempty"` + VirtualNetworkSubnetId *string `json:"virtualNetworkSubnetId,omitempty"` + WorkloadProfileName *string `json:"workloadProfileName,omitempty"` +} + +func (o *SiteProperties) GetLastModifiedTimeUtcAsTime() (*time.Time, error) { + if o.LastModifiedTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetLastModifiedTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTimeUtc = &formatted +} + +func (o *SiteProperties) GetSuspendedTillAsTime() (*time.Time, error) { + if o.SuspendedTill == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SuspendedTill, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetSuspendedTillAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SuspendedTill = &formatted +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_skucapacity.go b/resource-manager/web/2024-11-01/appserviceplans/model_skucapacity.go new file mode 100644 index 00000000000..7bbedd7e00e --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_skucapacity.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuCapacity struct { + Default *int64 `json:"default,omitempty"` + ElasticMaximum *int64 `json:"elasticMaximum,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` + Minimum *int64 `json:"minimum,omitempty"` + ScaleType *string `json:"scaleType,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_skudescription.go b/resource-manager/web/2024-11-01/appserviceplans/model_skudescription.go new file mode 100644 index 00000000000..290adb2a1ad --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_skudescription.go @@ -0,0 +1,15 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuDescription struct { + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Locations *[]string `json:"locations,omitempty"` + Name *string `json:"name,omitempty"` + Size *string `json:"size,omitempty"` + SkuCapacity *SkuCapacity `json:"skuCapacity,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_slotswapstatus.go b/resource-manager/web/2024-11-01/appserviceplans/model_slotswapstatus.go new file mode 100644 index 00000000000..707d5e1848f --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_slotswapstatus.go @@ -0,0 +1,28 @@ +package appserviceplans + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlotSwapStatus struct { + DestinationSlotName *string `json:"destinationSlotName,omitempty"` + SourceSlotName *string `json:"sourceSlotName,omitempty"` + TimestampUtc *string `json:"timestampUtc,omitempty"` +} + +func (o *SlotSwapStatus) GetTimestampUtcAsTime() (*time.Time, error) { + if o.TimestampUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimestampUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SlotSwapStatus) SetTimestampUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimestampUtc = &formatted +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_slowrequestsbasedtrigger.go b/resource-manager/web/2024-11-01/appserviceplans/model_slowrequestsbasedtrigger.go new file mode 100644 index 00000000000..d3f5bc55adb --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_slowrequestsbasedtrigger.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlowRequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + TimeTaken *string `json:"timeTaken,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_statuscodesbasedtrigger.go b/resource-manager/web/2024-11-01/appserviceplans/model_statuscodesbasedtrigger.go new file mode 100644 index 00000000000..9e615c4b53c --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_statuscodesbasedtrigger.go @@ -0,0 +1,13 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + Status *int64 `json:"status,omitempty"` + SubStatus *int64 `json:"subStatus,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + Win32Status *int64 `json:"win32Status,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_statuscodesrangebasedtrigger.go b/resource-manager/web/2024-11-01/appserviceplans/model_statuscodesrangebasedtrigger.go new file mode 100644 index 00000000000..b99ecfaebd7 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_statuscodesrangebasedtrigger.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesRangeBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + StatusCodes *string `json:"statusCodes,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_virtualapplication.go b/resource-manager/web/2024-11-01/appserviceplans/model_virtualapplication.go new file mode 100644 index 00000000000..dc79bed2982 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_virtualapplication.go @@ -0,0 +1,11 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplication struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + PreloadEnabled *bool `json:"preloadEnabled,omitempty"` + VirtualDirectories *[]VirtualDirectory `json:"virtualDirectories,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_virtualdirectory.go b/resource-manager/web/2024-11-01/appserviceplans/model_virtualdirectory.go new file mode 100644 index 00000000000..35b134e5664 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_virtualdirectory.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualDirectory struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_vnetgateway.go b/resource-manager/web/2024-11-01/appserviceplans/model_vnetgateway.go new file mode 100644 index 00000000000..f7474dfa9e0 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_vnetgateway.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetGateway struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetGatewayProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_vnetgatewayproperties.go b/resource-manager/web/2024-11-01/appserviceplans/model_vnetgatewayproperties.go new file mode 100644 index 00000000000..407a93e7f24 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_vnetgatewayproperties.go @@ -0,0 +1,9 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetGatewayProperties struct { + VnetName *string `json:"vnetName,omitempty"` + VpnPackageUri string `json:"vpnPackageUri"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_vnetinfo.go b/resource-manager/web/2024-11-01/appserviceplans/model_vnetinfo.go new file mode 100644 index 00000000000..fe7cf2d0253 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_vnetinfo.go @@ -0,0 +1,14 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetInfo struct { + CertBlob *string `json:"certBlob,omitempty"` + CertThumbprint *string `json:"certThumbprint,omitempty"` + DnsServers *string `json:"dnsServers,omitempty"` + IsSwift *bool `json:"isSwift,omitempty"` + ResyncRequired *bool `json:"resyncRequired,omitempty"` + Routes *[]VnetRoute `json:"routes,omitempty"` + VnetResourceId *string `json:"vnetResourceId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_vnetinforesource.go b/resource-manager/web/2024-11-01/appserviceplans/model_vnetinforesource.go new file mode 100644 index 00000000000..2a5fcabaeaa --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_vnetinforesource.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetInfoResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetInfo `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_vnetroute.go b/resource-manager/web/2024-11-01/appserviceplans/model_vnetroute.go new file mode 100644 index 00000000000..ea4f24d9d78 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_vnetroute.go @@ -0,0 +1,12 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRoute struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetRouteProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/model_vnetrouteproperties.go b/resource-manager/web/2024-11-01/appserviceplans/model_vnetrouteproperties.go new file mode 100644 index 00000000000..ccedc00af71 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/model_vnetrouteproperties.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRouteProperties struct { + EndAddress *string `json:"endAddress,omitempty"` + RouteType *RouteType `json:"routeType,omitempty"` + StartAddress *string `json:"startAddress,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/predicates.go b/resource-manager/web/2024-11-01/appserviceplans/predicates.go new file mode 100644 index 00000000000..31b4416ccb0 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/predicates.go @@ -0,0 +1,126 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServicePlanOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p AppServicePlanOperationPredicate) Matches(input AppServicePlan) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type CsmUsageQuotaOperationPredicate struct { + CurrentValue *int64 + Limit *int64 + NextResetTime *string + Unit *string +} + +func (p CsmUsageQuotaOperationPredicate) Matches(input CsmUsageQuota) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.NextResetTime != nil && (input.NextResetTime == nil || *p.NextResetTime != *input.NextResetTime) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} + +type HybridConnectionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p HybridConnectionOperationPredicate) Matches(input HybridConnection) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SiteOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p SiteOperationPredicate) Matches(input Site) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/appserviceplans/version.go b/resource-manager/web/2024-11-01/appserviceplans/version.go new file mode 100644 index 00000000000..ab07267a044 --- /dev/null +++ b/resource-manager/web/2024-11-01/appserviceplans/version.go @@ -0,0 +1,10 @@ +package appserviceplans + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/appserviceplans/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/README.md b/resource-manager/web/2024-11-01/certificateordersdiagnostics/README.md new file mode 100644 index 00000000000..8b45736db98 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/certificateordersdiagnostics` Documentation + +The `certificateordersdiagnostics` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/certificateordersdiagnostics" +``` + + +### Client Initialization + +```go +client := certificateordersdiagnostics.NewCertificateOrdersDiagnosticsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CertificateOrdersDiagnosticsClient.GetAppServiceCertificateOrderDetectorResponse` + +```go +ctx := context.TODO() +id := certificateordersdiagnostics.NewCertificateOrderDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "detectorName") + +read, err := client.GetAppServiceCertificateOrderDetectorResponse(ctx, id, certificateordersdiagnostics.DefaultGetAppServiceCertificateOrderDetectorResponseOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificateOrdersDiagnosticsClient.ListAppServiceCertificateOrderDetectorResponse` + +```go +ctx := context.TODO() +id := certificateordersdiagnostics.NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + +// alternatively `client.ListAppServiceCertificateOrderDetectorResponse(ctx, id)` can be used to do batched pagination +items, err := client.ListAppServiceCertificateOrderDetectorResponseComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/client.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/client.go new file mode 100644 index 00000000000..710732b4d7f --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/client.go @@ -0,0 +1,26 @@ +package certificateordersdiagnostics + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOrdersDiagnosticsClient struct { + Client *resourcemanager.Client +} + +func NewCertificateOrdersDiagnosticsClientWithBaseURI(sdkApi sdkEnv.Api) (*CertificateOrdersDiagnosticsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "certificateordersdiagnostics", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CertificateOrdersDiagnosticsClient: %+v", err) + } + + return &CertificateOrdersDiagnosticsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/constants.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/constants.go new file mode 100644 index 00000000000..5a46c7d7aeb --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/constants.go @@ -0,0 +1,214 @@ +package certificateordersdiagnostics + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorType string + +const ( + DetectorTypeAnalysis DetectorType = "Analysis" + DetectorTypeCategoryOverview DetectorType = "CategoryOverview" + DetectorTypeDetector DetectorType = "Detector" +) + +func PossibleValuesForDetectorType() []string { + return []string{ + string(DetectorTypeAnalysis), + string(DetectorTypeCategoryOverview), + string(DetectorTypeDetector), + } +} + +func (s *DetectorType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDetectorType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDetectorType(input string) (*DetectorType, error) { + vals := map[string]DetectorType{ + "analysis": DetectorTypeAnalysis, + "categoryoverview": DetectorTypeCategoryOverview, + "detector": DetectorTypeDetector, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DetectorType(input) + return &out, nil +} + +type InsightStatus string + +const ( + InsightStatusCritical InsightStatus = "Critical" + InsightStatusInfo InsightStatus = "Info" + InsightStatusNone InsightStatus = "None" + InsightStatusSuccess InsightStatus = "Success" + InsightStatusWarning InsightStatus = "Warning" +) + +func PossibleValuesForInsightStatus() []string { + return []string{ + string(InsightStatusCritical), + string(InsightStatusInfo), + string(InsightStatusNone), + string(InsightStatusSuccess), + string(InsightStatusWarning), + } +} + +func (s *InsightStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInsightStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInsightStatus(input string) (*InsightStatus, error) { + vals := map[string]InsightStatus{ + "critical": InsightStatusCritical, + "info": InsightStatusInfo, + "none": InsightStatusNone, + "success": InsightStatusSuccess, + "warning": InsightStatusWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InsightStatus(input) + return &out, nil +} + +type RenderingType string + +const ( + RenderingTypeAppInsight RenderingType = "AppInsight" + RenderingTypeAppInsightEnablement RenderingType = "AppInsightEnablement" + RenderingTypeCard RenderingType = "Card" + RenderingTypeChangeAnalysisOnboarding RenderingType = "ChangeAnalysisOnboarding" + RenderingTypeChangeSets RenderingType = "ChangeSets" + RenderingTypeChangesView RenderingType = "ChangesView" + RenderingTypeDataSummary RenderingType = "DataSummary" + RenderingTypeDependencyGraph RenderingType = "DependencyGraph" + RenderingTypeDetector RenderingType = "Detector" + RenderingTypeDownTime RenderingType = "DownTime" + RenderingTypeDropDown RenderingType = "DropDown" + RenderingTypeDynamicInsight RenderingType = "DynamicInsight" + RenderingTypeEmail RenderingType = "Email" + RenderingTypeForm RenderingType = "Form" + RenderingTypeGuage RenderingType = "Guage" + RenderingTypeInsights RenderingType = "Insights" + RenderingTypeMarkdown RenderingType = "Markdown" + RenderingTypeNoGraph RenderingType = "NoGraph" + RenderingTypePieChart RenderingType = "PieChart" + RenderingTypeSearchComponent RenderingType = "SearchComponent" + RenderingTypeSolution RenderingType = "Solution" + RenderingTypeSummaryCard RenderingType = "SummaryCard" + RenderingTypeTable RenderingType = "Table" + RenderingTypeTimeSeries RenderingType = "TimeSeries" + RenderingTypeTimeSeriesPerInstance RenderingType = "TimeSeriesPerInstance" +) + +func PossibleValuesForRenderingType() []string { + return []string{ + string(RenderingTypeAppInsight), + string(RenderingTypeAppInsightEnablement), + string(RenderingTypeCard), + string(RenderingTypeChangeAnalysisOnboarding), + string(RenderingTypeChangeSets), + string(RenderingTypeChangesView), + string(RenderingTypeDataSummary), + string(RenderingTypeDependencyGraph), + string(RenderingTypeDetector), + string(RenderingTypeDownTime), + string(RenderingTypeDropDown), + string(RenderingTypeDynamicInsight), + string(RenderingTypeEmail), + string(RenderingTypeForm), + string(RenderingTypeGuage), + string(RenderingTypeInsights), + string(RenderingTypeMarkdown), + string(RenderingTypeNoGraph), + string(RenderingTypePieChart), + string(RenderingTypeSearchComponent), + string(RenderingTypeSolution), + string(RenderingTypeSummaryCard), + string(RenderingTypeTable), + string(RenderingTypeTimeSeries), + string(RenderingTypeTimeSeriesPerInstance), + } +} + +func (s *RenderingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRenderingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRenderingType(input string) (*RenderingType, error) { + vals := map[string]RenderingType{ + "appinsight": RenderingTypeAppInsight, + "appinsightenablement": RenderingTypeAppInsightEnablement, + "card": RenderingTypeCard, + "changeanalysisonboarding": RenderingTypeChangeAnalysisOnboarding, + "changesets": RenderingTypeChangeSets, + "changesview": RenderingTypeChangesView, + "datasummary": RenderingTypeDataSummary, + "dependencygraph": RenderingTypeDependencyGraph, + "detector": RenderingTypeDetector, + "downtime": RenderingTypeDownTime, + "dropdown": RenderingTypeDropDown, + "dynamicinsight": RenderingTypeDynamicInsight, + "email": RenderingTypeEmail, + "form": RenderingTypeForm, + "guage": RenderingTypeGuage, + "insights": RenderingTypeInsights, + "markdown": RenderingTypeMarkdown, + "nograph": RenderingTypeNoGraph, + "piechart": RenderingTypePieChart, + "searchcomponent": RenderingTypeSearchComponent, + "solution": RenderingTypeSolution, + "summarycard": RenderingTypeSummaryCard, + "table": RenderingTypeTable, + "timeseries": RenderingTypeTimeSeries, + "timeseriesperinstance": RenderingTypeTimeSeriesPerInstance, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RenderingType(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/id_certificateorder.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/id_certificateorder.go new file mode 100644 index 00000000000..d1a94d4718a --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/id_certificateorder.go @@ -0,0 +1,130 @@ +package certificateordersdiagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CertificateOrderId{}) +} + +var _ resourceids.ResourceId = &CertificateOrderId{} + +// CertificateOrderId is a struct representing the Resource ID for a Certificate Order +type CertificateOrderId struct { + SubscriptionId string + ResourceGroupName string + CertificateOrderName string +} + +// NewCertificateOrderID returns a new CertificateOrderId struct +func NewCertificateOrderID(subscriptionId string, resourceGroupName string, certificateOrderName string) CertificateOrderId { + return CertificateOrderId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateOrderName: certificateOrderName, + } +} + +// ParseCertificateOrderID parses 'input' into a CertificateOrderId +func ParseCertificateOrderID(input string) (*CertificateOrderId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateOrderIDInsensitively parses 'input' case-insensitively into a CertificateOrderId +// note: this method should only be used for API response data and not user input +func ParseCertificateOrderIDInsensitively(input string) (*CertificateOrderId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateOrderId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CertificateOrderName, ok = input.Parsed["certificateOrderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateOrderName", input) + } + + return nil +} + +// ValidateCertificateOrderID checks that 'input' can be parsed as a Certificate Order ID +func ValidateCertificateOrderID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCertificateOrderID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate Order ID +func (id CertificateOrderId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate Order ID +func (id CertificateOrderId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCertificateRegistration", "Microsoft.CertificateRegistration", "Microsoft.CertificateRegistration"), + resourceids.StaticSegment("staticCertificateOrders", "certificateOrders", "certificateOrders"), + resourceids.UserSpecifiedSegment("certificateOrderName", "certificateOrderName"), + } +} + +// String returns a human-readable description of this Certificate Order ID +func (id CertificateOrderId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Order Name: %q", id.CertificateOrderName), + } + return fmt.Sprintf("Certificate Order (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/id_certificateorder_test.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/id_certificateorder_test.go new file mode 100644 index 00000000000..4b64845dc8b --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/id_certificateorder_test.go @@ -0,0 +1,282 @@ +package certificateordersdiagnostics + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CertificateOrderId{} + +func TestNewCertificateOrderID(t *testing.T) { + id := NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CertificateOrderName != "certificateOrderName" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateOrderName'", id.CertificateOrderName, "certificateOrderName") + } +} + +func TestFormatCertificateOrderID(t *testing.T) { + actual := NewCertificateOrderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateOrderID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + } +} + +func TestParseCertificateOrderIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE", + Expected: &CertificateOrderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CertificateOrderName: "cErTiFiCaTeOrDeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + } +} + +func TestSegmentsForCertificateOrderId(t *testing.T) { + segments := CertificateOrderId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateOrderId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/id_certificateorderdetector.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/id_certificateorderdetector.go new file mode 100644 index 00000000000..cbb8826cb13 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/id_certificateorderdetector.go @@ -0,0 +1,139 @@ +package certificateordersdiagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CertificateOrderDetectorId{}) +} + +var _ resourceids.ResourceId = &CertificateOrderDetectorId{} + +// CertificateOrderDetectorId is a struct representing the Resource ID for a Certificate Order Detector +type CertificateOrderDetectorId struct { + SubscriptionId string + ResourceGroupName string + CertificateOrderName string + DetectorName string +} + +// NewCertificateOrderDetectorID returns a new CertificateOrderDetectorId struct +func NewCertificateOrderDetectorID(subscriptionId string, resourceGroupName string, certificateOrderName string, detectorName string) CertificateOrderDetectorId { + return CertificateOrderDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateOrderName: certificateOrderName, + DetectorName: detectorName, + } +} + +// ParseCertificateOrderDetectorID parses 'input' into a CertificateOrderDetectorId +func ParseCertificateOrderDetectorID(input string) (*CertificateOrderDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateOrderDetectorIDInsensitively parses 'input' case-insensitively into a CertificateOrderDetectorId +// note: this method should only be used for API response data and not user input +func ParseCertificateOrderDetectorIDInsensitively(input string) (*CertificateOrderDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateOrderDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateOrderDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateOrderDetectorId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CertificateOrderName, ok = input.Parsed["certificateOrderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateOrderName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateCertificateOrderDetectorID checks that 'input' can be parsed as a Certificate Order Detector ID +func ValidateCertificateOrderDetectorID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCertificateOrderDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate Order Detector ID +func (id CertificateOrderDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CertificateRegistration/certificateOrders/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateOrderName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate Order Detector ID +func (id CertificateOrderDetectorId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCertificateRegistration", "Microsoft.CertificateRegistration", "Microsoft.CertificateRegistration"), + resourceids.StaticSegment("staticCertificateOrders", "certificateOrders", "certificateOrders"), + resourceids.UserSpecifiedSegment("certificateOrderName", "certificateOrderName"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorName"), + } +} + +// String returns a human-readable description of this Certificate Order Detector ID +func (id CertificateOrderDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Order Name: %q", id.CertificateOrderName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Certificate Order Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/id_certificateorderdetector_test.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/id_certificateorderdetector_test.go new file mode 100644 index 00000000000..b24ca655c01 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/id_certificateorderdetector_test.go @@ -0,0 +1,327 @@ +package certificateordersdiagnostics + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CertificateOrderDetectorId{} + +func TestNewCertificateOrderDetectorID(t *testing.T) { + id := NewCertificateOrderDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "detectorName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CertificateOrderName != "certificateOrderName" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateOrderName'", id.CertificateOrderName, "certificateOrderName") + } + + if id.DetectorName != "detectorName" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorName") + } +} + +func TestFormatCertificateOrderDetectorID(t *testing.T) { + actual := NewCertificateOrderDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateOrderName", "detectorName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/detectors/detectorName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateOrderDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderDetectorId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/detectors/detectorName", + Expected: &CertificateOrderDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/detectors/detectorName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseCertificateOrderDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateOrderDetectorId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/detectors/detectorName", + Expected: &CertificateOrderDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateOrderName: "certificateOrderName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.CertificateRegistration/certificateOrders/certificateOrderName/detectors/detectorName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE/dEtEcToRs/dEtEcToRnAmE", + Expected: &CertificateOrderDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CertificateOrderName: "cErTiFiCaTeOrDeRnAmE", + DetectorName: "dEtEcToRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cErTiFiCaTeReGiStRaTiOn/cErTiFiCaTeOrDeRs/cErTiFiCaTeOrDeRnAmE/dEtEcToRs/dEtEcToRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateOrderDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateOrderName != v.Expected.CertificateOrderName { + t.Fatalf("Expected %q but got %q for CertificateOrderName", v.Expected.CertificateOrderName, actual.CertificateOrderName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForCertificateOrderDetectorId(t *testing.T) { + segments := CertificateOrderDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateOrderDetectorId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/method_getappservicecertificateorderdetectorresponse.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/method_getappservicecertificateorderdetectorresponse.go new file mode 100644 index 00000000000..c23cb352353 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/method_getappservicecertificateorderdetectorresponse.go @@ -0,0 +1,91 @@ +package certificateordersdiagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAppServiceCertificateOrderDetectorResponseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorResponse +} + +type GetAppServiceCertificateOrderDetectorResponseOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultGetAppServiceCertificateOrderDetectorResponseOperationOptions() GetAppServiceCertificateOrderDetectorResponseOperationOptions { + return GetAppServiceCertificateOrderDetectorResponseOperationOptions{} +} + +func (o GetAppServiceCertificateOrderDetectorResponseOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetAppServiceCertificateOrderDetectorResponseOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetAppServiceCertificateOrderDetectorResponseOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// GetAppServiceCertificateOrderDetectorResponse ... +func (c CertificateOrdersDiagnosticsClient) GetAppServiceCertificateOrderDetectorResponse(ctx context.Context, id CertificateOrderDetectorId, options GetAppServiceCertificateOrderDetectorResponseOperationOptions) (result GetAppServiceCertificateOrderDetectorResponseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DetectorResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/method_listappservicecertificateorderdetectorresponse.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/method_listappservicecertificateorderdetectorresponse.go new file mode 100644 index 00000000000..405663304fc --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/method_listappservicecertificateorderdetectorresponse.go @@ -0,0 +1,105 @@ +package certificateordersdiagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAppServiceCertificateOrderDetectorResponseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorResponse +} + +type ListAppServiceCertificateOrderDetectorResponseCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorResponse +} + +type ListAppServiceCertificateOrderDetectorResponseCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAppServiceCertificateOrderDetectorResponseCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAppServiceCertificateOrderDetectorResponse ... +func (c CertificateOrdersDiagnosticsClient) ListAppServiceCertificateOrderDetectorResponse(ctx context.Context, id CertificateOrderId) (result ListAppServiceCertificateOrderDetectorResponseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAppServiceCertificateOrderDetectorResponseCustomPager{}, + Path: fmt.Sprintf("%s/detectors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DetectorResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAppServiceCertificateOrderDetectorResponseComplete retrieves all the results into a single object +func (c CertificateOrdersDiagnosticsClient) ListAppServiceCertificateOrderDetectorResponseComplete(ctx context.Context, id CertificateOrderId) (ListAppServiceCertificateOrderDetectorResponseCompleteResult, error) { + return c.ListAppServiceCertificateOrderDetectorResponseCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) +} + +// ListAppServiceCertificateOrderDetectorResponseCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificateOrdersDiagnosticsClient) ListAppServiceCertificateOrderDetectorResponseCompleteMatchingPredicate(ctx context.Context, id CertificateOrderId, predicate DetectorResponseOperationPredicate) (result ListAppServiceCertificateOrderDetectorResponseCompleteResult, err error) { + items := make([]DetectorResponse, 0) + + resp, err := c.ListAppServiceCertificateOrderDetectorResponse(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAppServiceCertificateOrderDetectorResponseCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_dataprovidermetadata.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_dataprovidermetadata.go new file mode 100644 index 00000000000..3ca232e10ea --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_dataprovidermetadata.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataProviderMetadata struct { + PropertyBag *[]KeyValuePairStringObject `json:"propertyBag,omitempty"` + ProviderName *string `json:"providerName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_datatableresponsecolumn.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_datatableresponsecolumn.go new file mode 100644 index 00000000000..94b13b9f1d3 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_datatableresponsecolumn.go @@ -0,0 +1,10 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataTableResponseColumn struct { + ColumnName *string `json:"columnName,omitempty"` + ColumnType *string `json:"columnType,omitempty"` + DataType *string `json:"dataType,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_datatableresponseobject.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_datatableresponseobject.go new file mode 100644 index 00000000000..0736e54ba5f --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_datatableresponseobject.go @@ -0,0 +1,10 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataTableResponseObject struct { + Columns *[]DataTableResponseColumn `json:"columns,omitempty"` + Rows *[][]string `json:"rows,omitempty"` + TableName *string `json:"tableName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_detectorinfo.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_detectorinfo.go new file mode 100644 index 00000000000..792b0133a14 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_detectorinfo.go @@ -0,0 +1,16 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorInfo struct { + AnalysisType *[]string `json:"analysisType,omitempty"` + Author *string `json:"author,omitempty"` + Category *string `json:"category,omitempty"` + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Score *float64 `json:"score,omitempty"` + SupportTopicList *[]SupportTopic `json:"supportTopicList,omitempty"` + Type *DetectorType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_detectorresponse.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_detectorresponse.go new file mode 100644 index 00000000000..8947d24dc8b --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_detectorresponse.go @@ -0,0 +1,12 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorResponse struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DetectorResponseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_detectorresponseproperties.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_detectorresponseproperties.go new file mode 100644 index 00000000000..409f708d65f --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_detectorresponseproperties.go @@ -0,0 +1,12 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorResponseProperties struct { + DataProvidersMetadata *[]DataProviderMetadata `json:"dataProvidersMetadata,omitempty"` + Dataset *[]DiagnosticData `json:"dataset,omitempty"` + Metadata *DetectorInfo `json:"metadata,omitempty"` + Status *Status `json:"status,omitempty"` + SuggestedUtterances *QueryUtterancesResults `json:"suggestedUtterances,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_diagnosticdata.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_diagnosticdata.go new file mode 100644 index 00000000000..23d24043011 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_diagnosticdata.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticData struct { + RenderingProperties *Rendering `json:"renderingProperties,omitempty"` + Table *DataTableResponseObject `json:"table,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_keyvaluepairstringobject.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_keyvaluepairstringobject.go new file mode 100644 index 00000000000..ebad30fedc1 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_keyvaluepairstringobject.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyValuePairStringObject struct { + Key *string `json:"key,omitempty"` + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_queryutterancesresult.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_queryutterancesresult.go new file mode 100644 index 00000000000..6c29753e795 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_queryutterancesresult.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryUtterancesResult struct { + SampleUtterance *SampleUtterance `json:"sampleUtterance,omitempty"` + Score *float64 `json:"score,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_queryutterancesresults.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_queryutterancesresults.go new file mode 100644 index 00000000000..c2120a0ebfd --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_queryutterancesresults.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryUtterancesResults struct { + Query *string `json:"query,omitempty"` + Results *[]QueryUtterancesResult `json:"results,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_rendering.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_rendering.go new file mode 100644 index 00000000000..c488d4de11e --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_rendering.go @@ -0,0 +1,10 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Rendering struct { + Description *string `json:"description,omitempty"` + Title *string `json:"title,omitempty"` + Type *RenderingType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_sampleutterance.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_sampleutterance.go new file mode 100644 index 00000000000..648bd768413 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_sampleutterance.go @@ -0,0 +1,10 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SampleUtterance struct { + Links *[]string `json:"links,omitempty"` + Qid *string `json:"qid,omitempty"` + Text *string `json:"text,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_status.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_status.go new file mode 100644 index 00000000000..87558b9b81c --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_status.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Status struct { + Message *string `json:"message,omitempty"` + StatusId *InsightStatus `json:"statusId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_supporttopic.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_supporttopic.go new file mode 100644 index 00000000000..cb170a8c08b --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/model_supporttopic.go @@ -0,0 +1,9 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportTopic struct { + Id *string `json:"id,omitempty"` + PesId *string `json:"pesId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/predicates.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/predicates.go new file mode 100644 index 00000000000..149b9af0e1c --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/predicates.go @@ -0,0 +1,32 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorResponseOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DetectorResponseOperationPredicate) Matches(input DetectorResponse) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/certificateordersdiagnostics/version.go b/resource-manager/web/2024-11-01/certificateordersdiagnostics/version.go new file mode 100644 index 00000000000..e7a794d1e47 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificateordersdiagnostics/version.go @@ -0,0 +1,10 @@ +package certificateordersdiagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/certificateordersdiagnostics/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/certificates/README.md b/resource-manager/web/2024-11-01/certificates/README.md new file mode 100644 index 00000000000..fa62048a715 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/README.md @@ -0,0 +1,129 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/certificates` Documentation + +The `certificates` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/certificates" +``` + + +### Client Initialization + +```go +client := certificates.NewCertificatesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CertificatesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateName") + +payload := certificates.Certificate{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificatesClient.Delete` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificatesClient.Get` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CertificatesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, certificates.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, certificates.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CertificatesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CertificatesClient.Update` + +```go +ctx := context.TODO() +id := certificates.NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateName") + +payload := certificates.CertificatePatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-11-01/certificates/client.go b/resource-manager/web/2024-11-01/certificates/client.go new file mode 100644 index 00000000000..f045f1b9265 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/client.go @@ -0,0 +1,26 @@ +package certificates + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificatesClient struct { + Client *resourcemanager.Client +} + +func NewCertificatesClientWithBaseURI(sdkApi sdkEnv.Api) (*CertificatesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "certificates", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CertificatesClient: %+v", err) + } + + return &CertificatesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/certificates/constants.go b/resource-manager/web/2024-11-01/certificates/constants.go new file mode 100644 index 00000000000..afe3445c7e6 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/constants.go @@ -0,0 +1,78 @@ +package certificates + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultSecretStatus string + +const ( + KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault KeyVaultSecretStatus = "AzureServiceUnauthorizedToAccessKeyVault" + KeyVaultSecretStatusCertificateOrderFailed KeyVaultSecretStatus = "CertificateOrderFailed" + KeyVaultSecretStatusExternalPrivateKey KeyVaultSecretStatus = "ExternalPrivateKey" + KeyVaultSecretStatusInitialized KeyVaultSecretStatus = "Initialized" + KeyVaultSecretStatusKeyVaultDoesNotExist KeyVaultSecretStatus = "KeyVaultDoesNotExist" + KeyVaultSecretStatusKeyVaultSecretDoesNotExist KeyVaultSecretStatus = "KeyVaultSecretDoesNotExist" + KeyVaultSecretStatusOperationNotPermittedOnKeyVault KeyVaultSecretStatus = "OperationNotPermittedOnKeyVault" + KeyVaultSecretStatusSucceeded KeyVaultSecretStatus = "Succeeded" + KeyVaultSecretStatusUnknown KeyVaultSecretStatus = "Unknown" + KeyVaultSecretStatusUnknownError KeyVaultSecretStatus = "UnknownError" + KeyVaultSecretStatusWaitingOnCertificateOrder KeyVaultSecretStatus = "WaitingOnCertificateOrder" +) + +func PossibleValuesForKeyVaultSecretStatus() []string { + return []string{ + string(KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault), + string(KeyVaultSecretStatusCertificateOrderFailed), + string(KeyVaultSecretStatusExternalPrivateKey), + string(KeyVaultSecretStatusInitialized), + string(KeyVaultSecretStatusKeyVaultDoesNotExist), + string(KeyVaultSecretStatusKeyVaultSecretDoesNotExist), + string(KeyVaultSecretStatusOperationNotPermittedOnKeyVault), + string(KeyVaultSecretStatusSucceeded), + string(KeyVaultSecretStatusUnknown), + string(KeyVaultSecretStatusUnknownError), + string(KeyVaultSecretStatusWaitingOnCertificateOrder), + } +} + +func (s *KeyVaultSecretStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyVaultSecretStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyVaultSecretStatus(input string) (*KeyVaultSecretStatus, error) { + vals := map[string]KeyVaultSecretStatus{ + "azureserviceunauthorizedtoaccesskeyvault": KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault, + "certificateorderfailed": KeyVaultSecretStatusCertificateOrderFailed, + "externalprivatekey": KeyVaultSecretStatusExternalPrivateKey, + "initialized": KeyVaultSecretStatusInitialized, + "keyvaultdoesnotexist": KeyVaultSecretStatusKeyVaultDoesNotExist, + "keyvaultsecretdoesnotexist": KeyVaultSecretStatusKeyVaultSecretDoesNotExist, + "operationnotpermittedonkeyvault": KeyVaultSecretStatusOperationNotPermittedOnKeyVault, + "succeeded": KeyVaultSecretStatusSucceeded, + "unknown": KeyVaultSecretStatusUnknown, + "unknownerror": KeyVaultSecretStatusUnknownError, + "waitingoncertificateorder": KeyVaultSecretStatusWaitingOnCertificateOrder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyVaultSecretStatus(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/certificates/id_certificate.go b/resource-manager/web/2024-11-01/certificates/id_certificate.go new file mode 100644 index 00000000000..3ef853c576d --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/id_certificate.go @@ -0,0 +1,130 @@ +package certificates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CertificateId{}) +} + +var _ resourceids.ResourceId = &CertificateId{} + +// CertificateId is a struct representing the Resource ID for a Certificate +type CertificateId struct { + SubscriptionId string + ResourceGroupName string + CertificateName string +} + +// NewCertificateID returns a new CertificateId struct +func NewCertificateID(subscriptionId string, resourceGroupName string, certificateName string) CertificateId { + return CertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + CertificateName: certificateName, + } +} + +// ParseCertificateID parses 'input' into a CertificateId +func ParseCertificateID(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCertificateIDInsensitively parses 'input' case-insensitively into a CertificateId +// note: this method should only be used for API response data and not user input +func ParseCertificateIDInsensitively(input string) (*CertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&CertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CertificateId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.CertificateName, ok = input.Parsed["certificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateName", input) + } + + return nil +} + +// ValidateCertificateID checks that 'input' can be parsed as a Certificate ID +func ValidateCertificateID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Certificate ID +func (id CertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.CertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Certificate ID +func (id CertificateId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticCertificates", "certificates", "certificates"), + resourceids.UserSpecifiedSegment("certificateName", "certificateName"), + } +} + +// String returns a human-readable description of this Certificate ID +func (id CertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/certificates/id_certificate_test.go b/resource-manager/web/2024-11-01/certificates/id_certificate_test.go new file mode 100644 index 00000000000..b4d6ef8d3b8 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/id_certificate_test.go @@ -0,0 +1,282 @@ +package certificates + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CertificateId{} + +func TestNewCertificateID(t *testing.T) { + id := NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.CertificateName != "certificateName" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateName'", id.CertificateName, "certificateName") + } +} + +func TestFormatCertificateID(t *testing.T) { + actual := NewCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "certificateName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates/certificateName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates/certificateName", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateName: "certificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates/certificateName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestParseCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates/certificateName", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + CertificateName: "certificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/certificates/certificateName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cErTiFiCaTeS/cErTiFiCaTeNaMe", + Expected: &CertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + CertificateName: "cErTiFiCaTeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/cErTiFiCaTeS/cErTiFiCaTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestSegmentsForCertificateId(t *testing.T) { + segments := CertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CertificateId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/certificates/method_createorupdate.go b/resource-manager/web/2024-11-01/certificates/method_createorupdate.go new file mode 100644 index 00000000000..ef3ac53ed39 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/method_createorupdate.go @@ -0,0 +1,57 @@ +package certificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// CreateOrUpdate ... +func (c CertificatesClient) CreateOrUpdate(ctx context.Context, id CertificateId, input Certificate) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/certificates/method_delete.go b/resource-manager/web/2024-11-01/certificates/method_delete.go new file mode 100644 index 00000000000..6f676ff9031 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/method_delete.go @@ -0,0 +1,47 @@ +package certificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c CertificatesClient) Delete(ctx context.Context, id CertificateId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/certificates/method_get.go b/resource-manager/web/2024-11-01/certificates/method_get.go new file mode 100644 index 00000000000..50817117dad --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/method_get.go @@ -0,0 +1,53 @@ +package certificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// Get ... +func (c CertificatesClient) Get(ctx context.Context, id CertificateId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/certificates/method_list.go b/resource-manager/web/2024-11-01/certificates/method_list.go new file mode 100644 index 00000000000..b9bba8df177 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/method_list.go @@ -0,0 +1,135 @@ +package certificates + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Certificate +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Certificate +} + +type ListOperationOptions struct { + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c CertificatesClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/certificates", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Certificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c CertificatesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, CertificateOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificatesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate CertificateOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Certificate, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/certificates/method_listbyresourcegroup.go b/resource-manager/web/2024-11-01/certificates/method_listbyresourcegroup.go new file mode 100644 index 00000000000..94e8fdd644a --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package certificates + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Certificate +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Certificate +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c CertificatesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/certificates", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Certificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c CertificatesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, CertificateOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CertificatesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate CertificateOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Certificate, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/certificates/method_update.go b/resource-manager/web/2024-11-01/certificates/method_update.go new file mode 100644 index 00000000000..e0cf13140fe --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/method_update.go @@ -0,0 +1,57 @@ +package certificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// Update ... +func (c CertificatesClient) Update(ctx context.Context, id CertificateId, input CertificatePatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/certificates/model_certificate.go b/resource-manager/web/2024-11-01/certificates/model_certificate.go new file mode 100644 index 00000000000..354c3cbb53b --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/model_certificate.go @@ -0,0 +1,14 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Certificate struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CertificateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/certificates/model_certificatepatchresource.go b/resource-manager/web/2024-11-01/certificates/model_certificatepatchresource.go new file mode 100644 index 00000000000..ad7a39f39b2 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/model_certificatepatchresource.go @@ -0,0 +1,12 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificatePatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CertificatePatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/certificates/model_certificatepatchresourceproperties.go b/resource-manager/web/2024-11-01/certificates/model_certificatepatchresourceproperties.go new file mode 100644 index 00000000000..a3aec635456 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/model_certificatepatchresourceproperties.go @@ -0,0 +1,58 @@ +package certificates + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificatePatchResourceProperties struct { + CanonicalName *string `json:"canonicalName,omitempty"` + CerBlob *string `json:"cerBlob,omitempty"` + DomainValidationMethod *string `json:"domainValidationMethod,omitempty"` + ExpirationDate *string `json:"expirationDate,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + IssueDate *string `json:"issueDate,omitempty"` + Issuer *string `json:"issuer,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultSecretName *string `json:"keyVaultSecretName,omitempty"` + KeyVaultSecretStatus *KeyVaultSecretStatus `json:"keyVaultSecretStatus,omitempty"` + Password *string `json:"password,omitempty"` + PfxBlob *string `json:"pfxBlob,omitempty"` + PublicKeyHash *string `json:"publicKeyHash,omitempty"` + SelfLink *string `json:"selfLink,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteName *string `json:"siteName,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Valid *bool `json:"valid,omitempty"` +} + +func (o *CertificatePatchResourceProperties) GetExpirationDateAsTime() (*time.Time, error) { + if o.ExpirationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificatePatchResourceProperties) SetExpirationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationDate = &formatted +} + +func (o *CertificatePatchResourceProperties) GetIssueDateAsTime() (*time.Time, error) { + if o.IssueDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.IssueDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificatePatchResourceProperties) SetIssueDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.IssueDate = &formatted +} diff --git a/resource-manager/web/2024-11-01/certificates/model_certificateproperties.go b/resource-manager/web/2024-11-01/certificates/model_certificateproperties.go new file mode 100644 index 00000000000..0d950ddcd12 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/model_certificateproperties.go @@ -0,0 +1,58 @@ +package certificates + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateProperties struct { + CanonicalName *string `json:"canonicalName,omitempty"` + CerBlob *string `json:"cerBlob,omitempty"` + DomainValidationMethod *string `json:"domainValidationMethod,omitempty"` + ExpirationDate *string `json:"expirationDate,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + IssueDate *string `json:"issueDate,omitempty"` + Issuer *string `json:"issuer,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultSecretName *string `json:"keyVaultSecretName,omitempty"` + KeyVaultSecretStatus *KeyVaultSecretStatus `json:"keyVaultSecretStatus,omitempty"` + Password *string `json:"password,omitempty"` + PfxBlob *string `json:"pfxBlob,omitempty"` + PublicKeyHash *string `json:"publicKeyHash,omitempty"` + SelfLink *string `json:"selfLink,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteName *string `json:"siteName,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Valid *bool `json:"valid,omitempty"` +} + +func (o *CertificateProperties) GetExpirationDateAsTime() (*time.Time, error) { + if o.ExpirationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetExpirationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationDate = &formatted +} + +func (o *CertificateProperties) GetIssueDateAsTime() (*time.Time, error) { + if o.IssueDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.IssueDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetIssueDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.IssueDate = &formatted +} diff --git a/resource-manager/web/2024-11-01/certificates/model_hostingenvironmentprofile.go b/resource-manager/web/2024-11-01/certificates/model_hostingenvironmentprofile.go new file mode 100644 index 00000000000..33ed6c863f8 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/model_hostingenvironmentprofile.go @@ -0,0 +1,10 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/certificates/predicates.go b/resource-manager/web/2024-11-01/certificates/predicates.go new file mode 100644 index 00000000000..6a9b6eaebc6 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/predicates.go @@ -0,0 +1,37 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p CertificateOperationPredicate) Matches(input Certificate) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/certificates/version.go b/resource-manager/web/2024-11-01/certificates/version.go new file mode 100644 index 00000000000..91f43eadbf2 --- /dev/null +++ b/resource-manager/web/2024-11-01/certificates/version.go @@ -0,0 +1,10 @@ +package certificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/certificates/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/client.go b/resource-manager/web/2024-11-01/client.go new file mode 100644 index 00000000000..74308123d87 --- /dev/null +++ b/resource-manager/web/2024-11-01/client.go @@ -0,0 +1,235 @@ +package v2024_11_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/appservicecertificateorders" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/appserviceenvironments" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/appserviceplans" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/certificateordersdiagnostics" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/certificates" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/deletedwebapps" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/diagnostics" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/domains" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/global" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/kubeenvironments" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/provider" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/recommendations" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/resourcehealthmetadata" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/resourceproviders" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/sitecertificates" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/staticsites" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/topleveldomains" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/webapps" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflowrunactions" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflowruns" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflows" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflowtriggerhistories" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflowtriggers" + "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflowversions" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AppServiceCertificateOrders *appservicecertificateorders.AppServiceCertificateOrdersClient + AppServiceEnvironments *appserviceenvironments.AppServiceEnvironmentsClient + AppServicePlans *appserviceplans.AppServicePlansClient + CertificateOrdersDiagnostics *certificateordersdiagnostics.CertificateOrdersDiagnosticsClient + Certificates *certificates.CertificatesClient + DeletedWebApps *deletedwebapps.DeletedWebAppsClient + Diagnostics *diagnostics.DiagnosticsClient + Domains *domains.DomainsClient + Global *global.GlobalClient + KubeEnvironments *kubeenvironments.KubeEnvironmentsClient + Provider *provider.ProviderClient + Recommendations *recommendations.RecommendationsClient + ResourceHealthMetadata *resourcehealthmetadata.ResourceHealthMetadataClient + ResourceProviders *resourceproviders.ResourceProvidersClient + SiteCertificates *sitecertificates.SiteCertificatesClient + StaticSites *staticsites.StaticSitesClient + TopLevelDomains *topleveldomains.TopLevelDomainsClient + WebApps *webapps.WebAppsClient + WorkflowRunActions *workflowrunactions.WorkflowRunActionsClient + WorkflowRuns *workflowruns.WorkflowRunsClient + WorkflowTriggerHistories *workflowtriggerhistories.WorkflowTriggerHistoriesClient + WorkflowTriggers *workflowtriggers.WorkflowTriggersClient + WorkflowVersions *workflowversions.WorkflowVersionsClient + Workflows *workflows.WorkflowsClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + appServiceCertificateOrdersClient, err := appservicecertificateorders.NewAppServiceCertificateOrdersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AppServiceCertificateOrders client: %+v", err) + } + configureFunc(appServiceCertificateOrdersClient.Client) + + appServiceEnvironmentsClient, err := appserviceenvironments.NewAppServiceEnvironmentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AppServiceEnvironments client: %+v", err) + } + configureFunc(appServiceEnvironmentsClient.Client) + + appServicePlansClient, err := appserviceplans.NewAppServicePlansClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AppServicePlans client: %+v", err) + } + configureFunc(appServicePlansClient.Client) + + certificateOrdersDiagnosticsClient, err := certificateordersdiagnostics.NewCertificateOrdersDiagnosticsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CertificateOrdersDiagnostics client: %+v", err) + } + configureFunc(certificateOrdersDiagnosticsClient.Client) + + certificatesClient, err := certificates.NewCertificatesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Certificates client: %+v", err) + } + configureFunc(certificatesClient.Client) + + deletedWebAppsClient, err := deletedwebapps.NewDeletedWebAppsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DeletedWebApps client: %+v", err) + } + configureFunc(deletedWebAppsClient.Client) + + diagnosticsClient, err := diagnostics.NewDiagnosticsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Diagnostics client: %+v", err) + } + configureFunc(diagnosticsClient.Client) + + domainsClient, err := domains.NewDomainsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Domains client: %+v", err) + } + configureFunc(domainsClient.Client) + + globalClient, err := global.NewGlobalClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Global client: %+v", err) + } + configureFunc(globalClient.Client) + + kubeEnvironmentsClient, err := kubeenvironments.NewKubeEnvironmentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building KubeEnvironments client: %+v", err) + } + configureFunc(kubeEnvironmentsClient.Client) + + providerClient, err := provider.NewProviderClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Provider client: %+v", err) + } + configureFunc(providerClient.Client) + + recommendationsClient, err := recommendations.NewRecommendationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Recommendations client: %+v", err) + } + configureFunc(recommendationsClient.Client) + + resourceHealthMetadataClient, err := resourcehealthmetadata.NewResourceHealthMetadataClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ResourceHealthMetadata client: %+v", err) + } + configureFunc(resourceHealthMetadataClient.Client) + + resourceProvidersClient, err := resourceproviders.NewResourceProvidersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ResourceProviders client: %+v", err) + } + configureFunc(resourceProvidersClient.Client) + + siteCertificatesClient, err := sitecertificates.NewSiteCertificatesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building SiteCertificates client: %+v", err) + } + configureFunc(siteCertificatesClient.Client) + + staticSitesClient, err := staticsites.NewStaticSitesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building StaticSites client: %+v", err) + } + configureFunc(staticSitesClient.Client) + + topLevelDomainsClient, err := topleveldomains.NewTopLevelDomainsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building TopLevelDomains client: %+v", err) + } + configureFunc(topLevelDomainsClient.Client) + + webAppsClient, err := webapps.NewWebAppsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WebApps client: %+v", err) + } + configureFunc(webAppsClient.Client) + + workflowRunActionsClient, err := workflowrunactions.NewWorkflowRunActionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WorkflowRunActions client: %+v", err) + } + configureFunc(workflowRunActionsClient.Client) + + workflowRunsClient, err := workflowruns.NewWorkflowRunsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WorkflowRuns client: %+v", err) + } + configureFunc(workflowRunsClient.Client) + + workflowTriggerHistoriesClient, err := workflowtriggerhistories.NewWorkflowTriggerHistoriesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WorkflowTriggerHistories client: %+v", err) + } + configureFunc(workflowTriggerHistoriesClient.Client) + + workflowTriggersClient, err := workflowtriggers.NewWorkflowTriggersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WorkflowTriggers client: %+v", err) + } + configureFunc(workflowTriggersClient.Client) + + workflowVersionsClient, err := workflowversions.NewWorkflowVersionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WorkflowVersions client: %+v", err) + } + configureFunc(workflowVersionsClient.Client) + + workflowsClient, err := workflows.NewWorkflowsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Workflows client: %+v", err) + } + configureFunc(workflowsClient.Client) + + return &Client{ + AppServiceCertificateOrders: appServiceCertificateOrdersClient, + AppServiceEnvironments: appServiceEnvironmentsClient, + AppServicePlans: appServicePlansClient, + CertificateOrdersDiagnostics: certificateOrdersDiagnosticsClient, + Certificates: certificatesClient, + DeletedWebApps: deletedWebAppsClient, + Diagnostics: diagnosticsClient, + Domains: domainsClient, + Global: globalClient, + KubeEnvironments: kubeEnvironmentsClient, + Provider: providerClient, + Recommendations: recommendationsClient, + ResourceHealthMetadata: resourceHealthMetadataClient, + ResourceProviders: resourceProvidersClient, + SiteCertificates: siteCertificatesClient, + StaticSites: staticSitesClient, + TopLevelDomains: topLevelDomainsClient, + WebApps: webAppsClient, + WorkflowRunActions: workflowRunActionsClient, + WorkflowRuns: workflowRunsClient, + WorkflowTriggerHistories: workflowTriggerHistoriesClient, + WorkflowTriggers: workflowTriggersClient, + WorkflowVersions: workflowVersionsClient, + Workflows: workflowsClient, + }, nil +} diff --git a/resource-manager/web/2024-11-01/deletedwebapps/README.md b/resource-manager/web/2024-11-01/deletedwebapps/README.md new file mode 100644 index 00000000000..3fbd2d0ce65 --- /dev/null +++ b/resource-manager/web/2024-11-01/deletedwebapps/README.md @@ -0,0 +1,71 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/deletedwebapps` Documentation + +The `deletedwebapps` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/deletedwebapps" +``` + + +### Client Initialization + +```go +client := deletedwebapps.NewDeletedWebAppsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DeletedWebAppsClient.GetDeletedWebAppByLocation` + +```go +ctx := context.TODO() +id := deletedwebapps.NewLocationDeletedSiteID("12345678-1234-9876-4563-123456789012", "locationName", "deletedSiteId") + +read, err := client.GetDeletedWebAppByLocation(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DeletedWebAppsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DeletedWebAppsClient.ListByLocation` + +```go +ctx := context.TODO() +id := deletedwebapps.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.ListByLocation(ctx, id)` can be used to do batched pagination +items, err := client.ListByLocationComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-11-01/deletedwebapps/client.go b/resource-manager/web/2024-11-01/deletedwebapps/client.go new file mode 100644 index 00000000000..75d69e08194 --- /dev/null +++ b/resource-manager/web/2024-11-01/deletedwebapps/client.go @@ -0,0 +1,26 @@ +package deletedwebapps + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedWebAppsClient struct { + Client *resourcemanager.Client +} + +func NewDeletedWebAppsClientWithBaseURI(sdkApi sdkEnv.Api) (*DeletedWebAppsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "deletedwebapps", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DeletedWebAppsClient: %+v", err) + } + + return &DeletedWebAppsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/deletedwebapps/id_locationdeletedsite.go b/resource-manager/web/2024-11-01/deletedwebapps/id_locationdeletedsite.go new file mode 100644 index 00000000000..28780740879 --- /dev/null +++ b/resource-manager/web/2024-11-01/deletedwebapps/id_locationdeletedsite.go @@ -0,0 +1,130 @@ +package deletedwebapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationDeletedSiteId{}) +} + +var _ resourceids.ResourceId = &LocationDeletedSiteId{} + +// LocationDeletedSiteId is a struct representing the Resource ID for a Location Deleted Site +type LocationDeletedSiteId struct { + SubscriptionId string + LocationName string + DeletedSiteId string +} + +// NewLocationDeletedSiteID returns a new LocationDeletedSiteId struct +func NewLocationDeletedSiteID(subscriptionId string, locationName string, deletedSiteId string) LocationDeletedSiteId { + return LocationDeletedSiteId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + DeletedSiteId: deletedSiteId, + } +} + +// ParseLocationDeletedSiteID parses 'input' into a LocationDeletedSiteId +func ParseLocationDeletedSiteID(input string) (*LocationDeletedSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationDeletedSiteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationDeletedSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationDeletedSiteIDInsensitively parses 'input' case-insensitively into a LocationDeletedSiteId +// note: this method should only be used for API response data and not user input +func ParseLocationDeletedSiteIDInsensitively(input string) (*LocationDeletedSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationDeletedSiteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationDeletedSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationDeletedSiteId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + if id.DeletedSiteId, ok = input.Parsed["deletedSiteId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deletedSiteId", input) + } + + return nil +} + +// ValidateLocationDeletedSiteID checks that 'input' can be parsed as a Location Deleted Site ID +func ValidateLocationDeletedSiteID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationDeletedSiteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location Deleted Site ID +func (id LocationDeletedSiteId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/locations/%s/deletedSites/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.DeletedSiteId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location Deleted Site ID +func (id LocationDeletedSiteId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + resourceids.StaticSegment("staticDeletedSites", "deletedSites", "deletedSites"), + resourceids.UserSpecifiedSegment("deletedSiteId", "deletedSiteId"), + } +} + +// String returns a human-readable description of this Location Deleted Site ID +func (id LocationDeletedSiteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Deleted Site: %q", id.DeletedSiteId), + } + return fmt.Sprintf("Location Deleted Site (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/deletedwebapps/id_locationdeletedsite_test.go b/resource-manager/web/2024-11-01/deletedwebapps/id_locationdeletedsite_test.go new file mode 100644 index 00000000000..b406ec22fa2 --- /dev/null +++ b/resource-manager/web/2024-11-01/deletedwebapps/id_locationdeletedsite_test.go @@ -0,0 +1,282 @@ +package deletedwebapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationDeletedSiteId{} + +func TestNewLocationDeletedSiteID(t *testing.T) { + id := NewLocationDeletedSiteID("12345678-1234-9876-4563-123456789012", "locationName", "deletedSiteId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } + + if id.DeletedSiteId != "deletedSiteId" { + t.Fatalf("Expected %q but got %q for Segment 'DeletedSiteId'", id.DeletedSiteId, "deletedSiteId") + } +} + +func TestFormatLocationDeletedSiteID(t *testing.T) { + actual := NewLocationDeletedSiteID("12345678-1234-9876-4563-123456789012", "locationName", "deletedSiteId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/deletedSites/deletedSiteId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationDeletedSiteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationDeletedSiteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/deletedSites", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/deletedSites/deletedSiteId", + Expected: &LocationDeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + DeletedSiteId: "deletedSiteId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/deletedSites/deletedSiteId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationDeletedSiteID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.DeletedSiteId != v.Expected.DeletedSiteId { + t.Fatalf("Expected %q but got %q for DeletedSiteId", v.Expected.DeletedSiteId, actual.DeletedSiteId) + } + + } +} + +func TestParseLocationDeletedSiteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationDeletedSiteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/deletedSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE/dElEtEdSiTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/deletedSites/deletedSiteId", + Expected: &LocationDeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + DeletedSiteId: "deletedSiteId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/deletedSites/deletedSiteId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE/dElEtEdSiTeS/dElEtEdSiTeId", + Expected: &LocationDeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + DeletedSiteId: "dElEtEdSiTeId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE/dElEtEdSiTeS/dElEtEdSiTeId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationDeletedSiteIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.DeletedSiteId != v.Expected.DeletedSiteId { + t.Fatalf("Expected %q but got %q for DeletedSiteId", v.Expected.DeletedSiteId, actual.DeletedSiteId) + } + + } +} + +func TestSegmentsForLocationDeletedSiteId(t *testing.T) { + segments := LocationDeletedSiteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationDeletedSiteId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/deletedwebapps/id_providerlocation.go b/resource-manager/web/2024-11-01/deletedwebapps/id_providerlocation.go new file mode 100644 index 00000000000..ba6b4940392 --- /dev/null +++ b/resource-manager/web/2024-11-01/deletedwebapps/id_providerlocation.go @@ -0,0 +1,121 @@ +package deletedwebapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/deletedwebapps/id_providerlocation_test.go b/resource-manager/web/2024-11-01/deletedwebapps/id_providerlocation_test.go new file mode 100644 index 00000000000..fb713255a98 --- /dev/null +++ b/resource-manager/web/2024-11-01/deletedwebapps/id_providerlocation_test.go @@ -0,0 +1,237 @@ +package deletedwebapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/deletedwebapps/method_getdeletedwebappbylocation.go b/resource-manager/web/2024-11-01/deletedwebapps/method_getdeletedwebappbylocation.go new file mode 100644 index 00000000000..c60231dbc7b --- /dev/null +++ b/resource-manager/web/2024-11-01/deletedwebapps/method_getdeletedwebappbylocation.go @@ -0,0 +1,53 @@ +package deletedwebapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetDeletedWebAppByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DeletedSite +} + +// GetDeletedWebAppByLocation ... +func (c DeletedWebAppsClient) GetDeletedWebAppByLocation(ctx context.Context, id LocationDeletedSiteId) (result GetDeletedWebAppByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DeletedSite + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/deletedwebapps/method_list.go b/resource-manager/web/2024-11-01/deletedwebapps/method_list.go new file mode 100644 index 00000000000..9727a056e86 --- /dev/null +++ b/resource-manager/web/2024-11-01/deletedwebapps/method_list.go @@ -0,0 +1,106 @@ +package deletedwebapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DeletedSite +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []DeletedSite +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c DeletedWebAppsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/deletedSites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DeletedSite `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c DeletedWebAppsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, DeletedSiteOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DeletedWebAppsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DeletedSiteOperationPredicate) (result ListCompleteResult, err error) { + items := make([]DeletedSite, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/deletedwebapps/method_listbylocation.go b/resource-manager/web/2024-11-01/deletedwebapps/method_listbylocation.go new file mode 100644 index 00000000000..09bdd361949 --- /dev/null +++ b/resource-manager/web/2024-11-01/deletedwebapps/method_listbylocation.go @@ -0,0 +1,105 @@ +package deletedwebapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DeletedSite +} + +type ListByLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []DeletedSite +} + +type ListByLocationCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByLocationCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByLocation ... +func (c DeletedWebAppsClient) ListByLocation(ctx context.Context, id ProviderLocationId) (result ListByLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByLocationCustomPager{}, + Path: fmt.Sprintf("%s/deletedSites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DeletedSite `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByLocationComplete retrieves all the results into a single object +func (c DeletedWebAppsClient) ListByLocationComplete(ctx context.Context, id ProviderLocationId) (ListByLocationCompleteResult, error) { + return c.ListByLocationCompleteMatchingPredicate(ctx, id, DeletedSiteOperationPredicate{}) +} + +// ListByLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DeletedWebAppsClient) ListByLocationCompleteMatchingPredicate(ctx context.Context, id ProviderLocationId, predicate DeletedSiteOperationPredicate) (result ListByLocationCompleteResult, err error) { + items := make([]DeletedSite, 0) + + resp, err := c.ListByLocation(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/deletedwebapps/model_deletedsite.go b/resource-manager/web/2024-11-01/deletedwebapps/model_deletedsite.go new file mode 100644 index 00000000000..680051fe469 --- /dev/null +++ b/resource-manager/web/2024-11-01/deletedwebapps/model_deletedsite.go @@ -0,0 +1,12 @@ +package deletedwebapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedSite struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DeletedSiteProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/deletedwebapps/model_deletedsiteproperties.go b/resource-manager/web/2024-11-01/deletedwebapps/model_deletedsiteproperties.go new file mode 100644 index 00000000000..0afbf334a61 --- /dev/null +++ b/resource-manager/web/2024-11-01/deletedwebapps/model_deletedsiteproperties.go @@ -0,0 +1,15 @@ +package deletedwebapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedSiteProperties struct { + DeletedSiteId *int64 `json:"deletedSiteId,omitempty"` + DeletedSiteName *string `json:"deletedSiteName,omitempty"` + DeletedTimestamp *string `json:"deletedTimestamp,omitempty"` + GeoRegionName *string `json:"geoRegionName,omitempty"` + Kind *string `json:"kind,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + Slot *string `json:"slot,omitempty"` + Subscription *string `json:"subscription,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/deletedwebapps/predicates.go b/resource-manager/web/2024-11-01/deletedwebapps/predicates.go new file mode 100644 index 00000000000..5db9392a06f --- /dev/null +++ b/resource-manager/web/2024-11-01/deletedwebapps/predicates.go @@ -0,0 +1,32 @@ +package deletedwebapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedSiteOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DeletedSiteOperationPredicate) Matches(input DeletedSite) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/deletedwebapps/version.go b/resource-manager/web/2024-11-01/deletedwebapps/version.go new file mode 100644 index 00000000000..35f3f1b3a2e --- /dev/null +++ b/resource-manager/web/2024-11-01/deletedwebapps/version.go @@ -0,0 +1,10 @@ +package deletedwebapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/deletedwebapps/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/diagnostics/README.md b/resource-manager/web/2024-11-01/diagnostics/README.md new file mode 100644 index 00000000000..8a56e1ec898 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/README.md @@ -0,0 +1,382 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/diagnostics` Documentation + +The `diagnostics` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/diagnostics" +``` + + +### Client Initialization + +```go +client := diagnostics.NewDiagnosticsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DiagnosticsClient.ExecuteSiteAnalysis` + +```go +ctx := context.TODO() +id := diagnostics.NewAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName", "analysisName") + +read, err := client.ExecuteSiteAnalysis(ctx, id, diagnostics.DefaultExecuteSiteAnalysisOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.ExecuteSiteAnalysisSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName", "analysisName") + +read, err := client.ExecuteSiteAnalysisSlot(ctx, id, diagnostics.DefaultExecuteSiteAnalysisSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.ExecuteSiteDetector` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName", "detectorName") + +read, err := client.ExecuteSiteDetector(ctx, id, diagnostics.DefaultExecuteSiteDetectorOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.ExecuteSiteDetectorSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName", "detectorName") + +read, err := client.ExecuteSiteDetectorSlot(ctx, id, diagnostics.DefaultExecuteSiteDetectorSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetHostingEnvironmentDetectorResponse` + +```go +ctx := context.TODO() +id := diagnostics.NewHostingEnvironmentDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "detectorName") + +read, err := client.GetHostingEnvironmentDetectorResponse(ctx, id, diagnostics.DefaultGetHostingEnvironmentDetectorResponseOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteAnalysis` + +```go +ctx := context.TODO() +id := diagnostics.NewAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName", "analysisName") + +read, err := client.GetSiteAnalysis(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteAnalysisSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName", "analysisName") + +read, err := client.GetSiteAnalysisSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDetector` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName", "detectorName") + +read, err := client.GetSiteDetector(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDetectorResponse` + +```go +ctx := context.TODO() +id := diagnostics.NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "detectorName") + +read, err := client.GetSiteDetectorResponse(ctx, id, diagnostics.DefaultGetSiteDetectorResponseOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDetectorResponseSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "detectorName") + +read, err := client.GetSiteDetectorResponseSlot(ctx, id, diagnostics.DefaultGetSiteDetectorResponseSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDetectorSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName", "detectorName") + +read, err := client.GetSiteDetectorSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDiagnosticCategory` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName") + +read, err := client.GetSiteDiagnosticCategory(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.GetSiteDiagnosticCategorySlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName") + +read, err := client.GetSiteDiagnosticCategorySlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DiagnosticsClient.ListHostingEnvironmentDetectorResponses` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListHostingEnvironmentDetectorResponses(ctx, id)` can be used to do batched pagination +items, err := client.ListHostingEnvironmentDetectorResponsesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteAnalyses` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName") + +// alternatively `client.ListSiteAnalyses(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteAnalysesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteAnalysesSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName") + +// alternatively `client.ListSiteAnalysesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteAnalysesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDetectorResponses` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListSiteDetectorResponses(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDetectorResponsesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDetectorResponsesSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListSiteDetectorResponsesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDetectorResponsesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDetectors` + +```go +ctx := context.TODO() +id := diagnostics.NewDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName") + +// alternatively `client.ListSiteDetectors(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDetectorsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDetectorsSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName") + +// alternatively `client.ListSiteDetectorsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDetectorsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDiagnosticCategories` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListSiteDiagnosticCategories(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDiagnosticCategoriesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DiagnosticsClient.ListSiteDiagnosticCategoriesSlot` + +```go +ctx := context.TODO() +id := diagnostics.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListSiteDiagnosticCategoriesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteDiagnosticCategoriesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-11-01/diagnostics/client.go b/resource-manager/web/2024-11-01/diagnostics/client.go new file mode 100644 index 00000000000..4b218f34ee2 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/client.go @@ -0,0 +1,26 @@ +package diagnostics + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticsClient struct { + Client *resourcemanager.Client +} + +func NewDiagnosticsClientWithBaseURI(sdkApi sdkEnv.Api) (*DiagnosticsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "diagnostics", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DiagnosticsClient: %+v", err) + } + + return &DiagnosticsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/diagnostics/constants.go b/resource-manager/web/2024-11-01/diagnostics/constants.go new file mode 100644 index 00000000000..47006b35190 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/constants.go @@ -0,0 +1,317 @@ +package diagnostics + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorType string + +const ( + DetectorTypeAnalysis DetectorType = "Analysis" + DetectorTypeCategoryOverview DetectorType = "CategoryOverview" + DetectorTypeDetector DetectorType = "Detector" +) + +func PossibleValuesForDetectorType() []string { + return []string{ + string(DetectorTypeAnalysis), + string(DetectorTypeCategoryOverview), + string(DetectorTypeDetector), + } +} + +func (s *DetectorType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDetectorType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDetectorType(input string) (*DetectorType, error) { + vals := map[string]DetectorType{ + "analysis": DetectorTypeAnalysis, + "categoryoverview": DetectorTypeCategoryOverview, + "detector": DetectorTypeDetector, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DetectorType(input) + return &out, nil +} + +type InsightStatus string + +const ( + InsightStatusCritical InsightStatus = "Critical" + InsightStatusInfo InsightStatus = "Info" + InsightStatusNone InsightStatus = "None" + InsightStatusSuccess InsightStatus = "Success" + InsightStatusWarning InsightStatus = "Warning" +) + +func PossibleValuesForInsightStatus() []string { + return []string{ + string(InsightStatusCritical), + string(InsightStatusInfo), + string(InsightStatusNone), + string(InsightStatusSuccess), + string(InsightStatusWarning), + } +} + +func (s *InsightStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInsightStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInsightStatus(input string) (*InsightStatus, error) { + vals := map[string]InsightStatus{ + "critical": InsightStatusCritical, + "info": InsightStatusInfo, + "none": InsightStatusNone, + "success": InsightStatusSuccess, + "warning": InsightStatusWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InsightStatus(input) + return &out, nil +} + +type IssueType string + +const ( + IssueTypeAppCrash IssueType = "AppCrash" + IssueTypeAppDeployment IssueType = "AppDeployment" + IssueTypeAseDeployment IssueType = "AseDeployment" + IssueTypeOther IssueType = "Other" + IssueTypePlatformIssue IssueType = "PlatformIssue" + IssueTypeRuntimeIssueDetected IssueType = "RuntimeIssueDetected" + IssueTypeServiceIncident IssueType = "ServiceIncident" + IssueTypeUserIssue IssueType = "UserIssue" +) + +func PossibleValuesForIssueType() []string { + return []string{ + string(IssueTypeAppCrash), + string(IssueTypeAppDeployment), + string(IssueTypeAseDeployment), + string(IssueTypeOther), + string(IssueTypePlatformIssue), + string(IssueTypeRuntimeIssueDetected), + string(IssueTypeServiceIncident), + string(IssueTypeUserIssue), + } +} + +func (s *IssueType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIssueType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIssueType(input string) (*IssueType, error) { + vals := map[string]IssueType{ + "appcrash": IssueTypeAppCrash, + "appdeployment": IssueTypeAppDeployment, + "asedeployment": IssueTypeAseDeployment, + "other": IssueTypeOther, + "platformissue": IssueTypePlatformIssue, + "runtimeissuedetected": IssueTypeRuntimeIssueDetected, + "serviceincident": IssueTypeServiceIncident, + "userissue": IssueTypeUserIssue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IssueType(input) + return &out, nil +} + +type RenderingType string + +const ( + RenderingTypeAppInsight RenderingType = "AppInsight" + RenderingTypeAppInsightEnablement RenderingType = "AppInsightEnablement" + RenderingTypeCard RenderingType = "Card" + RenderingTypeChangeAnalysisOnboarding RenderingType = "ChangeAnalysisOnboarding" + RenderingTypeChangeSets RenderingType = "ChangeSets" + RenderingTypeChangesView RenderingType = "ChangesView" + RenderingTypeDataSummary RenderingType = "DataSummary" + RenderingTypeDependencyGraph RenderingType = "DependencyGraph" + RenderingTypeDetector RenderingType = "Detector" + RenderingTypeDownTime RenderingType = "DownTime" + RenderingTypeDropDown RenderingType = "DropDown" + RenderingTypeDynamicInsight RenderingType = "DynamicInsight" + RenderingTypeEmail RenderingType = "Email" + RenderingTypeForm RenderingType = "Form" + RenderingTypeGuage RenderingType = "Guage" + RenderingTypeInsights RenderingType = "Insights" + RenderingTypeMarkdown RenderingType = "Markdown" + RenderingTypeNoGraph RenderingType = "NoGraph" + RenderingTypePieChart RenderingType = "PieChart" + RenderingTypeSearchComponent RenderingType = "SearchComponent" + RenderingTypeSolution RenderingType = "Solution" + RenderingTypeSummaryCard RenderingType = "SummaryCard" + RenderingTypeTable RenderingType = "Table" + RenderingTypeTimeSeries RenderingType = "TimeSeries" + RenderingTypeTimeSeriesPerInstance RenderingType = "TimeSeriesPerInstance" +) + +func PossibleValuesForRenderingType() []string { + return []string{ + string(RenderingTypeAppInsight), + string(RenderingTypeAppInsightEnablement), + string(RenderingTypeCard), + string(RenderingTypeChangeAnalysisOnboarding), + string(RenderingTypeChangeSets), + string(RenderingTypeChangesView), + string(RenderingTypeDataSummary), + string(RenderingTypeDependencyGraph), + string(RenderingTypeDetector), + string(RenderingTypeDownTime), + string(RenderingTypeDropDown), + string(RenderingTypeDynamicInsight), + string(RenderingTypeEmail), + string(RenderingTypeForm), + string(RenderingTypeGuage), + string(RenderingTypeInsights), + string(RenderingTypeMarkdown), + string(RenderingTypeNoGraph), + string(RenderingTypePieChart), + string(RenderingTypeSearchComponent), + string(RenderingTypeSolution), + string(RenderingTypeSummaryCard), + string(RenderingTypeTable), + string(RenderingTypeTimeSeries), + string(RenderingTypeTimeSeriesPerInstance), + } +} + +func (s *RenderingType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRenderingType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRenderingType(input string) (*RenderingType, error) { + vals := map[string]RenderingType{ + "appinsight": RenderingTypeAppInsight, + "appinsightenablement": RenderingTypeAppInsightEnablement, + "card": RenderingTypeCard, + "changeanalysisonboarding": RenderingTypeChangeAnalysisOnboarding, + "changesets": RenderingTypeChangeSets, + "changesview": RenderingTypeChangesView, + "datasummary": RenderingTypeDataSummary, + "dependencygraph": RenderingTypeDependencyGraph, + "detector": RenderingTypeDetector, + "downtime": RenderingTypeDownTime, + "dropdown": RenderingTypeDropDown, + "dynamicinsight": RenderingTypeDynamicInsight, + "email": RenderingTypeEmail, + "form": RenderingTypeForm, + "guage": RenderingTypeGuage, + "insights": RenderingTypeInsights, + "markdown": RenderingTypeMarkdown, + "nograph": RenderingTypeNoGraph, + "piechart": RenderingTypePieChart, + "searchcomponent": RenderingTypeSearchComponent, + "solution": RenderingTypeSolution, + "summarycard": RenderingTypeSummaryCard, + "table": RenderingTypeTable, + "timeseries": RenderingTypeTimeSeries, + "timeseriesperinstance": RenderingTypeTimeSeriesPerInstance, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RenderingType(input) + return &out, nil +} + +type SolutionType string + +const ( + SolutionTypeBestPractices SolutionType = "BestPractices" + SolutionTypeDeepInvestigation SolutionType = "DeepInvestigation" + SolutionTypeQuickSolution SolutionType = "QuickSolution" +) + +func PossibleValuesForSolutionType() []string { + return []string{ + string(SolutionTypeBestPractices), + string(SolutionTypeDeepInvestigation), + string(SolutionTypeQuickSolution), + } +} + +func (s *SolutionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSolutionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSolutionType(input string) (*SolutionType, error) { + vals := map[string]SolutionType{ + "bestpractices": SolutionTypeBestPractices, + "deepinvestigation": SolutionTypeDeepInvestigation, + "quicksolution": SolutionTypeQuickSolution, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SolutionType(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_analysis.go b/resource-manager/web/2024-11-01/diagnostics/id_analysis.go new file mode 100644 index 00000000000..4ad7593663b --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_analysis.go @@ -0,0 +1,148 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AnalysisId{}) +} + +var _ resourceids.ResourceId = &AnalysisId{} + +// AnalysisId is a struct representing the Resource ID for a Analysis +type AnalysisId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DiagnosticName string + AnalysisName string +} + +// NewAnalysisID returns a new AnalysisId struct +func NewAnalysisID(subscriptionId string, resourceGroupName string, siteName string, diagnosticName string, analysisName string) AnalysisId { + return AnalysisId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DiagnosticName: diagnosticName, + AnalysisName: analysisName, + } +} + +// ParseAnalysisID parses 'input' into a AnalysisId +func ParseAnalysisID(input string) (*AnalysisId, error) { + parser := resourceids.NewParserFromResourceIdType(&AnalysisId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AnalysisId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAnalysisIDInsensitively parses 'input' case-insensitively into a AnalysisId +// note: this method should only be used for API response data and not user input +func ParseAnalysisIDInsensitively(input string) (*AnalysisId, error) { + parser := resourceids.NewParserFromResourceIdType(&AnalysisId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AnalysisId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AnalysisId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + if id.AnalysisName, ok = input.Parsed["analysisName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "analysisName", input) + } + + return nil +} + +// ValidateAnalysisID checks that 'input' can be parsed as a Analysis ID +func ValidateAnalysisID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseAnalysisID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Analysis ID +func (id AnalysisId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/diagnostics/%s/analyses/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DiagnosticName, id.AnalysisName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Analysis ID +func (id AnalysisId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticName"), + resourceids.StaticSegment("staticAnalyses", "analyses", "analyses"), + resourceids.UserSpecifiedSegment("analysisName", "analysisName"), + } +} + +// String returns a human-readable description of this Analysis ID +func (id AnalysisId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + fmt.Sprintf("Analysis Name: %q", id.AnalysisName), + } + return fmt.Sprintf("Analysis (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_analysis_test.go b/resource-manager/web/2024-11-01/diagnostics/id_analysis_test.go new file mode 100644 index 00000000000..b5a41dcb6b7 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_analysis_test.go @@ -0,0 +1,372 @@ +package diagnostics + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AnalysisId{} + +func TestNewAnalysisID(t *testing.T) { + id := NewAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName", "analysisName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.DiagnosticName != "diagnosticName" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticName") + } + + if id.AnalysisName != "analysisName" { + t.Fatalf("Expected %q but got %q for Segment 'AnalysisName'", id.AnalysisName, "analysisName") + } +} + +func TestFormatAnalysisID(t *testing.T) { + actual := NewAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName", "analysisName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/analyses/analysisName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAnalysisID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AnalysisId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/analyses", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/analyses/analysisName", + Expected: &AnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DiagnosticName: "diagnosticName", + AnalysisName: "analysisName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/analyses/analysisName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAnalysisID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.AnalysisName != v.Expected.AnalysisName { + t.Fatalf("Expected %q but got %q for AnalysisName", v.Expected.AnalysisName, actual.AnalysisName) + } + + } +} + +func TestParseAnalysisIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AnalysisId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/analyses", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/aNaLySeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/analyses/analysisName", + Expected: &AnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DiagnosticName: "diagnosticName", + AnalysisName: "analysisName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/analyses/analysisName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/aNaLySeS/aNaLySiSnAmE", + Expected: &AnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + DiagnosticName: "dIaGnOsTiCnAmE", + AnalysisName: "aNaLySiSnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/aNaLySeS/aNaLySiSnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAnalysisIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.AnalysisName != v.Expected.AnalysisName { + t.Fatalf("Expected %q but got %q for AnalysisName", v.Expected.AnalysisName, actual.AnalysisName) + } + + } +} + +func TestSegmentsForAnalysisId(t *testing.T) { + segments := AnalysisId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AnalysisId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_detector.go b/resource-manager/web/2024-11-01/diagnostics/id_detector.go new file mode 100644 index 00000000000..5fbc7237434 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_detector.go @@ -0,0 +1,139 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DetectorId{}) +} + +var _ resourceids.ResourceId = &DetectorId{} + +// DetectorId is a struct representing the Resource ID for a Detector +type DetectorId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DetectorName string +} + +// NewDetectorID returns a new DetectorId struct +func NewDetectorID(subscriptionId string, resourceGroupName string, siteName string, detectorName string) DetectorId { + return DetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DetectorName: detectorName, + } +} + +// ParseDetectorID parses 'input' into a DetectorId +func ParseDetectorID(input string) (*DetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDetectorIDInsensitively parses 'input' case-insensitively into a DetectorId +// note: this method should only be used for API response data and not user input +func ParseDetectorIDInsensitively(input string) (*DetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DetectorId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateDetectorID checks that 'input' can be parsed as a Detector ID +func ValidateDetectorID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Detector ID +func (id DetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Detector ID +func (id DetectorId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorName"), + } +} + +// String returns a human-readable description of this Detector ID +func (id DetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_detector_test.go b/resource-manager/web/2024-11-01/diagnostics/id_detector_test.go new file mode 100644 index 00000000000..fd49dc7f61d --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_detector_test.go @@ -0,0 +1,327 @@ +package diagnostics + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DetectorId{} + +func TestNewDetectorID(t *testing.T) { + id := NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "detectorName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.DetectorName != "detectorName" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorName") + } +} + +func TestFormatDetectorID(t *testing.T) { + actual := NewDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "detectorName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/detectors/detectorName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DetectorId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/detectors/detectorName", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/detectors/detectorName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DetectorId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/detectors/detectorName", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/detectors/detectorName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dEtEcToRs/dEtEcToRnAmE", + Expected: &DetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + DetectorName: "dEtEcToRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dEtEcToRs/dEtEcToRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForDetectorId(t *testing.T) { + segments := DetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DetectorId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_diagnostic.go b/resource-manager/web/2024-11-01/diagnostics/id_diagnostic.go new file mode 100644 index 00000000000..d8f916e4863 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_diagnostic.go @@ -0,0 +1,139 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DiagnosticId{}) +} + +var _ resourceids.ResourceId = &DiagnosticId{} + +// DiagnosticId is a struct representing the Resource ID for a Diagnostic +type DiagnosticId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DiagnosticName string +} + +// NewDiagnosticID returns a new DiagnosticId struct +func NewDiagnosticID(subscriptionId string, resourceGroupName string, siteName string, diagnosticName string) DiagnosticId { + return DiagnosticId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DiagnosticName: diagnosticName, + } +} + +// ParseDiagnosticID parses 'input' into a DiagnosticId +func ParseDiagnosticID(input string) (*DiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDiagnosticIDInsensitively parses 'input' case-insensitively into a DiagnosticId +// note: this method should only be used for API response data and not user input +func ParseDiagnosticIDInsensitively(input string) (*DiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DiagnosticId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + return nil +} + +// ValidateDiagnosticID checks that 'input' can be parsed as a Diagnostic ID +func ValidateDiagnosticID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDiagnosticID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Diagnostic ID +func (id DiagnosticId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/diagnostics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DiagnosticName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Diagnostic ID +func (id DiagnosticId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticName"), + } +} + +// String returns a human-readable description of this Diagnostic ID +func (id DiagnosticId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + } + return fmt.Sprintf("Diagnostic (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_diagnostic_test.go b/resource-manager/web/2024-11-01/diagnostics/id_diagnostic_test.go new file mode 100644 index 00000000000..f75e156e5bb --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_diagnostic_test.go @@ -0,0 +1,327 @@ +package diagnostics + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DiagnosticId{} + +func TestNewDiagnosticID(t *testing.T) { + id := NewDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.DiagnosticName != "diagnosticName" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticName") + } +} + +func TestFormatDiagnosticID(t *testing.T) { + actual := NewDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDiagnosticID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName", + Expected: &DiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DiagnosticName: "diagnosticName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestParseDiagnosticIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName", + Expected: &DiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DiagnosticName: "diagnosticName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE", + Expected: &DiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + DiagnosticName: "dIaGnOsTiCnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestSegmentsForDiagnosticId(t *testing.T) { + segments := DiagnosticId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DiagnosticId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_diagnosticanalysis.go b/resource-manager/web/2024-11-01/diagnostics/id_diagnosticanalysis.go new file mode 100644 index 00000000000..c2a851a5780 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_diagnosticanalysis.go @@ -0,0 +1,157 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DiagnosticAnalysisId{}) +} + +var _ resourceids.ResourceId = &DiagnosticAnalysisId{} + +// DiagnosticAnalysisId is a struct representing the Resource ID for a Diagnostic Analysis +type DiagnosticAnalysisId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DiagnosticName string + AnalysisName string +} + +// NewDiagnosticAnalysisID returns a new DiagnosticAnalysisId struct +func NewDiagnosticAnalysisID(subscriptionId string, resourceGroupName string, siteName string, slotName string, diagnosticName string, analysisName string) DiagnosticAnalysisId { + return DiagnosticAnalysisId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DiagnosticName: diagnosticName, + AnalysisName: analysisName, + } +} + +// ParseDiagnosticAnalysisID parses 'input' into a DiagnosticAnalysisId +func ParseDiagnosticAnalysisID(input string) (*DiagnosticAnalysisId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticAnalysisId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticAnalysisId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDiagnosticAnalysisIDInsensitively parses 'input' case-insensitively into a DiagnosticAnalysisId +// note: this method should only be used for API response data and not user input +func ParseDiagnosticAnalysisIDInsensitively(input string) (*DiagnosticAnalysisId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticAnalysisId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticAnalysisId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DiagnosticAnalysisId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + if id.AnalysisName, ok = input.Parsed["analysisName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "analysisName", input) + } + + return nil +} + +// ValidateDiagnosticAnalysisID checks that 'input' can be parsed as a Diagnostic Analysis ID +func ValidateDiagnosticAnalysisID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDiagnosticAnalysisID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Diagnostic Analysis ID +func (id DiagnosticAnalysisId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/diagnostics/%s/analyses/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DiagnosticName, id.AnalysisName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Diagnostic Analysis ID +func (id DiagnosticAnalysisId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticName"), + resourceids.StaticSegment("staticAnalyses", "analyses", "analyses"), + resourceids.UserSpecifiedSegment("analysisName", "analysisName"), + } +} + +// String returns a human-readable description of this Diagnostic Analysis ID +func (id DiagnosticAnalysisId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + fmt.Sprintf("Analysis Name: %q", id.AnalysisName), + } + return fmt.Sprintf("Diagnostic Analysis (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_diagnosticanalysis_test.go b/resource-manager/web/2024-11-01/diagnostics/id_diagnosticanalysis_test.go new file mode 100644 index 00000000000..88593f85f7f --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_diagnosticanalysis_test.go @@ -0,0 +1,417 @@ +package diagnostics + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DiagnosticAnalysisId{} + +func TestNewDiagnosticAnalysisID(t *testing.T) { + id := NewDiagnosticAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName", "analysisName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.DiagnosticName != "diagnosticName" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticName") + } + + if id.AnalysisName != "analysisName" { + t.Fatalf("Expected %q but got %q for Segment 'AnalysisName'", id.AnalysisName, "analysisName") + } +} + +func TestFormatDiagnosticAnalysisID(t *testing.T) { + actual := NewDiagnosticAnalysisID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName", "analysisName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/analyses/analysisName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDiagnosticAnalysisID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticAnalysisId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/analyses", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/analyses/analysisName", + Expected: &DiagnosticAnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DiagnosticName: "diagnosticName", + AnalysisName: "analysisName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/analyses/analysisName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticAnalysisID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.AnalysisName != v.Expected.AnalysisName { + t.Fatalf("Expected %q but got %q for AnalysisName", v.Expected.AnalysisName, actual.AnalysisName) + } + + } +} + +func TestParseDiagnosticAnalysisIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticAnalysisId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/analyses", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/aNaLySeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/analyses/analysisName", + Expected: &DiagnosticAnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DiagnosticName: "diagnosticName", + AnalysisName: "analysisName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/analyses/analysisName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/aNaLySeS/aNaLySiSnAmE", + Expected: &DiagnosticAnalysisId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + DiagnosticName: "dIaGnOsTiCnAmE", + AnalysisName: "aNaLySiSnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/aNaLySeS/aNaLySiSnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticAnalysisIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.AnalysisName != v.Expected.AnalysisName { + t.Fatalf("Expected %q but got %q for AnalysisName", v.Expected.AnalysisName, actual.AnalysisName) + } + + } +} + +func TestSegmentsForDiagnosticAnalysisId(t *testing.T) { + segments := DiagnosticAnalysisId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DiagnosticAnalysisId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_diagnosticdetector.go b/resource-manager/web/2024-11-01/diagnostics/id_diagnosticdetector.go new file mode 100644 index 00000000000..cf131c1681f --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_diagnosticdetector.go @@ -0,0 +1,148 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DiagnosticDetectorId{}) +} + +var _ resourceids.ResourceId = &DiagnosticDetectorId{} + +// DiagnosticDetectorId is a struct representing the Resource ID for a Diagnostic Detector +type DiagnosticDetectorId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DiagnosticName string + DetectorName string +} + +// NewDiagnosticDetectorID returns a new DiagnosticDetectorId struct +func NewDiagnosticDetectorID(subscriptionId string, resourceGroupName string, siteName string, diagnosticName string, detectorName string) DiagnosticDetectorId { + return DiagnosticDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DiagnosticName: diagnosticName, + DetectorName: detectorName, + } +} + +// ParseDiagnosticDetectorID parses 'input' into a DiagnosticDetectorId +func ParseDiagnosticDetectorID(input string) (*DiagnosticDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDiagnosticDetectorIDInsensitively parses 'input' case-insensitively into a DiagnosticDetectorId +// note: this method should only be used for API response data and not user input +func ParseDiagnosticDetectorIDInsensitively(input string) (*DiagnosticDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&DiagnosticDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DiagnosticDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DiagnosticDetectorId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateDiagnosticDetectorID checks that 'input' can be parsed as a Diagnostic Detector ID +func ValidateDiagnosticDetectorID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDiagnosticDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Diagnostic Detector ID +func (id DiagnosticDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/diagnostics/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DiagnosticName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Diagnostic Detector ID +func (id DiagnosticDetectorId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticName"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorName"), + } +} + +// String returns a human-readable description of this Diagnostic Detector ID +func (id DiagnosticDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Diagnostic Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_diagnosticdetector_test.go b/resource-manager/web/2024-11-01/diagnostics/id_diagnosticdetector_test.go new file mode 100644 index 00000000000..cd45a7927c0 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_diagnosticdetector_test.go @@ -0,0 +1,372 @@ +package diagnostics + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DiagnosticDetectorId{} + +func TestNewDiagnosticDetectorID(t *testing.T) { + id := NewDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName", "detectorName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.DiagnosticName != "diagnosticName" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticName") + } + + if id.DetectorName != "detectorName" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorName") + } +} + +func TestFormatDiagnosticDetectorID(t *testing.T) { + actual := NewDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "diagnosticName", "detectorName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/detectors/detectorName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDiagnosticDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticDetectorId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/detectors/detectorName", + Expected: &DiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DiagnosticName: "diagnosticName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/detectors/detectorName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseDiagnosticDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DiagnosticDetectorId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/detectors/detectorName", + Expected: &DiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DiagnosticName: "diagnosticName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/diagnostics/diagnosticName/detectors/detectorName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/dEtEcToRs/dEtEcToRnAmE", + Expected: &DiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + DiagnosticName: "dIaGnOsTiCnAmE", + DetectorName: "dEtEcToRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/dEtEcToRs/dEtEcToRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDiagnosticDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForDiagnosticDetectorId(t *testing.T) { + segments := DiagnosticDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DiagnosticDetectorId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_hostingenvironmentdetector.go b/resource-manager/web/2024-11-01/diagnostics/id_hostingenvironmentdetector.go new file mode 100644 index 00000000000..617be4bec18 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_hostingenvironmentdetector.go @@ -0,0 +1,139 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostingEnvironmentDetectorId{}) +} + +var _ resourceids.ResourceId = &HostingEnvironmentDetectorId{} + +// HostingEnvironmentDetectorId is a struct representing the Resource ID for a Hosting Environment Detector +type HostingEnvironmentDetectorId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + DetectorName string +} + +// NewHostingEnvironmentDetectorID returns a new HostingEnvironmentDetectorId struct +func NewHostingEnvironmentDetectorID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, detectorName string) HostingEnvironmentDetectorId { + return HostingEnvironmentDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + DetectorName: detectorName, + } +} + +// ParseHostingEnvironmentDetectorID parses 'input' into a HostingEnvironmentDetectorId +func ParseHostingEnvironmentDetectorID(input string) (*HostingEnvironmentDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostingEnvironmentDetectorIDInsensitively parses 'input' case-insensitively into a HostingEnvironmentDetectorId +// note: this method should only be used for API response data and not user input +func ParseHostingEnvironmentDetectorIDInsensitively(input string) (*HostingEnvironmentDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostingEnvironmentDetectorId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateHostingEnvironmentDetectorID checks that 'input' can be parsed as a Hosting Environment Detector ID +func ValidateHostingEnvironmentDetectorID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostingEnvironmentDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hosting Environment Detector ID +func (id HostingEnvironmentDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hosting Environment Detector ID +func (id HostingEnvironmentDetectorId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentName"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorName"), + } +} + +// String returns a human-readable description of this Hosting Environment Detector ID +func (id HostingEnvironmentDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Hosting Environment Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_hostingenvironmentdetector_test.go b/resource-manager/web/2024-11-01/diagnostics/id_hostingenvironmentdetector_test.go new file mode 100644 index 00000000000..6063fa9cdc0 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_hostingenvironmentdetector_test.go @@ -0,0 +1,327 @@ +package diagnostics + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostingEnvironmentDetectorId{} + +func TestNewHostingEnvironmentDetectorID(t *testing.T) { + id := NewHostingEnvironmentDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "detectorName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostingEnvironmentName != "hostingEnvironmentName" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentName") + } + + if id.DetectorName != "detectorName" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorName") + } +} + +func TestFormatHostingEnvironmentDetectorID(t *testing.T) { + actual := NewHostingEnvironmentDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "detectorName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/detectors/detectorName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostingEnvironmentDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentDetectorId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/detectors/detectorName", + Expected: &HostingEnvironmentDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/detectors/detectorName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseHostingEnvironmentDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentDetectorId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/detectors/detectorName", + Expected: &HostingEnvironmentDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/detectors/detectorName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/dEtEcToRs/dEtEcToRnAmE", + Expected: &HostingEnvironmentDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTnAmE", + DetectorName: "dEtEcToRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/dEtEcToRs/dEtEcToRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForHostingEnvironmentDetectorId(t *testing.T) { + segments := HostingEnvironmentDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostingEnvironmentDetectorId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_slot.go b/resource-manager/web/2024-11-01/diagnostics/id_slot.go new file mode 100644 index 00000000000..3458e4a3bca --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_slot.go @@ -0,0 +1,139 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotId{}) +} + +var _ resourceids.ResourceId = &SlotId{} + +// SlotId is a struct representing the Resource ID for a Slot +type SlotId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string +} + +// NewSlotID returns a new SlotId struct +func NewSlotID(subscriptionId string, resourceGroupName string, siteName string, slotName string) SlotId { + return SlotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + } +} + +// ParseSlotID parses 'input' into a SlotId +func ParseSlotID(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotIDInsensitively parses 'input' case-insensitively into a SlotId +// note: this method should only be used for API response data and not user input +func ParseSlotIDInsensitively(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + return nil +} + +// ValidateSlotID checks that 'input' can be parsed as a Slot ID +func ValidateSlotID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot ID +func (id SlotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot ID +func (id SlotId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + } +} + +// String returns a human-readable description of this Slot ID +func (id SlotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + } + return fmt.Sprintf("Slot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_slot_test.go b/resource-manager/web/2024-11-01/diagnostics/id_slot_test.go new file mode 100644 index 00000000000..591c34ab7b7 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_slot_test.go @@ -0,0 +1,327 @@ +package diagnostics + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotId{} + +func TestNewSlotID(t *testing.T) { + id := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } +} + +func TestFormatSlotID(t *testing.T) { + actual := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestParseSlotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestSegmentsForSlotId(t *testing.T) { + segments := SlotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_slotdetector.go b/resource-manager/web/2024-11-01/diagnostics/id_slotdetector.go new file mode 100644 index 00000000000..287984b0bc5 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_slotdetector.go @@ -0,0 +1,148 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotDetectorId{}) +} + +var _ resourceids.ResourceId = &SlotDetectorId{} + +// SlotDetectorId is a struct representing the Resource ID for a Slot Detector +type SlotDetectorId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DetectorName string +} + +// NewSlotDetectorID returns a new SlotDetectorId struct +func NewSlotDetectorID(subscriptionId string, resourceGroupName string, siteName string, slotName string, detectorName string) SlotDetectorId { + return SlotDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DetectorName: detectorName, + } +} + +// ParseSlotDetectorID parses 'input' into a SlotDetectorId +func ParseSlotDetectorID(input string) (*SlotDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotDetectorIDInsensitively parses 'input' case-insensitively into a SlotDetectorId +// note: this method should only be used for API response data and not user input +func ParseSlotDetectorIDInsensitively(input string) (*SlotDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotDetectorId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateSlotDetectorID checks that 'input' can be parsed as a Slot Detector ID +func ValidateSlotDetectorID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Detector ID +func (id SlotDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Detector ID +func (id SlotDetectorId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorName"), + } +} + +// String returns a human-readable description of this Slot Detector ID +func (id SlotDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Slot Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_slotdetector_test.go b/resource-manager/web/2024-11-01/diagnostics/id_slotdetector_test.go new file mode 100644 index 00000000000..32e7f62003b --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_slotdetector_test.go @@ -0,0 +1,372 @@ +package diagnostics + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotDetectorId{} + +func TestNewSlotDetectorID(t *testing.T) { + id := NewSlotDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "detectorName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.DetectorName != "detectorName" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorName") + } +} + +func TestFormatSlotDetectorID(t *testing.T) { + actual := NewSlotDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "detectorName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/detectors/detectorName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDetectorId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/detectors/detectorName", + Expected: &SlotDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/detectors/detectorName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseSlotDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDetectorId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/detectors/detectorName", + Expected: &SlotDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/detectors/detectorName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dEtEcToRs/dEtEcToRnAmE", + Expected: &SlotDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + DetectorName: "dEtEcToRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dEtEcToRs/dEtEcToRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForSlotDetectorId(t *testing.T) { + segments := SlotDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotDetectorId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_slotdiagnostic.go b/resource-manager/web/2024-11-01/diagnostics/id_slotdiagnostic.go new file mode 100644 index 00000000000..d94b24e79f8 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_slotdiagnostic.go @@ -0,0 +1,148 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotDiagnosticId{}) +} + +var _ resourceids.ResourceId = &SlotDiagnosticId{} + +// SlotDiagnosticId is a struct representing the Resource ID for a Slot Diagnostic +type SlotDiagnosticId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DiagnosticName string +} + +// NewSlotDiagnosticID returns a new SlotDiagnosticId struct +func NewSlotDiagnosticID(subscriptionId string, resourceGroupName string, siteName string, slotName string, diagnosticName string) SlotDiagnosticId { + return SlotDiagnosticId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DiagnosticName: diagnosticName, + } +} + +// ParseSlotDiagnosticID parses 'input' into a SlotDiagnosticId +func ParseSlotDiagnosticID(input string) (*SlotDiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDiagnosticId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDiagnosticId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotDiagnosticIDInsensitively parses 'input' case-insensitively into a SlotDiagnosticId +// note: this method should only be used for API response data and not user input +func ParseSlotDiagnosticIDInsensitively(input string) (*SlotDiagnosticId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDiagnosticId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDiagnosticId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotDiagnosticId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + return nil +} + +// ValidateSlotDiagnosticID checks that 'input' can be parsed as a Slot Diagnostic ID +func ValidateSlotDiagnosticID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotDiagnosticID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Diagnostic ID +func (id SlotDiagnosticId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/diagnostics/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DiagnosticName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Diagnostic ID +func (id SlotDiagnosticId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticName"), + } +} + +// String returns a human-readable description of this Slot Diagnostic ID +func (id SlotDiagnosticId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + } + return fmt.Sprintf("Slot Diagnostic (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_slotdiagnostic_test.go b/resource-manager/web/2024-11-01/diagnostics/id_slotdiagnostic_test.go new file mode 100644 index 00000000000..af97181d8ad --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_slotdiagnostic_test.go @@ -0,0 +1,372 @@ +package diagnostics + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotDiagnosticId{} + +func TestNewSlotDiagnosticID(t *testing.T) { + id := NewSlotDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.DiagnosticName != "diagnosticName" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticName") + } +} + +func TestFormatSlotDiagnosticID(t *testing.T) { + actual := NewSlotDiagnosticID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotDiagnosticID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDiagnosticId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName", + Expected: &SlotDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DiagnosticName: "diagnosticName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDiagnosticID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestParseSlotDiagnosticIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDiagnosticId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName", + Expected: &SlotDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DiagnosticName: "diagnosticName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE", + Expected: &SlotDiagnosticId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + DiagnosticName: "dIaGnOsTiCnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDiagnosticIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + } +} + +func TestSegmentsForSlotDiagnosticId(t *testing.T) { + segments := SlotDiagnosticId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotDiagnosticId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_slotdiagnosticdetector.go b/resource-manager/web/2024-11-01/diagnostics/id_slotdiagnosticdetector.go new file mode 100644 index 00000000000..98ccbee3b33 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_slotdiagnosticdetector.go @@ -0,0 +1,157 @@ +package diagnostics + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotDiagnosticDetectorId{}) +} + +var _ resourceids.ResourceId = &SlotDiagnosticDetectorId{} + +// SlotDiagnosticDetectorId is a struct representing the Resource ID for a Slot Diagnostic Detector +type SlotDiagnosticDetectorId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DiagnosticName string + DetectorName string +} + +// NewSlotDiagnosticDetectorID returns a new SlotDiagnosticDetectorId struct +func NewSlotDiagnosticDetectorID(subscriptionId string, resourceGroupName string, siteName string, slotName string, diagnosticName string, detectorName string) SlotDiagnosticDetectorId { + return SlotDiagnosticDetectorId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DiagnosticName: diagnosticName, + DetectorName: detectorName, + } +} + +// ParseSlotDiagnosticDetectorID parses 'input' into a SlotDiagnosticDetectorId +func ParseSlotDiagnosticDetectorID(input string) (*SlotDiagnosticDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDiagnosticDetectorId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDiagnosticDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotDiagnosticDetectorIDInsensitively parses 'input' case-insensitively into a SlotDiagnosticDetectorId +// note: this method should only be used for API response data and not user input +func ParseSlotDiagnosticDetectorIDInsensitively(input string) (*SlotDiagnosticDetectorId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDiagnosticDetectorId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDiagnosticDetectorId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotDiagnosticDetectorId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DiagnosticName, ok = input.Parsed["diagnosticName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "diagnosticName", input) + } + + if id.DetectorName, ok = input.Parsed["detectorName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "detectorName", input) + } + + return nil +} + +// ValidateSlotDiagnosticDetectorID checks that 'input' can be parsed as a Slot Diagnostic Detector ID +func ValidateSlotDiagnosticDetectorID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotDiagnosticDetectorID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Diagnostic Detector ID +func (id SlotDiagnosticDetectorId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/diagnostics/%s/detectors/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DiagnosticName, id.DetectorName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Diagnostic Detector ID +func (id SlotDiagnosticDetectorId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticDiagnostics", "diagnostics", "diagnostics"), + resourceids.UserSpecifiedSegment("diagnosticName", "diagnosticName"), + resourceids.StaticSegment("staticDetectors", "detectors", "detectors"), + resourceids.UserSpecifiedSegment("detectorName", "detectorName"), + } +} + +// String returns a human-readable description of this Slot Diagnostic Detector ID +func (id SlotDiagnosticDetectorId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Diagnostic Name: %q", id.DiagnosticName), + fmt.Sprintf("Detector Name: %q", id.DetectorName), + } + return fmt.Sprintf("Slot Diagnostic Detector (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/diagnostics/id_slotdiagnosticdetector_test.go b/resource-manager/web/2024-11-01/diagnostics/id_slotdiagnosticdetector_test.go new file mode 100644 index 00000000000..bfb6c97fbd8 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/id_slotdiagnosticdetector_test.go @@ -0,0 +1,417 @@ +package diagnostics + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotDiagnosticDetectorId{} + +func TestNewSlotDiagnosticDetectorID(t *testing.T) { + id := NewSlotDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName", "detectorName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.DiagnosticName != "diagnosticName" { + t.Fatalf("Expected %q but got %q for Segment 'DiagnosticName'", id.DiagnosticName, "diagnosticName") + } + + if id.DetectorName != "detectorName" { + t.Fatalf("Expected %q but got %q for Segment 'DetectorName'", id.DetectorName, "detectorName") + } +} + +func TestFormatSlotDiagnosticDetectorID(t *testing.T) { + actual := NewSlotDiagnosticDetectorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "diagnosticName", "detectorName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/detectors/detectorName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotDiagnosticDetectorID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDiagnosticDetectorId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/detectors", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/detectors/detectorName", + Expected: &SlotDiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DiagnosticName: "diagnosticName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/detectors/detectorName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDiagnosticDetectorID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestParseSlotDiagnosticDetectorIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDiagnosticDetectorId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/detectors", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/dEtEcToRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/detectors/detectorName", + Expected: &SlotDiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DiagnosticName: "diagnosticName", + DetectorName: "detectorName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/diagnostics/diagnosticName/detectors/detectorName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/dEtEcToRs/dEtEcToRnAmE", + Expected: &SlotDiagnosticDetectorId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + DiagnosticName: "dIaGnOsTiCnAmE", + DetectorName: "dEtEcToRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dIaGnOsTiCs/dIaGnOsTiCnAmE/dEtEcToRs/dEtEcToRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDiagnosticDetectorIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DiagnosticName != v.Expected.DiagnosticName { + t.Fatalf("Expected %q but got %q for DiagnosticName", v.Expected.DiagnosticName, actual.DiagnosticName) + } + + if actual.DetectorName != v.Expected.DetectorName { + t.Fatalf("Expected %q but got %q for DetectorName", v.Expected.DetectorName, actual.DetectorName) + } + + } +} + +func TestSegmentsForSlotDiagnosticDetectorId(t *testing.T) { + segments := SlotDiagnosticDetectorId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotDiagnosticDetectorId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_executesiteanalysis.go b/resource-manager/web/2024-11-01/diagnostics/method_executesiteanalysis.go new file mode 100644 index 00000000000..d9114e45262 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_executesiteanalysis.go @@ -0,0 +1,91 @@ +package diagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExecuteSiteAnalysisOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticAnalysis +} + +type ExecuteSiteAnalysisOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultExecuteSiteAnalysisOperationOptions() ExecuteSiteAnalysisOperationOptions { + return ExecuteSiteAnalysisOperationOptions{} +} + +func (o ExecuteSiteAnalysisOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ExecuteSiteAnalysisOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ExecuteSiteAnalysisOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// ExecuteSiteAnalysis ... +func (c DiagnosticsClient) ExecuteSiteAnalysis(ctx context.Context, id AnalysisId, options ExecuteSiteAnalysisOperationOptions) (result ExecuteSiteAnalysisOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/execute", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DiagnosticAnalysis + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_executesiteanalysisslot.go b/resource-manager/web/2024-11-01/diagnostics/method_executesiteanalysisslot.go new file mode 100644 index 00000000000..fb43cf7b571 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_executesiteanalysisslot.go @@ -0,0 +1,91 @@ +package diagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExecuteSiteAnalysisSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticAnalysis +} + +type ExecuteSiteAnalysisSlotOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultExecuteSiteAnalysisSlotOperationOptions() ExecuteSiteAnalysisSlotOperationOptions { + return ExecuteSiteAnalysisSlotOperationOptions{} +} + +func (o ExecuteSiteAnalysisSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ExecuteSiteAnalysisSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ExecuteSiteAnalysisSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// ExecuteSiteAnalysisSlot ... +func (c DiagnosticsClient) ExecuteSiteAnalysisSlot(ctx context.Context, id DiagnosticAnalysisId, options ExecuteSiteAnalysisSlotOperationOptions) (result ExecuteSiteAnalysisSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/execute", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DiagnosticAnalysis + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_executesitedetector.go b/resource-manager/web/2024-11-01/diagnostics/method_executesitedetector.go new file mode 100644 index 00000000000..95fdc0e086d --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_executesitedetector.go @@ -0,0 +1,91 @@ +package diagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExecuteSiteDetectorOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticDetectorResponse +} + +type ExecuteSiteDetectorOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultExecuteSiteDetectorOperationOptions() ExecuteSiteDetectorOperationOptions { + return ExecuteSiteDetectorOperationOptions{} +} + +func (o ExecuteSiteDetectorOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ExecuteSiteDetectorOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ExecuteSiteDetectorOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// ExecuteSiteDetector ... +func (c DiagnosticsClient) ExecuteSiteDetector(ctx context.Context, id DiagnosticDetectorId, options ExecuteSiteDetectorOperationOptions) (result ExecuteSiteDetectorOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/execute", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DiagnosticDetectorResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_executesitedetectorslot.go b/resource-manager/web/2024-11-01/diagnostics/method_executesitedetectorslot.go new file mode 100644 index 00000000000..a4058304682 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_executesitedetectorslot.go @@ -0,0 +1,91 @@ +package diagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExecuteSiteDetectorSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticDetectorResponse +} + +type ExecuteSiteDetectorSlotOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultExecuteSiteDetectorSlotOperationOptions() ExecuteSiteDetectorSlotOperationOptions { + return ExecuteSiteDetectorSlotOperationOptions{} +} + +func (o ExecuteSiteDetectorSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ExecuteSiteDetectorSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ExecuteSiteDetectorSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// ExecuteSiteDetectorSlot ... +func (c DiagnosticsClient) ExecuteSiteDetectorSlot(ctx context.Context, id SlotDiagnosticDetectorId, options ExecuteSiteDetectorSlotOperationOptions) (result ExecuteSiteDetectorSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/execute", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DiagnosticDetectorResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_gethostingenvironmentdetectorresponse.go b/resource-manager/web/2024-11-01/diagnostics/method_gethostingenvironmentdetectorresponse.go new file mode 100644 index 00000000000..146dae82a1c --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_gethostingenvironmentdetectorresponse.go @@ -0,0 +1,91 @@ +package diagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetHostingEnvironmentDetectorResponseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorResponse +} + +type GetHostingEnvironmentDetectorResponseOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultGetHostingEnvironmentDetectorResponseOperationOptions() GetHostingEnvironmentDetectorResponseOperationOptions { + return GetHostingEnvironmentDetectorResponseOperationOptions{} +} + +func (o GetHostingEnvironmentDetectorResponseOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetHostingEnvironmentDetectorResponseOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetHostingEnvironmentDetectorResponseOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// GetHostingEnvironmentDetectorResponse ... +func (c DiagnosticsClient) GetHostingEnvironmentDetectorResponse(ctx context.Context, id HostingEnvironmentDetectorId, options GetHostingEnvironmentDetectorResponseOperationOptions) (result GetHostingEnvironmentDetectorResponseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DetectorResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_getsiteanalysis.go b/resource-manager/web/2024-11-01/diagnostics/method_getsiteanalysis.go new file mode 100644 index 00000000000..b730bee1e40 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_getsiteanalysis.go @@ -0,0 +1,53 @@ +package diagnostics + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSiteAnalysisOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AnalysisDefinition +} + +// GetSiteAnalysis ... +func (c DiagnosticsClient) GetSiteAnalysis(ctx context.Context, id AnalysisId) (result GetSiteAnalysisOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AnalysisDefinition + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_getsiteanalysisslot.go b/resource-manager/web/2024-11-01/diagnostics/method_getsiteanalysisslot.go new file mode 100644 index 00000000000..14ca76fb852 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_getsiteanalysisslot.go @@ -0,0 +1,53 @@ +package diagnostics + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSiteAnalysisSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AnalysisDefinition +} + +// GetSiteAnalysisSlot ... +func (c DiagnosticsClient) GetSiteAnalysisSlot(ctx context.Context, id DiagnosticAnalysisId) (result GetSiteAnalysisSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AnalysisDefinition + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_getsitedetector.go b/resource-manager/web/2024-11-01/diagnostics/method_getsitedetector.go new file mode 100644 index 00000000000..e90a21838ca --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_getsitedetector.go @@ -0,0 +1,53 @@ +package diagnostics + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSiteDetectorOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorDefinitionResource +} + +// GetSiteDetector ... +func (c DiagnosticsClient) GetSiteDetector(ctx context.Context, id DiagnosticDetectorId) (result GetSiteDetectorOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DetectorDefinitionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_getsitedetectorresponse.go b/resource-manager/web/2024-11-01/diagnostics/method_getsitedetectorresponse.go new file mode 100644 index 00000000000..91a987796f7 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_getsitedetectorresponse.go @@ -0,0 +1,91 @@ +package diagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSiteDetectorResponseOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorResponse +} + +type GetSiteDetectorResponseOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultGetSiteDetectorResponseOperationOptions() GetSiteDetectorResponseOperationOptions { + return GetSiteDetectorResponseOperationOptions{} +} + +func (o GetSiteDetectorResponseOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetSiteDetectorResponseOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetSiteDetectorResponseOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// GetSiteDetectorResponse ... +func (c DiagnosticsClient) GetSiteDetectorResponse(ctx context.Context, id DetectorId, options GetSiteDetectorResponseOperationOptions) (result GetSiteDetectorResponseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DetectorResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_getsitedetectorresponseslot.go b/resource-manager/web/2024-11-01/diagnostics/method_getsitedetectorresponseslot.go new file mode 100644 index 00000000000..84580774fc2 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_getsitedetectorresponseslot.go @@ -0,0 +1,91 @@ +package diagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSiteDetectorResponseSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorResponse +} + +type GetSiteDetectorResponseSlotOperationOptions struct { + EndTime *string + StartTime *string + TimeGrain *string +} + +func DefaultGetSiteDetectorResponseSlotOperationOptions() GetSiteDetectorResponseSlotOperationOptions { + return GetSiteDetectorResponseSlotOperationOptions{} +} + +func (o GetSiteDetectorResponseSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetSiteDetectorResponseSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetSiteDetectorResponseSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EndTime != nil { + out.Append("endTime", fmt.Sprintf("%v", *o.EndTime)) + } + if o.StartTime != nil { + out.Append("startTime", fmt.Sprintf("%v", *o.StartTime)) + } + if o.TimeGrain != nil { + out.Append("timeGrain", fmt.Sprintf("%v", *o.TimeGrain)) + } + return &out +} + +// GetSiteDetectorResponseSlot ... +func (c DiagnosticsClient) GetSiteDetectorResponseSlot(ctx context.Context, id SlotDetectorId, options GetSiteDetectorResponseSlotOperationOptions) (result GetSiteDetectorResponseSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DetectorResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_getsitedetectorslot.go b/resource-manager/web/2024-11-01/diagnostics/method_getsitedetectorslot.go new file mode 100644 index 00000000000..3f2a72744f1 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_getsitedetectorslot.go @@ -0,0 +1,53 @@ +package diagnostics + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSiteDetectorSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DetectorDefinitionResource +} + +// GetSiteDetectorSlot ... +func (c DiagnosticsClient) GetSiteDetectorSlot(ctx context.Context, id SlotDiagnosticDetectorId) (result GetSiteDetectorSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DetectorDefinitionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_getsitediagnosticcategory.go b/resource-manager/web/2024-11-01/diagnostics/method_getsitediagnosticcategory.go new file mode 100644 index 00000000000..1ddb7a72135 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_getsitediagnosticcategory.go @@ -0,0 +1,53 @@ +package diagnostics + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSiteDiagnosticCategoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticCategory +} + +// GetSiteDiagnosticCategory ... +func (c DiagnosticsClient) GetSiteDiagnosticCategory(ctx context.Context, id DiagnosticId) (result GetSiteDiagnosticCategoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DiagnosticCategory + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_getsitediagnosticcategoryslot.go b/resource-manager/web/2024-11-01/diagnostics/method_getsitediagnosticcategoryslot.go new file mode 100644 index 00000000000..c6572ee2994 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_getsitediagnosticcategoryslot.go @@ -0,0 +1,53 @@ +package diagnostics + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSiteDiagnosticCategorySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DiagnosticCategory +} + +// GetSiteDiagnosticCategorySlot ... +func (c DiagnosticsClient) GetSiteDiagnosticCategorySlot(ctx context.Context, id SlotDiagnosticId) (result GetSiteDiagnosticCategorySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DiagnosticCategory + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_listhostingenvironmentdetectorresponses.go b/resource-manager/web/2024-11-01/diagnostics/method_listhostingenvironmentdetectorresponses.go new file mode 100644 index 00000000000..f112dde06bf --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_listhostingenvironmentdetectorresponses.go @@ -0,0 +1,106 @@ +package diagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListHostingEnvironmentDetectorResponsesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorResponse +} + +type ListHostingEnvironmentDetectorResponsesCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorResponse +} + +type ListHostingEnvironmentDetectorResponsesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListHostingEnvironmentDetectorResponsesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListHostingEnvironmentDetectorResponses ... +func (c DiagnosticsClient) ListHostingEnvironmentDetectorResponses(ctx context.Context, id commonids.AppServiceEnvironmentId) (result ListHostingEnvironmentDetectorResponsesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListHostingEnvironmentDetectorResponsesCustomPager{}, + Path: fmt.Sprintf("%s/detectors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DetectorResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHostingEnvironmentDetectorResponsesComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListHostingEnvironmentDetectorResponsesComplete(ctx context.Context, id commonids.AppServiceEnvironmentId) (ListHostingEnvironmentDetectorResponsesCompleteResult, error) { + return c.ListHostingEnvironmentDetectorResponsesCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) +} + +// ListHostingEnvironmentDetectorResponsesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListHostingEnvironmentDetectorResponsesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, predicate DetectorResponseOperationPredicate) (result ListHostingEnvironmentDetectorResponsesCompleteResult, err error) { + items := make([]DetectorResponse, 0) + + resp, err := c.ListHostingEnvironmentDetectorResponses(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListHostingEnvironmentDetectorResponsesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_listsiteanalyses.go b/resource-manager/web/2024-11-01/diagnostics/method_listsiteanalyses.go new file mode 100644 index 00000000000..91c871786aa --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_listsiteanalyses.go @@ -0,0 +1,105 @@ +package diagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSiteAnalysesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AnalysisDefinition +} + +type ListSiteAnalysesCompleteResult struct { + LatestHttpResponse *http.Response + Items []AnalysisDefinition +} + +type ListSiteAnalysesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteAnalysesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteAnalyses ... +func (c DiagnosticsClient) ListSiteAnalyses(ctx context.Context, id DiagnosticId) (result ListSiteAnalysesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteAnalysesCustomPager{}, + Path: fmt.Sprintf("%s/analyses", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AnalysisDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteAnalysesComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteAnalysesComplete(ctx context.Context, id DiagnosticId) (ListSiteAnalysesCompleteResult, error) { + return c.ListSiteAnalysesCompleteMatchingPredicate(ctx, id, AnalysisDefinitionOperationPredicate{}) +} + +// ListSiteAnalysesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteAnalysesCompleteMatchingPredicate(ctx context.Context, id DiagnosticId, predicate AnalysisDefinitionOperationPredicate) (result ListSiteAnalysesCompleteResult, err error) { + items := make([]AnalysisDefinition, 0) + + resp, err := c.ListSiteAnalyses(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteAnalysesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_listsiteanalysesslot.go b/resource-manager/web/2024-11-01/diagnostics/method_listsiteanalysesslot.go new file mode 100644 index 00000000000..23f4e7d5c77 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_listsiteanalysesslot.go @@ -0,0 +1,105 @@ +package diagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSiteAnalysesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AnalysisDefinition +} + +type ListSiteAnalysesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []AnalysisDefinition +} + +type ListSiteAnalysesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteAnalysesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteAnalysesSlot ... +func (c DiagnosticsClient) ListSiteAnalysesSlot(ctx context.Context, id SlotDiagnosticId) (result ListSiteAnalysesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteAnalysesSlotCustomPager{}, + Path: fmt.Sprintf("%s/analyses", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AnalysisDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteAnalysesSlotComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteAnalysesSlotComplete(ctx context.Context, id SlotDiagnosticId) (ListSiteAnalysesSlotCompleteResult, error) { + return c.ListSiteAnalysesSlotCompleteMatchingPredicate(ctx, id, AnalysisDefinitionOperationPredicate{}) +} + +// ListSiteAnalysesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteAnalysesSlotCompleteMatchingPredicate(ctx context.Context, id SlotDiagnosticId, predicate AnalysisDefinitionOperationPredicate) (result ListSiteAnalysesSlotCompleteResult, err error) { + items := make([]AnalysisDefinition, 0) + + resp, err := c.ListSiteAnalysesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteAnalysesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_listsitedetectorresponses.go b/resource-manager/web/2024-11-01/diagnostics/method_listsitedetectorresponses.go new file mode 100644 index 00000000000..69a5711f698 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_listsitedetectorresponses.go @@ -0,0 +1,106 @@ +package diagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSiteDetectorResponsesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorResponse +} + +type ListSiteDetectorResponsesCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorResponse +} + +type ListSiteDetectorResponsesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteDetectorResponsesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteDetectorResponses ... +func (c DiagnosticsClient) ListSiteDetectorResponses(ctx context.Context, id commonids.AppServiceId) (result ListSiteDetectorResponsesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteDetectorResponsesCustomPager{}, + Path: fmt.Sprintf("%s/detectors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DetectorResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDetectorResponsesComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDetectorResponsesComplete(ctx context.Context, id commonids.AppServiceId) (ListSiteDetectorResponsesCompleteResult, error) { + return c.ListSiteDetectorResponsesCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) +} + +// ListSiteDetectorResponsesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDetectorResponsesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate DetectorResponseOperationPredicate) (result ListSiteDetectorResponsesCompleteResult, err error) { + items := make([]DetectorResponse, 0) + + resp, err := c.ListSiteDetectorResponses(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteDetectorResponsesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_listsitedetectorresponsesslot.go b/resource-manager/web/2024-11-01/diagnostics/method_listsitedetectorresponsesslot.go new file mode 100644 index 00000000000..d50bb289cf4 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_listsitedetectorresponsesslot.go @@ -0,0 +1,105 @@ +package diagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSiteDetectorResponsesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorResponse +} + +type ListSiteDetectorResponsesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorResponse +} + +type ListSiteDetectorResponsesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteDetectorResponsesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteDetectorResponsesSlot ... +func (c DiagnosticsClient) ListSiteDetectorResponsesSlot(ctx context.Context, id SlotId) (result ListSiteDetectorResponsesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteDetectorResponsesSlotCustomPager{}, + Path: fmt.Sprintf("%s/detectors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DetectorResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDetectorResponsesSlotComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDetectorResponsesSlotComplete(ctx context.Context, id SlotId) (ListSiteDetectorResponsesSlotCompleteResult, error) { + return c.ListSiteDetectorResponsesSlotCompleteMatchingPredicate(ctx, id, DetectorResponseOperationPredicate{}) +} + +// ListSiteDetectorResponsesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDetectorResponsesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate DetectorResponseOperationPredicate) (result ListSiteDetectorResponsesSlotCompleteResult, err error) { + items := make([]DetectorResponse, 0) + + resp, err := c.ListSiteDetectorResponsesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteDetectorResponsesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_listsitedetectors.go b/resource-manager/web/2024-11-01/diagnostics/method_listsitedetectors.go new file mode 100644 index 00000000000..ee307b8dfde --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_listsitedetectors.go @@ -0,0 +1,105 @@ +package diagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSiteDetectorsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorDefinitionResource +} + +type ListSiteDetectorsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorDefinitionResource +} + +type ListSiteDetectorsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteDetectorsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteDetectors ... +func (c DiagnosticsClient) ListSiteDetectors(ctx context.Context, id DiagnosticId) (result ListSiteDetectorsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteDetectorsCustomPager{}, + Path: fmt.Sprintf("%s/detectors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DetectorDefinitionResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDetectorsComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDetectorsComplete(ctx context.Context, id DiagnosticId) (ListSiteDetectorsCompleteResult, error) { + return c.ListSiteDetectorsCompleteMatchingPredicate(ctx, id, DetectorDefinitionResourceOperationPredicate{}) +} + +// ListSiteDetectorsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDetectorsCompleteMatchingPredicate(ctx context.Context, id DiagnosticId, predicate DetectorDefinitionResourceOperationPredicate) (result ListSiteDetectorsCompleteResult, err error) { + items := make([]DetectorDefinitionResource, 0) + + resp, err := c.ListSiteDetectors(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteDetectorsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_listsitedetectorsslot.go b/resource-manager/web/2024-11-01/diagnostics/method_listsitedetectorsslot.go new file mode 100644 index 00000000000..eb8b985ebc6 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_listsitedetectorsslot.go @@ -0,0 +1,105 @@ +package diagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSiteDetectorsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DetectorDefinitionResource +} + +type ListSiteDetectorsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []DetectorDefinitionResource +} + +type ListSiteDetectorsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteDetectorsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteDetectorsSlot ... +func (c DiagnosticsClient) ListSiteDetectorsSlot(ctx context.Context, id SlotDiagnosticId) (result ListSiteDetectorsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteDetectorsSlotCustomPager{}, + Path: fmt.Sprintf("%s/detectors", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DetectorDefinitionResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDetectorsSlotComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDetectorsSlotComplete(ctx context.Context, id SlotDiagnosticId) (ListSiteDetectorsSlotCompleteResult, error) { + return c.ListSiteDetectorsSlotCompleteMatchingPredicate(ctx, id, DetectorDefinitionResourceOperationPredicate{}) +} + +// ListSiteDetectorsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDetectorsSlotCompleteMatchingPredicate(ctx context.Context, id SlotDiagnosticId, predicate DetectorDefinitionResourceOperationPredicate) (result ListSiteDetectorsSlotCompleteResult, err error) { + items := make([]DetectorDefinitionResource, 0) + + resp, err := c.ListSiteDetectorsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteDetectorsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_listsitediagnosticcategories.go b/resource-manager/web/2024-11-01/diagnostics/method_listsitediagnosticcategories.go new file mode 100644 index 00000000000..29ffd71a26c --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_listsitediagnosticcategories.go @@ -0,0 +1,106 @@ +package diagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSiteDiagnosticCategoriesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiagnosticCategory +} + +type ListSiteDiagnosticCategoriesCompleteResult struct { + LatestHttpResponse *http.Response + Items []DiagnosticCategory +} + +type ListSiteDiagnosticCategoriesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteDiagnosticCategoriesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteDiagnosticCategories ... +func (c DiagnosticsClient) ListSiteDiagnosticCategories(ctx context.Context, id commonids.AppServiceId) (result ListSiteDiagnosticCategoriesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteDiagnosticCategoriesCustomPager{}, + Path: fmt.Sprintf("%s/diagnostics", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DiagnosticCategory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDiagnosticCategoriesComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesComplete(ctx context.Context, id commonids.AppServiceId) (ListSiteDiagnosticCategoriesCompleteResult, error) { + return c.ListSiteDiagnosticCategoriesCompleteMatchingPredicate(ctx, id, DiagnosticCategoryOperationPredicate{}) +} + +// ListSiteDiagnosticCategoriesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate DiagnosticCategoryOperationPredicate) (result ListSiteDiagnosticCategoriesCompleteResult, err error) { + items := make([]DiagnosticCategory, 0) + + resp, err := c.ListSiteDiagnosticCategories(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteDiagnosticCategoriesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/method_listsitediagnosticcategoriesslot.go b/resource-manager/web/2024-11-01/diagnostics/method_listsitediagnosticcategoriesslot.go new file mode 100644 index 00000000000..1236f4d4ea2 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/method_listsitediagnosticcategoriesslot.go @@ -0,0 +1,105 @@ +package diagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSiteDiagnosticCategoriesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DiagnosticCategory +} + +type ListSiteDiagnosticCategoriesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []DiagnosticCategory +} + +type ListSiteDiagnosticCategoriesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteDiagnosticCategoriesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteDiagnosticCategoriesSlot ... +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesSlot(ctx context.Context, id SlotId) (result ListSiteDiagnosticCategoriesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteDiagnosticCategoriesSlotCustomPager{}, + Path: fmt.Sprintf("%s/diagnostics", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DiagnosticCategory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteDiagnosticCategoriesSlotComplete retrieves all the results into a single object +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesSlotComplete(ctx context.Context, id SlotId) (ListSiteDiagnosticCategoriesSlotCompleteResult, error) { + return c.ListSiteDiagnosticCategoriesSlotCompleteMatchingPredicate(ctx, id, DiagnosticCategoryOperationPredicate{}) +} + +// ListSiteDiagnosticCategoriesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DiagnosticsClient) ListSiteDiagnosticCategoriesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate DiagnosticCategoryOperationPredicate) (result ListSiteDiagnosticCategoriesSlotCompleteResult, err error) { + items := make([]DiagnosticCategory, 0) + + resp, err := c.ListSiteDiagnosticCategoriesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteDiagnosticCategoriesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_abnormaltimeperiod.go b/resource-manager/web/2024-11-01/diagnostics/model_abnormaltimeperiod.go new file mode 100644 index 00000000000..a6df9ee83ab --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_abnormaltimeperiod.go @@ -0,0 +1,41 @@ +package diagnostics + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AbnormalTimePeriod struct { + EndTime *string `json:"endTime,omitempty"` + Events *[]DetectorAbnormalTimePeriod `json:"events,omitempty"` + Solutions *[]Solution `json:"solutions,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *AbnormalTimePeriod) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AbnormalTimePeriod) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *AbnormalTimePeriod) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AbnormalTimePeriod) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_analysisdata.go b/resource-manager/web/2024-11-01/diagnostics/model_analysisdata.go new file mode 100644 index 00000000000..58dc2411c1b --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_analysisdata.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalysisData struct { + Data *[][]NameValuePair `json:"data,omitempty"` + DetectorDefinition *DetectorDefinition `json:"detectorDefinition,omitempty"` + DetectorMetaData *ResponseMetaData `json:"detectorMetaData,omitempty"` + Metrics *[]DiagnosticMetricSet `json:"metrics,omitempty"` + Source *string `json:"source,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_analysisdefinition.go b/resource-manager/web/2024-11-01/diagnostics/model_analysisdefinition.go new file mode 100644 index 00000000000..08e03e1c0a0 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_analysisdefinition.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalysisDefinition struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AnalysisDefinitionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_analysisdefinitionproperties.go b/resource-manager/web/2024-11-01/diagnostics/model_analysisdefinitionproperties.go new file mode 100644 index 00000000000..8a0e57964d3 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_analysisdefinitionproperties.go @@ -0,0 +1,8 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalysisDefinitionProperties struct { + Description *string `json:"description,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_dataprovidermetadata.go b/resource-manager/web/2024-11-01/diagnostics/model_dataprovidermetadata.go new file mode 100644 index 00000000000..c6f80aabe5f --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_dataprovidermetadata.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataProviderMetadata struct { + PropertyBag *[]KeyValuePairStringObject `json:"propertyBag,omitempty"` + ProviderName *string `json:"providerName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_datasource.go b/resource-manager/web/2024-11-01/diagnostics/model_datasource.go new file mode 100644 index 00000000000..5843559ebf5 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_datasource.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataSource struct { + DataSourceUri *[]NameValuePair `json:"dataSourceUri,omitempty"` + Instructions *[]string `json:"instructions,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_datatableresponsecolumn.go b/resource-manager/web/2024-11-01/diagnostics/model_datatableresponsecolumn.go new file mode 100644 index 00000000000..7ff0fb87216 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_datatableresponsecolumn.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataTableResponseColumn struct { + ColumnName *string `json:"columnName,omitempty"` + ColumnType *string `json:"columnType,omitempty"` + DataType *string `json:"dataType,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_datatableresponseobject.go b/resource-manager/web/2024-11-01/diagnostics/model_datatableresponseobject.go new file mode 100644 index 00000000000..579ce5cc5d2 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_datatableresponseobject.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataTableResponseObject struct { + Columns *[]DataTableResponseColumn `json:"columns,omitempty"` + Rows *[][]string `json:"rows,omitempty"` + TableName *string `json:"tableName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_detectorabnormaltimeperiod.go b/resource-manager/web/2024-11-01/diagnostics/model_detectorabnormaltimeperiod.go new file mode 100644 index 00000000000..e0f1933477a --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_detectorabnormaltimeperiod.go @@ -0,0 +1,45 @@ +package diagnostics + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorAbnormalTimePeriod struct { + EndTime *string `json:"endTime,omitempty"` + Message *string `json:"message,omitempty"` + MetaData *[][]NameValuePair `json:"metaData,omitempty"` + Priority *float64 `json:"priority,omitempty"` + Solutions *[]Solution `json:"solutions,omitempty"` + Source *string `json:"source,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Type *IssueType `json:"type,omitempty"` +} + +func (o *DetectorAbnormalTimePeriod) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DetectorAbnormalTimePeriod) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DetectorAbnormalTimePeriod) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DetectorAbnormalTimePeriod) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_detectordefinition.go b/resource-manager/web/2024-11-01/diagnostics/model_detectordefinition.go new file mode 100644 index 00000000000..8bd10bf28f2 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_detectordefinition.go @@ -0,0 +1,11 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorDefinition struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` + Rank *float64 `json:"rank,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_detectordefinitionresource.go b/resource-manager/web/2024-11-01/diagnostics/model_detectordefinitionresource.go new file mode 100644 index 00000000000..3493647c958 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_detectordefinitionresource.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorDefinitionResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DetectorDefinition `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_detectorinfo.go b/resource-manager/web/2024-11-01/diagnostics/model_detectorinfo.go new file mode 100644 index 00000000000..153af1a6eec --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_detectorinfo.go @@ -0,0 +1,16 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorInfo struct { + AnalysisType *[]string `json:"analysisType,omitempty"` + Author *string `json:"author,omitempty"` + Category *string `json:"category,omitempty"` + Description *string `json:"description,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Score *float64 `json:"score,omitempty"` + SupportTopicList *[]SupportTopic `json:"supportTopicList,omitempty"` + Type *DetectorType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_detectorresponse.go b/resource-manager/web/2024-11-01/diagnostics/model_detectorresponse.go new file mode 100644 index 00000000000..3f2ea2b54a4 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_detectorresponse.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorResponse struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DetectorResponseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_detectorresponseproperties.go b/resource-manager/web/2024-11-01/diagnostics/model_detectorresponseproperties.go new file mode 100644 index 00000000000..dbad1bb6b3c --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_detectorresponseproperties.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetectorResponseProperties struct { + DataProvidersMetadata *[]DataProviderMetadata `json:"dataProvidersMetadata,omitempty"` + Dataset *[]DiagnosticData `json:"dataset,omitempty"` + Metadata *DetectorInfo `json:"metadata,omitempty"` + Status *Status `json:"status,omitempty"` + SuggestedUtterances *QueryUtterancesResults `json:"suggestedUtterances,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_diagnosticanalysis.go b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticanalysis.go new file mode 100644 index 00000000000..86feeab70a5 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticanalysis.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticAnalysis struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DiagnosticAnalysisProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_diagnosticanalysisproperties.go b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticanalysisproperties.go new file mode 100644 index 00000000000..e60f737dd9c --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticanalysisproperties.go @@ -0,0 +1,42 @@ +package diagnostics + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticAnalysisProperties struct { + AbnormalTimePeriods *[]AbnormalTimePeriod `json:"abnormalTimePeriods,omitempty"` + EndTime *string `json:"endTime,omitempty"` + NonCorrelatedDetectors *[]DetectorDefinition `json:"nonCorrelatedDetectors,omitempty"` + Payload *[]AnalysisData `json:"payload,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *DiagnosticAnalysisProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticAnalysisProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DiagnosticAnalysisProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticAnalysisProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_diagnosticcategory.go b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticcategory.go new file mode 100644 index 00000000000..edcfc1a5905 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticcategory.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticCategory struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DiagnosticCategoryProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_diagnosticcategoryproperties.go b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticcategoryproperties.go new file mode 100644 index 00000000000..d00339539f9 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticcategoryproperties.go @@ -0,0 +1,8 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticCategoryProperties struct { + Description *string `json:"description,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_diagnosticdata.go b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticdata.go new file mode 100644 index 00000000000..86888b44d22 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticdata.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticData struct { + RenderingProperties *Rendering `json:"renderingProperties,omitempty"` + Table *DataTableResponseObject `json:"table,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_diagnosticdetectorresponse.go b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticdetectorresponse.go new file mode 100644 index 00000000000..7cdae4bd506 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticdetectorresponse.go @@ -0,0 +1,12 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDetectorResponse struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DiagnosticDetectorResponseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_diagnosticdetectorresponseproperties.go b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticdetectorresponseproperties.go new file mode 100644 index 00000000000..b936047e0c4 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticdetectorresponseproperties.go @@ -0,0 +1,45 @@ +package diagnostics + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticDetectorResponseProperties struct { + AbnormalTimePeriods *[]DetectorAbnormalTimePeriod `json:"abnormalTimePeriods,omitempty"` + Data *[][]NameValuePair `json:"data,omitempty"` + DetectorDefinition *DetectorDefinition `json:"detectorDefinition,omitempty"` + EndTime *string `json:"endTime,omitempty"` + IssueDetected *bool `json:"issueDetected,omitempty"` + Metrics *[]DiagnosticMetricSet `json:"metrics,omitempty"` + ResponseMetaData *ResponseMetaData `json:"responseMetaData,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *DiagnosticDetectorResponseProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticDetectorResponseProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DiagnosticDetectorResponseProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticDetectorResponseProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_diagnosticmetricsample.go b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticmetricsample.go new file mode 100644 index 00000000000..1d0bb623c41 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticmetricsample.go @@ -0,0 +1,31 @@ +package diagnostics + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticMetricSample struct { + IsAggregated *bool `json:"isAggregated,omitempty"` + Maximum *float64 `json:"maximum,omitempty"` + Minimum *float64 `json:"minimum,omitempty"` + RoleInstance *string `json:"roleInstance,omitempty"` + Timestamp *string `json:"timestamp,omitempty"` + Total *float64 `json:"total,omitempty"` +} + +func (o *DiagnosticMetricSample) GetTimestampAsTime() (*time.Time, error) { + if o.Timestamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Timestamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticMetricSample) SetTimestampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Timestamp = &formatted +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_diagnosticmetricset.go b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticmetricset.go new file mode 100644 index 00000000000..b1331ff017b --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_diagnosticmetricset.go @@ -0,0 +1,43 @@ +package diagnostics + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnosticMetricSet struct { + EndTime *string `json:"endTime,omitempty"` + Name *string `json:"name,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeGrain *string `json:"timeGrain,omitempty"` + Unit *string `json:"unit,omitempty"` + Values *[]DiagnosticMetricSample `json:"values,omitempty"` +} + +func (o *DiagnosticMetricSet) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticMetricSet) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DiagnosticMetricSet) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DiagnosticMetricSet) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_keyvaluepairstringobject.go b/resource-manager/web/2024-11-01/diagnostics/model_keyvaluepairstringobject.go new file mode 100644 index 00000000000..f1376667ff2 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_keyvaluepairstringobject.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyValuePairStringObject struct { + Key *string `json:"key,omitempty"` + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_namevaluepair.go b/resource-manager/web/2024-11-01/diagnostics/model_namevaluepair.go new file mode 100644 index 00000000000..78a664c6c65 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_namevaluepair.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameValuePair struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_queryutterancesresult.go b/resource-manager/web/2024-11-01/diagnostics/model_queryutterancesresult.go new file mode 100644 index 00000000000..e2f31e703c4 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_queryutterancesresult.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryUtterancesResult struct { + SampleUtterance *SampleUtterance `json:"sampleUtterance,omitempty"` + Score *float64 `json:"score,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_queryutterancesresults.go b/resource-manager/web/2024-11-01/diagnostics/model_queryutterancesresults.go new file mode 100644 index 00000000000..3a4443fd8f5 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_queryutterancesresults.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueryUtterancesResults struct { + Query *string `json:"query,omitempty"` + Results *[]QueryUtterancesResult `json:"results,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_rendering.go b/resource-manager/web/2024-11-01/diagnostics/model_rendering.go new file mode 100644 index 00000000000..a5a796665bc --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_rendering.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Rendering struct { + Description *string `json:"description,omitempty"` + Title *string `json:"title,omitempty"` + Type *RenderingType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_responsemetadata.go b/resource-manager/web/2024-11-01/diagnostics/model_responsemetadata.go new file mode 100644 index 00000000000..e887117c071 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_responsemetadata.go @@ -0,0 +1,8 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResponseMetaData struct { + DataSource *DataSource `json:"dataSource,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_sampleutterance.go b/resource-manager/web/2024-11-01/diagnostics/model_sampleutterance.go new file mode 100644 index 00000000000..a6d9970ed40 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_sampleutterance.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SampleUtterance struct { + Links *[]string `json:"links,omitempty"` + Qid *string `json:"qid,omitempty"` + Text *string `json:"text,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_solution.go b/resource-manager/web/2024-11-01/diagnostics/model_solution.go new file mode 100644 index 00000000000..c19e80a66a9 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_solution.go @@ -0,0 +1,14 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Solution struct { + Data *[][]NameValuePair `json:"data,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Id *float64 `json:"id,omitempty"` + Metadata *[][]NameValuePair `json:"metadata,omitempty"` + Order *float64 `json:"order,omitempty"` + Type *SolutionType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_status.go b/resource-manager/web/2024-11-01/diagnostics/model_status.go new file mode 100644 index 00000000000..3f71907964e --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_status.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Status struct { + Message *string `json:"message,omitempty"` + StatusId *InsightStatus `json:"statusId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/model_supporttopic.go b/resource-manager/web/2024-11-01/diagnostics/model_supporttopic.go new file mode 100644 index 00000000000..096120c069d --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/model_supporttopic.go @@ -0,0 +1,9 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SupportTopic struct { + Id *string `json:"id,omitempty"` + PesId *string `json:"pesId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/diagnostics/predicates.go b/resource-manager/web/2024-11-01/diagnostics/predicates.go new file mode 100644 index 00000000000..660a1c908be --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/predicates.go @@ -0,0 +1,116 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalysisDefinitionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p AnalysisDefinitionOperationPredicate) Matches(input AnalysisDefinition) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type DetectorDefinitionResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DetectorDefinitionResourceOperationPredicate) Matches(input DetectorDefinitionResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type DetectorResponseOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DetectorResponseOperationPredicate) Matches(input DetectorResponse) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type DiagnosticCategoryOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DiagnosticCategoryOperationPredicate) Matches(input DiagnosticCategory) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/diagnostics/version.go b/resource-manager/web/2024-11-01/diagnostics/version.go new file mode 100644 index 00000000000..01efbfc0ae4 --- /dev/null +++ b/resource-manager/web/2024-11-01/diagnostics/version.go @@ -0,0 +1,10 @@ +package diagnostics + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/diagnostics/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/domains/README.md b/resource-manager/web/2024-11-01/domains/README.md new file mode 100644 index 00000000000..f96eb488afb --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/README.md @@ -0,0 +1,307 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/domains` Documentation + +The `domains` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/domains" +``` + + +### Client Initialization + +```go +client := domains.NewDomainsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DomainsClient.CheckAvailability` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := domains.NameIdentifier{ + // ... +} + + +read, err := client.CheckAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName") + +payload := domains.Domain{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DomainsClient.CreateOrUpdateOwnershipIdentifier` + +```go +ctx := context.TODO() +id := domains.NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName", "domainOwnershipIdentifierName") + +payload := domains.DomainOwnershipIdentifier{ + // ... +} + + +read, err := client.CreateOrUpdateOwnershipIdentifier(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.Delete` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName") + +read, err := client.Delete(ctx, id, domains.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.DeleteOwnershipIdentifier` + +```go +ctx := context.TODO() +id := domains.NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName", "domainOwnershipIdentifierName") + +read, err := client.DeleteOwnershipIdentifier(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.Get` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.GetControlCenterSsoRequest` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.GetControlCenterSsoRequest(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.GetOwnershipIdentifier` + +```go +ctx := context.TODO() +id := domains.NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName", "domainOwnershipIdentifierName") + +read, err := client.GetOwnershipIdentifier(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DomainsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DomainsClient.ListOwnershipIdentifiers` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName") + +// alternatively `client.ListOwnershipIdentifiers(ctx, id)` can be used to do batched pagination +items, err := client.ListOwnershipIdentifiersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DomainsClient.ListRecommendations` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := domains.DomainRecommendationSearchParameters{ + // ... +} + + +// alternatively `client.ListRecommendations(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListRecommendationsComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DomainsClient.Renew` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName") + +read, err := client.Renew(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.TransferOut` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName") + +read, err := client.TransferOut(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.Update` + +```go +ctx := context.TODO() +id := domains.NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName") + +payload := domains.DomainPatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DomainsClient.UpdateOwnershipIdentifier` + +```go +ctx := context.TODO() +id := domains.NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName", "domainOwnershipIdentifierName") + +payload := domains.DomainOwnershipIdentifier{ + // ... +} + + +read, err := client.UpdateOwnershipIdentifier(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-11-01/domains/client.go b/resource-manager/web/2024-11-01/domains/client.go new file mode 100644 index 00000000000..59ee394333f --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/client.go @@ -0,0 +1,26 @@ +package domains + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainsClient struct { + Client *resourcemanager.Client +} + +func NewDomainsClientWithBaseURI(sdkApi sdkEnv.Api) (*DomainsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "domains", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DomainsClient: %+v", err) + } + + return &DomainsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/domains/constants.go b/resource-manager/web/2024-11-01/domains/constants.go new file mode 100644 index 00000000000..a2302025ac5 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/constants.go @@ -0,0 +1,407 @@ +package domains + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureResourceType string + +const ( + AzureResourceTypeTrafficManager AzureResourceType = "TrafficManager" + AzureResourceTypeWebsite AzureResourceType = "Website" +) + +func PossibleValuesForAzureResourceType() []string { + return []string{ + string(AzureResourceTypeTrafficManager), + string(AzureResourceTypeWebsite), + } +} + +func (s *AzureResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureResourceType(input string) (*AzureResourceType, error) { + vals := map[string]AzureResourceType{ + "trafficmanager": AzureResourceTypeTrafficManager, + "website": AzureResourceTypeWebsite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureResourceType(input) + return &out, nil +} + +type CustomHostNameDnsRecordType string + +const ( + CustomHostNameDnsRecordTypeA CustomHostNameDnsRecordType = "A" + CustomHostNameDnsRecordTypeCName CustomHostNameDnsRecordType = "CName" +) + +func PossibleValuesForCustomHostNameDnsRecordType() []string { + return []string{ + string(CustomHostNameDnsRecordTypeA), + string(CustomHostNameDnsRecordTypeCName), + } +} + +func (s *CustomHostNameDnsRecordType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomHostNameDnsRecordType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomHostNameDnsRecordType(input string) (*CustomHostNameDnsRecordType, error) { + vals := map[string]CustomHostNameDnsRecordType{ + "a": CustomHostNameDnsRecordTypeA, + "cname": CustomHostNameDnsRecordTypeCName, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomHostNameDnsRecordType(input) + return &out, nil +} + +type DnsType string + +const ( + DnsTypeAzureDns DnsType = "AzureDns" + DnsTypeDefaultDomainRegistrarDns DnsType = "DefaultDomainRegistrarDns" +) + +func PossibleValuesForDnsType() []string { + return []string{ + string(DnsTypeAzureDns), + string(DnsTypeDefaultDomainRegistrarDns), + } +} + +func (s *DnsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDnsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDnsType(input string) (*DnsType, error) { + vals := map[string]DnsType{ + "azuredns": DnsTypeAzureDns, + "defaultdomainregistrardns": DnsTypeDefaultDomainRegistrarDns, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DnsType(input) + return &out, nil +} + +type DomainStatus string + +const ( + DomainStatusActive DomainStatus = "Active" + DomainStatusAwaiting DomainStatus = "Awaiting" + DomainStatusCancelled DomainStatus = "Cancelled" + DomainStatusConfiscated DomainStatus = "Confiscated" + DomainStatusDisabled DomainStatus = "Disabled" + DomainStatusExcluded DomainStatus = "Excluded" + DomainStatusExpired DomainStatus = "Expired" + DomainStatusFailed DomainStatus = "Failed" + DomainStatusHeld DomainStatus = "Held" + DomainStatusJsonConverterFailed DomainStatus = "JsonConverterFailed" + DomainStatusLocked DomainStatus = "Locked" + DomainStatusParked DomainStatus = "Parked" + DomainStatusPending DomainStatus = "Pending" + DomainStatusReserved DomainStatus = "Reserved" + DomainStatusReverted DomainStatus = "Reverted" + DomainStatusSuspended DomainStatus = "Suspended" + DomainStatusTransferred DomainStatus = "Transferred" + DomainStatusUnknown DomainStatus = "Unknown" + DomainStatusUnlocked DomainStatus = "Unlocked" + DomainStatusUnparked DomainStatus = "Unparked" + DomainStatusUpdated DomainStatus = "Updated" +) + +func PossibleValuesForDomainStatus() []string { + return []string{ + string(DomainStatusActive), + string(DomainStatusAwaiting), + string(DomainStatusCancelled), + string(DomainStatusConfiscated), + string(DomainStatusDisabled), + string(DomainStatusExcluded), + string(DomainStatusExpired), + string(DomainStatusFailed), + string(DomainStatusHeld), + string(DomainStatusJsonConverterFailed), + string(DomainStatusLocked), + string(DomainStatusParked), + string(DomainStatusPending), + string(DomainStatusReserved), + string(DomainStatusReverted), + string(DomainStatusSuspended), + string(DomainStatusTransferred), + string(DomainStatusUnknown), + string(DomainStatusUnlocked), + string(DomainStatusUnparked), + string(DomainStatusUpdated), + } +} + +func (s *DomainStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDomainStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDomainStatus(input string) (*DomainStatus, error) { + vals := map[string]DomainStatus{ + "active": DomainStatusActive, + "awaiting": DomainStatusAwaiting, + "cancelled": DomainStatusCancelled, + "confiscated": DomainStatusConfiscated, + "disabled": DomainStatusDisabled, + "excluded": DomainStatusExcluded, + "expired": DomainStatusExpired, + "failed": DomainStatusFailed, + "held": DomainStatusHeld, + "jsonconverterfailed": DomainStatusJsonConverterFailed, + "locked": DomainStatusLocked, + "parked": DomainStatusParked, + "pending": DomainStatusPending, + "reserved": DomainStatusReserved, + "reverted": DomainStatusReverted, + "suspended": DomainStatusSuspended, + "transferred": DomainStatusTransferred, + "unknown": DomainStatusUnknown, + "unlocked": DomainStatusUnlocked, + "unparked": DomainStatusUnparked, + "updated": DomainStatusUpdated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DomainStatus(input) + return &out, nil +} + +type DomainType string + +const ( + DomainTypeRegular DomainType = "Regular" + DomainTypeSoftDeleted DomainType = "SoftDeleted" +) + +func PossibleValuesForDomainType() []string { + return []string{ + string(DomainTypeRegular), + string(DomainTypeSoftDeleted), + } +} + +func (s *DomainType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDomainType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDomainType(input string) (*DomainType, error) { + vals := map[string]DomainType{ + "regular": DomainTypeRegular, + "softdeleted": DomainTypeSoftDeleted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DomainType(input) + return &out, nil +} + +type HostNameType string + +const ( + HostNameTypeManaged HostNameType = "Managed" + HostNameTypeVerified HostNameType = "Verified" +) + +func PossibleValuesForHostNameType() []string { + return []string{ + string(HostNameTypeManaged), + string(HostNameTypeVerified), + } +} + +func (s *HostNameType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostNameType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostNameType(input string) (*HostNameType, error) { + vals := map[string]HostNameType{ + "managed": HostNameTypeManaged, + "verified": HostNameTypeVerified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostNameType(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ResourceNotRenewableReason string + +const ( + ResourceNotRenewableReasonExpirationNotInRenewalTimeRange ResourceNotRenewableReason = "ExpirationNotInRenewalTimeRange" + ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal ResourceNotRenewableReason = "RegistrationStatusNotSupportedForRenewal" + ResourceNotRenewableReasonSubscriptionNotActive ResourceNotRenewableReason = "SubscriptionNotActive" +) + +func PossibleValuesForResourceNotRenewableReason() []string { + return []string{ + string(ResourceNotRenewableReasonExpirationNotInRenewalTimeRange), + string(ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal), + string(ResourceNotRenewableReasonSubscriptionNotActive), + } +} + +func (s *ResourceNotRenewableReason) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceNotRenewableReason(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceNotRenewableReason(input string) (*ResourceNotRenewableReason, error) { + vals := map[string]ResourceNotRenewableReason{ + "expirationnotinrenewaltimerange": ResourceNotRenewableReasonExpirationNotInRenewalTimeRange, + "registrationstatusnotsupportedforrenewal": ResourceNotRenewableReasonRegistrationStatusNotSupportedForRenewal, + "subscriptionnotactive": ResourceNotRenewableReasonSubscriptionNotActive, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceNotRenewableReason(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/domains/id_domain.go b/resource-manager/web/2024-11-01/domains/id_domain.go new file mode 100644 index 00000000000..2aa26691017 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/id_domain.go @@ -0,0 +1,130 @@ +package domains + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DomainId{}) +} + +var _ resourceids.ResourceId = &DomainId{} + +// DomainId is a struct representing the Resource ID for a Domain +type DomainId struct { + SubscriptionId string + ResourceGroupName string + DomainName string +} + +// NewDomainID returns a new DomainId struct +func NewDomainID(subscriptionId string, resourceGroupName string, domainName string) DomainId { + return DomainId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DomainName: domainName, + } +} + +// ParseDomainID parses 'input' into a DomainId +func ParseDomainID(input string) (*DomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&DomainId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DomainId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDomainIDInsensitively parses 'input' case-insensitively into a DomainId +// note: this method should only be used for API response data and not user input +func ParseDomainIDInsensitively(input string) (*DomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&DomainId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DomainId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DomainId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.DomainName, ok = input.Parsed["domainName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "domainName", input) + } + + return nil +} + +// ValidateDomainID checks that 'input' can be parsed as a Domain ID +func ValidateDomainID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDomainID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Domain ID +func (id DomainId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DomainRegistration/domains/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DomainName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Domain ID +func (id DomainId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDomainRegistration", "Microsoft.DomainRegistration", "Microsoft.DomainRegistration"), + resourceids.StaticSegment("staticDomains", "domains", "domains"), + resourceids.UserSpecifiedSegment("domainName", "domainName"), + } +} + +// String returns a human-readable description of this Domain ID +func (id DomainId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Domain Name: %q", id.DomainName), + } + return fmt.Sprintf("Domain (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/domains/id_domain_test.go b/resource-manager/web/2024-11-01/domains/id_domain_test.go new file mode 100644 index 00000000000..e07dc94da5a --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/id_domain_test.go @@ -0,0 +1,282 @@ +package domains + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DomainId{} + +func TestNewDomainID(t *testing.T) { + id := NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.DomainName != "domainName" { + t.Fatalf("Expected %q but got %q for Segment 'DomainName'", id.DomainName, "domainName") + } +} + +func TestFormatDomainID(t *testing.T) { + actual := NewDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDomainID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DomainId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName", + Expected: &DomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DomainName: "domainName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDomainID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DomainName != v.Expected.DomainName { + t.Fatalf("Expected %q but got %q for DomainName", v.Expected.DomainName, actual.DomainName) + } + + } +} + +func TestParseDomainIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DomainId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName", + Expected: &DomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DomainName: "domainName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNnAmE", + Expected: &DomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DomainName: "dOmAiNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDomainIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DomainName != v.Expected.DomainName { + t.Fatalf("Expected %q but got %q for DomainName", v.Expected.DomainName, actual.DomainName) + } + + } +} + +func TestSegmentsForDomainId(t *testing.T) { + segments := DomainId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DomainId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/domains/id_domainownershipidentifier.go b/resource-manager/web/2024-11-01/domains/id_domainownershipidentifier.go new file mode 100644 index 00000000000..d15193f1a7b --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/id_domainownershipidentifier.go @@ -0,0 +1,139 @@ +package domains + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DomainOwnershipIdentifierId{}) +} + +var _ resourceids.ResourceId = &DomainOwnershipIdentifierId{} + +// DomainOwnershipIdentifierId is a struct representing the Resource ID for a Domain Ownership Identifier +type DomainOwnershipIdentifierId struct { + SubscriptionId string + ResourceGroupName string + DomainName string + DomainOwnershipIdentifierName string +} + +// NewDomainOwnershipIdentifierID returns a new DomainOwnershipIdentifierId struct +func NewDomainOwnershipIdentifierID(subscriptionId string, resourceGroupName string, domainName string, domainOwnershipIdentifierName string) DomainOwnershipIdentifierId { + return DomainOwnershipIdentifierId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DomainName: domainName, + DomainOwnershipIdentifierName: domainOwnershipIdentifierName, + } +} + +// ParseDomainOwnershipIdentifierID parses 'input' into a DomainOwnershipIdentifierId +func ParseDomainOwnershipIdentifierID(input string) (*DomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&DomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DomainOwnershipIdentifierId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDomainOwnershipIdentifierIDInsensitively parses 'input' case-insensitively into a DomainOwnershipIdentifierId +// note: this method should only be used for API response data and not user input +func ParseDomainOwnershipIdentifierIDInsensitively(input string) (*DomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&DomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DomainOwnershipIdentifierId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DomainOwnershipIdentifierId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.DomainName, ok = input.Parsed["domainName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "domainName", input) + } + + if id.DomainOwnershipIdentifierName, ok = input.Parsed["domainOwnershipIdentifierName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "domainOwnershipIdentifierName", input) + } + + return nil +} + +// ValidateDomainOwnershipIdentifierID checks that 'input' can be parsed as a Domain Ownership Identifier ID +func ValidateDomainOwnershipIdentifierID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDomainOwnershipIdentifierID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Domain Ownership Identifier ID +func (id DomainOwnershipIdentifierId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DomainRegistration/domains/%s/domainOwnershipIdentifiers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DomainName, id.DomainOwnershipIdentifierName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Domain Ownership Identifier ID +func (id DomainOwnershipIdentifierId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDomainRegistration", "Microsoft.DomainRegistration", "Microsoft.DomainRegistration"), + resourceids.StaticSegment("staticDomains", "domains", "domains"), + resourceids.UserSpecifiedSegment("domainName", "domainName"), + resourceids.StaticSegment("staticDomainOwnershipIdentifiers", "domainOwnershipIdentifiers", "domainOwnershipIdentifiers"), + resourceids.UserSpecifiedSegment("domainOwnershipIdentifierName", "domainOwnershipIdentifierName"), + } +} + +// String returns a human-readable description of this Domain Ownership Identifier ID +func (id DomainOwnershipIdentifierId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Domain Name: %q", id.DomainName), + fmt.Sprintf("Domain Ownership Identifier Name: %q", id.DomainOwnershipIdentifierName), + } + return fmt.Sprintf("Domain Ownership Identifier (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/domains/id_domainownershipidentifier_test.go b/resource-manager/web/2024-11-01/domains/id_domainownershipidentifier_test.go new file mode 100644 index 00000000000..14debd4f5fb --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/id_domainownershipidentifier_test.go @@ -0,0 +1,327 @@ +package domains + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DomainOwnershipIdentifierId{} + +func TestNewDomainOwnershipIdentifierID(t *testing.T) { + id := NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName", "domainOwnershipIdentifierName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.DomainName != "domainName" { + t.Fatalf("Expected %q but got %q for Segment 'DomainName'", id.DomainName, "domainName") + } + + if id.DomainOwnershipIdentifierName != "domainOwnershipIdentifierName" { + t.Fatalf("Expected %q but got %q for Segment 'DomainOwnershipIdentifierName'", id.DomainOwnershipIdentifierName, "domainOwnershipIdentifierName") + } +} + +func TestFormatDomainOwnershipIdentifierID(t *testing.T) { + actual := NewDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "domainName", "domainOwnershipIdentifierName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/domainOwnershipIdentifiers/domainOwnershipIdentifierName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDomainOwnershipIdentifierID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DomainOwnershipIdentifierId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/domainOwnershipIdentifiers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/domainOwnershipIdentifiers/domainOwnershipIdentifierName", + Expected: &DomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DomainName: "domainName", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/domainOwnershipIdentifiers/domainOwnershipIdentifierName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDomainOwnershipIdentifierID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DomainName != v.Expected.DomainName { + t.Fatalf("Expected %q but got %q for DomainName", v.Expected.DomainName, actual.DomainName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestParseDomainOwnershipIdentifierIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DomainOwnershipIdentifierId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/domainOwnershipIdentifiers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNnAmE/dOmAiNoWnErShIpIdEnTiFiErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/domainOwnershipIdentifiers/domainOwnershipIdentifierName", + Expected: &DomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DomainName: "domainName", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.DomainRegistration/domains/domainName/domainOwnershipIdentifiers/domainOwnershipIdentifierName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNnAmE/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErNaMe", + Expected: &DomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DomainName: "dOmAiNnAmE", + DomainOwnershipIdentifierName: "dOmAiNoWnErShIpIdEnTiFiErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/dOmAiNs/dOmAiNnAmE/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDomainOwnershipIdentifierIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DomainName != v.Expected.DomainName { + t.Fatalf("Expected %q but got %q for DomainName", v.Expected.DomainName, actual.DomainName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestSegmentsForDomainOwnershipIdentifierId(t *testing.T) { + segments := DomainOwnershipIdentifierId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DomainOwnershipIdentifierId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/domains/method_checkavailability.go b/resource-manager/web/2024-11-01/domains/method_checkavailability.go new file mode 100644 index 00000000000..1ebced69f7f --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/method_checkavailability.go @@ -0,0 +1,59 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainAvailabilityCheckResult +} + +// CheckAvailability ... +func (c DomainsClient) CheckAvailability(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier) (result CheckAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/checkDomainAvailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DomainAvailabilityCheckResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/domains/method_createorupdate.go b/resource-manager/web/2024-11-01/domains/method_createorupdate.go new file mode 100644 index 00000000000..42b7775e27c --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/method_createorupdate.go @@ -0,0 +1,75 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Domain +} + +// CreateOrUpdate ... +func (c DomainsClient) CreateOrUpdate(ctx context.Context, id DomainId, input Domain) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c DomainsClient) CreateOrUpdateThenPoll(ctx context.Context, id DomainId, input Domain) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/domains/method_createorupdateownershipidentifier.go b/resource-manager/web/2024-11-01/domains/method_createorupdateownershipidentifier.go new file mode 100644 index 00000000000..7a48ce2a59c --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/method_createorupdateownershipidentifier.go @@ -0,0 +1,57 @@ +package domains + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainOwnershipIdentifier +} + +// CreateOrUpdateOwnershipIdentifier ... +func (c DomainsClient) CreateOrUpdateOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input DomainOwnershipIdentifier) (result CreateOrUpdateOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DomainOwnershipIdentifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/domains/method_delete.go b/resource-manager/web/2024-11-01/domains/method_delete.go new file mode 100644 index 00000000000..6d7df4dfe6c --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/method_delete.go @@ -0,0 +1,77 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + ForceHardDeleteDomain *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ForceHardDeleteDomain != nil { + out.Append("forceHardDeleteDomain", fmt.Sprintf("%v", *o.ForceHardDeleteDomain)) + } + return &out +} + +// Delete ... +func (c DomainsClient) Delete(ctx context.Context, id DomainId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/domains/method_deleteownershipidentifier.go b/resource-manager/web/2024-11-01/domains/method_deleteownershipidentifier.go new file mode 100644 index 00000000000..d1367d2232d --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/method_deleteownershipidentifier.go @@ -0,0 +1,47 @@ +package domains + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteOwnershipIdentifier ... +func (c DomainsClient) DeleteOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (result DeleteOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/domains/method_get.go b/resource-manager/web/2024-11-01/domains/method_get.go new file mode 100644 index 00000000000..20619dde9a0 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/method_get.go @@ -0,0 +1,53 @@ +package domains + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Domain +} + +// Get ... +func (c DomainsClient) Get(ctx context.Context, id DomainId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Domain + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/domains/method_getcontrolcenterssorequest.go b/resource-manager/web/2024-11-01/domains/method_getcontrolcenterssorequest.go new file mode 100644 index 00000000000..97001bc7198 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/method_getcontrolcenterssorequest.go @@ -0,0 +1,55 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetControlCenterSsoRequestOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainControlCenterSsoRequest +} + +// GetControlCenterSsoRequest ... +func (c DomainsClient) GetControlCenterSsoRequest(ctx context.Context, id commonids.SubscriptionId) (result GetControlCenterSsoRequestOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/generateSsoRequest", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DomainControlCenterSsoRequest + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/domains/method_getownershipidentifier.go b/resource-manager/web/2024-11-01/domains/method_getownershipidentifier.go new file mode 100644 index 00000000000..b40df756137 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/method_getownershipidentifier.go @@ -0,0 +1,53 @@ +package domains + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainOwnershipIdentifier +} + +// GetOwnershipIdentifier ... +func (c DomainsClient) GetOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId) (result GetOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DomainOwnershipIdentifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/domains/method_list.go b/resource-manager/web/2024-11-01/domains/method_list.go new file mode 100644 index 00000000000..526910a6cc5 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/method_list.go @@ -0,0 +1,106 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Domain +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Domain +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c DomainsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/domains", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Domain `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c DomainsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, DomainOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DomainsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DomainOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Domain, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/domains/method_listbyresourcegroup.go b/resource-manager/web/2024-11-01/domains/method_listbyresourcegroup.go new file mode 100644 index 00000000000..d65249dc0bb --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Domain +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Domain +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c DomainsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/domains", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Domain `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c DomainsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, DomainOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DomainsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate DomainOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Domain, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/domains/method_listownershipidentifiers.go b/resource-manager/web/2024-11-01/domains/method_listownershipidentifiers.go new file mode 100644 index 00000000000..7081d3bef77 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/method_listownershipidentifiers.go @@ -0,0 +1,105 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOwnershipIdentifiersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DomainOwnershipIdentifier +} + +type ListOwnershipIdentifiersCompleteResult struct { + LatestHttpResponse *http.Response + Items []DomainOwnershipIdentifier +} + +type ListOwnershipIdentifiersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListOwnershipIdentifiersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListOwnershipIdentifiers ... +func (c DomainsClient) ListOwnershipIdentifiers(ctx context.Context, id DomainId) (result ListOwnershipIdentifiersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListOwnershipIdentifiersCustomPager{}, + Path: fmt.Sprintf("%s/domainOwnershipIdentifiers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DomainOwnershipIdentifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListOwnershipIdentifiersComplete retrieves all the results into a single object +func (c DomainsClient) ListOwnershipIdentifiersComplete(ctx context.Context, id DomainId) (ListOwnershipIdentifiersCompleteResult, error) { + return c.ListOwnershipIdentifiersCompleteMatchingPredicate(ctx, id, DomainOwnershipIdentifierOperationPredicate{}) +} + +// ListOwnershipIdentifiersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DomainsClient) ListOwnershipIdentifiersCompleteMatchingPredicate(ctx context.Context, id DomainId, predicate DomainOwnershipIdentifierOperationPredicate) (result ListOwnershipIdentifiersCompleteResult, err error) { + items := make([]DomainOwnershipIdentifier, 0) + + resp, err := c.ListOwnershipIdentifiers(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListOwnershipIdentifiersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/domains/method_listrecommendations.go b/resource-manager/web/2024-11-01/domains/method_listrecommendations.go new file mode 100644 index 00000000000..e59b7c9f97c --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/method_listrecommendations.go @@ -0,0 +1,106 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListRecommendationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NameIdentifier +} + +type ListRecommendationsCompleteResult struct { + LatestHttpResponse *http.Response + Items []NameIdentifier +} + +type ListRecommendationsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListRecommendationsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListRecommendations ... +func (c DomainsClient) ListRecommendations(ctx context.Context, id commonids.SubscriptionId, input DomainRecommendationSearchParameters) (result ListRecommendationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListRecommendationsCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/listDomainRecommendations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]NameIdentifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListRecommendationsComplete retrieves all the results into a single object +func (c DomainsClient) ListRecommendationsComplete(ctx context.Context, id commonids.SubscriptionId, input DomainRecommendationSearchParameters) (ListRecommendationsCompleteResult, error) { + return c.ListRecommendationsCompleteMatchingPredicate(ctx, id, input, NameIdentifierOperationPredicate{}) +} + +// ListRecommendationsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DomainsClient) ListRecommendationsCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, input DomainRecommendationSearchParameters, predicate NameIdentifierOperationPredicate) (result ListRecommendationsCompleteResult, err error) { + items := make([]NameIdentifier, 0) + + resp, err := c.ListRecommendations(ctx, id, input) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListRecommendationsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/domains/method_renew.go b/resource-manager/web/2024-11-01/domains/method_renew.go new file mode 100644 index 00000000000..e3a9b6abefd --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/method_renew.go @@ -0,0 +1,49 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RenewOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Renew ... +func (c DomainsClient) Renew(ctx context.Context, id DomainId) (result RenewOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/renew", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/domains/method_transferout.go b/resource-manager/web/2024-11-01/domains/method_transferout.go new file mode 100644 index 00000000000..463bfd22489 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/method_transferout.go @@ -0,0 +1,54 @@ +package domains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TransferOutOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Domain +} + +// TransferOut ... +func (c DomainsClient) TransferOut(ctx context.Context, id DomainId) (result TransferOutOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/transferOut", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Domain + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/domains/method_update.go b/resource-manager/web/2024-11-01/domains/method_update.go new file mode 100644 index 00000000000..08ef3fbeef2 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/method_update.go @@ -0,0 +1,58 @@ +package domains + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Domain +} + +// Update ... +func (c DomainsClient) Update(ctx context.Context, id DomainId, input DomainPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Domain + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/domains/method_updateownershipidentifier.go b/resource-manager/web/2024-11-01/domains/method_updateownershipidentifier.go new file mode 100644 index 00000000000..0ac28164a96 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/method_updateownershipidentifier.go @@ -0,0 +1,57 @@ +package domains + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DomainOwnershipIdentifier +} + +// UpdateOwnershipIdentifier ... +func (c DomainsClient) UpdateOwnershipIdentifier(ctx context.Context, id DomainOwnershipIdentifierId, input DomainOwnershipIdentifier) (result UpdateOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DomainOwnershipIdentifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/domains/model_address.go b/resource-manager/web/2024-11-01/domains/model_address.go new file mode 100644 index 00000000000..7d9d06d5e19 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/model_address.go @@ -0,0 +1,13 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Address struct { + Address1 string `json:"address1"` + Address2 *string `json:"address2,omitempty"` + City string `json:"city"` + Country string `json:"country"` + PostalCode string `json:"postalCode"` + State string `json:"state"` +} diff --git a/resource-manager/web/2024-11-01/domains/model_contact.go b/resource-manager/web/2024-11-01/domains/model_contact.go new file mode 100644 index 00000000000..742a9691f02 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/model_contact.go @@ -0,0 +1,16 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Contact struct { + AddressMailing *Address `json:"addressMailing,omitempty"` + Email string `json:"email"` + Fax *string `json:"fax,omitempty"` + JobTitle *string `json:"jobTitle,omitempty"` + NameFirst string `json:"nameFirst"` + NameLast string `json:"nameLast"` + NameMiddle *string `json:"nameMiddle,omitempty"` + Organization *string `json:"organization,omitempty"` + Phone string `json:"phone"` +} diff --git a/resource-manager/web/2024-11-01/domains/model_domain.go b/resource-manager/web/2024-11-01/domains/model_domain.go new file mode 100644 index 00000000000..2befd74efa0 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/model_domain.go @@ -0,0 +1,14 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Domain struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *DomainProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/domains/model_domainavailabilitycheckresult.go b/resource-manager/web/2024-11-01/domains/model_domainavailabilitycheckresult.go new file mode 100644 index 00000000000..5e189d049c2 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/model_domainavailabilitycheckresult.go @@ -0,0 +1,10 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainAvailabilityCheckResult struct { + Available *bool `json:"available,omitempty"` + DomainType *DomainType `json:"domainType,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/domains/model_domaincontrolcenterssorequest.go b/resource-manager/web/2024-11-01/domains/model_domaincontrolcenterssorequest.go new file mode 100644 index 00000000000..cddf04a4702 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/model_domaincontrolcenterssorequest.go @@ -0,0 +1,10 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainControlCenterSsoRequest struct { + PostParameterKey *string `json:"postParameterKey,omitempty"` + PostParameterValue *string `json:"postParameterValue,omitempty"` + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/domains/model_domainownershipidentifier.go b/resource-manager/web/2024-11-01/domains/model_domainownershipidentifier.go new file mode 100644 index 00000000000..b5ef7bbb733 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/model_domainownershipidentifier.go @@ -0,0 +1,12 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainOwnershipIdentifier struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DomainOwnershipIdentifierProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/domains/model_domainownershipidentifierproperties.go b/resource-manager/web/2024-11-01/domains/model_domainownershipidentifierproperties.go new file mode 100644 index 00000000000..64cd1600998 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/model_domainownershipidentifierproperties.go @@ -0,0 +1,8 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainOwnershipIdentifierProperties struct { + OwnershipId *string `json:"ownershipId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/domains/model_domainpatchresource.go b/resource-manager/web/2024-11-01/domains/model_domainpatchresource.go new file mode 100644 index 00000000000..3a744cc4328 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/model_domainpatchresource.go @@ -0,0 +1,12 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DomainPatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/domains/model_domainpatchresourceproperties.go b/resource-manager/web/2024-11-01/domains/model_domainpatchresourceproperties.go new file mode 100644 index 00000000000..aaec61895f2 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/model_domainpatchresourceproperties.go @@ -0,0 +1,69 @@ +package domains + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainPatchResourceProperties struct { + AuthCode *string `json:"authCode,omitempty"` + AutoRenew *bool `json:"autoRenew,omitempty"` + Consent DomainPurchaseConsent `json:"consent"` + ContactAdmin Contact `json:"contactAdmin"` + ContactBilling Contact `json:"contactBilling"` + ContactRegistrant Contact `json:"contactRegistrant"` + ContactTech Contact `json:"contactTech"` + CreatedTime *string `json:"createdTime,omitempty"` + DnsType *DnsType `json:"dnsType,omitempty"` + DnsZoneId *string `json:"dnsZoneId,omitempty"` + DomainNotRenewableReasons *[]ResourceNotRenewableReason `json:"domainNotRenewableReasons,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + LastRenewedTime *string `json:"lastRenewedTime,omitempty"` + ManagedHostNames *[]HostName `json:"managedHostNames,omitempty"` + NameServers *[]string `json:"nameServers,omitempty"` + Privacy *bool `json:"privacy,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ReadyForDnsRecordManagement *bool `json:"readyForDnsRecordManagement,omitempty"` + RegistrationStatus *DomainStatus `json:"registrationStatus,omitempty"` + TargetDnsType *DnsType `json:"targetDnsType,omitempty"` +} + +func (o *DomainPatchResourceProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainPatchResourceProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *DomainPatchResourceProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainPatchResourceProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *DomainPatchResourceProperties) GetLastRenewedTimeAsTime() (*time.Time, error) { + if o.LastRenewedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRenewedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainPatchResourceProperties) SetLastRenewedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRenewedTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/domains/model_domainproperties.go b/resource-manager/web/2024-11-01/domains/model_domainproperties.go new file mode 100644 index 00000000000..860ae366326 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/model_domainproperties.go @@ -0,0 +1,69 @@ +package domains + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainProperties struct { + AuthCode *string `json:"authCode,omitempty"` + AutoRenew *bool `json:"autoRenew,omitempty"` + Consent DomainPurchaseConsent `json:"consent"` + ContactAdmin Contact `json:"contactAdmin"` + ContactBilling Contact `json:"contactBilling"` + ContactRegistrant Contact `json:"contactRegistrant"` + ContactTech Contact `json:"contactTech"` + CreatedTime *string `json:"createdTime,omitempty"` + DnsType *DnsType `json:"dnsType,omitempty"` + DnsZoneId *string `json:"dnsZoneId,omitempty"` + DomainNotRenewableReasons *[]ResourceNotRenewableReason `json:"domainNotRenewableReasons,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + LastRenewedTime *string `json:"lastRenewedTime,omitempty"` + ManagedHostNames *[]HostName `json:"managedHostNames,omitempty"` + NameServers *[]string `json:"nameServers,omitempty"` + Privacy *bool `json:"privacy,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ReadyForDnsRecordManagement *bool `json:"readyForDnsRecordManagement,omitempty"` + RegistrationStatus *DomainStatus `json:"registrationStatus,omitempty"` + TargetDnsType *DnsType `json:"targetDnsType,omitempty"` +} + +func (o *DomainProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *DomainProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *DomainProperties) GetLastRenewedTimeAsTime() (*time.Time, error) { + if o.LastRenewedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRenewedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainProperties) SetLastRenewedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRenewedTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/domains/model_domainpurchaseconsent.go b/resource-manager/web/2024-11-01/domains/model_domainpurchaseconsent.go new file mode 100644 index 00000000000..afc6cdb7d25 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/model_domainpurchaseconsent.go @@ -0,0 +1,28 @@ +package domains + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainPurchaseConsent struct { + AgreedAt *string `json:"agreedAt,omitempty"` + AgreedBy *string `json:"agreedBy,omitempty"` + AgreementKeys *[]string `json:"agreementKeys,omitempty"` +} + +func (o *DomainPurchaseConsent) GetAgreedAtAsTime() (*time.Time, error) { + if o.AgreedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AgreedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *DomainPurchaseConsent) SetAgreedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AgreedAt = &formatted +} diff --git a/resource-manager/web/2024-11-01/domains/model_domainrecommendationsearchparameters.go b/resource-manager/web/2024-11-01/domains/model_domainrecommendationsearchparameters.go new file mode 100644 index 00000000000..161e93dc3aa --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/model_domainrecommendationsearchparameters.go @@ -0,0 +1,9 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainRecommendationSearchParameters struct { + Keywords *string `json:"keywords,omitempty"` + MaxDomainRecommendations *int64 `json:"maxDomainRecommendations,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/domains/model_hostname.go b/resource-manager/web/2024-11-01/domains/model_hostname.go new file mode 100644 index 00000000000..e81ea21cc80 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/model_hostname.go @@ -0,0 +1,13 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostName struct { + AzureResourceName *string `json:"azureResourceName,omitempty"` + AzureResourceType *AzureResourceType `json:"azureResourceType,omitempty"` + CustomHostNameDnsRecordType *CustomHostNameDnsRecordType `json:"customHostNameDnsRecordType,omitempty"` + HostNameType *HostNameType `json:"hostNameType,omitempty"` + Name *string `json:"name,omitempty"` + SiteNames *[]string `json:"siteNames,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/domains/model_nameidentifier.go b/resource-manager/web/2024-11-01/domains/model_nameidentifier.go new file mode 100644 index 00000000000..8602a243966 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/model_nameidentifier.go @@ -0,0 +1,8 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameIdentifier struct { + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/domains/predicates.go b/resource-manager/web/2024-11-01/domains/predicates.go new file mode 100644 index 00000000000..dcd7e69873b --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/predicates.go @@ -0,0 +1,78 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DomainOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p DomainOperationPredicate) Matches(input Domain) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type DomainOwnershipIdentifierOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DomainOwnershipIdentifierOperationPredicate) Matches(input DomainOwnershipIdentifier) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type NameIdentifierOperationPredicate struct { + Name *string +} + +func (p NameIdentifierOperationPredicate) Matches(input NameIdentifier) bool { + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/domains/version.go b/resource-manager/web/2024-11-01/domains/version.go new file mode 100644 index 00000000000..01d84a4a452 --- /dev/null +++ b/resource-manager/web/2024-11-01/domains/version.go @@ -0,0 +1,10 @@ +package domains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/domains/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/global/README.md b/resource-manager/web/2024-11-01/global/README.md new file mode 100644 index 00000000000..37b6e54f11a --- /dev/null +++ b/resource-manager/web/2024-11-01/global/README.md @@ -0,0 +1,52 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/global` Documentation + +The `global` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/global" +``` + + +### Client Initialization + +```go +client := global.NewGlobalClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `GlobalClient.GetDeletedWebApp` + +```go +ctx := context.TODO() +id := global.NewDeletedSiteID("12345678-1234-9876-4563-123456789012", "deletedSiteId") + +read, err := client.GetDeletedWebApp(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `GlobalClient.GetDeletedWebAppSnapshots` + +```go +ctx := context.TODO() +id := global.NewDeletedSiteID("12345678-1234-9876-4563-123456789012", "deletedSiteId") + +read, err := client.GetDeletedWebAppSnapshots(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-11-01/global/client.go b/resource-manager/web/2024-11-01/global/client.go new file mode 100644 index 00000000000..d760ea36811 --- /dev/null +++ b/resource-manager/web/2024-11-01/global/client.go @@ -0,0 +1,26 @@ +package global + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GlobalClient struct { + Client *resourcemanager.Client +} + +func NewGlobalClientWithBaseURI(sdkApi sdkEnv.Api) (*GlobalClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "global", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating GlobalClient: %+v", err) + } + + return &GlobalClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/global/id_deletedsite.go b/resource-manager/web/2024-11-01/global/id_deletedsite.go new file mode 100644 index 00000000000..4591f6ffafa --- /dev/null +++ b/resource-manager/web/2024-11-01/global/id_deletedsite.go @@ -0,0 +1,121 @@ +package global + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DeletedSiteId{}) +} + +var _ resourceids.ResourceId = &DeletedSiteId{} + +// DeletedSiteId is a struct representing the Resource ID for a Deleted Site +type DeletedSiteId struct { + SubscriptionId string + DeletedSiteId string +} + +// NewDeletedSiteID returns a new DeletedSiteId struct +func NewDeletedSiteID(subscriptionId string, deletedSiteId string) DeletedSiteId { + return DeletedSiteId{ + SubscriptionId: subscriptionId, + DeletedSiteId: deletedSiteId, + } +} + +// ParseDeletedSiteID parses 'input' into a DeletedSiteId +func ParseDeletedSiteID(input string) (*DeletedSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeletedSiteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeletedSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDeletedSiteIDInsensitively parses 'input' case-insensitively into a DeletedSiteId +// note: this method should only be used for API response data and not user input +func ParseDeletedSiteIDInsensitively(input string) (*DeletedSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeletedSiteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeletedSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DeletedSiteId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.DeletedSiteId, ok = input.Parsed["deletedSiteId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deletedSiteId", input) + } + + return nil +} + +// ValidateDeletedSiteID checks that 'input' can be parsed as a Deleted Site ID +func ValidateDeletedSiteID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDeletedSiteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Deleted Site ID +func (id DeletedSiteId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/deletedSites/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.DeletedSiteId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Deleted Site ID +func (id DeletedSiteId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticDeletedSites", "deletedSites", "deletedSites"), + resourceids.UserSpecifiedSegment("deletedSiteId", "deletedSiteId"), + } +} + +// String returns a human-readable description of this Deleted Site ID +func (id DeletedSiteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Deleted Site: %q", id.DeletedSiteId), + } + return fmt.Sprintf("Deleted Site (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/global/id_deletedsite_test.go b/resource-manager/web/2024-11-01/global/id_deletedsite_test.go new file mode 100644 index 00000000000..31318f3d772 --- /dev/null +++ b/resource-manager/web/2024-11-01/global/id_deletedsite_test.go @@ -0,0 +1,237 @@ +package global + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DeletedSiteId{} + +func TestNewDeletedSiteID(t *testing.T) { + id := NewDeletedSiteID("12345678-1234-9876-4563-123456789012", "deletedSiteId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.DeletedSiteId != "deletedSiteId" { + t.Fatalf("Expected %q but got %q for Segment 'DeletedSiteId'", id.DeletedSiteId, "deletedSiteId") + } +} + +func TestFormatDeletedSiteID(t *testing.T) { + actual := NewDeletedSiteID("12345678-1234-9876-4563-123456789012", "deletedSiteId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites/deletedSiteId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDeletedSiteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeletedSiteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites/deletedSiteId", + Expected: &DeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + DeletedSiteId: "deletedSiteId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites/deletedSiteId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeletedSiteID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.DeletedSiteId != v.Expected.DeletedSiteId { + t.Fatalf("Expected %q but got %q for DeletedSiteId", v.Expected.DeletedSiteId, actual.DeletedSiteId) + } + + } +} + +func TestParseDeletedSiteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeletedSiteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/dElEtEdSiTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites/deletedSiteId", + Expected: &DeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + DeletedSiteId: "deletedSiteId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/deletedSites/deletedSiteId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/dElEtEdSiTeS/dElEtEdSiTeId", + Expected: &DeletedSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + DeletedSiteId: "dElEtEdSiTeId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/dElEtEdSiTeS/dElEtEdSiTeId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeletedSiteIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.DeletedSiteId != v.Expected.DeletedSiteId { + t.Fatalf("Expected %q but got %q for DeletedSiteId", v.Expected.DeletedSiteId, actual.DeletedSiteId) + } + + } +} + +func TestSegmentsForDeletedSiteId(t *testing.T) { + segments := DeletedSiteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DeletedSiteId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/global/method_getdeletedwebapp.go b/resource-manager/web/2024-11-01/global/method_getdeletedwebapp.go new file mode 100644 index 00000000000..9daa1017f5c --- /dev/null +++ b/resource-manager/web/2024-11-01/global/method_getdeletedwebapp.go @@ -0,0 +1,53 @@ +package global + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetDeletedWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DeletedSite +} + +// GetDeletedWebApp ... +func (c GlobalClient) GetDeletedWebApp(ctx context.Context, id DeletedSiteId) (result GetDeletedWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DeletedSite + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/global/method_getdeletedwebappsnapshots.go b/resource-manager/web/2024-11-01/global/method_getdeletedwebappsnapshots.go new file mode 100644 index 00000000000..e18e9e44a71 --- /dev/null +++ b/resource-manager/web/2024-11-01/global/method_getdeletedwebappsnapshots.go @@ -0,0 +1,54 @@ +package global + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetDeletedWebAppSnapshotsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +// GetDeletedWebAppSnapshots ... +func (c GlobalClient) GetDeletedWebAppSnapshots(ctx context.Context, id DeletedSiteId) (result GetDeletedWebAppSnapshotsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/snapshots", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []Snapshot + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/global/model_deletedsite.go b/resource-manager/web/2024-11-01/global/model_deletedsite.go new file mode 100644 index 00000000000..99e49e47843 --- /dev/null +++ b/resource-manager/web/2024-11-01/global/model_deletedsite.go @@ -0,0 +1,12 @@ +package global + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedSite struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DeletedSiteProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/global/model_deletedsiteproperties.go b/resource-manager/web/2024-11-01/global/model_deletedsiteproperties.go new file mode 100644 index 00000000000..3c42017baf5 --- /dev/null +++ b/resource-manager/web/2024-11-01/global/model_deletedsiteproperties.go @@ -0,0 +1,15 @@ +package global + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedSiteProperties struct { + DeletedSiteId *int64 `json:"deletedSiteId,omitempty"` + DeletedSiteName *string `json:"deletedSiteName,omitempty"` + DeletedTimestamp *string `json:"deletedTimestamp,omitempty"` + GeoRegionName *string `json:"geoRegionName,omitempty"` + Kind *string `json:"kind,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + Slot *string `json:"slot,omitempty"` + Subscription *string `json:"subscription,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/global/model_snapshot.go b/resource-manager/web/2024-11-01/global/model_snapshot.go new file mode 100644 index 00000000000..6bd24519f97 --- /dev/null +++ b/resource-manager/web/2024-11-01/global/model_snapshot.go @@ -0,0 +1,12 @@ +package global + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Snapshot struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SnapshotProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/global/model_snapshotproperties.go b/resource-manager/web/2024-11-01/global/model_snapshotproperties.go new file mode 100644 index 00000000000..bbae9a0171c --- /dev/null +++ b/resource-manager/web/2024-11-01/global/model_snapshotproperties.go @@ -0,0 +1,8 @@ +package global + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotProperties struct { + Time *string `json:"time,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/global/version.go b/resource-manager/web/2024-11-01/global/version.go new file mode 100644 index 00000000000..9b0e21f151c --- /dev/null +++ b/resource-manager/web/2024-11-01/global/version.go @@ -0,0 +1,10 @@ +package global + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/global/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/README.md b/resource-manager/web/2024-11-01/kubeenvironments/README.md new file mode 100644 index 00000000000..81570d84354 --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/kubeenvironments` Documentation + +The `kubeenvironments` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/kubeenvironments" +``` + + +### Client Initialization + +```go +client := kubeenvironments.NewKubeEnvironmentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `KubeEnvironmentsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := kubeenvironments.NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentName") + +payload := kubeenvironments.KubeEnvironment{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `KubeEnvironmentsClient.Delete` + +```go +ctx := context.TODO() +id := kubeenvironments.NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `KubeEnvironmentsClient.Get` + +```go +ctx := context.TODO() +id := kubeenvironments.NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `KubeEnvironmentsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `KubeEnvironmentsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `KubeEnvironmentsClient.Update` + +```go +ctx := context.TODO() +id := kubeenvironments.NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentName") + +payload := kubeenvironments.KubeEnvironmentPatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-11-01/kubeenvironments/client.go b/resource-manager/web/2024-11-01/kubeenvironments/client.go new file mode 100644 index 00000000000..7bcf8670016 --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/client.go @@ -0,0 +1,26 @@ +package kubeenvironments + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentsClient struct { + Client *resourcemanager.Client +} + +func NewKubeEnvironmentsClientWithBaseURI(sdkApi sdkEnv.Api) (*KubeEnvironmentsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "kubeenvironments", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating KubeEnvironmentsClient: %+v", err) + } + + return &KubeEnvironmentsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/constants.go b/resource-manager/web/2024-11-01/kubeenvironments/constants.go new file mode 100644 index 00000000000..7aaae27eece --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/constants.go @@ -0,0 +1,157 @@ +package kubeenvironments + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontEndServiceType string + +const ( + FrontEndServiceTypeLoadBalancer FrontEndServiceType = "LoadBalancer" + FrontEndServiceTypeNodePort FrontEndServiceType = "NodePort" +) + +func PossibleValuesForFrontEndServiceType() []string { + return []string{ + string(FrontEndServiceTypeLoadBalancer), + string(FrontEndServiceTypeNodePort), + } +} + +func (s *FrontEndServiceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFrontEndServiceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFrontEndServiceType(input string) (*FrontEndServiceType, error) { + vals := map[string]FrontEndServiceType{ + "loadbalancer": FrontEndServiceTypeLoadBalancer, + "nodeport": FrontEndServiceTypeNodePort, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FrontEndServiceType(input) + return &out, nil +} + +type KubeEnvironmentProvisioningState string + +const ( + KubeEnvironmentProvisioningStateCanceled KubeEnvironmentProvisioningState = "Canceled" + KubeEnvironmentProvisioningStateFailed KubeEnvironmentProvisioningState = "Failed" + KubeEnvironmentProvisioningStateInfrastructureSetupComplete KubeEnvironmentProvisioningState = "InfrastructureSetupComplete" + KubeEnvironmentProvisioningStateInfrastructureSetupInProgress KubeEnvironmentProvisioningState = "InfrastructureSetupInProgress" + KubeEnvironmentProvisioningStateInitializationInProgress KubeEnvironmentProvisioningState = "InitializationInProgress" + KubeEnvironmentProvisioningStateScheduledForDelete KubeEnvironmentProvisioningState = "ScheduledForDelete" + KubeEnvironmentProvisioningStateSucceeded KubeEnvironmentProvisioningState = "Succeeded" + KubeEnvironmentProvisioningStateUpgradeFailed KubeEnvironmentProvisioningState = "UpgradeFailed" + KubeEnvironmentProvisioningStateUpgradeRequested KubeEnvironmentProvisioningState = "UpgradeRequested" + KubeEnvironmentProvisioningStateWaiting KubeEnvironmentProvisioningState = "Waiting" +) + +func PossibleValuesForKubeEnvironmentProvisioningState() []string { + return []string{ + string(KubeEnvironmentProvisioningStateCanceled), + string(KubeEnvironmentProvisioningStateFailed), + string(KubeEnvironmentProvisioningStateInfrastructureSetupComplete), + string(KubeEnvironmentProvisioningStateInfrastructureSetupInProgress), + string(KubeEnvironmentProvisioningStateInitializationInProgress), + string(KubeEnvironmentProvisioningStateScheduledForDelete), + string(KubeEnvironmentProvisioningStateSucceeded), + string(KubeEnvironmentProvisioningStateUpgradeFailed), + string(KubeEnvironmentProvisioningStateUpgradeRequested), + string(KubeEnvironmentProvisioningStateWaiting), + } +} + +func (s *KubeEnvironmentProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubeEnvironmentProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubeEnvironmentProvisioningState(input string) (*KubeEnvironmentProvisioningState, error) { + vals := map[string]KubeEnvironmentProvisioningState{ + "canceled": KubeEnvironmentProvisioningStateCanceled, + "failed": KubeEnvironmentProvisioningStateFailed, + "infrastructuresetupcomplete": KubeEnvironmentProvisioningStateInfrastructureSetupComplete, + "infrastructuresetupinprogress": KubeEnvironmentProvisioningStateInfrastructureSetupInProgress, + "initializationinprogress": KubeEnvironmentProvisioningStateInitializationInProgress, + "scheduledfordelete": KubeEnvironmentProvisioningStateScheduledForDelete, + "succeeded": KubeEnvironmentProvisioningStateSucceeded, + "upgradefailed": KubeEnvironmentProvisioningStateUpgradeFailed, + "upgraderequested": KubeEnvironmentProvisioningStateUpgradeRequested, + "waiting": KubeEnvironmentProvisioningStateWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubeEnvironmentProvisioningState(input) + return &out, nil +} + +type StorageType string + +const ( + StorageTypeLocalNode StorageType = "LocalNode" + StorageTypeNetworkFileSystem StorageType = "NetworkFileSystem" +) + +func PossibleValuesForStorageType() []string { + return []string{ + string(StorageTypeLocalNode), + string(StorageTypeNetworkFileSystem), + } +} + +func (s *StorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageType(input string) (*StorageType, error) { + vals := map[string]StorageType{ + "localnode": StorageTypeLocalNode, + "networkfilesystem": StorageTypeNetworkFileSystem, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageType(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/id_kubeenvironment.go b/resource-manager/web/2024-11-01/kubeenvironments/id_kubeenvironment.go new file mode 100644 index 00000000000..73c1a578e48 --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/id_kubeenvironment.go @@ -0,0 +1,130 @@ +package kubeenvironments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&KubeEnvironmentId{}) +} + +var _ resourceids.ResourceId = &KubeEnvironmentId{} + +// KubeEnvironmentId is a struct representing the Resource ID for a Kube Environment +type KubeEnvironmentId struct { + SubscriptionId string + ResourceGroupName string + KubeEnvironmentName string +} + +// NewKubeEnvironmentID returns a new KubeEnvironmentId struct +func NewKubeEnvironmentID(subscriptionId string, resourceGroupName string, kubeEnvironmentName string) KubeEnvironmentId { + return KubeEnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + KubeEnvironmentName: kubeEnvironmentName, + } +} + +// ParseKubeEnvironmentID parses 'input' into a KubeEnvironmentId +func ParseKubeEnvironmentID(input string) (*KubeEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&KubeEnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KubeEnvironmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseKubeEnvironmentIDInsensitively parses 'input' case-insensitively into a KubeEnvironmentId +// note: this method should only be used for API response data and not user input +func ParseKubeEnvironmentIDInsensitively(input string) (*KubeEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&KubeEnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KubeEnvironmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *KubeEnvironmentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.KubeEnvironmentName, ok = input.Parsed["kubeEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "kubeEnvironmentName", input) + } + + return nil +} + +// ValidateKubeEnvironmentID checks that 'input' can be parsed as a Kube Environment ID +func ValidateKubeEnvironmentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseKubeEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Kube Environment ID +func (id KubeEnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/kubeEnvironments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.KubeEnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Kube Environment ID +func (id KubeEnvironmentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticKubeEnvironments", "kubeEnvironments", "kubeEnvironments"), + resourceids.UserSpecifiedSegment("kubeEnvironmentName", "kubeEnvironmentName"), + } +} + +// String returns a human-readable description of this Kube Environment ID +func (id KubeEnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Kube Environment Name: %q", id.KubeEnvironmentName), + } + return fmt.Sprintf("Kube Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/id_kubeenvironment_test.go b/resource-manager/web/2024-11-01/kubeenvironments/id_kubeenvironment_test.go new file mode 100644 index 00000000000..e209728abab --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/id_kubeenvironment_test.go @@ -0,0 +1,282 @@ +package kubeenvironments + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &KubeEnvironmentId{} + +func TestNewKubeEnvironmentID(t *testing.T) { + id := NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.KubeEnvironmentName != "kubeEnvironmentName" { + t.Fatalf("Expected %q but got %q for Segment 'KubeEnvironmentName'", id.KubeEnvironmentName, "kubeEnvironmentName") + } +} + +func TestFormatKubeEnvironmentID(t *testing.T) { + actual := NewKubeEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "kubeEnvironmentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments/kubeEnvironmentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseKubeEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KubeEnvironmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments/kubeEnvironmentName", + Expected: &KubeEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + KubeEnvironmentName: "kubeEnvironmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments/kubeEnvironmentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKubeEnvironmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.KubeEnvironmentName != v.Expected.KubeEnvironmentName { + t.Fatalf("Expected %q but got %q for KubeEnvironmentName", v.Expected.KubeEnvironmentName, actual.KubeEnvironmentName) + } + + } +} + +func TestParseKubeEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KubeEnvironmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/kUbEeNvIrOnMeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments/kubeEnvironmentName", + Expected: &KubeEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + KubeEnvironmentName: "kubeEnvironmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/kubeEnvironments/kubeEnvironmentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/kUbEeNvIrOnMeNtS/kUbEeNvIrOnMeNtNaMe", + Expected: &KubeEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + KubeEnvironmentName: "kUbEeNvIrOnMeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/kUbEeNvIrOnMeNtS/kUbEeNvIrOnMeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKubeEnvironmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.KubeEnvironmentName != v.Expected.KubeEnvironmentName { + t.Fatalf("Expected %q but got %q for KubeEnvironmentName", v.Expected.KubeEnvironmentName, actual.KubeEnvironmentName) + } + + } +} + +func TestSegmentsForKubeEnvironmentId(t *testing.T) { + segments := KubeEnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("KubeEnvironmentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/method_createorupdate.go b/resource-manager/web/2024-11-01/kubeenvironments/method_createorupdate.go new file mode 100644 index 00000000000..e6af85b34b3 --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/method_createorupdate.go @@ -0,0 +1,75 @@ +package kubeenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *KubeEnvironment +} + +// CreateOrUpdate ... +func (c KubeEnvironmentsClient) CreateOrUpdate(ctx context.Context, id KubeEnvironmentId, input KubeEnvironment) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c KubeEnvironmentsClient) CreateOrUpdateThenPoll(ctx context.Context, id KubeEnvironmentId, input KubeEnvironment) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/method_delete.go b/resource-manager/web/2024-11-01/kubeenvironments/method_delete.go new file mode 100644 index 00000000000..9a86ed36127 --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/method_delete.go @@ -0,0 +1,71 @@ +package kubeenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c KubeEnvironmentsClient) Delete(ctx context.Context, id KubeEnvironmentId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c KubeEnvironmentsClient) DeleteThenPoll(ctx context.Context, id KubeEnvironmentId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/method_get.go b/resource-manager/web/2024-11-01/kubeenvironments/method_get.go new file mode 100644 index 00000000000..4dde6e8cfea --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/method_get.go @@ -0,0 +1,53 @@ +package kubeenvironments + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KubeEnvironment +} + +// Get ... +func (c KubeEnvironmentsClient) Get(ctx context.Context, id KubeEnvironmentId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model KubeEnvironment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/method_listbyresourcegroup.go b/resource-manager/web/2024-11-01/kubeenvironments/method_listbyresourcegroup.go new file mode 100644 index 00000000000..5b378fe3212 --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package kubeenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]KubeEnvironment +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []KubeEnvironment +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c KubeEnvironmentsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/kubeEnvironments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]KubeEnvironment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c KubeEnvironmentsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, KubeEnvironmentOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c KubeEnvironmentsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate KubeEnvironmentOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]KubeEnvironment, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/method_listbysubscription.go b/resource-manager/web/2024-11-01/kubeenvironments/method_listbysubscription.go new file mode 100644 index 00000000000..a315f826e7c --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/method_listbysubscription.go @@ -0,0 +1,106 @@ +package kubeenvironments + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]KubeEnvironment +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []KubeEnvironment +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c KubeEnvironmentsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/kubeEnvironments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]KubeEnvironment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c KubeEnvironmentsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, KubeEnvironmentOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c KubeEnvironmentsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate KubeEnvironmentOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]KubeEnvironment, 0) + + resp, err := c.ListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/method_update.go b/resource-manager/web/2024-11-01/kubeenvironments/method_update.go new file mode 100644 index 00000000000..7192afd41a4 --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/method_update.go @@ -0,0 +1,58 @@ +package kubeenvironments + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KubeEnvironment +} + +// Update ... +func (c KubeEnvironmentsClient) Update(ctx context.Context, id KubeEnvironmentId, input KubeEnvironmentPatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model KubeEnvironment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/model_applogsconfiguration.go b/resource-manager/web/2024-11-01/kubeenvironments/model_applogsconfiguration.go new file mode 100644 index 00000000000..1d001f4eb4b --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/model_applogsconfiguration.go @@ -0,0 +1,9 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppLogsConfiguration struct { + Destination *string `json:"destination,omitempty"` + LogAnalyticsConfiguration *LogAnalyticsConfiguration `json:"logAnalyticsConfiguration,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/model_arcconfiguration.go b/resource-manager/web/2024-11-01/kubeenvironments/model_arcconfiguration.go new file mode 100644 index 00000000000..a3340b2ff85 --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/model_arcconfiguration.go @@ -0,0 +1,14 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArcConfiguration struct { + ArtifactStorageAccessMode *string `json:"artifactStorageAccessMode,omitempty"` + ArtifactStorageClassName *string `json:"artifactStorageClassName,omitempty"` + ArtifactStorageMountPath *string `json:"artifactStorageMountPath,omitempty"` + ArtifactStorageNodeName *string `json:"artifactStorageNodeName,omitempty"` + ArtifactsStorageType *StorageType `json:"artifactsStorageType,omitempty"` + FrontEndServiceConfiguration *FrontEndConfiguration `json:"frontEndServiceConfiguration,omitempty"` + KubeConfig *string `json:"kubeConfig,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/model_containerappsconfiguration.go b/resource-manager/web/2024-11-01/kubeenvironments/model_containerappsconfiguration.go new file mode 100644 index 00000000000..8d72c14cee2 --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/model_containerappsconfiguration.go @@ -0,0 +1,13 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerAppsConfiguration struct { + AppSubnetResourceId *string `json:"appSubnetResourceId,omitempty"` + ControlPlaneSubnetResourceId *string `json:"controlPlaneSubnetResourceId,omitempty"` + DaprAIInstrumentationKey *string `json:"daprAIInstrumentationKey,omitempty"` + DockerBridgeCidr *string `json:"dockerBridgeCidr,omitempty"` + PlatformReservedCidr *string `json:"platformReservedCidr,omitempty"` + PlatformReservedDnsIP *string `json:"platformReservedDnsIP,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/model_extendedlocation.go b/resource-manager/web/2024-11-01/kubeenvironments/model_extendedlocation.go new file mode 100644 index 00000000000..616cec03daa --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/model_extendedlocation.go @@ -0,0 +1,9 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/model_frontendconfiguration.go b/resource-manager/web/2024-11-01/kubeenvironments/model_frontendconfiguration.go new file mode 100644 index 00000000000..c19181a1257 --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/model_frontendconfiguration.go @@ -0,0 +1,8 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FrontEndConfiguration struct { + Kind *FrontEndServiceType `json:"kind,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/model_kubeenvironment.go b/resource-manager/web/2024-11-01/kubeenvironments/model_kubeenvironment.go new file mode 100644 index 00000000000..d57722efdef --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/model_kubeenvironment.go @@ -0,0 +1,15 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironment struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *KubeEnvironmentProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/model_kubeenvironmentpatchresource.go b/resource-manager/web/2024-11-01/kubeenvironments/model_kubeenvironmentpatchresource.go new file mode 100644 index 00000000000..912ea3cb9c4 --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/model_kubeenvironmentpatchresource.go @@ -0,0 +1,12 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *KubeEnvironmentPatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/model_kubeenvironmentpatchresourceproperties.go b/resource-manager/web/2024-11-01/kubeenvironments/model_kubeenvironmentpatchresourceproperties.go new file mode 100644 index 00000000000..49c9bfaabc1 --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/model_kubeenvironmentpatchresourceproperties.go @@ -0,0 +1,16 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentPatchResourceProperties struct { + AksResourceID *string `json:"aksResourceID,omitempty"` + AppLogsConfiguration *AppLogsConfiguration `json:"appLogsConfiguration,omitempty"` + ArcConfiguration *ArcConfiguration `json:"arcConfiguration,omitempty"` + ContainerAppsConfiguration *ContainerAppsConfiguration `json:"containerAppsConfiguration,omitempty"` + DefaultDomain *string `json:"defaultDomain,omitempty"` + DeploymentErrors *string `json:"deploymentErrors,omitempty"` + InternalLoadBalancerEnabled *bool `json:"internalLoadBalancerEnabled,omitempty"` + ProvisioningState *KubeEnvironmentProvisioningState `json:"provisioningState,omitempty"` + StaticIP *string `json:"staticIp,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/model_kubeenvironmentproperties.go b/resource-manager/web/2024-11-01/kubeenvironments/model_kubeenvironmentproperties.go new file mode 100644 index 00000000000..c56c83c5220 --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/model_kubeenvironmentproperties.go @@ -0,0 +1,17 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentProperties struct { + AksResourceID *string `json:"aksResourceID,omitempty"` + AppLogsConfiguration *AppLogsConfiguration `json:"appLogsConfiguration,omitempty"` + ArcConfiguration *ArcConfiguration `json:"arcConfiguration,omitempty"` + ContainerAppsConfiguration *ContainerAppsConfiguration `json:"containerAppsConfiguration,omitempty"` + DefaultDomain *string `json:"defaultDomain,omitempty"` + DeploymentErrors *string `json:"deploymentErrors,omitempty"` + EnvironmentType *string `json:"environmentType,omitempty"` + InternalLoadBalancerEnabled *bool `json:"internalLoadBalancerEnabled,omitempty"` + ProvisioningState *KubeEnvironmentProvisioningState `json:"provisioningState,omitempty"` + StaticIP *string `json:"staticIp,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/model_loganalyticsconfiguration.go b/resource-manager/web/2024-11-01/kubeenvironments/model_loganalyticsconfiguration.go new file mode 100644 index 00000000000..0e361710361 --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/model_loganalyticsconfiguration.go @@ -0,0 +1,9 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LogAnalyticsConfiguration struct { + CustomerId *string `json:"customerId,omitempty"` + SharedKey *string `json:"sharedKey,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/predicates.go b/resource-manager/web/2024-11-01/kubeenvironments/predicates.go new file mode 100644 index 00000000000..cf25ede1f18 --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/predicates.go @@ -0,0 +1,37 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeEnvironmentOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p KubeEnvironmentOperationPredicate) Matches(input KubeEnvironment) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/kubeenvironments/version.go b/resource-manager/web/2024-11-01/kubeenvironments/version.go new file mode 100644 index 00000000000..0e2c540ce0c --- /dev/null +++ b/resource-manager/web/2024-11-01/kubeenvironments/version.go @@ -0,0 +1,10 @@ +package kubeenvironments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/kubeenvironments/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/provider/README.md b/resource-manager/web/2024-11-01/provider/README.md new file mode 100644 index 00000000000..19dcca1e91d --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/README.md @@ -0,0 +1,123 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/provider` Documentation + +The `provider` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/provider" +``` + + +### Client Initialization + +```go +client := provider.NewProviderClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProviderClient.GetAvailableStacks` + +```go +ctx := context.TODO() + + +// alternatively `client.GetAvailableStacks(ctx, provider.DefaultGetAvailableStacksOperationOptions())` can be used to do batched pagination +items, err := client.GetAvailableStacksComplete(ctx, provider.DefaultGetAvailableStacksOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProviderClient.GetAvailableStacksOnPrem` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.GetAvailableStacksOnPrem(ctx, id, provider.DefaultGetAvailableStacksOnPremOperationOptions())` can be used to do batched pagination +items, err := client.GetAvailableStacksOnPremComplete(ctx, id, provider.DefaultGetAvailableStacksOnPremOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProviderClient.GetFunctionAppStacks` + +```go +ctx := context.TODO() + + +// alternatively `client.GetFunctionAppStacks(ctx, provider.DefaultGetFunctionAppStacksOperationOptions())` can be used to do batched pagination +items, err := client.GetFunctionAppStacksComplete(ctx, provider.DefaultGetFunctionAppStacksOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProviderClient.GetFunctionAppStacksForLocation` + +```go +ctx := context.TODO() +id := provider.NewLocationID("locationName") + +// alternatively `client.GetFunctionAppStacksForLocation(ctx, id, provider.DefaultGetFunctionAppStacksForLocationOperationOptions())` can be used to do batched pagination +items, err := client.GetFunctionAppStacksForLocationComplete(ctx, id, provider.DefaultGetFunctionAppStacksForLocationOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProviderClient.GetWebAppStacks` + +```go +ctx := context.TODO() + + +// alternatively `client.GetWebAppStacks(ctx, provider.DefaultGetWebAppStacksOperationOptions())` can be used to do batched pagination +items, err := client.GetWebAppStacksComplete(ctx, provider.DefaultGetWebAppStacksOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ProviderClient.GetWebAppStacksForLocation` + +```go +ctx := context.TODO() +id := provider.NewLocationID("locationName") + +// alternatively `client.GetWebAppStacksForLocation(ctx, id, provider.DefaultGetWebAppStacksForLocationOperationOptions())` can be used to do batched pagination +items, err := client.GetWebAppStacksForLocationComplete(ctx, id, provider.DefaultGetWebAppStacksForLocationOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-11-01/provider/client.go b/resource-manager/web/2024-11-01/provider/client.go new file mode 100644 index 00000000000..b982cfdab87 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/client.go @@ -0,0 +1,26 @@ +package provider + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProviderClient struct { + Client *resourcemanager.Client +} + +func NewProviderClientWithBaseURI(sdkApi sdkEnv.Api) (*ProviderClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "provider", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProviderClient: %+v", err) + } + + return &ProviderClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/provider/constants.go b/resource-manager/web/2024-11-01/provider/constants.go new file mode 100644 index 00000000000..27444d5870f --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/constants.go @@ -0,0 +1,145 @@ +package provider + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProviderOsTypeSelected string + +const ( + ProviderOsTypeSelectedAll ProviderOsTypeSelected = "All" + ProviderOsTypeSelectedLinux ProviderOsTypeSelected = "Linux" + ProviderOsTypeSelectedLinuxFunctions ProviderOsTypeSelected = "LinuxFunctions" + ProviderOsTypeSelectedWindows ProviderOsTypeSelected = "Windows" + ProviderOsTypeSelectedWindowsFunctions ProviderOsTypeSelected = "WindowsFunctions" +) + +func PossibleValuesForProviderOsTypeSelected() []string { + return []string{ + string(ProviderOsTypeSelectedAll), + string(ProviderOsTypeSelectedLinux), + string(ProviderOsTypeSelectedLinuxFunctions), + string(ProviderOsTypeSelectedWindows), + string(ProviderOsTypeSelectedWindowsFunctions), + } +} + +func (s *ProviderOsTypeSelected) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProviderOsTypeSelected(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProviderOsTypeSelected(input string) (*ProviderOsTypeSelected, error) { + vals := map[string]ProviderOsTypeSelected{ + "all": ProviderOsTypeSelectedAll, + "linux": ProviderOsTypeSelectedLinux, + "linuxfunctions": ProviderOsTypeSelectedLinuxFunctions, + "windows": ProviderOsTypeSelectedWindows, + "windowsfunctions": ProviderOsTypeSelectedWindowsFunctions, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProviderOsTypeSelected(input) + return &out, nil +} + +type ProviderStackOsType string + +const ( + ProviderStackOsTypeAll ProviderStackOsType = "All" + ProviderStackOsTypeLinux ProviderStackOsType = "Linux" + ProviderStackOsTypeWindows ProviderStackOsType = "Windows" +) + +func PossibleValuesForProviderStackOsType() []string { + return []string{ + string(ProviderStackOsTypeAll), + string(ProviderStackOsTypeLinux), + string(ProviderStackOsTypeWindows), + } +} + +func (s *ProviderStackOsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProviderStackOsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProviderStackOsType(input string) (*ProviderStackOsType, error) { + vals := map[string]ProviderStackOsType{ + "all": ProviderStackOsTypeAll, + "linux": ProviderStackOsTypeLinux, + "windows": ProviderStackOsTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProviderStackOsType(input) + return &out, nil +} + +type StackPreferredOs string + +const ( + StackPreferredOsLinux StackPreferredOs = "Linux" + StackPreferredOsWindows StackPreferredOs = "Windows" +) + +func PossibleValuesForStackPreferredOs() []string { + return []string{ + string(StackPreferredOsLinux), + string(StackPreferredOsWindows), + } +} + +func (s *StackPreferredOs) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStackPreferredOs(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStackPreferredOs(input string) (*StackPreferredOs, error) { + vals := map[string]StackPreferredOs{ + "linux": StackPreferredOsLinux, + "windows": StackPreferredOsWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StackPreferredOs(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/provider/id_location.go b/resource-manager/web/2024-11-01/provider/id_location.go new file mode 100644 index 00000000000..73ea1c40a58 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/id_location.go @@ -0,0 +1,112 @@ +package provider + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(locationName string) LocationId { + return LocationId{ + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/providers/Microsoft.Web/locations/%s" + return fmt.Sprintf(fmtString, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/provider/id_location_test.go b/resource-manager/web/2024-11-01/provider/id_location_test.go new file mode 100644 index 00000000000..e0391552ed6 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/id_location_test.go @@ -0,0 +1,192 @@ +package provider + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("locationName") + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("locationName").ID() + expected := "/providers/Microsoft.Web/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Web/locations/locationName", + Expected: &LocationId{ + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Web/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Web/locations/locationName", + Expected: &LocationId{ + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Web/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &LocationId{ + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/provider/method_getavailablestacks.go b/resource-manager/web/2024-11-01/provider/method_getavailablestacks.go new file mode 100644 index 00000000000..1572e58bd2a --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/method_getavailablestacks.go @@ -0,0 +1,134 @@ +package provider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAvailableStacksOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationStackResource +} + +type GetAvailableStacksCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationStackResource +} + +type GetAvailableStacksOperationOptions struct { + OsTypeSelected *ProviderOsTypeSelected +} + +func DefaultGetAvailableStacksOperationOptions() GetAvailableStacksOperationOptions { + return GetAvailableStacksOperationOptions{} +} + +func (o GetAvailableStacksOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetAvailableStacksOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetAvailableStacksOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.OsTypeSelected != nil { + out.Append("osTypeSelected", fmt.Sprintf("%v", *o.OsTypeSelected)) + } + return &out +} + +type GetAvailableStacksCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetAvailableStacksCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetAvailableStacks ... +func (c ProviderClient) GetAvailableStacks(ctx context.Context, options GetAvailableStacksOperationOptions) (result GetAvailableStacksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &GetAvailableStacksCustomPager{}, + Path: "/providers/Microsoft.Web/availableStacks", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApplicationStackResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetAvailableStacksComplete retrieves all the results into a single object +func (c ProviderClient) GetAvailableStacksComplete(ctx context.Context, options GetAvailableStacksOperationOptions) (GetAvailableStacksCompleteResult, error) { + return c.GetAvailableStacksCompleteMatchingPredicate(ctx, options, ApplicationStackResourceOperationPredicate{}) +} + +// GetAvailableStacksCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetAvailableStacksCompleteMatchingPredicate(ctx context.Context, options GetAvailableStacksOperationOptions, predicate ApplicationStackResourceOperationPredicate) (result GetAvailableStacksCompleteResult, err error) { + items := make([]ApplicationStackResource, 0) + + resp, err := c.GetAvailableStacks(ctx, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetAvailableStacksCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/provider/method_getavailablestacksonprem.go b/resource-manager/web/2024-11-01/provider/method_getavailablestacksonprem.go new file mode 100644 index 00000000000..20773813e76 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/method_getavailablestacksonprem.go @@ -0,0 +1,135 @@ +package provider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAvailableStacksOnPremOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApplicationStackResource +} + +type GetAvailableStacksOnPremCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApplicationStackResource +} + +type GetAvailableStacksOnPremOperationOptions struct { + OsTypeSelected *ProviderOsTypeSelected +} + +func DefaultGetAvailableStacksOnPremOperationOptions() GetAvailableStacksOnPremOperationOptions { + return GetAvailableStacksOnPremOperationOptions{} +} + +func (o GetAvailableStacksOnPremOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetAvailableStacksOnPremOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetAvailableStacksOnPremOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.OsTypeSelected != nil { + out.Append("osTypeSelected", fmt.Sprintf("%v", *o.OsTypeSelected)) + } + return &out +} + +type GetAvailableStacksOnPremCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetAvailableStacksOnPremCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetAvailableStacksOnPrem ... +func (c ProviderClient) GetAvailableStacksOnPrem(ctx context.Context, id commonids.SubscriptionId, options GetAvailableStacksOnPremOperationOptions) (result GetAvailableStacksOnPremOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &GetAvailableStacksOnPremCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/availableStacks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApplicationStackResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetAvailableStacksOnPremComplete retrieves all the results into a single object +func (c ProviderClient) GetAvailableStacksOnPremComplete(ctx context.Context, id commonids.SubscriptionId, options GetAvailableStacksOnPremOperationOptions) (GetAvailableStacksOnPremCompleteResult, error) { + return c.GetAvailableStacksOnPremCompleteMatchingPredicate(ctx, id, options, ApplicationStackResourceOperationPredicate{}) +} + +// GetAvailableStacksOnPremCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetAvailableStacksOnPremCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options GetAvailableStacksOnPremOperationOptions, predicate ApplicationStackResourceOperationPredicate) (result GetAvailableStacksOnPremCompleteResult, err error) { + items := make([]ApplicationStackResource, 0) + + resp, err := c.GetAvailableStacksOnPrem(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetAvailableStacksOnPremCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/provider/method_getfunctionappstacks.go b/resource-manager/web/2024-11-01/provider/method_getfunctionappstacks.go new file mode 100644 index 00000000000..a1846c17cd1 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/method_getfunctionappstacks.go @@ -0,0 +1,134 @@ +package provider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetFunctionAppStacksOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FunctionAppStack +} + +type GetFunctionAppStacksCompleteResult struct { + LatestHttpResponse *http.Response + Items []FunctionAppStack +} + +type GetFunctionAppStacksOperationOptions struct { + StackOsType *ProviderStackOsType +} + +func DefaultGetFunctionAppStacksOperationOptions() GetFunctionAppStacksOperationOptions { + return GetFunctionAppStacksOperationOptions{} +} + +func (o GetFunctionAppStacksOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetFunctionAppStacksOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetFunctionAppStacksOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.StackOsType != nil { + out.Append("stackOsType", fmt.Sprintf("%v", *o.StackOsType)) + } + return &out +} + +type GetFunctionAppStacksCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetFunctionAppStacksCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetFunctionAppStacks ... +func (c ProviderClient) GetFunctionAppStacks(ctx context.Context, options GetFunctionAppStacksOperationOptions) (result GetFunctionAppStacksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &GetFunctionAppStacksCustomPager{}, + Path: "/providers/Microsoft.Web/functionAppStacks", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FunctionAppStack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetFunctionAppStacksComplete retrieves all the results into a single object +func (c ProviderClient) GetFunctionAppStacksComplete(ctx context.Context, options GetFunctionAppStacksOperationOptions) (GetFunctionAppStacksCompleteResult, error) { + return c.GetFunctionAppStacksCompleteMatchingPredicate(ctx, options, FunctionAppStackOperationPredicate{}) +} + +// GetFunctionAppStacksCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetFunctionAppStacksCompleteMatchingPredicate(ctx context.Context, options GetFunctionAppStacksOperationOptions, predicate FunctionAppStackOperationPredicate) (result GetFunctionAppStacksCompleteResult, err error) { + items := make([]FunctionAppStack, 0) + + resp, err := c.GetFunctionAppStacks(ctx, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetFunctionAppStacksCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/provider/method_getfunctionappstacksforlocation.go b/resource-manager/web/2024-11-01/provider/method_getfunctionappstacksforlocation.go new file mode 100644 index 00000000000..684a0b14882 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/method_getfunctionappstacksforlocation.go @@ -0,0 +1,134 @@ +package provider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetFunctionAppStacksForLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FunctionAppStack +} + +type GetFunctionAppStacksForLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []FunctionAppStack +} + +type GetFunctionAppStacksForLocationOperationOptions struct { + StackOsType *ProviderStackOsType +} + +func DefaultGetFunctionAppStacksForLocationOperationOptions() GetFunctionAppStacksForLocationOperationOptions { + return GetFunctionAppStacksForLocationOperationOptions{} +} + +func (o GetFunctionAppStacksForLocationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetFunctionAppStacksForLocationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetFunctionAppStacksForLocationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.StackOsType != nil { + out.Append("stackOsType", fmt.Sprintf("%v", *o.StackOsType)) + } + return &out +} + +type GetFunctionAppStacksForLocationCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetFunctionAppStacksForLocationCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetFunctionAppStacksForLocation ... +func (c ProviderClient) GetFunctionAppStacksForLocation(ctx context.Context, id LocationId, options GetFunctionAppStacksForLocationOperationOptions) (result GetFunctionAppStacksForLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &GetFunctionAppStacksForLocationCustomPager{}, + Path: fmt.Sprintf("%s/functionAppStacks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FunctionAppStack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetFunctionAppStacksForLocationComplete retrieves all the results into a single object +func (c ProviderClient) GetFunctionAppStacksForLocationComplete(ctx context.Context, id LocationId, options GetFunctionAppStacksForLocationOperationOptions) (GetFunctionAppStacksForLocationCompleteResult, error) { + return c.GetFunctionAppStacksForLocationCompleteMatchingPredicate(ctx, id, options, FunctionAppStackOperationPredicate{}) +} + +// GetFunctionAppStacksForLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetFunctionAppStacksForLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, options GetFunctionAppStacksForLocationOperationOptions, predicate FunctionAppStackOperationPredicate) (result GetFunctionAppStacksForLocationCompleteResult, err error) { + items := make([]FunctionAppStack, 0) + + resp, err := c.GetFunctionAppStacksForLocation(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetFunctionAppStacksForLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/provider/method_getwebappstacks.go b/resource-manager/web/2024-11-01/provider/method_getwebappstacks.go new file mode 100644 index 00000000000..3223aecd71b --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/method_getwebappstacks.go @@ -0,0 +1,134 @@ +package provider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetWebAppStacksOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebAppStack +} + +type GetWebAppStacksCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebAppStack +} + +type GetWebAppStacksOperationOptions struct { + StackOsType *ProviderStackOsType +} + +func DefaultGetWebAppStacksOperationOptions() GetWebAppStacksOperationOptions { + return GetWebAppStacksOperationOptions{} +} + +func (o GetWebAppStacksOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetWebAppStacksOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetWebAppStacksOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.StackOsType != nil { + out.Append("stackOsType", fmt.Sprintf("%v", *o.StackOsType)) + } + return &out +} + +type GetWebAppStacksCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetWebAppStacksCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetWebAppStacks ... +func (c ProviderClient) GetWebAppStacks(ctx context.Context, options GetWebAppStacksOperationOptions) (result GetWebAppStacksOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &GetWebAppStacksCustomPager{}, + Path: "/providers/Microsoft.Web/webAppStacks", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WebAppStack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetWebAppStacksComplete retrieves all the results into a single object +func (c ProviderClient) GetWebAppStacksComplete(ctx context.Context, options GetWebAppStacksOperationOptions) (GetWebAppStacksCompleteResult, error) { + return c.GetWebAppStacksCompleteMatchingPredicate(ctx, options, WebAppStackOperationPredicate{}) +} + +// GetWebAppStacksCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetWebAppStacksCompleteMatchingPredicate(ctx context.Context, options GetWebAppStacksOperationOptions, predicate WebAppStackOperationPredicate) (result GetWebAppStacksCompleteResult, err error) { + items := make([]WebAppStack, 0) + + resp, err := c.GetWebAppStacks(ctx, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetWebAppStacksCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/provider/method_getwebappstacksforlocation.go b/resource-manager/web/2024-11-01/provider/method_getwebappstacksforlocation.go new file mode 100644 index 00000000000..2dad249e986 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/method_getwebappstacksforlocation.go @@ -0,0 +1,134 @@ +package provider + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetWebAppStacksForLocationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebAppStack +} + +type GetWebAppStacksForLocationCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebAppStack +} + +type GetWebAppStacksForLocationOperationOptions struct { + StackOsType *ProviderStackOsType +} + +func DefaultGetWebAppStacksForLocationOperationOptions() GetWebAppStacksForLocationOperationOptions { + return GetWebAppStacksForLocationOperationOptions{} +} + +func (o GetWebAppStacksForLocationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetWebAppStacksForLocationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetWebAppStacksForLocationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.StackOsType != nil { + out.Append("stackOsType", fmt.Sprintf("%v", *o.StackOsType)) + } + return &out +} + +type GetWebAppStacksForLocationCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetWebAppStacksForLocationCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetWebAppStacksForLocation ... +func (c ProviderClient) GetWebAppStacksForLocation(ctx context.Context, id LocationId, options GetWebAppStacksForLocationOperationOptions) (result GetWebAppStacksForLocationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &GetWebAppStacksForLocationCustomPager{}, + Path: fmt.Sprintf("%s/webAppStacks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WebAppStack `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetWebAppStacksForLocationComplete retrieves all the results into a single object +func (c ProviderClient) GetWebAppStacksForLocationComplete(ctx context.Context, id LocationId, options GetWebAppStacksForLocationOperationOptions) (GetWebAppStacksForLocationCompleteResult, error) { + return c.GetWebAppStacksForLocationCompleteMatchingPredicate(ctx, id, options, WebAppStackOperationPredicate{}) +} + +// GetWebAppStacksForLocationCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ProviderClient) GetWebAppStacksForLocationCompleteMatchingPredicate(ctx context.Context, id LocationId, options GetWebAppStacksForLocationOperationOptions, predicate WebAppStackOperationPredicate) (result GetWebAppStacksForLocationCompleteResult, err error) { + items := make([]WebAppStack, 0) + + resp, err := c.GetWebAppStacksForLocation(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetWebAppStacksForLocationCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/provider/model_appinsightswebappstacksettings.go b/resource-manager/web/2024-11-01/provider/model_appinsightswebappstacksettings.go new file mode 100644 index 00000000000..33c98c5a840 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_appinsightswebappstacksettings.go @@ -0,0 +1,9 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppInsightsWebAppStackSettings struct { + IsDefaultOff *bool `json:"isDefaultOff,omitempty"` + IsSupported *bool `json:"isSupported,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/provider/model_applicationstack.go b/resource-manager/web/2024-11-01/provider/model_applicationstack.go new file mode 100644 index 00000000000..2f4a241919a --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_applicationstack.go @@ -0,0 +1,13 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationStack struct { + Dependency *string `json:"dependency,omitempty"` + Display *string `json:"display,omitempty"` + Frameworks *[]ApplicationStack `json:"frameworks,omitempty"` + IsDeprecated *[]ApplicationStack `json:"isDeprecated,omitempty"` + MajorVersions *[]StackMajorVersion `json:"majorVersions,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/provider/model_applicationstackresource.go b/resource-manager/web/2024-11-01/provider/model_applicationstackresource.go new file mode 100644 index 00000000000..6257ea657ae --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_applicationstackresource.go @@ -0,0 +1,12 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationStackResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApplicationStack `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/provider/model_functionappmajorversion.go b/resource-manager/web/2024-11-01/provider/model_functionappmajorversion.go new file mode 100644 index 00000000000..b256d10d2d2 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_functionappmajorversion.go @@ -0,0 +1,10 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppMajorVersion struct { + DisplayText *string `json:"displayText,omitempty"` + MinorVersions *[]FunctionAppMinorVersion `json:"minorVersions,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/provider/model_functionappminorversion.go b/resource-manager/web/2024-11-01/provider/model_functionappminorversion.go new file mode 100644 index 00000000000..2fdcc030a72 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_functionappminorversion.go @@ -0,0 +1,10 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppMinorVersion struct { + DisplayText *string `json:"displayText,omitempty"` + StackSettings *FunctionAppRuntimes `json:"stackSettings,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/provider/model_functionappruntimes.go b/resource-manager/web/2024-11-01/provider/model_functionappruntimes.go new file mode 100644 index 00000000000..8c3b2a595f1 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_functionappruntimes.go @@ -0,0 +1,9 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppRuntimes struct { + LinuxRuntimeSettings *FunctionAppRuntimeSettings `json:"linuxRuntimeSettings,omitempty"` + WindowsRuntimeSettings *FunctionAppRuntimeSettings `json:"windowsRuntimeSettings,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/provider/model_functionappruntimesettings.go b/resource-manager/web/2024-11-01/provider/model_functionappruntimesettings.go new file mode 100644 index 00000000000..14b93765b39 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_functionappruntimesettings.go @@ -0,0 +1,39 @@ +package provider + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppRuntimeSettings struct { + AppInsightsSettings *AppInsightsWebAppStackSettings `json:"appInsightsSettings,omitempty"` + AppSettingsDictionary *map[string]string `json:"appSettingsDictionary,omitempty"` + EndOfLifeDate *string `json:"endOfLifeDate,omitempty"` + GitHubActionSettings *GitHubActionWebAppStackSettings `json:"gitHubActionSettings,omitempty"` + IsAutoUpdate *bool `json:"isAutoUpdate,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + IsDeprecated *bool `json:"isDeprecated,omitempty"` + IsEarlyAccess *bool `json:"isEarlyAccess,omitempty"` + IsHidden *bool `json:"isHidden,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + RemoteDebuggingSupported *bool `json:"remoteDebuggingSupported,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` + SiteConfigPropertiesDictionary *SiteConfigPropertiesDictionary `json:"siteConfigPropertiesDictionary,omitempty"` + SupportedFunctionsExtensionVersions *[]string `json:"supportedFunctionsExtensionVersions,omitempty"` +} + +func (o *FunctionAppRuntimeSettings) GetEndOfLifeDateAsTime() (*time.Time, error) { + if o.EndOfLifeDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndOfLifeDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *FunctionAppRuntimeSettings) SetEndOfLifeDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndOfLifeDate = &formatted +} diff --git a/resource-manager/web/2024-11-01/provider/model_functionappstack.go b/resource-manager/web/2024-11-01/provider/model_functionappstack.go new file mode 100644 index 00000000000..e4237db1a8b --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_functionappstack.go @@ -0,0 +1,13 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppStack struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FunctionAppStackProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/provider/model_functionappstackproperties.go b/resource-manager/web/2024-11-01/provider/model_functionappstackproperties.go new file mode 100644 index 00000000000..fdc2ac67ad2 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_functionappstackproperties.go @@ -0,0 +1,11 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppStackProperties struct { + DisplayText *string `json:"displayText,omitempty"` + MajorVersions *[]FunctionAppMajorVersion `json:"majorVersions,omitempty"` + PreferredOs *StackPreferredOs `json:"preferredOs,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/provider/model_githubactionwebappstacksettings.go b/resource-manager/web/2024-11-01/provider/model_githubactionwebappstacksettings.go new file mode 100644 index 00000000000..e43a56abbf1 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_githubactionwebappstacksettings.go @@ -0,0 +1,9 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GitHubActionWebAppStackSettings struct { + IsSupported *bool `json:"isSupported,omitempty"` + SupportedVersion *string `json:"supportedVersion,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/provider/model_linuxjavacontainersettings.go b/resource-manager/web/2024-11-01/provider/model_linuxjavacontainersettings.go new file mode 100644 index 00000000000..9f872d51929 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_linuxjavacontainersettings.go @@ -0,0 +1,33 @@ +package provider + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinuxJavaContainerSettings struct { + EndOfLifeDate *string `json:"endOfLifeDate,omitempty"` + IsAutoUpdate *bool `json:"isAutoUpdate,omitempty"` + IsDeprecated *bool `json:"isDeprecated,omitempty"` + IsEarlyAccess *bool `json:"isEarlyAccess,omitempty"` + IsHidden *bool `json:"isHidden,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + Java11Runtime *string `json:"java11Runtime,omitempty"` + Java8Runtime *string `json:"java8Runtime,omitempty"` +} + +func (o *LinuxJavaContainerSettings) GetEndOfLifeDateAsTime() (*time.Time, error) { + if o.EndOfLifeDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndOfLifeDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *LinuxJavaContainerSettings) SetEndOfLifeDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndOfLifeDate = &formatted +} diff --git a/resource-manager/web/2024-11-01/provider/model_siteconfigpropertiesdictionary.go b/resource-manager/web/2024-11-01/provider/model_siteconfigpropertiesdictionary.go new file mode 100644 index 00000000000..a0f34e1f2c6 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_siteconfigpropertiesdictionary.go @@ -0,0 +1,11 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteConfigPropertiesDictionary struct { + JavaVersion *string `json:"javaVersion,omitempty"` + LinuxFxVersion *string `json:"linuxFxVersion,omitempty"` + PowerShellVersion *string `json:"powerShellVersion,omitempty"` + Use32BitWorkerProcess *bool `json:"use32BitWorkerProcess,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/provider/model_stackmajorversion.go b/resource-manager/web/2024-11-01/provider/model_stackmajorversion.go new file mode 100644 index 00000000000..3790b4a134a --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_stackmajorversion.go @@ -0,0 +1,17 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StackMajorVersion struct { + AppSettingsDictionary *map[string]interface{} `json:"appSettingsDictionary,omitempty"` + ApplicationInsights *bool `json:"applicationInsights,omitempty"` + DisplayVersion *string `json:"displayVersion,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + IsDeprecated *bool `json:"isDeprecated,omitempty"` + IsHidden *bool `json:"isHidden,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + MinorVersions *[]StackMinorVersion `json:"minorVersions,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` + SiteConfigPropertiesDictionary *map[string]interface{} `json:"siteConfigPropertiesDictionary,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/provider/model_stackminorversion.go b/resource-manager/web/2024-11-01/provider/model_stackminorversion.go new file mode 100644 index 00000000000..7cd0a233af1 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_stackminorversion.go @@ -0,0 +1,11 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StackMinorVersion struct { + DisplayVersion *string `json:"displayVersion,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + IsRemoteDebuggingEnabled *bool `json:"isRemoteDebuggingEnabled,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/provider/model_webappmajorversion.go b/resource-manager/web/2024-11-01/provider/model_webappmajorversion.go new file mode 100644 index 00000000000..14ddab92252 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_webappmajorversion.go @@ -0,0 +1,10 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebAppMajorVersion struct { + DisplayText *string `json:"displayText,omitempty"` + MinorVersions *[]WebAppMinorVersion `json:"minorVersions,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/provider/model_webappminorversion.go b/resource-manager/web/2024-11-01/provider/model_webappminorversion.go new file mode 100644 index 00000000000..c38aae7508d --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_webappminorversion.go @@ -0,0 +1,10 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebAppMinorVersion struct { + DisplayText *string `json:"displayText,omitempty"` + StackSettings *WebAppRuntimes `json:"stackSettings,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/provider/model_webappruntimes.go b/resource-manager/web/2024-11-01/provider/model_webappruntimes.go new file mode 100644 index 00000000000..d5d1d7691d1 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_webappruntimes.go @@ -0,0 +1,11 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebAppRuntimes struct { + LinuxContainerSettings *LinuxJavaContainerSettings `json:"linuxContainerSettings,omitempty"` + LinuxRuntimeSettings *WebAppRuntimeSettings `json:"linuxRuntimeSettings,omitempty"` + WindowsContainerSettings *WindowsJavaContainerSettings `json:"windowsContainerSettings,omitempty"` + WindowsRuntimeSettings *WebAppRuntimeSettings `json:"windowsRuntimeSettings,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/provider/model_webappruntimesettings.go b/resource-manager/web/2024-11-01/provider/model_webappruntimesettings.go new file mode 100644 index 00000000000..f828522456d --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_webappruntimesettings.go @@ -0,0 +1,35 @@ +package provider + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebAppRuntimeSettings struct { + AppInsightsSettings *AppInsightsWebAppStackSettings `json:"appInsightsSettings,omitempty"` + EndOfLifeDate *string `json:"endOfLifeDate,omitempty"` + GitHubActionSettings *GitHubActionWebAppStackSettings `json:"gitHubActionSettings,omitempty"` + IsAutoUpdate *bool `json:"isAutoUpdate,omitempty"` + IsDeprecated *bool `json:"isDeprecated,omitempty"` + IsEarlyAccess *bool `json:"isEarlyAccess,omitempty"` + IsHidden *bool `json:"isHidden,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + RemoteDebuggingSupported *bool `json:"remoteDebuggingSupported,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` +} + +func (o *WebAppRuntimeSettings) GetEndOfLifeDateAsTime() (*time.Time, error) { + if o.EndOfLifeDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndOfLifeDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *WebAppRuntimeSettings) SetEndOfLifeDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndOfLifeDate = &formatted +} diff --git a/resource-manager/web/2024-11-01/provider/model_webappstack.go b/resource-manager/web/2024-11-01/provider/model_webappstack.go new file mode 100644 index 00000000000..6d111339d6d --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_webappstack.go @@ -0,0 +1,13 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebAppStack struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WebAppStackProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/provider/model_webappstackproperties.go b/resource-manager/web/2024-11-01/provider/model_webappstackproperties.go new file mode 100644 index 00000000000..a37e8588aae --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_webappstackproperties.go @@ -0,0 +1,11 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebAppStackProperties struct { + DisplayText *string `json:"displayText,omitempty"` + MajorVersions *[]WebAppMajorVersion `json:"majorVersions,omitempty"` + PreferredOs *StackPreferredOs `json:"preferredOs,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/provider/model_windowsjavacontainersettings.go b/resource-manager/web/2024-11-01/provider/model_windowsjavacontainersettings.go new file mode 100644 index 00000000000..0bba076cec7 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/model_windowsjavacontainersettings.go @@ -0,0 +1,33 @@ +package provider + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WindowsJavaContainerSettings struct { + EndOfLifeDate *string `json:"endOfLifeDate,omitempty"` + IsAutoUpdate *bool `json:"isAutoUpdate,omitempty"` + IsDeprecated *bool `json:"isDeprecated,omitempty"` + IsEarlyAccess *bool `json:"isEarlyAccess,omitempty"` + IsHidden *bool `json:"isHidden,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + JavaContainer *string `json:"javaContainer,omitempty"` + JavaContainerVersion *string `json:"javaContainerVersion,omitempty"` +} + +func (o *WindowsJavaContainerSettings) GetEndOfLifeDateAsTime() (*time.Time, error) { + if o.EndOfLifeDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndOfLifeDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *WindowsJavaContainerSettings) SetEndOfLifeDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndOfLifeDate = &formatted +} diff --git a/resource-manager/web/2024-11-01/provider/predicates.go b/resource-manager/web/2024-11-01/provider/predicates.go new file mode 100644 index 00000000000..152a0bd64bb --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/predicates.go @@ -0,0 +1,98 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationStackResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ApplicationStackResourceOperationPredicate) Matches(input ApplicationStackResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type FunctionAppStackOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p FunctionAppStackOperationPredicate) Matches(input FunctionAppStack) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type WebAppStackOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p WebAppStackOperationPredicate) Matches(input WebAppStack) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/provider/version.go b/resource-manager/web/2024-11-01/provider/version.go new file mode 100644 index 00000000000..7a9c10d0140 --- /dev/null +++ b/resource-manager/web/2024-11-01/provider/version.go @@ -0,0 +1,10 @@ +package provider + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/provider/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/recommendations/README.md b/resource-manager/web/2024-11-01/recommendations/README.md new file mode 100644 index 00000000000..45fa1a359fc --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/README.md @@ -0,0 +1,266 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/recommendations` Documentation + +The `recommendations` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/recommendations" +``` + + +### Client Initialization + +```go +client := recommendations.NewRecommendationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RecommendationsClient.DisableAllForHostingEnvironment` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.DisableAllForHostingEnvironment(ctx, id, recommendations.DefaultDisableAllForHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.DisableAllForWebApp` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.DisableAllForWebApp(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.DisableRecommendationForHostingEnvironment` + +```go +ctx := context.TODO() +id := recommendations.NewHostingEnvironmentRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "recommendationName") + +read, err := client.DisableRecommendationForHostingEnvironment(ctx, id, recommendations.DefaultDisableRecommendationForHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.DisableRecommendationForSite` + +```go +ctx := context.TODO() +id := recommendations.NewSiteRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "recommendationName") + +read, err := client.DisableRecommendationForSite(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.DisableRecommendationForSubscription` + +```go +ctx := context.TODO() +id := recommendations.NewRecommendationID("12345678-1234-9876-4563-123456789012", "recommendationName") + +read, err := client.DisableRecommendationForSubscription(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.GetRuleDetailsByHostingEnvironment` + +```go +ctx := context.TODO() +id := recommendations.NewHostingEnvironmentRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "recommendationName") + +read, err := client.GetRuleDetailsByHostingEnvironment(ctx, id, recommendations.DefaultGetRuleDetailsByHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.GetRuleDetailsByWebApp` + +```go +ctx := context.TODO() +id := recommendations.NewSiteRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "recommendationName") + +read, err := client.GetRuleDetailsByWebApp(ctx, id, recommendations.DefaultGetRuleDetailsByWebAppOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, recommendations.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, recommendations.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecommendationsClient.ListHistoryForHostingEnvironment` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListHistoryForHostingEnvironment(ctx, id, recommendations.DefaultListHistoryForHostingEnvironmentOperationOptions())` can be used to do batched pagination +items, err := client.ListHistoryForHostingEnvironmentComplete(ctx, id, recommendations.DefaultListHistoryForHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecommendationsClient.ListHistoryForWebApp` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListHistoryForWebApp(ctx, id, recommendations.DefaultListHistoryForWebAppOperationOptions())` can be used to do batched pagination +items, err := client.ListHistoryForWebAppComplete(ctx, id, recommendations.DefaultListHistoryForWebAppOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecommendationsClient.ListRecommendedRulesForHostingEnvironment` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +// alternatively `client.ListRecommendedRulesForHostingEnvironment(ctx, id, recommendations.DefaultListRecommendedRulesForHostingEnvironmentOperationOptions())` can be used to do batched pagination +items, err := client.ListRecommendedRulesForHostingEnvironmentComplete(ctx, id, recommendations.DefaultListRecommendedRulesForHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecommendationsClient.ListRecommendedRulesForWebApp` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListRecommendedRulesForWebApp(ctx, id, recommendations.DefaultListRecommendedRulesForWebAppOperationOptions())` can be used to do batched pagination +items, err := client.ListRecommendedRulesForWebAppComplete(ctx, id, recommendations.DefaultListRecommendedRulesForWebAppOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RecommendationsClient.ResetAllFilters` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.ResetAllFilters(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.ResetAllFiltersForHostingEnvironment` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName") + +read, err := client.ResetAllFiltersForHostingEnvironment(ctx, id, recommendations.DefaultResetAllFiltersForHostingEnvironmentOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RecommendationsClient.ResetAllFiltersForWebApp` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ResetAllFiltersForWebApp(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-11-01/recommendations/client.go b/resource-manager/web/2024-11-01/recommendations/client.go new file mode 100644 index 00000000000..5c0b92661cf --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/client.go @@ -0,0 +1,26 @@ +package recommendations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecommendationsClient struct { + Client *resourcemanager.Client +} + +func NewRecommendationsClientWithBaseURI(sdkApi sdkEnv.Api) (*RecommendationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "recommendations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RecommendationsClient: %+v", err) + } + + return &RecommendationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/recommendations/constants.go b/resource-manager/web/2024-11-01/recommendations/constants.go new file mode 100644 index 00000000000..207c2a4c8a5 --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/constants.go @@ -0,0 +1,151 @@ +package recommendations + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Channels string + +const ( + ChannelsAll Channels = "All" + ChannelsApi Channels = "Api" + ChannelsEmail Channels = "Email" + ChannelsNotification Channels = "Notification" + ChannelsWebhook Channels = "Webhook" +) + +func PossibleValuesForChannels() []string { + return []string{ + string(ChannelsAll), + string(ChannelsApi), + string(ChannelsEmail), + string(ChannelsNotification), + string(ChannelsWebhook), + } +} + +func (s *Channels) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseChannels(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseChannels(input string) (*Channels, error) { + vals := map[string]Channels{ + "all": ChannelsAll, + "api": ChannelsApi, + "email": ChannelsEmail, + "notification": ChannelsNotification, + "webhook": ChannelsWebhook, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Channels(input) + return &out, nil +} + +type NotificationLevel string + +const ( + NotificationLevelCritical NotificationLevel = "Critical" + NotificationLevelInformation NotificationLevel = "Information" + NotificationLevelNonUrgentSuggestion NotificationLevel = "NonUrgentSuggestion" + NotificationLevelWarning NotificationLevel = "Warning" +) + +func PossibleValuesForNotificationLevel() []string { + return []string{ + string(NotificationLevelCritical), + string(NotificationLevelInformation), + string(NotificationLevelNonUrgentSuggestion), + string(NotificationLevelWarning), + } +} + +func (s *NotificationLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNotificationLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNotificationLevel(input string) (*NotificationLevel, error) { + vals := map[string]NotificationLevel{ + "critical": NotificationLevelCritical, + "information": NotificationLevelInformation, + "nonurgentsuggestion": NotificationLevelNonUrgentSuggestion, + "warning": NotificationLevelWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NotificationLevel(input) + return &out, nil +} + +type ResourceScopeType string + +const ( + ResourceScopeTypeServerFarm ResourceScopeType = "ServerFarm" + ResourceScopeTypeSubscription ResourceScopeType = "Subscription" + ResourceScopeTypeWebSite ResourceScopeType = "WebSite" +) + +func PossibleValuesForResourceScopeType() []string { + return []string{ + string(ResourceScopeTypeServerFarm), + string(ResourceScopeTypeSubscription), + string(ResourceScopeTypeWebSite), + } +} + +func (s *ResourceScopeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResourceScopeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResourceScopeType(input string) (*ResourceScopeType, error) { + vals := map[string]ResourceScopeType{ + "serverfarm": ResourceScopeTypeServerFarm, + "subscription": ResourceScopeTypeSubscription, + "website": ResourceScopeTypeWebSite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResourceScopeType(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/recommendations/id_hostingenvironmentrecommendation.go b/resource-manager/web/2024-11-01/recommendations/id_hostingenvironmentrecommendation.go new file mode 100644 index 00000000000..6c8bb19b20b --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/id_hostingenvironmentrecommendation.go @@ -0,0 +1,139 @@ +package recommendations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostingEnvironmentRecommendationId{}) +} + +var _ resourceids.ResourceId = &HostingEnvironmentRecommendationId{} + +// HostingEnvironmentRecommendationId is a struct representing the Resource ID for a Hosting Environment Recommendation +type HostingEnvironmentRecommendationId struct { + SubscriptionId string + ResourceGroupName string + HostingEnvironmentName string + RecommendationName string +} + +// NewHostingEnvironmentRecommendationID returns a new HostingEnvironmentRecommendationId struct +func NewHostingEnvironmentRecommendationID(subscriptionId string, resourceGroupName string, hostingEnvironmentName string, recommendationName string) HostingEnvironmentRecommendationId { + return HostingEnvironmentRecommendationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + HostingEnvironmentName: hostingEnvironmentName, + RecommendationName: recommendationName, + } +} + +// ParseHostingEnvironmentRecommendationID parses 'input' into a HostingEnvironmentRecommendationId +func ParseHostingEnvironmentRecommendationID(input string) (*HostingEnvironmentRecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentRecommendationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentRecommendationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostingEnvironmentRecommendationIDInsensitively parses 'input' case-insensitively into a HostingEnvironmentRecommendationId +// note: this method should only be used for API response data and not user input +func ParseHostingEnvironmentRecommendationIDInsensitively(input string) (*HostingEnvironmentRecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostingEnvironmentRecommendationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostingEnvironmentRecommendationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostingEnvironmentRecommendationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.HostingEnvironmentName, ok = input.Parsed["hostingEnvironmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostingEnvironmentName", input) + } + + if id.RecommendationName, ok = input.Parsed["recommendationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recommendationName", input) + } + + return nil +} + +// ValidateHostingEnvironmentRecommendationID checks that 'input' can be parsed as a Hosting Environment Recommendation ID +func ValidateHostingEnvironmentRecommendationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostingEnvironmentRecommendationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hosting Environment Recommendation ID +func (id HostingEnvironmentRecommendationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/hostingEnvironments/%s/recommendations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.HostingEnvironmentName, id.RecommendationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hosting Environment Recommendation ID +func (id HostingEnvironmentRecommendationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticHostingEnvironments", "hostingEnvironments", "hostingEnvironments"), + resourceids.UserSpecifiedSegment("hostingEnvironmentName", "hostingEnvironmentName"), + resourceids.StaticSegment("staticRecommendations", "recommendations", "recommendations"), + resourceids.UserSpecifiedSegment("recommendationName", "recommendationName"), + } +} + +// String returns a human-readable description of this Hosting Environment Recommendation ID +func (id HostingEnvironmentRecommendationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Hosting Environment Name: %q", id.HostingEnvironmentName), + fmt.Sprintf("Recommendation Name: %q", id.RecommendationName), + } + return fmt.Sprintf("Hosting Environment Recommendation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/recommendations/id_hostingenvironmentrecommendation_test.go b/resource-manager/web/2024-11-01/recommendations/id_hostingenvironmentrecommendation_test.go new file mode 100644 index 00000000000..89a2959452d --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/id_hostingenvironmentrecommendation_test.go @@ -0,0 +1,327 @@ +package recommendations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostingEnvironmentRecommendationId{} + +func TestNewHostingEnvironmentRecommendationID(t *testing.T) { + id := NewHostingEnvironmentRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "recommendationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.HostingEnvironmentName != "hostingEnvironmentName" { + t.Fatalf("Expected %q but got %q for Segment 'HostingEnvironmentName'", id.HostingEnvironmentName, "hostingEnvironmentName") + } + + if id.RecommendationName != "recommendationName" { + t.Fatalf("Expected %q but got %q for Segment 'RecommendationName'", id.RecommendationName, "recommendationName") + } +} + +func TestFormatHostingEnvironmentRecommendationID(t *testing.T) { + actual := NewHostingEnvironmentRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "hostingEnvironmentName", "recommendationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/recommendations/recommendationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostingEnvironmentRecommendationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentRecommendationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/recommendations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/recommendations/recommendationName", + Expected: &HostingEnvironmentRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + RecommendationName: "recommendationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/recommendations/recommendationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentRecommendationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestParseHostingEnvironmentRecommendationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostingEnvironmentRecommendationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/recommendations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/rEcOmMeNdAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/recommendations/recommendationName", + Expected: &HostingEnvironmentRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + HostingEnvironmentName: "hostingEnvironmentName", + RecommendationName: "recommendationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/hostingEnvironments/hostingEnvironmentName/recommendations/recommendationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNnAmE", + Expected: &HostingEnvironmentRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + HostingEnvironmentName: "hOsTiNgEnViRoNmEnTnAmE", + RecommendationName: "rEcOmMeNdAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/hOsTiNgEnViRoNmEnTs/hOsTiNgEnViRoNmEnTnAmE/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostingEnvironmentRecommendationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.HostingEnvironmentName != v.Expected.HostingEnvironmentName { + t.Fatalf("Expected %q but got %q for HostingEnvironmentName", v.Expected.HostingEnvironmentName, actual.HostingEnvironmentName) + } + + if actual.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestSegmentsForHostingEnvironmentRecommendationId(t *testing.T) { + segments := HostingEnvironmentRecommendationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostingEnvironmentRecommendationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/recommendations/id_recommendation.go b/resource-manager/web/2024-11-01/recommendations/id_recommendation.go new file mode 100644 index 00000000000..b42bf6faa1d --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/id_recommendation.go @@ -0,0 +1,121 @@ +package recommendations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RecommendationId{}) +} + +var _ resourceids.ResourceId = &RecommendationId{} + +// RecommendationId is a struct representing the Resource ID for a Recommendation +type RecommendationId struct { + SubscriptionId string + RecommendationName string +} + +// NewRecommendationID returns a new RecommendationId struct +func NewRecommendationID(subscriptionId string, recommendationName string) RecommendationId { + return RecommendationId{ + SubscriptionId: subscriptionId, + RecommendationName: recommendationName, + } +} + +// ParseRecommendationID parses 'input' into a RecommendationId +func ParseRecommendationID(input string) (*RecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecommendationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecommendationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRecommendationIDInsensitively parses 'input' case-insensitively into a RecommendationId +// note: this method should only be used for API response data and not user input +func ParseRecommendationIDInsensitively(input string) (*RecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&RecommendationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RecommendationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RecommendationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.RecommendationName, ok = input.Parsed["recommendationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recommendationName", input) + } + + return nil +} + +// ValidateRecommendationID checks that 'input' can be parsed as a Recommendation ID +func ValidateRecommendationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRecommendationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Recommendation ID +func (id RecommendationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/recommendations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.RecommendationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Recommendation ID +func (id RecommendationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticRecommendations", "recommendations", "recommendations"), + resourceids.UserSpecifiedSegment("recommendationName", "recommendationName"), + } +} + +// String returns a human-readable description of this Recommendation ID +func (id RecommendationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Recommendation Name: %q", id.RecommendationName), + } + return fmt.Sprintf("Recommendation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/recommendations/id_recommendation_test.go b/resource-manager/web/2024-11-01/recommendations/id_recommendation_test.go new file mode 100644 index 00000000000..a6c44f1f14c --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/id_recommendation_test.go @@ -0,0 +1,237 @@ +package recommendations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RecommendationId{} + +func TestNewRecommendationID(t *testing.T) { + id := NewRecommendationID("12345678-1234-9876-4563-123456789012", "recommendationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.RecommendationName != "recommendationName" { + t.Fatalf("Expected %q but got %q for Segment 'RecommendationName'", id.RecommendationName, "recommendationName") + } +} + +func TestFormatRecommendationID(t *testing.T) { + actual := NewRecommendationID("12345678-1234-9876-4563-123456789012", "recommendationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations/recommendationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRecommendationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecommendationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations/recommendationName", + Expected: &RecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + RecommendationName: "recommendationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations/recommendationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecommendationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestParseRecommendationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RecommendationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/rEcOmMeNdAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations/recommendationName", + Expected: &RecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + RecommendationName: "recommendationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/recommendations/recommendationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNnAmE", + Expected: &RecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + RecommendationName: "rEcOmMeNdAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRecommendationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestSegmentsForRecommendationId(t *testing.T) { + segments := RecommendationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RecommendationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/recommendations/id_siterecommendation.go b/resource-manager/web/2024-11-01/recommendations/id_siterecommendation.go new file mode 100644 index 00000000000..2876f7cd3e0 --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/id_siterecommendation.go @@ -0,0 +1,139 @@ +package recommendations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SiteRecommendationId{}) +} + +var _ resourceids.ResourceId = &SiteRecommendationId{} + +// SiteRecommendationId is a struct representing the Resource ID for a Site Recommendation +type SiteRecommendationId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + RecommendationName string +} + +// NewSiteRecommendationID returns a new SiteRecommendationId struct +func NewSiteRecommendationID(subscriptionId string, resourceGroupName string, siteName string, recommendationName string) SiteRecommendationId { + return SiteRecommendationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + RecommendationName: recommendationName, + } +} + +// ParseSiteRecommendationID parses 'input' into a SiteRecommendationId +func ParseSiteRecommendationID(input string) (*SiteRecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteRecommendationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteRecommendationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSiteRecommendationIDInsensitively parses 'input' case-insensitively into a SiteRecommendationId +// note: this method should only be used for API response data and not user input +func ParseSiteRecommendationIDInsensitively(input string) (*SiteRecommendationId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteRecommendationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteRecommendationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SiteRecommendationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.RecommendationName, ok = input.Parsed["recommendationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "recommendationName", input) + } + + return nil +} + +// ValidateSiteRecommendationID checks that 'input' can be parsed as a Site Recommendation ID +func ValidateSiteRecommendationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSiteRecommendationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Site Recommendation ID +func (id SiteRecommendationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/recommendations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.RecommendationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Site Recommendation ID +func (id SiteRecommendationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticRecommendations", "recommendations", "recommendations"), + resourceids.UserSpecifiedSegment("recommendationName", "recommendationName"), + } +} + +// String returns a human-readable description of this Site Recommendation ID +func (id SiteRecommendationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Recommendation Name: %q", id.RecommendationName), + } + return fmt.Sprintf("Site Recommendation (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/recommendations/id_siterecommendation_test.go b/resource-manager/web/2024-11-01/recommendations/id_siterecommendation_test.go new file mode 100644 index 00000000000..5bf28fb326c --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/id_siterecommendation_test.go @@ -0,0 +1,327 @@ +package recommendations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SiteRecommendationId{} + +func TestNewSiteRecommendationID(t *testing.T) { + id := NewSiteRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "recommendationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.RecommendationName != "recommendationName" { + t.Fatalf("Expected %q but got %q for Segment 'RecommendationName'", id.RecommendationName, "recommendationName") + } +} + +func TestFormatSiteRecommendationID(t *testing.T) { + actual := NewSiteRecommendationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "recommendationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/recommendations/recommendationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSiteRecommendationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteRecommendationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/recommendations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/recommendations/recommendationName", + Expected: &SiteRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + RecommendationName: "recommendationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/recommendations/recommendationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteRecommendationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestParseSiteRecommendationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteRecommendationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/recommendations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/rEcOmMeNdAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/recommendations/recommendationName", + Expected: &SiteRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + RecommendationName: "recommendationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/recommendations/recommendationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNnAmE", + Expected: &SiteRecommendationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + RecommendationName: "rEcOmMeNdAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/rEcOmMeNdAtIoNs/rEcOmMeNdAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteRecommendationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.RecommendationName != v.Expected.RecommendationName { + t.Fatalf("Expected %q but got %q for RecommendationName", v.Expected.RecommendationName, actual.RecommendationName) + } + + } +} + +func TestSegmentsForSiteRecommendationId(t *testing.T) { + segments := SiteRecommendationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SiteRecommendationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/recommendations/method_disableallforhostingenvironment.go b/resource-manager/web/2024-11-01/recommendations/method_disableallforhostingenvironment.go new file mode 100644 index 00000000000..3f1378ddbbc --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/method_disableallforhostingenvironment.go @@ -0,0 +1,77 @@ +package recommendations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DisableAllForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DisableAllForHostingEnvironmentOperationOptions struct { + EnvironmentName *string +} + +func DefaultDisableAllForHostingEnvironmentOperationOptions() DisableAllForHostingEnvironmentOperationOptions { + return DisableAllForHostingEnvironmentOperationOptions{} +} + +func (o DisableAllForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DisableAllForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DisableAllForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EnvironmentName != nil { + out.Append("environmentName", fmt.Sprintf("%v", *o.EnvironmentName)) + } + return &out +} + +// DisableAllForHostingEnvironment ... +func (c RecommendationsClient) DisableAllForHostingEnvironment(ctx context.Context, id commonids.AppServiceEnvironmentId, options DisableAllForHostingEnvironmentOperationOptions) (result DisableAllForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/recommendations/disable", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/recommendations/method_disableallforwebapp.go b/resource-manager/web/2024-11-01/recommendations/method_disableallforwebapp.go new file mode 100644 index 00000000000..ce325151614 --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/method_disableallforwebapp.go @@ -0,0 +1,48 @@ +package recommendations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DisableAllForWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DisableAllForWebApp ... +func (c RecommendationsClient) DisableAllForWebApp(ctx context.Context, id commonids.AppServiceId) (result DisableAllForWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recommendations/disable", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/recommendations/method_disablerecommendationforhostingenvironment.go b/resource-manager/web/2024-11-01/recommendations/method_disablerecommendationforhostingenvironment.go new file mode 100644 index 00000000000..452a1d24ac9 --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/method_disablerecommendationforhostingenvironment.go @@ -0,0 +1,76 @@ +package recommendations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DisableRecommendationForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DisableRecommendationForHostingEnvironmentOperationOptions struct { + EnvironmentName *string +} + +func DefaultDisableRecommendationForHostingEnvironmentOperationOptions() DisableRecommendationForHostingEnvironmentOperationOptions { + return DisableRecommendationForHostingEnvironmentOperationOptions{} +} + +func (o DisableRecommendationForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DisableRecommendationForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DisableRecommendationForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EnvironmentName != nil { + out.Append("environmentName", fmt.Sprintf("%v", *o.EnvironmentName)) + } + return &out +} + +// DisableRecommendationForHostingEnvironment ... +func (c RecommendationsClient) DisableRecommendationForHostingEnvironment(ctx context.Context, id HostingEnvironmentRecommendationId, options DisableRecommendationForHostingEnvironmentOperationOptions) (result DisableRecommendationForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/disable", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/recommendations/method_disablerecommendationforsite.go b/resource-manager/web/2024-11-01/recommendations/method_disablerecommendationforsite.go new file mode 100644 index 00000000000..da51644b3c1 --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/method_disablerecommendationforsite.go @@ -0,0 +1,47 @@ +package recommendations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DisableRecommendationForSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DisableRecommendationForSite ... +func (c RecommendationsClient) DisableRecommendationForSite(ctx context.Context, id SiteRecommendationId) (result DisableRecommendationForSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disable", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/recommendations/method_disablerecommendationforsubscription.go b/resource-manager/web/2024-11-01/recommendations/method_disablerecommendationforsubscription.go new file mode 100644 index 00000000000..a3f4f94f085 --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/method_disablerecommendationforsubscription.go @@ -0,0 +1,47 @@ +package recommendations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DisableRecommendationForSubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DisableRecommendationForSubscription ... +func (c RecommendationsClient) DisableRecommendationForSubscription(ctx context.Context, id RecommendationId) (result DisableRecommendationForSubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/disable", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/recommendations/method_getruledetailsbyhostingenvironment.go b/resource-manager/web/2024-11-01/recommendations/method_getruledetailsbyhostingenvironment.go new file mode 100644 index 00000000000..0086ec07d1d --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/method_getruledetailsbyhostingenvironment.go @@ -0,0 +1,87 @@ +package recommendations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetRuleDetailsByHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RecommendationRule +} + +type GetRuleDetailsByHostingEnvironmentOperationOptions struct { + RecommendationId *string + UpdateSeen *bool +} + +func DefaultGetRuleDetailsByHostingEnvironmentOperationOptions() GetRuleDetailsByHostingEnvironmentOperationOptions { + return GetRuleDetailsByHostingEnvironmentOperationOptions{} +} + +func (o GetRuleDetailsByHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetRuleDetailsByHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetRuleDetailsByHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.RecommendationId != nil { + out.Append("recommendationId", fmt.Sprintf("%v", *o.RecommendationId)) + } + if o.UpdateSeen != nil { + out.Append("updateSeen", fmt.Sprintf("%v", *o.UpdateSeen)) + } + return &out +} + +// GetRuleDetailsByHostingEnvironment ... +func (c RecommendationsClient) GetRuleDetailsByHostingEnvironment(ctx context.Context, id HostingEnvironmentRecommendationId, options GetRuleDetailsByHostingEnvironmentOperationOptions) (result GetRuleDetailsByHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RecommendationRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/recommendations/method_getruledetailsbywebapp.go b/resource-manager/web/2024-11-01/recommendations/method_getruledetailsbywebapp.go new file mode 100644 index 00000000000..9d34652f182 --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/method_getruledetailsbywebapp.go @@ -0,0 +1,87 @@ +package recommendations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetRuleDetailsByWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RecommendationRule +} + +type GetRuleDetailsByWebAppOperationOptions struct { + RecommendationId *string + UpdateSeen *bool +} + +func DefaultGetRuleDetailsByWebAppOperationOptions() GetRuleDetailsByWebAppOperationOptions { + return GetRuleDetailsByWebAppOperationOptions{} +} + +func (o GetRuleDetailsByWebAppOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetRuleDetailsByWebAppOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o GetRuleDetailsByWebAppOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.RecommendationId != nil { + out.Append("recommendationId", fmt.Sprintf("%v", *o.RecommendationId)) + } + if o.UpdateSeen != nil { + out.Append("updateSeen", fmt.Sprintf("%v", *o.UpdateSeen)) + } + return &out +} + +// GetRuleDetailsByWebApp ... +func (c RecommendationsClient) GetRuleDetailsByWebApp(ctx context.Context, id SiteRecommendationId, options GetRuleDetailsByWebAppOperationOptions) (result GetRuleDetailsByWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RecommendationRule + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/recommendations/method_list.go b/resource-manager/web/2024-11-01/recommendations/method_list.go new file mode 100644 index 00000000000..784389aa71e --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/method_list.go @@ -0,0 +1,139 @@ +package recommendations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Recommendation +} + +type ListOperationOptions struct { + Featured *bool + Filter *string +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Featured != nil { + out.Append("featured", fmt.Sprintf("%v", *o.Featured)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c RecommendationsClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/recommendations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c RecommendationsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate RecommendationOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/recommendations/method_listhistoryforhostingenvironment.go b/resource-manager/web/2024-11-01/recommendations/method_listhistoryforhostingenvironment.go new file mode 100644 index 00000000000..6b92d0e2bb0 --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/method_listhistoryforhostingenvironment.go @@ -0,0 +1,139 @@ +package recommendations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListHistoryForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListHistoryForHostingEnvironmentCompleteResult struct { + LatestHttpResponse *http.Response + Items []Recommendation +} + +type ListHistoryForHostingEnvironmentOperationOptions struct { + ExpiredOnly *bool + Filter *string +} + +func DefaultListHistoryForHostingEnvironmentOperationOptions() ListHistoryForHostingEnvironmentOperationOptions { + return ListHistoryForHostingEnvironmentOperationOptions{} +} + +func (o ListHistoryForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListHistoryForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListHistoryForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpiredOnly != nil { + out.Append("expiredOnly", fmt.Sprintf("%v", *o.ExpiredOnly)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListHistoryForHostingEnvironmentCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListHistoryForHostingEnvironmentCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListHistoryForHostingEnvironment ... +func (c RecommendationsClient) ListHistoryForHostingEnvironment(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListHistoryForHostingEnvironmentOperationOptions) (result ListHistoryForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListHistoryForHostingEnvironmentCustomPager{}, + Path: fmt.Sprintf("%s/recommendationHistory", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHistoryForHostingEnvironmentComplete retrieves all the results into a single object +func (c RecommendationsClient) ListHistoryForHostingEnvironmentComplete(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListHistoryForHostingEnvironmentOperationOptions) (ListHistoryForHostingEnvironmentCompleteResult, error) { + return c.ListHistoryForHostingEnvironmentCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListHistoryForHostingEnvironmentCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListHistoryForHostingEnvironmentCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListHistoryForHostingEnvironmentOperationOptions, predicate RecommendationOperationPredicate) (result ListHistoryForHostingEnvironmentCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.ListHistoryForHostingEnvironment(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListHistoryForHostingEnvironmentCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/recommendations/method_listhistoryforwebapp.go b/resource-manager/web/2024-11-01/recommendations/method_listhistoryforwebapp.go new file mode 100644 index 00000000000..9fe581ed380 --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/method_listhistoryforwebapp.go @@ -0,0 +1,139 @@ +package recommendations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListHistoryForWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListHistoryForWebAppCompleteResult struct { + LatestHttpResponse *http.Response + Items []Recommendation +} + +type ListHistoryForWebAppOperationOptions struct { + ExpiredOnly *bool + Filter *string +} + +func DefaultListHistoryForWebAppOperationOptions() ListHistoryForWebAppOperationOptions { + return ListHistoryForWebAppOperationOptions{} +} + +func (o ListHistoryForWebAppOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListHistoryForWebAppOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListHistoryForWebAppOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ExpiredOnly != nil { + out.Append("expiredOnly", fmt.Sprintf("%v", *o.ExpiredOnly)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListHistoryForWebAppCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListHistoryForWebAppCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListHistoryForWebApp ... +func (c RecommendationsClient) ListHistoryForWebApp(ctx context.Context, id commonids.AppServiceId, options ListHistoryForWebAppOperationOptions) (result ListHistoryForWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListHistoryForWebAppCustomPager{}, + Path: fmt.Sprintf("%s/recommendationHistory", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHistoryForWebAppComplete retrieves all the results into a single object +func (c RecommendationsClient) ListHistoryForWebAppComplete(ctx context.Context, id commonids.AppServiceId, options ListHistoryForWebAppOperationOptions) (ListHistoryForWebAppCompleteResult, error) { + return c.ListHistoryForWebAppCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListHistoryForWebAppCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListHistoryForWebAppCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, options ListHistoryForWebAppOperationOptions, predicate RecommendationOperationPredicate) (result ListHistoryForWebAppCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.ListHistoryForWebApp(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListHistoryForWebAppCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/recommendations/method_listrecommendedrulesforhostingenvironment.go b/resource-manager/web/2024-11-01/recommendations/method_listrecommendedrulesforhostingenvironment.go new file mode 100644 index 00000000000..3d8956760e1 --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/method_listrecommendedrulesforhostingenvironment.go @@ -0,0 +1,139 @@ +package recommendations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListRecommendedRulesForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListRecommendedRulesForHostingEnvironmentCompleteResult struct { + LatestHttpResponse *http.Response + Items []Recommendation +} + +type ListRecommendedRulesForHostingEnvironmentOperationOptions struct { + Featured *bool + Filter *string +} + +func DefaultListRecommendedRulesForHostingEnvironmentOperationOptions() ListRecommendedRulesForHostingEnvironmentOperationOptions { + return ListRecommendedRulesForHostingEnvironmentOperationOptions{} +} + +func (o ListRecommendedRulesForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListRecommendedRulesForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListRecommendedRulesForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Featured != nil { + out.Append("featured", fmt.Sprintf("%v", *o.Featured)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListRecommendedRulesForHostingEnvironmentCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListRecommendedRulesForHostingEnvironmentCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListRecommendedRulesForHostingEnvironment ... +func (c RecommendationsClient) ListRecommendedRulesForHostingEnvironment(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListRecommendedRulesForHostingEnvironmentOperationOptions) (result ListRecommendedRulesForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListRecommendedRulesForHostingEnvironmentCustomPager{}, + Path: fmt.Sprintf("%s/recommendations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListRecommendedRulesForHostingEnvironmentComplete retrieves all the results into a single object +func (c RecommendationsClient) ListRecommendedRulesForHostingEnvironmentComplete(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListRecommendedRulesForHostingEnvironmentOperationOptions) (ListRecommendedRulesForHostingEnvironmentCompleteResult, error) { + return c.ListRecommendedRulesForHostingEnvironmentCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListRecommendedRulesForHostingEnvironmentCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListRecommendedRulesForHostingEnvironmentCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceEnvironmentId, options ListRecommendedRulesForHostingEnvironmentOperationOptions, predicate RecommendationOperationPredicate) (result ListRecommendedRulesForHostingEnvironmentCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.ListRecommendedRulesForHostingEnvironment(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListRecommendedRulesForHostingEnvironmentCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/recommendations/method_listrecommendedrulesforwebapp.go b/resource-manager/web/2024-11-01/recommendations/method_listrecommendedrulesforwebapp.go new file mode 100644 index 00000000000..f417cf7c61a --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/method_listrecommendedrulesforwebapp.go @@ -0,0 +1,139 @@ +package recommendations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListRecommendedRulesForWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Recommendation +} + +type ListRecommendedRulesForWebAppCompleteResult struct { + LatestHttpResponse *http.Response + Items []Recommendation +} + +type ListRecommendedRulesForWebAppOperationOptions struct { + Featured *bool + Filter *string +} + +func DefaultListRecommendedRulesForWebAppOperationOptions() ListRecommendedRulesForWebAppOperationOptions { + return ListRecommendedRulesForWebAppOperationOptions{} +} + +func (o ListRecommendedRulesForWebAppOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListRecommendedRulesForWebAppOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListRecommendedRulesForWebAppOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Featured != nil { + out.Append("featured", fmt.Sprintf("%v", *o.Featured)) + } + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListRecommendedRulesForWebAppCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListRecommendedRulesForWebAppCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListRecommendedRulesForWebApp ... +func (c RecommendationsClient) ListRecommendedRulesForWebApp(ctx context.Context, id commonids.AppServiceId, options ListRecommendedRulesForWebAppOperationOptions) (result ListRecommendedRulesForWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListRecommendedRulesForWebAppCustomPager{}, + Path: fmt.Sprintf("%s/recommendations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Recommendation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListRecommendedRulesForWebAppComplete retrieves all the results into a single object +func (c RecommendationsClient) ListRecommendedRulesForWebAppComplete(ctx context.Context, id commonids.AppServiceId, options ListRecommendedRulesForWebAppOperationOptions) (ListRecommendedRulesForWebAppCompleteResult, error) { + return c.ListRecommendedRulesForWebAppCompleteMatchingPredicate(ctx, id, options, RecommendationOperationPredicate{}) +} + +// ListRecommendedRulesForWebAppCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RecommendationsClient) ListRecommendedRulesForWebAppCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, options ListRecommendedRulesForWebAppOperationOptions, predicate RecommendationOperationPredicate) (result ListRecommendedRulesForWebAppCompleteResult, err error) { + items := make([]Recommendation, 0) + + resp, err := c.ListRecommendedRulesForWebApp(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListRecommendedRulesForWebAppCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/recommendations/method_resetallfilters.go b/resource-manager/web/2024-11-01/recommendations/method_resetallfilters.go new file mode 100644 index 00000000000..9ca523a21a2 --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/method_resetallfilters.go @@ -0,0 +1,48 @@ +package recommendations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResetAllFiltersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetAllFilters ... +func (c RecommendationsClient) ResetAllFilters(ctx context.Context, id commonids.SubscriptionId) (result ResetAllFiltersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/recommendations/reset", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/recommendations/method_resetallfiltersforhostingenvironment.go b/resource-manager/web/2024-11-01/recommendations/method_resetallfiltersforhostingenvironment.go new file mode 100644 index 00000000000..c6d9e982291 --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/method_resetallfiltersforhostingenvironment.go @@ -0,0 +1,77 @@ +package recommendations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResetAllFiltersForHostingEnvironmentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type ResetAllFiltersForHostingEnvironmentOperationOptions struct { + EnvironmentName *string +} + +func DefaultResetAllFiltersForHostingEnvironmentOperationOptions() ResetAllFiltersForHostingEnvironmentOperationOptions { + return ResetAllFiltersForHostingEnvironmentOperationOptions{} +} + +func (o ResetAllFiltersForHostingEnvironmentOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ResetAllFiltersForHostingEnvironmentOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ResetAllFiltersForHostingEnvironmentOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.EnvironmentName != nil { + out.Append("environmentName", fmt.Sprintf("%v", *o.EnvironmentName)) + } + return &out +} + +// ResetAllFiltersForHostingEnvironment ... +func (c RecommendationsClient) ResetAllFiltersForHostingEnvironment(ctx context.Context, id commonids.AppServiceEnvironmentId, options ResetAllFiltersForHostingEnvironmentOperationOptions) (result ResetAllFiltersForHostingEnvironmentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/recommendations/reset", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/recommendations/method_resetallfiltersforwebapp.go b/resource-manager/web/2024-11-01/recommendations/method_resetallfiltersforwebapp.go new file mode 100644 index 00000000000..79dcbd7603a --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/method_resetallfiltersforwebapp.go @@ -0,0 +1,48 @@ +package recommendations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResetAllFiltersForWebAppOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetAllFiltersForWebApp ... +func (c RecommendationsClient) ResetAllFiltersForWebApp(ctx context.Context, id commonids.AppServiceId) (result ResetAllFiltersForWebAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recommendations/reset", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/recommendations/model_recommendation.go b/resource-manager/web/2024-11-01/recommendations/model_recommendation.go new file mode 100644 index 00000000000..341907a80ad --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/model_recommendation.go @@ -0,0 +1,12 @@ +package recommendations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Recommendation struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RecommendationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/recommendations/model_recommendationproperties.go b/resource-manager/web/2024-11-01/recommendations/model_recommendationproperties.go new file mode 100644 index 00000000000..af604189bbf --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/model_recommendationproperties.go @@ -0,0 +1,108 @@ +package recommendations + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecommendationProperties struct { + ActionName *string `json:"actionName,omitempty"` + BladeName *string `json:"bladeName,omitempty"` + CategoryTags *[]string `json:"categoryTags,omitempty"` + Channels *Channels `json:"channels,omitempty"` + CreationTime *string `json:"creationTime,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Enabled *int64 `json:"enabled,omitempty"` + EndTime *string `json:"endTime,omitempty"` + ExtensionName *string `json:"extensionName,omitempty"` + ForwardLink *string `json:"forwardLink,omitempty"` + IsDynamic *bool `json:"isDynamic,omitempty"` + Level *NotificationLevel `json:"level,omitempty"` + Message *string `json:"message,omitempty"` + NextNotificationTime *string `json:"nextNotificationTime,omitempty"` + NotificationExpirationTime *string `json:"notificationExpirationTime,omitempty"` + NotifiedTime *string `json:"notifiedTime,omitempty"` + RecommendationId *string `json:"recommendationId,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + ResourceScope *ResourceScopeType `json:"resourceScope,omitempty"` + RuleName *string `json:"ruleName,omitempty"` + Score *float64 `json:"score,omitempty"` + StartTime *string `json:"startTime,omitempty"` + States *[]string `json:"states,omitempty"` +} + +func (o *RecommendationProperties) GetCreationTimeAsTime() (*time.Time, error) { + if o.CreationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetCreationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreationTime = &formatted +} + +func (o *RecommendationProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *RecommendationProperties) GetNextNotificationTimeAsTime() (*time.Time, error) { + if o.NextNotificationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextNotificationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetNextNotificationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextNotificationTime = &formatted +} + +func (o *RecommendationProperties) GetNotificationExpirationTimeAsTime() (*time.Time, error) { + if o.NotificationExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NotificationExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetNotificationExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NotificationExpirationTime = &formatted +} + +func (o *RecommendationProperties) GetNotifiedTimeAsTime() (*time.Time, error) { + if o.NotifiedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NotifiedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetNotifiedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NotifiedTime = &formatted +} + +func (o *RecommendationProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RecommendationProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/recommendations/model_recommendationrule.go b/resource-manager/web/2024-11-01/recommendations/model_recommendationrule.go new file mode 100644 index 00000000000..48fdfd600fd --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/model_recommendationrule.go @@ -0,0 +1,12 @@ +package recommendations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecommendationRule struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RecommendationRuleProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/recommendations/model_recommendationruleproperties.go b/resource-manager/web/2024-11-01/recommendations/model_recommendationruleproperties.go new file mode 100644 index 00000000000..0352c174d79 --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/model_recommendationruleproperties.go @@ -0,0 +1,20 @@ +package recommendations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecommendationRuleProperties struct { + ActionName *string `json:"actionName,omitempty"` + BladeName *string `json:"bladeName,omitempty"` + CategoryTags *[]string `json:"categoryTags,omitempty"` + Channels *Channels `json:"channels,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExtensionName *string `json:"extensionName,omitempty"` + ForwardLink *string `json:"forwardLink,omitempty"` + IsDynamic *bool `json:"isDynamic,omitempty"` + Level *NotificationLevel `json:"level,omitempty"` + Message *string `json:"message,omitempty"` + RecommendationId *string `json:"recommendationId,omitempty"` + RecommendationName *string `json:"recommendationName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/recommendations/predicates.go b/resource-manager/web/2024-11-01/recommendations/predicates.go new file mode 100644 index 00000000000..bb0901fe9f3 --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/predicates.go @@ -0,0 +1,32 @@ +package recommendations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecommendationOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p RecommendationOperationPredicate) Matches(input Recommendation) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/recommendations/version.go b/resource-manager/web/2024-11-01/recommendations/version.go new file mode 100644 index 00000000000..8e8e77c60f1 --- /dev/null +++ b/resource-manager/web/2024-11-01/recommendations/version.go @@ -0,0 +1,10 @@ +package recommendations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/recommendations/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/resourcehealthmetadata/README.md b/resource-manager/web/2024-11-01/resourcehealthmetadata/README.md new file mode 100644 index 00000000000..eb4708ad05a --- /dev/null +++ b/resource-manager/web/2024-11-01/resourcehealthmetadata/README.md @@ -0,0 +1,121 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/resourcehealthmetadata` Documentation + +The `resourcehealthmetadata` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/resourcehealthmetadata" +``` + + +### Client Initialization + +```go +client := resourcehealthmetadata.NewResourceHealthMetadataClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ResourceHealthMetadataClient.GetBySite` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetBySite(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceHealthMetadataClient.GetBySiteSlot` + +```go +ctx := context.TODO() +id := resourcehealthmetadata.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetBySiteSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceHealthMetadataClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceHealthMetadataClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceHealthMetadataClient.ListBySite` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListBySite(ctx, id)` can be used to do batched pagination +items, err := client.ListBySiteComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceHealthMetadataClient.ListBySiteSlot` + +```go +ctx := context.TODO() +id := resourcehealthmetadata.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListBySiteSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListBySiteSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-11-01/resourcehealthmetadata/client.go b/resource-manager/web/2024-11-01/resourcehealthmetadata/client.go new file mode 100644 index 00000000000..8d0b22d4c33 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourcehealthmetadata/client.go @@ -0,0 +1,26 @@ +package resourcehealthmetadata + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceHealthMetadataClient struct { + Client *resourcemanager.Client +} + +func NewResourceHealthMetadataClientWithBaseURI(sdkApi sdkEnv.Api) (*ResourceHealthMetadataClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "resourcehealthmetadata", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ResourceHealthMetadataClient: %+v", err) + } + + return &ResourceHealthMetadataClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/resourcehealthmetadata/id_slot.go b/resource-manager/web/2024-11-01/resourcehealthmetadata/id_slot.go new file mode 100644 index 00000000000..ef1e7ddf14c --- /dev/null +++ b/resource-manager/web/2024-11-01/resourcehealthmetadata/id_slot.go @@ -0,0 +1,139 @@ +package resourcehealthmetadata + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotId{}) +} + +var _ resourceids.ResourceId = &SlotId{} + +// SlotId is a struct representing the Resource ID for a Slot +type SlotId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string +} + +// NewSlotID returns a new SlotId struct +func NewSlotID(subscriptionId string, resourceGroupName string, siteName string, slotName string) SlotId { + return SlotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + } +} + +// ParseSlotID parses 'input' into a SlotId +func ParseSlotID(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotIDInsensitively parses 'input' case-insensitively into a SlotId +// note: this method should only be used for API response data and not user input +func ParseSlotIDInsensitively(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + return nil +} + +// ValidateSlotID checks that 'input' can be parsed as a Slot ID +func ValidateSlotID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot ID +func (id SlotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot ID +func (id SlotId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + } +} + +// String returns a human-readable description of this Slot ID +func (id SlotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + } + return fmt.Sprintf("Slot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/resourcehealthmetadata/id_slot_test.go b/resource-manager/web/2024-11-01/resourcehealthmetadata/id_slot_test.go new file mode 100644 index 00000000000..1713ffbdc7d --- /dev/null +++ b/resource-manager/web/2024-11-01/resourcehealthmetadata/id_slot_test.go @@ -0,0 +1,327 @@ +package resourcehealthmetadata + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotId{} + +func TestNewSlotID(t *testing.T) { + id := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } +} + +func TestFormatSlotID(t *testing.T) { + actual := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestParseSlotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestSegmentsForSlotId(t *testing.T) { + segments := SlotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/resourcehealthmetadata/method_getbysite.go b/resource-manager/web/2024-11-01/resourcehealthmetadata/method_getbysite.go new file mode 100644 index 00000000000..0b5f4205ef8 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourcehealthmetadata/method_getbysite.go @@ -0,0 +1,55 @@ +package resourcehealthmetadata + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBySiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceHealthMetadata +} + +// GetBySite ... +func (c ResourceHealthMetadataClient) GetBySite(ctx context.Context, id commonids.AppServiceId) (result GetBySiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/resourceHealthMetadata/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ResourceHealthMetadata + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/resourcehealthmetadata/method_getbysiteslot.go b/resource-manager/web/2024-11-01/resourcehealthmetadata/method_getbysiteslot.go new file mode 100644 index 00000000000..24365f1341a --- /dev/null +++ b/resource-manager/web/2024-11-01/resourcehealthmetadata/method_getbysiteslot.go @@ -0,0 +1,54 @@ +package resourcehealthmetadata + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBySiteSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceHealthMetadata +} + +// GetBySiteSlot ... +func (c ResourceHealthMetadataClient) GetBySiteSlot(ctx context.Context, id SlotId) (result GetBySiteSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/resourceHealthMetadata/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ResourceHealthMetadata + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/resourcehealthmetadata/method_list.go b/resource-manager/web/2024-11-01/resourcehealthmetadata/method_list.go new file mode 100644 index 00000000000..fc5ca6a83d6 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourcehealthmetadata/method_list.go @@ -0,0 +1,106 @@ +package resourcehealthmetadata + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceHealthMetadata +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceHealthMetadata +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ResourceHealthMetadataClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/resourceHealthMetadata", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceHealthMetadata `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ResourceHealthMetadataClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceHealthMetadataClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ResourceHealthMetadataOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ResourceHealthMetadata, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/resourcehealthmetadata/method_listbyresourcegroup.go b/resource-manager/web/2024-11-01/resourcehealthmetadata/method_listbyresourcegroup.go new file mode 100644 index 00000000000..44f705f6ee9 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourcehealthmetadata/method_listbyresourcegroup.go @@ -0,0 +1,106 @@ +package resourcehealthmetadata + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceHealthMetadata +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceHealthMetadata +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c ResourceHealthMetadataClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/resourceHealthMetadata", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceHealthMetadata `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ResourceHealthMetadataClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceHealthMetadataClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ResourceHealthMetadataOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ResourceHealthMetadata, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/resourcehealthmetadata/method_listbysite.go b/resource-manager/web/2024-11-01/resourcehealthmetadata/method_listbysite.go new file mode 100644 index 00000000000..8b3c47e6b0c --- /dev/null +++ b/resource-manager/web/2024-11-01/resourcehealthmetadata/method_listbysite.go @@ -0,0 +1,106 @@ +package resourcehealthmetadata + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceHealthMetadata +} + +type ListBySiteCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceHealthMetadata +} + +type ListBySiteCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySiteCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySite ... +func (c ResourceHealthMetadataClient) ListBySite(ctx context.Context, id commonids.AppServiceId) (result ListBySiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySiteCustomPager{}, + Path: fmt.Sprintf("%s/resourceHealthMetadata", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceHealthMetadata `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySiteComplete retrieves all the results into a single object +func (c ResourceHealthMetadataClient) ListBySiteComplete(ctx context.Context, id commonids.AppServiceId) (ListBySiteCompleteResult, error) { + return c.ListBySiteCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) +} + +// ListBySiteCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceHealthMetadataClient) ListBySiteCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate ResourceHealthMetadataOperationPredicate) (result ListBySiteCompleteResult, err error) { + items := make([]ResourceHealthMetadata, 0) + + resp, err := c.ListBySite(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySiteCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/resourcehealthmetadata/method_listbysiteslot.go b/resource-manager/web/2024-11-01/resourcehealthmetadata/method_listbysiteslot.go new file mode 100644 index 00000000000..49e47b7379d --- /dev/null +++ b/resource-manager/web/2024-11-01/resourcehealthmetadata/method_listbysiteslot.go @@ -0,0 +1,105 @@ +package resourcehealthmetadata + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySiteSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ResourceHealthMetadata +} + +type ListBySiteSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceHealthMetadata +} + +type ListBySiteSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySiteSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySiteSlot ... +func (c ResourceHealthMetadataClient) ListBySiteSlot(ctx context.Context, id SlotId) (result ListBySiteSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBySiteSlotCustomPager{}, + Path: fmt.Sprintf("%s/resourceHealthMetadata", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceHealthMetadata `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySiteSlotComplete retrieves all the results into a single object +func (c ResourceHealthMetadataClient) ListBySiteSlotComplete(ctx context.Context, id SlotId) (ListBySiteSlotCompleteResult, error) { + return c.ListBySiteSlotCompleteMatchingPredicate(ctx, id, ResourceHealthMetadataOperationPredicate{}) +} + +// ListBySiteSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceHealthMetadataClient) ListBySiteSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ResourceHealthMetadataOperationPredicate) (result ListBySiteSlotCompleteResult, err error) { + items := make([]ResourceHealthMetadata, 0) + + resp, err := c.ListBySiteSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySiteSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/resourcehealthmetadata/model_resourcehealthmetadata.go b/resource-manager/web/2024-11-01/resourcehealthmetadata/model_resourcehealthmetadata.go new file mode 100644 index 00000000000..14d0fa99d6c --- /dev/null +++ b/resource-manager/web/2024-11-01/resourcehealthmetadata/model_resourcehealthmetadata.go @@ -0,0 +1,12 @@ +package resourcehealthmetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceHealthMetadata struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceHealthMetadataProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourcehealthmetadata/model_resourcehealthmetadataproperties.go b/resource-manager/web/2024-11-01/resourcehealthmetadata/model_resourcehealthmetadataproperties.go new file mode 100644 index 00000000000..a59e92db1ed --- /dev/null +++ b/resource-manager/web/2024-11-01/resourcehealthmetadata/model_resourcehealthmetadataproperties.go @@ -0,0 +1,9 @@ +package resourcehealthmetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceHealthMetadataProperties struct { + Category *string `json:"category,omitempty"` + SignalAvailability *bool `json:"signalAvailability,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourcehealthmetadata/predicates.go b/resource-manager/web/2024-11-01/resourcehealthmetadata/predicates.go new file mode 100644 index 00000000000..5682d0611c2 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourcehealthmetadata/predicates.go @@ -0,0 +1,32 @@ +package resourcehealthmetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceHealthMetadataOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ResourceHealthMetadataOperationPredicate) Matches(input ResourceHealthMetadata) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/resourcehealthmetadata/version.go b/resource-manager/web/2024-11-01/resourcehealthmetadata/version.go new file mode 100644 index 00000000000..eff42a48d72 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourcehealthmetadata/version.go @@ -0,0 +1,10 @@ +package resourcehealthmetadata + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/resourcehealthmetadata/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/README.md b/resource-manager/web/2024-11-01/resourceproviders/README.md new file mode 100644 index 00000000000..c1304511ed0 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/README.md @@ -0,0 +1,393 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/resourceproviders` Documentation + +The `resourceproviders` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/resourceproviders" +``` + + +### Client Initialization + +```go +client := resourceproviders.NewResourceProvidersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ResourceProvidersClient.CheckNameAvailability` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := resourceproviders.ResourceNameAvailabilityRequest{ + // ... +} + + +read, err := client.CheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.GetPublishingUser` + +```go +ctx := context.TODO() + + +read, err := client.GetPublishingUser(ctx) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.GetSourceControl` + +```go +ctx := context.TODO() +id := resourceproviders.NewSourceControlID("sourceControlName") + +read, err := client.GetSourceControl(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.GetSubscriptionDeploymentLocations` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.GetSubscriptionDeploymentLocations(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.GetUsagesInLocationlist` + +```go +ctx := context.TODO() +id := resourceproviders.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.GetUsagesInLocationlist(ctx, id)` can be used to do batched pagination +items, err := client.GetUsagesInLocationlistComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListAseRegions` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListAseRegions(ctx, id)` can be used to do batched pagination +items, err := client.ListAseRegionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListBillingMeters` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBillingMeters(ctx, id, resourceproviders.DefaultListBillingMetersOperationOptions())` can be used to do batched pagination +items, err := client.ListBillingMetersComplete(ctx, id, resourceproviders.DefaultListBillingMetersOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListCustomHostNameSites` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListCustomHostNameSites(ctx, id, resourceproviders.DefaultListCustomHostNameSitesOperationOptions())` can be used to do batched pagination +items, err := client.ListCustomHostNameSitesComplete(ctx, id, resourceproviders.DefaultListCustomHostNameSitesOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListGeoRegions` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListGeoRegions(ctx, id, resourceproviders.DefaultListGeoRegionsOperationOptions())` can be used to do batched pagination +items, err := client.ListGeoRegionsComplete(ctx, id, resourceproviders.DefaultListGeoRegionsOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListPremierAddOnOffers` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListPremierAddOnOffers(ctx, id)` can be used to do batched pagination +items, err := client.ListPremierAddOnOffersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListSiteIdentifiersAssignedToHostName` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := resourceproviders.NameIdentifier{ + // ... +} + + +// alternatively `client.ListSiteIdentifiersAssignedToHostName(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListSiteIdentifiersAssignedToHostNameComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.ListSkus` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.ListSkus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.ListSourceControls` + +```go +ctx := context.TODO() + + +// alternatively `client.ListSourceControls(ctx)` can be used to do batched pagination +items, err := client.ListSourceControlsComplete(ctx) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ResourceProvidersClient.Move` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +payload := resourceproviders.CsmMoveResourceEnvelope{ + // ... +} + + +read, err := client.Move(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.RegionalCheckNameAvailability` + +```go +ctx := context.TODO() +id := resourceproviders.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := resourceproviders.DnlResourceNameAvailabilityRequest{ + // ... +} + + +read, err := client.RegionalCheckNameAvailability(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.UpdatePublishingUser` + +```go +ctx := context.TODO() + +payload := resourceproviders.User{ + // ... +} + + +read, err := client.UpdatePublishingUser(ctx, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.UpdateSourceControl` + +```go +ctx := context.TODO() +id := resourceproviders.NewSourceControlID("sourceControlName") + +payload := resourceproviders.SourceControl{ + // ... +} + + +read, err := client.UpdateSourceControl(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.Validate` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +payload := resourceproviders.ValidateRequest{ + // ... +} + + +read, err := client.Validate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.ValidateMove` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +payload := resourceproviders.CsmMoveResourceEnvelope{ + // ... +} + + +read, err := client.ValidateMove(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceProvidersClient.VerifyHostingEnvironmentVnet` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +payload := resourceproviders.VnetParameters{ + // ... +} + + +read, err := client.VerifyHostingEnvironmentVnet(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-11-01/resourceproviders/client.go b/resource-manager/web/2024-11-01/resourceproviders/client.go new file mode 100644 index 00000000000..f5374bb3bc3 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/client.go @@ -0,0 +1,26 @@ +package resourceproviders + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceProvidersClient struct { + Client *resourcemanager.Client +} + +func NewResourceProvidersClientWithBaseURI(sdkApi sdkEnv.Api) (*ResourceProvidersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "resourceproviders", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ResourceProvidersClient: %+v", err) + } + + return &ResourceProvidersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/constants.go b/resource-manager/web/2024-11-01/resourceproviders/constants.go new file mode 100644 index 00000000000..3f211102eb2 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/constants.go @@ -0,0 +1,563 @@ +package resourceproviders + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServicePlanRestrictions string + +const ( + AppServicePlanRestrictionsBasic AppServicePlanRestrictions = "Basic" + AppServicePlanRestrictionsFree AppServicePlanRestrictions = "Free" + AppServicePlanRestrictionsNone AppServicePlanRestrictions = "None" + AppServicePlanRestrictionsPremium AppServicePlanRestrictions = "Premium" + AppServicePlanRestrictionsShared AppServicePlanRestrictions = "Shared" + AppServicePlanRestrictionsStandard AppServicePlanRestrictions = "Standard" +) + +func PossibleValuesForAppServicePlanRestrictions() []string { + return []string{ + string(AppServicePlanRestrictionsBasic), + string(AppServicePlanRestrictionsFree), + string(AppServicePlanRestrictionsNone), + string(AppServicePlanRestrictionsPremium), + string(AppServicePlanRestrictionsShared), + string(AppServicePlanRestrictionsStandard), + } +} + +func (s *AppServicePlanRestrictions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAppServicePlanRestrictions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAppServicePlanRestrictions(input string) (*AppServicePlanRestrictions, error) { + vals := map[string]AppServicePlanRestrictions{ + "basic": AppServicePlanRestrictionsBasic, + "free": AppServicePlanRestrictionsFree, + "none": AppServicePlanRestrictionsNone, + "premium": AppServicePlanRestrictionsPremium, + "shared": AppServicePlanRestrictionsShared, + "standard": AppServicePlanRestrictionsStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AppServicePlanRestrictions(input) + return &out, nil +} + +type CheckNameResourceTypes string + +const ( + CheckNameResourceTypesHostingEnvironment CheckNameResourceTypes = "HostingEnvironment" + CheckNameResourceTypesMicrosoftPointWebHostingEnvironments CheckNameResourceTypes = "Microsoft.Web/hostingEnvironments" + CheckNameResourceTypesMicrosoftPointWebPublishingUsers CheckNameResourceTypes = "Microsoft.Web/publishingUsers" + CheckNameResourceTypesMicrosoftPointWebSites CheckNameResourceTypes = "Microsoft.Web/sites" + CheckNameResourceTypesMicrosoftPointWebSitesSlots CheckNameResourceTypes = "Microsoft.Web/sites/slots" + CheckNameResourceTypesPublishingUser CheckNameResourceTypes = "PublishingUser" + CheckNameResourceTypesSite CheckNameResourceTypes = "Site" + CheckNameResourceTypesSlot CheckNameResourceTypes = "Slot" +) + +func PossibleValuesForCheckNameResourceTypes() []string { + return []string{ + string(CheckNameResourceTypesHostingEnvironment), + string(CheckNameResourceTypesMicrosoftPointWebHostingEnvironments), + string(CheckNameResourceTypesMicrosoftPointWebPublishingUsers), + string(CheckNameResourceTypesMicrosoftPointWebSites), + string(CheckNameResourceTypesMicrosoftPointWebSitesSlots), + string(CheckNameResourceTypesPublishingUser), + string(CheckNameResourceTypesSite), + string(CheckNameResourceTypesSlot), + } +} + +func (s *CheckNameResourceTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCheckNameResourceTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCheckNameResourceTypes(input string) (*CheckNameResourceTypes, error) { + vals := map[string]CheckNameResourceTypes{ + "hostingenvironment": CheckNameResourceTypesHostingEnvironment, + "microsoft.web/hostingenvironments": CheckNameResourceTypesMicrosoftPointWebHostingEnvironments, + "microsoft.web/publishingusers": CheckNameResourceTypesMicrosoftPointWebPublishingUsers, + "microsoft.web/sites": CheckNameResourceTypesMicrosoftPointWebSites, + "microsoft.web/sites/slots": CheckNameResourceTypesMicrosoftPointWebSitesSlots, + "publishinguser": CheckNameResourceTypesPublishingUser, + "site": CheckNameResourceTypesSite, + "slot": CheckNameResourceTypesSlot, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CheckNameResourceTypes(input) + return &out, nil +} + +type CustomDnsSuffixProvisioningState string + +const ( + CustomDnsSuffixProvisioningStateDegraded CustomDnsSuffixProvisioningState = "Degraded" + CustomDnsSuffixProvisioningStateFailed CustomDnsSuffixProvisioningState = "Failed" + CustomDnsSuffixProvisioningStateInProgress CustomDnsSuffixProvisioningState = "InProgress" + CustomDnsSuffixProvisioningStateSucceeded CustomDnsSuffixProvisioningState = "Succeeded" +) + +func PossibleValuesForCustomDnsSuffixProvisioningState() []string { + return []string{ + string(CustomDnsSuffixProvisioningStateDegraded), + string(CustomDnsSuffixProvisioningStateFailed), + string(CustomDnsSuffixProvisioningStateInProgress), + string(CustomDnsSuffixProvisioningStateSucceeded), + } +} + +func (s *CustomDnsSuffixProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomDnsSuffixProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomDnsSuffixProvisioningState(input string) (*CustomDnsSuffixProvisioningState, error) { + vals := map[string]CustomDnsSuffixProvisioningState{ + "degraded": CustomDnsSuffixProvisioningStateDegraded, + "failed": CustomDnsSuffixProvisioningStateFailed, + "inprogress": CustomDnsSuffixProvisioningStateInProgress, + "succeeded": CustomDnsSuffixProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomDnsSuffixProvisioningState(input) + return &out, nil +} + +type HostingEnvironmentStatus string + +const ( + HostingEnvironmentStatusDeleting HostingEnvironmentStatus = "Deleting" + HostingEnvironmentStatusPreparing HostingEnvironmentStatus = "Preparing" + HostingEnvironmentStatusReady HostingEnvironmentStatus = "Ready" + HostingEnvironmentStatusScaling HostingEnvironmentStatus = "Scaling" +) + +func PossibleValuesForHostingEnvironmentStatus() []string { + return []string{ + string(HostingEnvironmentStatusDeleting), + string(HostingEnvironmentStatusPreparing), + string(HostingEnvironmentStatusReady), + string(HostingEnvironmentStatusScaling), + } +} + +func (s *HostingEnvironmentStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostingEnvironmentStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostingEnvironmentStatus(input string) (*HostingEnvironmentStatus, error) { + vals := map[string]HostingEnvironmentStatus{ + "deleting": HostingEnvironmentStatusDeleting, + "preparing": HostingEnvironmentStatusPreparing, + "ready": HostingEnvironmentStatusReady, + "scaling": HostingEnvironmentStatusScaling, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostingEnvironmentStatus(input) + return &out, nil +} + +type InAvailabilityReasonType string + +const ( + InAvailabilityReasonTypeAlreadyExists InAvailabilityReasonType = "AlreadyExists" + InAvailabilityReasonTypeInvalid InAvailabilityReasonType = "Invalid" +) + +func PossibleValuesForInAvailabilityReasonType() []string { + return []string{ + string(InAvailabilityReasonTypeAlreadyExists), + string(InAvailabilityReasonTypeInvalid), + } +} + +func (s *InAvailabilityReasonType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInAvailabilityReasonType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInAvailabilityReasonType(input string) (*InAvailabilityReasonType, error) { + vals := map[string]InAvailabilityReasonType{ + "alreadyexists": InAvailabilityReasonTypeAlreadyExists, + "invalid": InAvailabilityReasonTypeInvalid, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InAvailabilityReasonType(input) + return &out, nil +} + +type LoadBalancingMode string + +const ( + LoadBalancingModeNone LoadBalancingMode = "None" + LoadBalancingModePublishing LoadBalancingMode = "Publishing" + LoadBalancingModeWeb LoadBalancingMode = "Web" + LoadBalancingModeWebPublishing LoadBalancingMode = "Web, Publishing" +) + +func PossibleValuesForLoadBalancingMode() []string { + return []string{ + string(LoadBalancingModeNone), + string(LoadBalancingModePublishing), + string(LoadBalancingModeWeb), + string(LoadBalancingModeWebPublishing), + } +} + +func (s *LoadBalancingMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancingMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancingMode(input string) (*LoadBalancingMode, error) { + vals := map[string]LoadBalancingMode{ + "none": LoadBalancingModeNone, + "publishing": LoadBalancingModePublishing, + "web": LoadBalancingModeWeb, + "web, publishing": LoadBalancingModeWebPublishing, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancingMode(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateInProgress), + string(ProvisioningStateSucceeded), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "inprogress": ProvisioningStateInProgress, + "succeeded": ProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type SkuName string + +const ( + SkuNameBasic SkuName = "Basic" + SkuNameDynamic SkuName = "Dynamic" + SkuNameElasticIsolated SkuName = "ElasticIsolated" + SkuNameElasticPremium SkuName = "ElasticPremium" + SkuNameFlexConsumption SkuName = "FlexConsumption" + SkuNameFree SkuName = "Free" + SkuNameIsolated SkuName = "Isolated" + SkuNameIsolatedVTwo SkuName = "IsolatedV2" + SkuNamePremium SkuName = "Premium" + SkuNamePremiumContainer SkuName = "PremiumContainer" + SkuNamePremiumVThree SkuName = "PremiumV3" + SkuNamePremiumVTwo SkuName = "PremiumV2" + SkuNameShared SkuName = "Shared" + SkuNameStandard SkuName = "Standard" +) + +func PossibleValuesForSkuName() []string { + return []string{ + string(SkuNameBasic), + string(SkuNameDynamic), + string(SkuNameElasticIsolated), + string(SkuNameElasticPremium), + string(SkuNameFlexConsumption), + string(SkuNameFree), + string(SkuNameIsolated), + string(SkuNameIsolatedVTwo), + string(SkuNamePremium), + string(SkuNamePremiumContainer), + string(SkuNamePremiumVThree), + string(SkuNamePremiumVTwo), + string(SkuNameShared), + string(SkuNameStandard), + } +} + +func (s *SkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuName(input string) (*SkuName, error) { + vals := map[string]SkuName{ + "basic": SkuNameBasic, + "dynamic": SkuNameDynamic, + "elasticisolated": SkuNameElasticIsolated, + "elasticpremium": SkuNameElasticPremium, + "flexconsumption": SkuNameFlexConsumption, + "free": SkuNameFree, + "isolated": SkuNameIsolated, + "isolatedv2": SkuNameIsolatedVTwo, + "premium": SkuNamePremium, + "premiumcontainer": SkuNamePremiumContainer, + "premiumv3": SkuNamePremiumVThree, + "premiumv2": SkuNamePremiumVTwo, + "shared": SkuNameShared, + "standard": SkuNameStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuName(input) + return &out, nil +} + +type UpgradeAvailability string + +const ( + UpgradeAvailabilityNone UpgradeAvailability = "None" + UpgradeAvailabilityReady UpgradeAvailability = "Ready" +) + +func PossibleValuesForUpgradeAvailability() []string { + return []string{ + string(UpgradeAvailabilityNone), + string(UpgradeAvailabilityReady), + } +} + +func (s *UpgradeAvailability) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradeAvailability(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpgradeAvailability(input string) (*UpgradeAvailability, error) { + vals := map[string]UpgradeAvailability{ + "none": UpgradeAvailabilityNone, + "ready": UpgradeAvailabilityReady, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpgradeAvailability(input) + return &out, nil +} + +type UpgradePreference string + +const ( + UpgradePreferenceEarly UpgradePreference = "Early" + UpgradePreferenceLate UpgradePreference = "Late" + UpgradePreferenceManual UpgradePreference = "Manual" + UpgradePreferenceNone UpgradePreference = "None" +) + +func PossibleValuesForUpgradePreference() []string { + return []string{ + string(UpgradePreferenceEarly), + string(UpgradePreferenceLate), + string(UpgradePreferenceManual), + string(UpgradePreferenceNone), + } +} + +func (s *UpgradePreference) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradePreference(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpgradePreference(input string) (*UpgradePreference, error) { + vals := map[string]UpgradePreference{ + "early": UpgradePreferenceEarly, + "late": UpgradePreferenceLate, + "manual": UpgradePreferenceManual, + "none": UpgradePreferenceNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpgradePreference(input) + return &out, nil +} + +type ValidateResourceTypes string + +const ( + ValidateResourceTypesMicrosoftPointWebHostingEnvironments ValidateResourceTypes = "Microsoft.Web/hostingEnvironments" + ValidateResourceTypesServerFarm ValidateResourceTypes = "ServerFarm" + ValidateResourceTypesSite ValidateResourceTypes = "Site" +) + +func PossibleValuesForValidateResourceTypes() []string { + return []string{ + string(ValidateResourceTypesMicrosoftPointWebHostingEnvironments), + string(ValidateResourceTypesServerFarm), + string(ValidateResourceTypesSite), + } +} + +func (s *ValidateResourceTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseValidateResourceTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseValidateResourceTypes(input string) (*ValidateResourceTypes, error) { + vals := map[string]ValidateResourceTypes{ + "microsoft.web/hostingenvironments": ValidateResourceTypesMicrosoftPointWebHostingEnvironments, + "serverfarm": ValidateResourceTypesServerFarm, + "site": ValidateResourceTypesSite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ValidateResourceTypes(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/id_providerlocation.go b/resource-manager/web/2024-11-01/resourceproviders/id_providerlocation.go new file mode 100644 index 00000000000..93f55de2bf3 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/id_providerlocation.go @@ -0,0 +1,121 @@ +package resourceproviders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/id_providerlocation_test.go b/resource-manager/web/2024-11-01/resourceproviders/id_providerlocation_test.go new file mode 100644 index 00000000000..4d560e91917 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/id_providerlocation_test.go @@ -0,0 +1,237 @@ +package resourceproviders + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/id_sourcecontrol.go b/resource-manager/web/2024-11-01/resourceproviders/id_sourcecontrol.go new file mode 100644 index 00000000000..a78436e8801 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/id_sourcecontrol.go @@ -0,0 +1,112 @@ +package resourceproviders + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SourceControlId{}) +} + +var _ resourceids.ResourceId = &SourceControlId{} + +// SourceControlId is a struct representing the Resource ID for a Source Control +type SourceControlId struct { + SourceControlName string +} + +// NewSourceControlID returns a new SourceControlId struct +func NewSourceControlID(sourceControlName string) SourceControlId { + return SourceControlId{ + SourceControlName: sourceControlName, + } +} + +// ParseSourceControlID parses 'input' into a SourceControlId +func ParseSourceControlID(input string) (*SourceControlId, error) { + parser := resourceids.NewParserFromResourceIdType(&SourceControlId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SourceControlId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSourceControlIDInsensitively parses 'input' case-insensitively into a SourceControlId +// note: this method should only be used for API response data and not user input +func ParseSourceControlIDInsensitively(input string) (*SourceControlId, error) { + parser := resourceids.NewParserFromResourceIdType(&SourceControlId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SourceControlId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SourceControlId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SourceControlName, ok = input.Parsed["sourceControlName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sourceControlName", input) + } + + return nil +} + +// ValidateSourceControlID checks that 'input' can be parsed as a Source Control ID +func ValidateSourceControlID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSourceControlID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Source Control ID +func (id SourceControlId) ID() string { + fmtString := "/providers/Microsoft.Web/sourceControls/%s" + return fmt.Sprintf(fmtString, id.SourceControlName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Source Control ID +func (id SourceControlId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSourceControls", "sourceControls", "sourceControls"), + resourceids.UserSpecifiedSegment("sourceControlName", "sourceControlName"), + } +} + +// String returns a human-readable description of this Source Control ID +func (id SourceControlId) String() string { + components := []string{ + fmt.Sprintf("Source Control Name: %q", id.SourceControlName), + } + return fmt.Sprintf("Source Control (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/id_sourcecontrol_test.go b/resource-manager/web/2024-11-01/resourceproviders/id_sourcecontrol_test.go new file mode 100644 index 00000000000..a64983484b3 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/id_sourcecontrol_test.go @@ -0,0 +1,192 @@ +package resourceproviders + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SourceControlId{} + +func TestNewSourceControlID(t *testing.T) { + id := NewSourceControlID("sourceControlName") + + if id.SourceControlName != "sourceControlName" { + t.Fatalf("Expected %q but got %q for Segment 'SourceControlName'", id.SourceControlName, "sourceControlName") + } +} + +func TestFormatSourceControlID(t *testing.T) { + actual := NewSourceControlID("sourceControlName").ID() + expected := "/providers/Microsoft.Web/sourceControls/sourceControlName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSourceControlID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SourceControlId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web/sourceControls", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Web/sourceControls/sourceControlName", + Expected: &SourceControlId{ + SourceControlName: "sourceControlName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Web/sourceControls/sourceControlName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSourceControlID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SourceControlName != v.Expected.SourceControlName { + t.Fatalf("Expected %q but got %q for SourceControlName", v.Expected.SourceControlName, actual.SourceControlName) + } + + } +} + +func TestParseSourceControlIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SourceControlId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/providers/Microsoft.Web/sourceControls", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/sOuRcEcOnTrOlS", + Error: true, + }, + { + // Valid URI + Input: "/providers/Microsoft.Web/sourceControls/sourceControlName", + Expected: &SourceControlId{ + SourceControlName: "sourceControlName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/providers/Microsoft.Web/sourceControls/sourceControlName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/sOuRcEcOnTrOlS/sOuRcEcOnTrOlNaMe", + Expected: &SourceControlId{ + SourceControlName: "sOuRcEcOnTrOlNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pRoViDeRs/mIcRoSoFt.wEb/sOuRcEcOnTrOlS/sOuRcEcOnTrOlNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSourceControlIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SourceControlName != v.Expected.SourceControlName { + t.Fatalf("Expected %q but got %q for SourceControlName", v.Expected.SourceControlName, actual.SourceControlName) + } + + } +} + +func TestSegmentsForSourceControlId(t *testing.T) { + segments := SourceControlId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SourceControlId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_checknameavailability.go b/resource-manager/web/2024-11-01/resourceproviders/method_checknameavailability.go new file mode 100644 index 00000000000..8d708561b66 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_checknameavailability.go @@ -0,0 +1,59 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceNameAvailability +} + +// CheckNameAvailability ... +func (c ResourceProvidersClient) CheckNameAvailability(ctx context.Context, id commonids.SubscriptionId, input ResourceNameAvailabilityRequest) (result CheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/checknameavailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ResourceNameAvailability + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_getpublishinguser.go b/resource-manager/web/2024-11-01/resourceproviders/method_getpublishinguser.go new file mode 100644 index 00000000000..e0529900390 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_getpublishinguser.go @@ -0,0 +1,53 @@ +package resourceproviders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPublishingUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *User +} + +// GetPublishingUser ... +func (c ResourceProvidersClient) GetPublishingUser(ctx context.Context) (result GetPublishingUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: "/providers/Microsoft.Web/publishingUsers/web", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model User + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_getsourcecontrol.go b/resource-manager/web/2024-11-01/resourceproviders/method_getsourcecontrol.go new file mode 100644 index 00000000000..2684d63d83c --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_getsourcecontrol.go @@ -0,0 +1,53 @@ +package resourceproviders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SourceControl +} + +// GetSourceControl ... +func (c ResourceProvidersClient) GetSourceControl(ctx context.Context, id SourceControlId) (result GetSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SourceControl + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_getsubscriptiondeploymentlocations.go b/resource-manager/web/2024-11-01/resourceproviders/method_getsubscriptiondeploymentlocations.go new file mode 100644 index 00000000000..3564d1ecad9 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_getsubscriptiondeploymentlocations.go @@ -0,0 +1,55 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSubscriptionDeploymentLocationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DeploymentLocations +} + +// GetSubscriptionDeploymentLocations ... +func (c ResourceProvidersClient) GetSubscriptionDeploymentLocations(ctx context.Context, id commonids.SubscriptionId) (result GetSubscriptionDeploymentLocationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/deploymentLocations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DeploymentLocations + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_getusagesinlocationlist.go b/resource-manager/web/2024-11-01/resourceproviders/method_getusagesinlocationlist.go new file mode 100644 index 00000000000..34301f4dd5f --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_getusagesinlocationlist.go @@ -0,0 +1,105 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetUsagesInLocationlistOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type GetUsagesInLocationlistCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmUsageQuota +} + +type GetUsagesInLocationlistCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetUsagesInLocationlistCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetUsagesInLocationlist ... +func (c ResourceProvidersClient) GetUsagesInLocationlist(ctx context.Context, id ProviderLocationId) (result GetUsagesInLocationlistOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetUsagesInLocationlistCustomPager{}, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetUsagesInLocationlistComplete retrieves all the results into a single object +func (c ResourceProvidersClient) GetUsagesInLocationlistComplete(ctx context.Context, id ProviderLocationId) (GetUsagesInLocationlistCompleteResult, error) { + return c.GetUsagesInLocationlistCompleteMatchingPredicate(ctx, id, CsmUsageQuotaOperationPredicate{}) +} + +// GetUsagesInLocationlistCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) GetUsagesInLocationlistCompleteMatchingPredicate(ctx context.Context, id ProviderLocationId, predicate CsmUsageQuotaOperationPredicate) (result GetUsagesInLocationlistCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.GetUsagesInLocationlist(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetUsagesInLocationlistCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_listaseregions.go b/resource-manager/web/2024-11-01/resourceproviders/method_listaseregions.go new file mode 100644 index 00000000000..401237f0e41 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_listaseregions.go @@ -0,0 +1,106 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAseRegionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AseRegion +} + +type ListAseRegionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []AseRegion +} + +type ListAseRegionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAseRegionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAseRegions ... +func (c ResourceProvidersClient) ListAseRegions(ctx context.Context, id commonids.SubscriptionId) (result ListAseRegionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListAseRegionsCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/aseRegions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AseRegion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAseRegionsComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListAseRegionsComplete(ctx context.Context, id commonids.SubscriptionId) (ListAseRegionsCompleteResult, error) { + return c.ListAseRegionsCompleteMatchingPredicate(ctx, id, AseRegionOperationPredicate{}) +} + +// ListAseRegionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListAseRegionsCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate AseRegionOperationPredicate) (result ListAseRegionsCompleteResult, err error) { + items := make([]AseRegion, 0) + + resp, err := c.ListAseRegions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAseRegionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_listbillingmeters.go b/resource-manager/web/2024-11-01/resourceproviders/method_listbillingmeters.go new file mode 100644 index 00000000000..97f4b003c15 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_listbillingmeters.go @@ -0,0 +1,139 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBillingMetersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BillingMeter +} + +type ListBillingMetersCompleteResult struct { + LatestHttpResponse *http.Response + Items []BillingMeter +} + +type ListBillingMetersOperationOptions struct { + BillingLocation *string + OsType *string +} + +func DefaultListBillingMetersOperationOptions() ListBillingMetersOperationOptions { + return ListBillingMetersOperationOptions{} +} + +func (o ListBillingMetersOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBillingMetersOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBillingMetersOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.BillingLocation != nil { + out.Append("billingLocation", fmt.Sprintf("%v", *o.BillingLocation)) + } + if o.OsType != nil { + out.Append("osType", fmt.Sprintf("%v", *o.OsType)) + } + return &out +} + +type ListBillingMetersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBillingMetersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBillingMeters ... +func (c ResourceProvidersClient) ListBillingMeters(ctx context.Context, id commonids.SubscriptionId, options ListBillingMetersOperationOptions) (result ListBillingMetersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListBillingMetersCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/billingMeters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BillingMeter `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBillingMetersComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListBillingMetersComplete(ctx context.Context, id commonids.SubscriptionId, options ListBillingMetersOperationOptions) (ListBillingMetersCompleteResult, error) { + return c.ListBillingMetersCompleteMatchingPredicate(ctx, id, options, BillingMeterOperationPredicate{}) +} + +// ListBillingMetersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListBillingMetersCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBillingMetersOperationOptions, predicate BillingMeterOperationPredicate) (result ListBillingMetersCompleteResult, err error) { + items := make([]BillingMeter, 0) + + resp, err := c.ListBillingMeters(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBillingMetersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_listcustomhostnamesites.go b/resource-manager/web/2024-11-01/resourceproviders/method_listcustomhostnamesites.go new file mode 100644 index 00000000000..f3f451bdaf0 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_listcustomhostnamesites.go @@ -0,0 +1,135 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListCustomHostNameSitesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CustomHostnameSites +} + +type ListCustomHostNameSitesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CustomHostnameSites +} + +type ListCustomHostNameSitesOperationOptions struct { + Hostname *string +} + +func DefaultListCustomHostNameSitesOperationOptions() ListCustomHostNameSitesOperationOptions { + return ListCustomHostNameSitesOperationOptions{} +} + +func (o ListCustomHostNameSitesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListCustomHostNameSitesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListCustomHostNameSitesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Hostname != nil { + out.Append("hostname", fmt.Sprintf("%v", *o.Hostname)) + } + return &out +} + +type ListCustomHostNameSitesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomHostNameSitesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListCustomHostNameSites ... +func (c ResourceProvidersClient) ListCustomHostNameSites(ctx context.Context, id commonids.SubscriptionId, options ListCustomHostNameSitesOperationOptions) (result ListCustomHostNameSitesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomHostNameSitesCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/customhostnameSites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CustomHostnameSites `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListCustomHostNameSitesComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListCustomHostNameSitesComplete(ctx context.Context, id commonids.SubscriptionId, options ListCustomHostNameSitesOperationOptions) (ListCustomHostNameSitesCompleteResult, error) { + return c.ListCustomHostNameSitesCompleteMatchingPredicate(ctx, id, options, CustomHostnameSitesOperationPredicate{}) +} + +// ListCustomHostNameSitesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListCustomHostNameSitesCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListCustomHostNameSitesOperationOptions, predicate CustomHostnameSitesOperationPredicate) (result ListCustomHostNameSitesCompleteResult, err error) { + items := make([]CustomHostnameSites, 0) + + resp, err := c.ListCustomHostNameSites(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCustomHostNameSitesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_listgeoregions.go b/resource-manager/web/2024-11-01/resourceproviders/method_listgeoregions.go new file mode 100644 index 00000000000..e1022e689b7 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_listgeoregions.go @@ -0,0 +1,147 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListGeoRegionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GeoRegion +} + +type ListGeoRegionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []GeoRegion +} + +type ListGeoRegionsOperationOptions struct { + LinuxDynamicWorkersEnabled *bool + LinuxWorkersEnabled *bool + Sku *SkuName + XenonWorkersEnabled *bool +} + +func DefaultListGeoRegionsOperationOptions() ListGeoRegionsOperationOptions { + return ListGeoRegionsOperationOptions{} +} + +func (o ListGeoRegionsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListGeoRegionsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListGeoRegionsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.LinuxDynamicWorkersEnabled != nil { + out.Append("linuxDynamicWorkersEnabled", fmt.Sprintf("%v", *o.LinuxDynamicWorkersEnabled)) + } + if o.LinuxWorkersEnabled != nil { + out.Append("linuxWorkersEnabled", fmt.Sprintf("%v", *o.LinuxWorkersEnabled)) + } + if o.Sku != nil { + out.Append("sku", fmt.Sprintf("%v", *o.Sku)) + } + if o.XenonWorkersEnabled != nil { + out.Append("xenonWorkersEnabled", fmt.Sprintf("%v", *o.XenonWorkersEnabled)) + } + return &out +} + +type ListGeoRegionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListGeoRegionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListGeoRegions ... +func (c ResourceProvidersClient) ListGeoRegions(ctx context.Context, id commonids.SubscriptionId, options ListGeoRegionsOperationOptions) (result ListGeoRegionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListGeoRegionsCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/geoRegions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GeoRegion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListGeoRegionsComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListGeoRegionsComplete(ctx context.Context, id commonids.SubscriptionId, options ListGeoRegionsOperationOptions) (ListGeoRegionsCompleteResult, error) { + return c.ListGeoRegionsCompleteMatchingPredicate(ctx, id, options, GeoRegionOperationPredicate{}) +} + +// ListGeoRegionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListGeoRegionsCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListGeoRegionsOperationOptions, predicate GeoRegionOperationPredicate) (result ListGeoRegionsCompleteResult, err error) { + items := make([]GeoRegion, 0) + + resp, err := c.ListGeoRegions(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListGeoRegionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_listpremieraddonoffers.go b/resource-manager/web/2024-11-01/resourceproviders/method_listpremieraddonoffers.go new file mode 100644 index 00000000000..330e4571b61 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_listpremieraddonoffers.go @@ -0,0 +1,106 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListPremierAddOnOffersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PremierAddOnOffer +} + +type ListPremierAddOnOffersCompleteResult struct { + LatestHttpResponse *http.Response + Items []PremierAddOnOffer +} + +type ListPremierAddOnOffersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListPremierAddOnOffersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListPremierAddOnOffers ... +func (c ResourceProvidersClient) ListPremierAddOnOffers(ctx context.Context, id commonids.SubscriptionId) (result ListPremierAddOnOffersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListPremierAddOnOffersCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/premieraddonoffers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PremierAddOnOffer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPremierAddOnOffersComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListPremierAddOnOffersComplete(ctx context.Context, id commonids.SubscriptionId) (ListPremierAddOnOffersCompleteResult, error) { + return c.ListPremierAddOnOffersCompleteMatchingPredicate(ctx, id, PremierAddOnOfferOperationPredicate{}) +} + +// ListPremierAddOnOffersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListPremierAddOnOffersCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate PremierAddOnOfferOperationPredicate) (result ListPremierAddOnOffersCompleteResult, err error) { + items := make([]PremierAddOnOffer, 0) + + resp, err := c.ListPremierAddOnOffers(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListPremierAddOnOffersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_listsiteidentifiersassignedtohostname.go b/resource-manager/web/2024-11-01/resourceproviders/method_listsiteidentifiersassignedtohostname.go new file mode 100644 index 00000000000..b759ab015d3 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_listsiteidentifiersassignedtohostname.go @@ -0,0 +1,106 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSiteIdentifiersAssignedToHostNameOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Identifier +} + +type ListSiteIdentifiersAssignedToHostNameCompleteResult struct { + LatestHttpResponse *http.Response + Items []Identifier +} + +type ListSiteIdentifiersAssignedToHostNameCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteIdentifiersAssignedToHostNameCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteIdentifiersAssignedToHostName ... +func (c ResourceProvidersClient) ListSiteIdentifiersAssignedToHostName(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier) (result ListSiteIdentifiersAssignedToHostNameOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListSiteIdentifiersAssignedToHostNameCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/listSitesAssignedToHostName", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Identifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteIdentifiersAssignedToHostNameComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListSiteIdentifiersAssignedToHostNameComplete(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier) (ListSiteIdentifiersAssignedToHostNameCompleteResult, error) { + return c.ListSiteIdentifiersAssignedToHostNameCompleteMatchingPredicate(ctx, id, input, IdentifierOperationPredicate{}) +} + +// ListSiteIdentifiersAssignedToHostNameCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListSiteIdentifiersAssignedToHostNameCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, input NameIdentifier, predicate IdentifierOperationPredicate) (result ListSiteIdentifiersAssignedToHostNameCompleteResult, err error) { + items := make([]Identifier, 0) + + resp, err := c.ListSiteIdentifiersAssignedToHostName(ctx, id, input) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteIdentifiersAssignedToHostNameCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_listskus.go b/resource-manager/web/2024-11-01/resourceproviders/method_listskus.go new file mode 100644 index 00000000000..cffe2769c1b --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_listskus.go @@ -0,0 +1,55 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SkuInfos +} + +// ListSkus ... +func (c ResourceProvidersClient) ListSkus(ctx context.Context, id commonids.SubscriptionId) (result ListSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/skus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SkuInfos + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_listsourcecontrols.go b/resource-manager/web/2024-11-01/resourceproviders/method_listsourcecontrols.go new file mode 100644 index 00000000000..b06f0d3e624 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_listsourcecontrols.go @@ -0,0 +1,105 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSourceControlsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SourceControl +} + +type ListSourceControlsCompleteResult struct { + LatestHttpResponse *http.Response + Items []SourceControl +} + +type ListSourceControlsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSourceControlsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSourceControls ... +func (c ResourceProvidersClient) ListSourceControls(ctx context.Context) (result ListSourceControlsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSourceControlsCustomPager{}, + Path: "/providers/Microsoft.Web/sourceControls", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SourceControl `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSourceControlsComplete retrieves all the results into a single object +func (c ResourceProvidersClient) ListSourceControlsComplete(ctx context.Context) (ListSourceControlsCompleteResult, error) { + return c.ListSourceControlsCompleteMatchingPredicate(ctx, SourceControlOperationPredicate{}) +} + +// ListSourceControlsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ResourceProvidersClient) ListSourceControlsCompleteMatchingPredicate(ctx context.Context, predicate SourceControlOperationPredicate) (result ListSourceControlsCompleteResult, err error) { + items := make([]SourceControl, 0) + + resp, err := c.ListSourceControls(ctx) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSourceControlsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_move.go b/resource-manager/web/2024-11-01/resourceproviders/method_move.go new file mode 100644 index 00000000000..1d47ce748e7 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_move.go @@ -0,0 +1,52 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MoveOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Move ... +func (c ResourceProvidersClient) Move(ctx context.Context, id commonids.ResourceGroupId, input CsmMoveResourceEnvelope) (result MoveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/moveResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_regionalchecknameavailability.go b/resource-manager/web/2024-11-01/resourceproviders/method_regionalchecknameavailability.go new file mode 100644 index 00000000000..85b200ff9ea --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_regionalchecknameavailability.go @@ -0,0 +1,58 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegionalCheckNameAvailabilityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DnlResourceNameAvailability +} + +// RegionalCheckNameAvailability ... +func (c ResourceProvidersClient) RegionalCheckNameAvailability(ctx context.Context, id ProviderLocationId, input DnlResourceNameAvailabilityRequest) (result RegionalCheckNameAvailabilityOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/checknameavailability", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DnlResourceNameAvailability + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_updatepublishinguser.go b/resource-manager/web/2024-11-01/resourceproviders/method_updatepublishinguser.go new file mode 100644 index 00000000000..e994b006317 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_updatepublishinguser.go @@ -0,0 +1,57 @@ +package resourceproviders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdatePublishingUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *User +} + +// UpdatePublishingUser ... +func (c ResourceProvidersClient) UpdatePublishingUser(ctx context.Context, input User) (result UpdatePublishingUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: "/providers/Microsoft.Web/publishingUsers/web", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model User + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_updatesourcecontrol.go b/resource-manager/web/2024-11-01/resourceproviders/method_updatesourcecontrol.go new file mode 100644 index 00000000000..1d9f45f198e --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_updatesourcecontrol.go @@ -0,0 +1,57 @@ +package resourceproviders + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SourceControl +} + +// UpdateSourceControl ... +func (c ResourceProvidersClient) UpdateSourceControl(ctx context.Context, id SourceControlId, input SourceControl) (result UpdateSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SourceControl + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_validate.go b/resource-manager/web/2024-11-01/resourceproviders/method_validate.go new file mode 100644 index 00000000000..4db5e1bb83c --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_validate.go @@ -0,0 +1,59 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ValidateResponse +} + +// Validate ... +func (c ResourceProvidersClient) Validate(ctx context.Context, id commonids.ResourceGroupId, input ValidateRequest) (result ValidateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/validate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ValidateResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_validatemove.go b/resource-manager/web/2024-11-01/resourceproviders/method_validatemove.go new file mode 100644 index 00000000000..7df2e3df0eb --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_validatemove.go @@ -0,0 +1,52 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateMoveOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ValidateMove ... +func (c ResourceProvidersClient) ValidateMove(ctx context.Context, id commonids.ResourceGroupId, input CsmMoveResourceEnvelope) (result ValidateMoveOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validateMoveResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/method_verifyhostingenvironmentvnet.go b/resource-manager/web/2024-11-01/resourceproviders/method_verifyhostingenvironmentvnet.go new file mode 100644 index 00000000000..733f7cd2e65 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/method_verifyhostingenvironmentvnet.go @@ -0,0 +1,59 @@ +package resourceproviders + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VerifyHostingEnvironmentVnetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetValidationFailureDetails +} + +// VerifyHostingEnvironmentVnet ... +func (c ResourceProvidersClient) VerifyHostingEnvironmentVnet(ctx context.Context, id commonids.SubscriptionId, input VnetParameters) (result VerifyHostingEnvironmentVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/verifyHostingEnvironmentVnet", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetValidationFailureDetails + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_appserviceenvironment.go b/resource-manager/web/2024-11-01/resourceproviders/model_appserviceenvironment.go new file mode 100644 index 00000000000..4c64f3befc2 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_appserviceenvironment.go @@ -0,0 +1,27 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppServiceEnvironment struct { + ClusterSettings *[]NameValuePair `json:"clusterSettings,omitempty"` + CustomDnsSuffixConfiguration *CustomDnsSuffixConfiguration `json:"customDnsSuffixConfiguration,omitempty"` + DedicatedHostCount *int64 `json:"dedicatedHostCount,omitempty"` + DnsSuffix *string `json:"dnsSuffix,omitempty"` + FrontEndScaleFactor *int64 `json:"frontEndScaleFactor,omitempty"` + HasLinuxWorkers *bool `json:"hasLinuxWorkers,omitempty"` + IPsslAddressCount *int64 `json:"ipsslAddressCount,omitempty"` + InternalLoadBalancingMode *LoadBalancingMode `json:"internalLoadBalancingMode,omitempty"` + MaximumNumberOfMachines *int64 `json:"maximumNumberOfMachines,omitempty"` + MultiRoleCount *int64 `json:"multiRoleCount,omitempty"` + MultiSize *string `json:"multiSize,omitempty"` + NetworkingConfiguration *AseV3NetworkingConfiguration `json:"networkingConfiguration,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Status *HostingEnvironmentStatus `json:"status,omitempty"` + Suspended *bool `json:"suspended,omitempty"` + UpgradeAvailability *UpgradeAvailability `json:"upgradeAvailability,omitempty"` + UpgradePreference *UpgradePreference `json:"upgradePreference,omitempty"` + UserWhitelistedIPRanges *[]string `json:"userWhitelistedIpRanges,omitempty"` + VirtualNetwork VirtualNetworkProfile `json:"virtualNetwork"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_aseregion.go b/resource-manager/web/2024-11-01/resourceproviders/model_aseregion.go new file mode 100644 index 00000000000..75229a008cc --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_aseregion.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseRegion struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AseRegionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_aseregionproperties.go b/resource-manager/web/2024-11-01/resourceproviders/model_aseregionproperties.go new file mode 100644 index 00000000000..193d6e9cc24 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_aseregionproperties.go @@ -0,0 +1,13 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseRegionProperties struct { + AvailableOS *[]string `json:"availableOS,omitempty"` + AvailableSku *[]string `json:"availableSku,omitempty"` + DedicatedHost *bool `json:"dedicatedHost,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Standard *bool `json:"standard,omitempty"` + ZoneRedundant *bool `json:"zoneRedundant,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_asev3networkingconfiguration.go b/resource-manager/web/2024-11-01/resourceproviders/model_asev3networkingconfiguration.go new file mode 100644 index 00000000000..44e592b0c22 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_asev3networkingconfiguration.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseV3NetworkingConfiguration struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *AseV3NetworkingConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_asev3networkingconfigurationproperties.go b/resource-manager/web/2024-11-01/resourceproviders/model_asev3networkingconfigurationproperties.go new file mode 100644 index 00000000000..d93b1c90db6 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_asev3networkingconfigurationproperties.go @@ -0,0 +1,15 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseV3NetworkingConfigurationProperties struct { + AllowNewPrivateEndpointConnections *bool `json:"allowNewPrivateEndpointConnections,omitempty"` + ExternalInboundIPAddresses *[]string `json:"externalInboundIpAddresses,omitempty"` + FtpEnabled *bool `json:"ftpEnabled,omitempty"` + InboundIPAddressOverride *string `json:"inboundIpAddressOverride,omitempty"` + InternalInboundIPAddresses *[]string `json:"internalInboundIpAddresses,omitempty"` + LinuxOutboundIPAddresses *[]string `json:"linuxOutboundIpAddresses,omitempty"` + RemoteDebugEnabled *bool `json:"remoteDebugEnabled,omitempty"` + WindowsOutboundIPAddresses *[]string `json:"windowsOutboundIpAddresses,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_billingmeter.go b/resource-manager/web/2024-11-01/resourceproviders/model_billingmeter.go new file mode 100644 index 00000000000..5d22f02ed37 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_billingmeter.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BillingMeter struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BillingMeterProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_billingmeterproperties.go b/resource-manager/web/2024-11-01/resourceproviders/model_billingmeterproperties.go new file mode 100644 index 00000000000..aae6e22c948 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_billingmeterproperties.go @@ -0,0 +1,14 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BillingMeterProperties struct { + BillingLocation *string `json:"billingLocation,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + MeterId *string `json:"meterId,omitempty"` + Multiplier *float64 `json:"multiplier,omitempty"` + OsType *string `json:"osType,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + ShortName *string `json:"shortName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_capability.go b/resource-manager/web/2024-11-01/resourceproviders/model_capability.go new file mode 100644 index 00000000000..85356855f60 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_capability.go @@ -0,0 +1,10 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Capability struct { + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_csmmoveresourceenvelope.go b/resource-manager/web/2024-11-01/resourceproviders/model_csmmoveresourceenvelope.go new file mode 100644 index 00000000000..6e585fdc416 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_csmmoveresourceenvelope.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmMoveResourceEnvelope struct { + Resources *[]string `json:"resources,omitempty"` + TargetResourceGroup *string `json:"targetResourceGroup,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_csmusagequota.go b/resource-manager/web/2024-11-01/resourceproviders/model_csmusagequota.go new file mode 100644 index 00000000000..d3c613eb248 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_csmusagequota.go @@ -0,0 +1,30 @@ +package resourceproviders + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmUsageQuota struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *LocalizableString `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +func (o *CsmUsageQuota) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CsmUsageQuota) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_customdnssuffixconfiguration.go b/resource-manager/web/2024-11-01/resourceproviders/model_customdnssuffixconfiguration.go new file mode 100644 index 00000000000..59f89a9a6b2 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_customdnssuffixconfiguration.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsSuffixConfiguration struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CustomDnsSuffixConfigurationProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_customdnssuffixconfigurationproperties.go b/resource-manager/web/2024-11-01/resourceproviders/model_customdnssuffixconfigurationproperties.go new file mode 100644 index 00000000000..cac2d224e58 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_customdnssuffixconfigurationproperties.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomDnsSuffixConfigurationProperties struct { + CertificateURL *string `json:"certificateUrl,omitempty"` + DnsSuffix *string `json:"dnsSuffix,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + ProvisioningDetails *string `json:"provisioningDetails,omitempty"` + ProvisioningState *CustomDnsSuffixProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_customhostnamesites.go b/resource-manager/web/2024-11-01/resourceproviders/model_customhostnamesites.go new file mode 100644 index 00000000000..f967d7a3153 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_customhostnamesites.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomHostnameSites struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CustomHostnameSitesProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_customhostnamesitesproperties.go b/resource-manager/web/2024-11-01/resourceproviders/model_customhostnamesitesproperties.go new file mode 100644 index 00000000000..d7767777efa --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_customhostnamesitesproperties.go @@ -0,0 +1,10 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomHostnameSitesProperties struct { + CustomHostname *string `json:"customHostname,omitempty"` + Region *string `json:"region,omitempty"` + SiteResourceIds *[]Identifier `json:"siteResourceIds,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_deploymentlocations.go b/resource-manager/web/2024-11-01/resourceproviders/model_deploymentlocations.go new file mode 100644 index 00000000000..0cf632a9502 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_deploymentlocations.go @@ -0,0 +1,10 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeploymentLocations struct { + HostingEnvironmentDeploymentInfos *[]HostingEnvironmentDeploymentInfo `json:"hostingEnvironmentDeploymentInfos,omitempty"` + HostingEnvironments *[]AppServiceEnvironment `json:"hostingEnvironments,omitempty"` + Locations *[]GeoRegion `json:"locations,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_dnlresourcenameavailability.go b/resource-manager/web/2024-11-01/resourceproviders/model_dnlresourcenameavailability.go new file mode 100644 index 00000000000..ac67840014d --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_dnlresourcenameavailability.go @@ -0,0 +1,11 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DnlResourceNameAvailability struct { + HostName *string `json:"hostName,omitempty"` + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *InAvailabilityReasonType `json:"reason,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_dnlresourcenameavailabilityrequest.go b/resource-manager/web/2024-11-01/resourceproviders/model_dnlresourcenameavailabilityrequest.go new file mode 100644 index 00000000000..22e90745456 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_dnlresourcenameavailabilityrequest.go @@ -0,0 +1,11 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DnlResourceNameAvailabilityRequest struct { + AutoGeneratedDomainNameLabelScope *string `json:"autoGeneratedDomainNameLabelScope,omitempty"` + Name string `json:"name"` + ResourceGroupName *string `json:"resourceGroupName,omitempty"` + Type CheckNameResourceTypes `json:"type"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_georegion.go b/resource-manager/web/2024-11-01/resourceproviders/model_georegion.go new file mode 100644 index 00000000000..bc4c17360b5 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_georegion.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GeoRegion struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *GeoRegionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_georegionproperties.go b/resource-manager/web/2024-11-01/resourceproviders/model_georegionproperties.go new file mode 100644 index 00000000000..1511ccc9e28 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_georegionproperties.go @@ -0,0 +1,10 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GeoRegionProperties struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + OrgDomain *string `json:"orgDomain,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_globalcsmskudescription.go b/resource-manager/web/2024-11-01/resourceproviders/model_globalcsmskudescription.go new file mode 100644 index 00000000000..fee5a130039 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_globalcsmskudescription.go @@ -0,0 +1,14 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GlobalCsmSkuDescription struct { + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *SkuCapacity `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Locations *[]string `json:"locations,omitempty"` + Name *string `json:"name,omitempty"` + Size *string `json:"size,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_hostingenvironmentdeploymentinfo.go b/resource-manager/web/2024-11-01/resourceproviders/model_hostingenvironmentdeploymentinfo.go new file mode 100644 index 00000000000..5cbdecfc3f3 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_hostingenvironmentdeploymentinfo.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentDeploymentInfo struct { + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_identifier.go b/resource-manager/web/2024-11-01/resourceproviders/model_identifier.go new file mode 100644 index 00000000000..879aff521be --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_identifier.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Identifier struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IdentifierProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_identifierproperties.go b/resource-manager/web/2024-11-01/resourceproviders/model_identifierproperties.go new file mode 100644 index 00000000000..5fee3a1ed5d --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_identifierproperties.go @@ -0,0 +1,8 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentifierProperties struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_localizablestring.go b/resource-manager/web/2024-11-01/resourceproviders/model_localizablestring.go new file mode 100644 index 00000000000..4ee07f00d95 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_localizablestring.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalizableString struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_nameidentifier.go b/resource-manager/web/2024-11-01/resourceproviders/model_nameidentifier.go new file mode 100644 index 00000000000..94caff8a110 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_nameidentifier.go @@ -0,0 +1,8 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameIdentifier struct { + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_namevaluepair.go b/resource-manager/web/2024-11-01/resourceproviders/model_namevaluepair.go new file mode 100644 index 00000000000..30d7a8f6546 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_namevaluepair.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameValuePair struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_premieraddonoffer.go b/resource-manager/web/2024-11-01/resourceproviders/model_premieraddonoffer.go new file mode 100644 index 00000000000..8245c61bc6e --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_premieraddonoffer.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOnOffer struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PremierAddOnOfferProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_premieraddonofferproperties.go b/resource-manager/web/2024-11-01/resourceproviders/model_premieraddonofferproperties.go new file mode 100644 index 00000000000..4d6d6786360 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_premieraddonofferproperties.go @@ -0,0 +1,17 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOnOfferProperties struct { + LegalTermsURL *string `json:"legalTermsUrl,omitempty"` + MarketplaceOffer *string `json:"marketplaceOffer,omitempty"` + MarketplacePublisher *string `json:"marketplacePublisher,omitempty"` + PrivacyPolicyURL *string `json:"privacyPolicyUrl,omitempty"` + Product *string `json:"product,omitempty"` + PromoCodeRequired *bool `json:"promoCodeRequired,omitempty"` + Quota *int64 `json:"quota,omitempty"` + Sku *string `json:"sku,omitempty"` + Vendor *string `json:"vendor,omitempty"` + WebHostingPlanRestrictions *AppServicePlanRestrictions `json:"webHostingPlanRestrictions,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_resourcenameavailability.go b/resource-manager/web/2024-11-01/resourceproviders/model_resourcenameavailability.go new file mode 100644 index 00000000000..0a19de2fac8 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_resourcenameavailability.go @@ -0,0 +1,10 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNameAvailability struct { + Message *string `json:"message,omitempty"` + NameAvailable *bool `json:"nameAvailable,omitempty"` + Reason *InAvailabilityReasonType `json:"reason,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_resourcenameavailabilityrequest.go b/resource-manager/web/2024-11-01/resourceproviders/model_resourcenameavailabilityrequest.go new file mode 100644 index 00000000000..abefca1cda6 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_resourcenameavailabilityrequest.go @@ -0,0 +1,11 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceNameAvailabilityRequest struct { + EnvironmentId *string `json:"environmentId,omitempty"` + IsFqdn *bool `json:"isFqdn,omitempty"` + Name string `json:"name"` + Type CheckNameResourceTypes `json:"type"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_skucapacity.go b/resource-manager/web/2024-11-01/resourceproviders/model_skucapacity.go new file mode 100644 index 00000000000..9f5bcf3423d --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_skucapacity.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuCapacity struct { + Default *int64 `json:"default,omitempty"` + ElasticMaximum *int64 `json:"elasticMaximum,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` + Minimum *int64 `json:"minimum,omitempty"` + ScaleType *string `json:"scaleType,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_skuinfos.go b/resource-manager/web/2024-11-01/resourceproviders/model_skuinfos.go new file mode 100644 index 00000000000..c0c36d86b52 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_skuinfos.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuInfos struct { + ResourceType *string `json:"resourceType,omitempty"` + Skus *[]GlobalCsmSkuDescription `json:"skus,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_sourcecontrol.go b/resource-manager/web/2024-11-01/resourceproviders/model_sourcecontrol.go new file mode 100644 index 00000000000..03ce9771a74 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_sourcecontrol.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SourceControl struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SourceControlProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_sourcecontrolproperties.go b/resource-manager/web/2024-11-01/resourceproviders/model_sourcecontrolproperties.go new file mode 100644 index 00000000000..012dfe7a3c3 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_sourcecontrolproperties.go @@ -0,0 +1,29 @@ +package resourceproviders + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SourceControlProperties struct { + ExpirationTime *string `json:"expirationTime,omitempty"` + RefreshToken *string `json:"refreshToken,omitempty"` + Token *string `json:"token,omitempty"` + TokenSecret *string `json:"tokenSecret,omitempty"` +} + +func (o *SourceControlProperties) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SourceControlProperties) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_user.go b/resource-manager/web/2024-11-01/resourceproviders/model_user.go new file mode 100644 index 00000000000..adb8119b83f --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_user.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type User struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *UserProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_userproperties.go b/resource-manager/web/2024-11-01/resourceproviders/model_userproperties.go new file mode 100644 index 00000000000..7ac82ad3b1f --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_userproperties.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserProperties struct { + PublishingPassword *string `json:"publishingPassword,omitempty"` + PublishingPasswordHash *string `json:"publishingPasswordHash,omitempty"` + PublishingPasswordHashSalt *string `json:"publishingPasswordHashSalt,omitempty"` + PublishingUserName string `json:"publishingUserName"` + ScmUri *string `json:"scmUri,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_validateproperties.go b/resource-manager/web/2024-11-01/resourceproviders/model_validateproperties.go new file mode 100644 index 00000000000..76c9b025d30 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_validateproperties.go @@ -0,0 +1,21 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateProperties struct { + AppServiceEnvironment *AppServiceEnvironment `json:"appServiceEnvironment,omitempty"` + Capacity *int64 `json:"capacity,omitempty"` + ContainerImagePlatform *string `json:"containerImagePlatform,omitempty"` + ContainerImageRepository *string `json:"containerImageRepository,omitempty"` + ContainerImageTag *string `json:"containerImageTag,omitempty"` + ContainerRegistryBaseURL *string `json:"containerRegistryBaseUrl,omitempty"` + ContainerRegistryPassword *string `json:"containerRegistryPassword,omitempty"` + ContainerRegistryUsername *string `json:"containerRegistryUsername,omitempty"` + HostingEnvironment *string `json:"hostingEnvironment,omitempty"` + IsSpot *bool `json:"isSpot,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + NeedLinuxWorkers *bool `json:"needLinuxWorkers,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SkuName *string `json:"skuName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_validaterequest.go b/resource-manager/web/2024-11-01/resourceproviders/model_validaterequest.go new file mode 100644 index 00000000000..c7dc8dc05f4 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_validaterequest.go @@ -0,0 +1,11 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateRequest struct { + Location string `json:"location"` + Name string `json:"name"` + Properties ValidateProperties `json:"properties"` + Type ValidateResourceTypes `json:"type"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_validateresponse.go b/resource-manager/web/2024-11-01/resourceproviders/model_validateresponse.go new file mode 100644 index 00000000000..dbc96e23750 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_validateresponse.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateResponse struct { + Error *ValidateResponseError `json:"error,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_validateresponseerror.go b/resource-manager/web/2024-11-01/resourceproviders/model_validateresponseerror.go new file mode 100644 index 00000000000..8d4f8adf944 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_validateresponseerror.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateResponseError struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_virtualnetworkprofile.go b/resource-manager/web/2024-11-01/resourceproviders/model_virtualnetworkprofile.go new file mode 100644 index 00000000000..b6498b01aea --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_virtualnetworkprofile.go @@ -0,0 +1,11 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkProfile struct { + Id string `json:"id"` + Name *string `json:"name,omitempty"` + Subnet *string `json:"subnet,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_vnetparameters.go b/resource-manager/web/2024-11-01/resourceproviders/model_vnetparameters.go new file mode 100644 index 00000000000..195de734cb3 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_vnetparameters.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetParameters struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetParametersProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_vnetparametersproperties.go b/resource-manager/web/2024-11-01/resourceproviders/model_vnetparametersproperties.go new file mode 100644 index 00000000000..86fff378387 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_vnetparametersproperties.go @@ -0,0 +1,11 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetParametersProperties struct { + SubnetResourceId *string `json:"subnetResourceId,omitempty"` + VnetName *string `json:"vnetName,omitempty"` + VnetResourceGroup *string `json:"vnetResourceGroup,omitempty"` + VnetSubnetName *string `json:"vnetSubnetName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_vnetvalidationfailuredetails.go b/resource-manager/web/2024-11-01/resourceproviders/model_vnetvalidationfailuredetails.go new file mode 100644 index 00000000000..c6f31ff5b83 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_vnetvalidationfailuredetails.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetValidationFailureDetails struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetValidationFailureDetailsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_vnetvalidationfailuredetailsproperties.go b/resource-manager/web/2024-11-01/resourceproviders/model_vnetvalidationfailuredetailsproperties.go new file mode 100644 index 00000000000..edae58023cb --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_vnetvalidationfailuredetailsproperties.go @@ -0,0 +1,11 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetValidationFailureDetailsProperties struct { + Failed *bool `json:"failed,omitempty"` + FailedTests *[]VnetValidationTestFailure `json:"failedTests,omitempty"` + Message *string `json:"message,omitempty"` + Warnings *[]VnetValidationTestFailure `json:"warnings,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_vnetvalidationtestfailure.go b/resource-manager/web/2024-11-01/resourceproviders/model_vnetvalidationtestfailure.go new file mode 100644 index 00000000000..2ecad9b35ca --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_vnetvalidationtestfailure.go @@ -0,0 +1,12 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetValidationTestFailure struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetValidationTestFailureProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/model_vnetvalidationtestfailureproperties.go b/resource-manager/web/2024-11-01/resourceproviders/model_vnetvalidationtestfailureproperties.go new file mode 100644 index 00000000000..68ba825c530 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/model_vnetvalidationtestfailureproperties.go @@ -0,0 +1,9 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetValidationTestFailureProperties struct { + Details *string `json:"details,omitempty"` + TestName *string `json:"testName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/predicates.go b/resource-manager/web/2024-11-01/resourceproviders/predicates.go new file mode 100644 index 00000000000..c633f44ef01 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/predicates.go @@ -0,0 +1,228 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AseRegionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p AseRegionOperationPredicate) Matches(input AseRegion) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type BillingMeterOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p BillingMeterOperationPredicate) Matches(input BillingMeter) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type CsmUsageQuotaOperationPredicate struct { + CurrentValue *int64 + Limit *int64 + NextResetTime *string + Unit *string +} + +func (p CsmUsageQuotaOperationPredicate) Matches(input CsmUsageQuota) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.NextResetTime != nil && (input.NextResetTime == nil || *p.NextResetTime != *input.NextResetTime) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} + +type CustomHostnameSitesOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p CustomHostnameSitesOperationPredicate) Matches(input CustomHostnameSites) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type GeoRegionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p GeoRegionOperationPredicate) Matches(input GeoRegion) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type IdentifierOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p IdentifierOperationPredicate) Matches(input Identifier) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type PremierAddOnOfferOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p PremierAddOnOfferOperationPredicate) Matches(input PremierAddOnOffer) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SourceControlOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SourceControlOperationPredicate) Matches(input SourceControl) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/resourceproviders/version.go b/resource-manager/web/2024-11-01/resourceproviders/version.go new file mode 100644 index 00000000000..00ff98e61c7 --- /dev/null +++ b/resource-manager/web/2024-11-01/resourceproviders/version.go @@ -0,0 +1,10 @@ +package resourceproviders + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/resourceproviders/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/README.md b/resource-manager/web/2024-11-01/sitecertificates/README.md new file mode 100644 index 00000000000..cda562bfa65 --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/README.md @@ -0,0 +1,203 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/sitecertificates` Documentation + +The `sitecertificates` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/sitecertificates" +``` + + +### Client Initialization + +```go +client := sitecertificates.NewSiteCertificatesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SiteCertificatesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := sitecertificates.NewSiteCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "certificateName") + +payload := sitecertificates.Certificate{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SiteCertificatesClient.CreateOrUpdateSlot` + +```go +ctx := context.TODO() +id := sitecertificates.NewSlotCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "certificateName") + +payload := sitecertificates.Certificate{ + // ... +} + + +read, err := client.CreateOrUpdateSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SiteCertificatesClient.Delete` + +```go +ctx := context.TODO() +id := sitecertificates.NewSiteCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "certificateName") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SiteCertificatesClient.DeleteSlot` + +```go +ctx := context.TODO() +id := sitecertificates.NewSlotCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "certificateName") + +read, err := client.DeleteSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SiteCertificatesClient.Get` + +```go +ctx := context.TODO() +id := sitecertificates.NewSiteCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "certificateName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SiteCertificatesClient.GetSlot` + +```go +ctx := context.TODO() +id := sitecertificates.NewSlotCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "certificateName") + +read, err := client.GetSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SiteCertificatesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SiteCertificatesClient.ListSlot` + +```go +ctx := context.TODO() +id := sitecertificates.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SiteCertificatesClient.Update` + +```go +ctx := context.TODO() +id := sitecertificates.NewSiteCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "certificateName") + +payload := sitecertificates.CertificatePatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SiteCertificatesClient.UpdateSlot` + +```go +ctx := context.TODO() +id := sitecertificates.NewSlotCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "certificateName") + +payload := sitecertificates.CertificatePatchResource{ + // ... +} + + +read, err := client.UpdateSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-11-01/sitecertificates/client.go b/resource-manager/web/2024-11-01/sitecertificates/client.go new file mode 100644 index 00000000000..ef049103a2c --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/client.go @@ -0,0 +1,26 @@ +package sitecertificates + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteCertificatesClient struct { + Client *resourcemanager.Client +} + +func NewSiteCertificatesClientWithBaseURI(sdkApi sdkEnv.Api) (*SiteCertificatesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "sitecertificates", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SiteCertificatesClient: %+v", err) + } + + return &SiteCertificatesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/constants.go b/resource-manager/web/2024-11-01/sitecertificates/constants.go new file mode 100644 index 00000000000..1f8eedb838c --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/constants.go @@ -0,0 +1,78 @@ +package sitecertificates + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultSecretStatus string + +const ( + KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault KeyVaultSecretStatus = "AzureServiceUnauthorizedToAccessKeyVault" + KeyVaultSecretStatusCertificateOrderFailed KeyVaultSecretStatus = "CertificateOrderFailed" + KeyVaultSecretStatusExternalPrivateKey KeyVaultSecretStatus = "ExternalPrivateKey" + KeyVaultSecretStatusInitialized KeyVaultSecretStatus = "Initialized" + KeyVaultSecretStatusKeyVaultDoesNotExist KeyVaultSecretStatus = "KeyVaultDoesNotExist" + KeyVaultSecretStatusKeyVaultSecretDoesNotExist KeyVaultSecretStatus = "KeyVaultSecretDoesNotExist" + KeyVaultSecretStatusOperationNotPermittedOnKeyVault KeyVaultSecretStatus = "OperationNotPermittedOnKeyVault" + KeyVaultSecretStatusSucceeded KeyVaultSecretStatus = "Succeeded" + KeyVaultSecretStatusUnknown KeyVaultSecretStatus = "Unknown" + KeyVaultSecretStatusUnknownError KeyVaultSecretStatus = "UnknownError" + KeyVaultSecretStatusWaitingOnCertificateOrder KeyVaultSecretStatus = "WaitingOnCertificateOrder" +) + +func PossibleValuesForKeyVaultSecretStatus() []string { + return []string{ + string(KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault), + string(KeyVaultSecretStatusCertificateOrderFailed), + string(KeyVaultSecretStatusExternalPrivateKey), + string(KeyVaultSecretStatusInitialized), + string(KeyVaultSecretStatusKeyVaultDoesNotExist), + string(KeyVaultSecretStatusKeyVaultSecretDoesNotExist), + string(KeyVaultSecretStatusOperationNotPermittedOnKeyVault), + string(KeyVaultSecretStatusSucceeded), + string(KeyVaultSecretStatusUnknown), + string(KeyVaultSecretStatusUnknownError), + string(KeyVaultSecretStatusWaitingOnCertificateOrder), + } +} + +func (s *KeyVaultSecretStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyVaultSecretStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyVaultSecretStatus(input string) (*KeyVaultSecretStatus, error) { + vals := map[string]KeyVaultSecretStatus{ + "azureserviceunauthorizedtoaccesskeyvault": KeyVaultSecretStatusAzureServiceUnauthorizedToAccessKeyVault, + "certificateorderfailed": KeyVaultSecretStatusCertificateOrderFailed, + "externalprivatekey": KeyVaultSecretStatusExternalPrivateKey, + "initialized": KeyVaultSecretStatusInitialized, + "keyvaultdoesnotexist": KeyVaultSecretStatusKeyVaultDoesNotExist, + "keyvaultsecretdoesnotexist": KeyVaultSecretStatusKeyVaultSecretDoesNotExist, + "operationnotpermittedonkeyvault": KeyVaultSecretStatusOperationNotPermittedOnKeyVault, + "succeeded": KeyVaultSecretStatusSucceeded, + "unknown": KeyVaultSecretStatusUnknown, + "unknownerror": KeyVaultSecretStatusUnknownError, + "waitingoncertificateorder": KeyVaultSecretStatusWaitingOnCertificateOrder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyVaultSecretStatus(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/id_sitecertificate.go b/resource-manager/web/2024-11-01/sitecertificates/id_sitecertificate.go new file mode 100644 index 00000000000..dd796894b10 --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/id_sitecertificate.go @@ -0,0 +1,139 @@ +package sitecertificates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SiteCertificateId{}) +} + +var _ resourceids.ResourceId = &SiteCertificateId{} + +// SiteCertificateId is a struct representing the Resource ID for a Site Certificate +type SiteCertificateId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + CertificateName string +} + +// NewSiteCertificateID returns a new SiteCertificateId struct +func NewSiteCertificateID(subscriptionId string, resourceGroupName string, siteName string, certificateName string) SiteCertificateId { + return SiteCertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + CertificateName: certificateName, + } +} + +// ParseSiteCertificateID parses 'input' into a SiteCertificateId +func ParseSiteCertificateID(input string) (*SiteCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteCertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteCertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSiteCertificateIDInsensitively parses 'input' case-insensitively into a SiteCertificateId +// note: this method should only be used for API response data and not user input +func ParseSiteCertificateIDInsensitively(input string) (*SiteCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteCertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteCertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SiteCertificateId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.CertificateName, ok = input.Parsed["certificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateName", input) + } + + return nil +} + +// ValidateSiteCertificateID checks that 'input' can be parsed as a Site Certificate ID +func ValidateSiteCertificateID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSiteCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Site Certificate ID +func (id SiteCertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.CertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Site Certificate ID +func (id SiteCertificateId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticCertificates", "certificates", "certificates"), + resourceids.UserSpecifiedSegment("certificateName", "certificateName"), + } +} + +// String returns a human-readable description of this Site Certificate ID +func (id SiteCertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Site Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/id_sitecertificate_test.go b/resource-manager/web/2024-11-01/sitecertificates/id_sitecertificate_test.go new file mode 100644 index 00000000000..d19ad892351 --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/id_sitecertificate_test.go @@ -0,0 +1,327 @@ +package sitecertificates + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SiteCertificateId{} + +func TestNewSiteCertificateID(t *testing.T) { + id := NewSiteCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "certificateName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.CertificateName != "certificateName" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateName'", id.CertificateName, "certificateName") + } +} + +func TestFormatSiteCertificateID(t *testing.T) { + actual := NewSiteCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "certificateName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/certificates/certificateName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSiteCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteCertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/certificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/certificates/certificateName", + Expected: &SiteCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + CertificateName: "certificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/certificates/certificateName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestParseSiteCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteCertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/certificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/certificates/certificateName", + Expected: &SiteCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + CertificateName: "certificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/certificates/certificateName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cErTiFiCaTeS/cErTiFiCaTeNaMe", + Expected: &SiteCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + CertificateName: "cErTiFiCaTeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cErTiFiCaTeS/cErTiFiCaTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestSegmentsForSiteCertificateId(t *testing.T) { + segments := SiteCertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SiteCertificateId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/id_slot.go b/resource-manager/web/2024-11-01/sitecertificates/id_slot.go new file mode 100644 index 00000000000..8b04f369f23 --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/id_slot.go @@ -0,0 +1,139 @@ +package sitecertificates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotId{}) +} + +var _ resourceids.ResourceId = &SlotId{} + +// SlotId is a struct representing the Resource ID for a Slot +type SlotId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string +} + +// NewSlotID returns a new SlotId struct +func NewSlotID(subscriptionId string, resourceGroupName string, siteName string, slotName string) SlotId { + return SlotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + } +} + +// ParseSlotID parses 'input' into a SlotId +func ParseSlotID(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotIDInsensitively parses 'input' case-insensitively into a SlotId +// note: this method should only be used for API response data and not user input +func ParseSlotIDInsensitively(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + return nil +} + +// ValidateSlotID checks that 'input' can be parsed as a Slot ID +func ValidateSlotID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot ID +func (id SlotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot ID +func (id SlotId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + } +} + +// String returns a human-readable description of this Slot ID +func (id SlotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + } + return fmt.Sprintf("Slot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/id_slot_test.go b/resource-manager/web/2024-11-01/sitecertificates/id_slot_test.go new file mode 100644 index 00000000000..1afde94ee46 --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/id_slot_test.go @@ -0,0 +1,327 @@ +package sitecertificates + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotId{} + +func TestNewSlotID(t *testing.T) { + id := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } +} + +func TestFormatSlotID(t *testing.T) { + actual := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestParseSlotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestSegmentsForSlotId(t *testing.T) { + segments := SlotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/id_slotcertificate.go b/resource-manager/web/2024-11-01/sitecertificates/id_slotcertificate.go new file mode 100644 index 00000000000..c9b5ac7e538 --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/id_slotcertificate.go @@ -0,0 +1,148 @@ +package sitecertificates + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotCertificateId{}) +} + +var _ resourceids.ResourceId = &SlotCertificateId{} + +// SlotCertificateId is a struct representing the Resource ID for a Slot Certificate +type SlotCertificateId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + CertificateName string +} + +// NewSlotCertificateID returns a new SlotCertificateId struct +func NewSlotCertificateID(subscriptionId string, resourceGroupName string, siteName string, slotName string, certificateName string) SlotCertificateId { + return SlotCertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + CertificateName: certificateName, + } +} + +// ParseSlotCertificateID parses 'input' into a SlotCertificateId +func ParseSlotCertificateID(input string) (*SlotCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotCertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotCertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotCertificateIDInsensitively parses 'input' case-insensitively into a SlotCertificateId +// note: this method should only be used for API response data and not user input +func ParseSlotCertificateIDInsensitively(input string) (*SlotCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotCertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotCertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotCertificateId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.CertificateName, ok = input.Parsed["certificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "certificateName", input) + } + + return nil +} + +// ValidateSlotCertificateID checks that 'input' can be parsed as a Slot Certificate ID +func ValidateSlotCertificateID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Certificate ID +func (id SlotCertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/certificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.CertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Certificate ID +func (id SlotCertificateId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticCertificates", "certificates", "certificates"), + resourceids.UserSpecifiedSegment("certificateName", "certificateName"), + } +} + +// String returns a human-readable description of this Slot Certificate ID +func (id SlotCertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Certificate Name: %q", id.CertificateName), + } + return fmt.Sprintf("Slot Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/id_slotcertificate_test.go b/resource-manager/web/2024-11-01/sitecertificates/id_slotcertificate_test.go new file mode 100644 index 00000000000..cc9cbc9c124 --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/id_slotcertificate_test.go @@ -0,0 +1,372 @@ +package sitecertificates + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotCertificateId{} + +func TestNewSlotCertificateID(t *testing.T) { + id := NewSlotCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "certificateName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.CertificateName != "certificateName" { + t.Fatalf("Expected %q but got %q for Segment 'CertificateName'", id.CertificateName, "certificateName") + } +} + +func TestFormatSlotCertificateID(t *testing.T) { + actual := NewSlotCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "certificateName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/certificates/certificateName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotCertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/certificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/certificates/certificateName", + Expected: &SlotCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + CertificateName: "certificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/certificates/certificateName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestParseSlotCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotCertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/certificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/certificates/certificateName", + Expected: &SlotCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + CertificateName: "certificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/certificates/certificateName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cErTiFiCaTeS/cErTiFiCaTeNaMe", + Expected: &SlotCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + CertificateName: "cErTiFiCaTeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cErTiFiCaTeS/cErTiFiCaTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.CertificateName != v.Expected.CertificateName { + t.Fatalf("Expected %q but got %q for CertificateName", v.Expected.CertificateName, actual.CertificateName) + } + + } +} + +func TestSegmentsForSlotCertificateId(t *testing.T) { + segments := SlotCertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotCertificateId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/method_createorupdate.go b/resource-manager/web/2024-11-01/sitecertificates/method_createorupdate.go new file mode 100644 index 00000000000..c80d5ab7f95 --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/method_createorupdate.go @@ -0,0 +1,58 @@ +package sitecertificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// CreateOrUpdate ... +func (c SiteCertificatesClient) CreateOrUpdate(ctx context.Context, id SiteCertificateId, input Certificate) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/method_createorupdateslot.go b/resource-manager/web/2024-11-01/sitecertificates/method_createorupdateslot.go new file mode 100644 index 00000000000..bd8d792102f --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/method_createorupdateslot.go @@ -0,0 +1,58 @@ +package sitecertificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// CreateOrUpdateSlot ... +func (c SiteCertificatesClient) CreateOrUpdateSlot(ctx context.Context, id SlotCertificateId, input Certificate) (result CreateOrUpdateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/method_delete.go b/resource-manager/web/2024-11-01/sitecertificates/method_delete.go new file mode 100644 index 00000000000..065d2475f00 --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/method_delete.go @@ -0,0 +1,47 @@ +package sitecertificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c SiteCertificatesClient) Delete(ctx context.Context, id SiteCertificateId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/method_deleteslot.go b/resource-manager/web/2024-11-01/sitecertificates/method_deleteslot.go new file mode 100644 index 00000000000..b5e0e8df80e --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/method_deleteslot.go @@ -0,0 +1,47 @@ +package sitecertificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSlot ... +func (c SiteCertificatesClient) DeleteSlot(ctx context.Context, id SlotCertificateId) (result DeleteSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/method_get.go b/resource-manager/web/2024-11-01/sitecertificates/method_get.go new file mode 100644 index 00000000000..bba3eaaeffd --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/method_get.go @@ -0,0 +1,53 @@ +package sitecertificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// Get ... +func (c SiteCertificatesClient) Get(ctx context.Context, id SiteCertificateId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/method_getslot.go b/resource-manager/web/2024-11-01/sitecertificates/method_getslot.go new file mode 100644 index 00000000000..b86cad9bdea --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/method_getslot.go @@ -0,0 +1,53 @@ +package sitecertificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// GetSlot ... +func (c SiteCertificatesClient) GetSlot(ctx context.Context, id SlotCertificateId) (result GetSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/method_list.go b/resource-manager/web/2024-11-01/sitecertificates/method_list.go new file mode 100644 index 00000000000..aac53ac6baa --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/method_list.go @@ -0,0 +1,106 @@ +package sitecertificates + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Certificate +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Certificate +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c SiteCertificatesClient) List(ctx context.Context, id commonids.AppServiceId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/certificates", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Certificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c SiteCertificatesClient) ListComplete(ctx context.Context, id commonids.AppServiceId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, CertificateOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SiteCertificatesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate CertificateOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Certificate, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/method_listslot.go b/resource-manager/web/2024-11-01/sitecertificates/method_listslot.go new file mode 100644 index 00000000000..464ce665ec8 --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/method_listslot.go @@ -0,0 +1,105 @@ +package sitecertificates + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Certificate +} + +type ListSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []Certificate +} + +type ListSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSlot ... +func (c SiteCertificatesClient) ListSlot(ctx context.Context, id SlotId) (result ListSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSlotCustomPager{}, + Path: fmt.Sprintf("%s/certificates", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Certificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSlotComplete retrieves all the results into a single object +func (c SiteCertificatesClient) ListSlotComplete(ctx context.Context, id SlotId) (ListSlotCompleteResult, error) { + return c.ListSlotCompleteMatchingPredicate(ctx, id, CertificateOperationPredicate{}) +} + +// ListSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SiteCertificatesClient) ListSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate CertificateOperationPredicate) (result ListSlotCompleteResult, err error) { + items := make([]Certificate, 0) + + resp, err := c.ListSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/method_update.go b/resource-manager/web/2024-11-01/sitecertificates/method_update.go new file mode 100644 index 00000000000..b99cdaadff4 --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/method_update.go @@ -0,0 +1,57 @@ +package sitecertificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// Update ... +func (c SiteCertificatesClient) Update(ctx context.Context, id SiteCertificateId, input CertificatePatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/method_updateslot.go b/resource-manager/web/2024-11-01/sitecertificates/method_updateslot.go new file mode 100644 index 00000000000..4a7bb5e7cd7 --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/method_updateslot.go @@ -0,0 +1,57 @@ +package sitecertificates + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Certificate +} + +// UpdateSlot ... +func (c SiteCertificatesClient) UpdateSlot(ctx context.Context, id SlotCertificateId, input CertificatePatchResource) (result UpdateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Certificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/model_certificate.go b/resource-manager/web/2024-11-01/sitecertificates/model_certificate.go new file mode 100644 index 00000000000..de67a28d19b --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/model_certificate.go @@ -0,0 +1,14 @@ +package sitecertificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Certificate struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *CertificateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/model_certificatepatchresource.go b/resource-manager/web/2024-11-01/sitecertificates/model_certificatepatchresource.go new file mode 100644 index 00000000000..1c617787384 --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/model_certificatepatchresource.go @@ -0,0 +1,12 @@ +package sitecertificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificatePatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CertificatePatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/model_certificatepatchresourceproperties.go b/resource-manager/web/2024-11-01/sitecertificates/model_certificatepatchresourceproperties.go new file mode 100644 index 00000000000..86c5283a038 --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/model_certificatepatchresourceproperties.go @@ -0,0 +1,58 @@ +package sitecertificates + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificatePatchResourceProperties struct { + CanonicalName *string `json:"canonicalName,omitempty"` + CerBlob *string `json:"cerBlob,omitempty"` + DomainValidationMethod *string `json:"domainValidationMethod,omitempty"` + ExpirationDate *string `json:"expirationDate,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + IssueDate *string `json:"issueDate,omitempty"` + Issuer *string `json:"issuer,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultSecretName *string `json:"keyVaultSecretName,omitempty"` + KeyVaultSecretStatus *KeyVaultSecretStatus `json:"keyVaultSecretStatus,omitempty"` + Password *string `json:"password,omitempty"` + PfxBlob *string `json:"pfxBlob,omitempty"` + PublicKeyHash *string `json:"publicKeyHash,omitempty"` + SelfLink *string `json:"selfLink,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteName *string `json:"siteName,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Valid *bool `json:"valid,omitempty"` +} + +func (o *CertificatePatchResourceProperties) GetExpirationDateAsTime() (*time.Time, error) { + if o.ExpirationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificatePatchResourceProperties) SetExpirationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationDate = &formatted +} + +func (o *CertificatePatchResourceProperties) GetIssueDateAsTime() (*time.Time, error) { + if o.IssueDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.IssueDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificatePatchResourceProperties) SetIssueDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.IssueDate = &formatted +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/model_certificateproperties.go b/resource-manager/web/2024-11-01/sitecertificates/model_certificateproperties.go new file mode 100644 index 00000000000..38d0717eb2c --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/model_certificateproperties.go @@ -0,0 +1,58 @@ +package sitecertificates + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateProperties struct { + CanonicalName *string `json:"canonicalName,omitempty"` + CerBlob *string `json:"cerBlob,omitempty"` + DomainValidationMethod *string `json:"domainValidationMethod,omitempty"` + ExpirationDate *string `json:"expirationDate,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + IssueDate *string `json:"issueDate,omitempty"` + Issuer *string `json:"issuer,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` + KeyVaultSecretName *string `json:"keyVaultSecretName,omitempty"` + KeyVaultSecretStatus *KeyVaultSecretStatus `json:"keyVaultSecretStatus,omitempty"` + Password *string `json:"password,omitempty"` + PfxBlob *string `json:"pfxBlob,omitempty"` + PublicKeyHash *string `json:"publicKeyHash,omitempty"` + SelfLink *string `json:"selfLink,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteName *string `json:"siteName,omitempty"` + SubjectName *string `json:"subjectName,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + Valid *bool `json:"valid,omitempty"` +} + +func (o *CertificateProperties) GetExpirationDateAsTime() (*time.Time, error) { + if o.ExpirationDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetExpirationDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationDate = &formatted +} + +func (o *CertificateProperties) GetIssueDateAsTime() (*time.Time, error) { + if o.IssueDate == nil { + return nil, nil + } + return dates.ParseAsFormat(o.IssueDate, "2006-01-02T15:04:05Z07:00") +} + +func (o *CertificateProperties) SetIssueDateAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.IssueDate = &formatted +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/model_hostingenvironmentprofile.go b/resource-manager/web/2024-11-01/sitecertificates/model_hostingenvironmentprofile.go new file mode 100644 index 00000000000..19fee2b35b9 --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/model_hostingenvironmentprofile.go @@ -0,0 +1,10 @@ +package sitecertificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/predicates.go b/resource-manager/web/2024-11-01/sitecertificates/predicates.go new file mode 100644 index 00000000000..19d07dffd2d --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/predicates.go @@ -0,0 +1,37 @@ +package sitecertificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CertificateOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p CertificateOperationPredicate) Matches(input Certificate) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/sitecertificates/version.go b/resource-manager/web/2024-11-01/sitecertificates/version.go new file mode 100644 index 00000000000..65e44bc998b --- /dev/null +++ b/resource-manager/web/2024-11-01/sitecertificates/version.go @@ -0,0 +1,10 @@ +package sitecertificates + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/sitecertificates/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/staticsites/README.md b/resource-manager/web/2024-11-01/staticsites/README.md new file mode 100644 index 00000000000..f5b67326796 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/README.md @@ -0,0 +1,1300 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/staticsites` Documentation + +The `staticsites` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/staticsites" +``` + + +### Client Initialization + +```go +client := staticsites.NewStaticSitesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `StaticSitesClient.ApproveOrRejectPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSitePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "privateEndpointConnectionName") + +payload := staticsites.RemotePrivateEndpointConnectionARMResource{ + // ... +} + + +if err := client.ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateBasicAuth` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +payload := staticsites.StaticSiteBasicAuthPropertiesARMResource{ + // ... +} + + +read, err := client.CreateOrUpdateBasicAuth(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateBuildDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "databaseConnectionName") + +payload := staticsites.DatabaseConnection{ + // ... +} + + +read, err := client.CreateOrUpdateBuildDatabaseConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "databaseConnectionName") + +payload := staticsites.DatabaseConnection{ + // ... +} + + +read, err := client.CreateOrUpdateDatabaseConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +payload := staticsites.StaticSiteARMResource{ + // ... +} + + +if err := client.CreateOrUpdateStaticSiteThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSiteAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +payload := staticsites.StringDictionary{ + // ... +} + + +read, err := client.CreateOrUpdateStaticSiteAppSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSiteBuildAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +payload := staticsites.StringDictionary{ + // ... +} + + +read, err := client.CreateOrUpdateStaticSiteBuildAppSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSiteBuildFunctionAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +payload := staticsites.StringDictionary{ + // ... +} + + +read, err := client.CreateOrUpdateStaticSiteBuildFunctionAppSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSiteCustomDomain` + +```go +ctx := context.TODO() +id := staticsites.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "customDomainName") + +payload := staticsites.StaticSiteCustomDomainRequestPropertiesARMResource{ + // ... +} + + +if err := client.CreateOrUpdateStaticSiteCustomDomainThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.CreateOrUpdateStaticSiteFunctionAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +payload := staticsites.StringDictionary{ + // ... +} + + +read, err := client.CreateOrUpdateStaticSiteFunctionAppSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateUserRolesInvitationLink` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +payload := staticsites.StaticSiteUserInvitationRequestResource{ + // ... +} + + +read, err := client.CreateUserRolesInvitationLink(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.CreateZipDeploymentForStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +payload := staticsites.StaticSiteZipDeploymentARMResource{ + // ... +} + + +if err := client.CreateZipDeploymentForStaticSiteThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.CreateZipDeploymentForStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +payload := staticsites.StaticSiteZipDeploymentARMResource{ + // ... +} + + +if err := client.CreateZipDeploymentForStaticSiteBuildThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DeleteBuildDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "databaseConnectionName") + +read, err := client.DeleteBuildDatabaseConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.DeleteDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "databaseConnectionName") + +read, err := client.DeleteDatabaseConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.DeletePrivateEndpointConnection` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSitePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "privateEndpointConnectionName") + +if err := client.DeletePrivateEndpointConnectionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DeleteStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +if err := client.DeleteStaticSiteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DeleteStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +if err := client.DeleteStaticSiteBuildThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DeleteStaticSiteCustomDomain` + +```go +ctx := context.TODO() +id := staticsites.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "customDomainName") + +if err := client.DeleteStaticSiteCustomDomainThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DeleteStaticSiteUser` + +```go +ctx := context.TODO() +id := staticsites.NewUserID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "authProviderName", "userName") + +read, err := client.DeleteStaticSiteUser(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.DetachStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +if err := client.DetachStaticSiteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.DetachUserProvidedFunctionAppFromStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "userProvidedFunctionAppName") + +read, err := client.DetachUserProvidedFunctionAppFromStaticSite(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.DetachUserProvidedFunctionAppFromStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "userProvidedFunctionAppName") + +read, err := client.DetachUserProvidedFunctionAppFromStaticSiteBuild(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetBasicAuth` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +read, err := client.GetBasicAuth(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetBuildDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "databaseConnectionName") + +read, err := client.GetBuildDatabaseConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetBuildDatabaseConnectionWithDetails` + +```go +ctx := context.TODO() +id := staticsites.NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "databaseConnectionName") + +read, err := client.GetBuildDatabaseConnectionWithDetails(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetBuildDatabaseConnections` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +// alternatively `client.GetBuildDatabaseConnections(ctx, id)` can be used to do batched pagination +items, err := client.GetBuildDatabaseConnectionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetBuildDatabaseConnectionsWithDetails` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +// alternatively `client.GetBuildDatabaseConnectionsWithDetails(ctx, id)` can be used to do batched pagination +items, err := client.GetBuildDatabaseConnectionsWithDetailsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "databaseConnectionName") + +read, err := client.GetDatabaseConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetDatabaseConnectionWithDetails` + +```go +ctx := context.TODO() +id := staticsites.NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "databaseConnectionName") + +read, err := client.GetDatabaseConnectionWithDetails(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetDatabaseConnections` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.GetDatabaseConnections(ctx, id)` can be used to do batched pagination +items, err := client.GetDatabaseConnectionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetDatabaseConnectionsWithDetails` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.GetDatabaseConnectionsWithDetails(ctx, id)` can be used to do batched pagination +items, err := client.GetDatabaseConnectionsWithDetailsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetLinkedBackend` + +```go +ctx := context.TODO() +id := staticsites.NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "linkedBackendName") + +read, err := client.GetLinkedBackend(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetLinkedBackendForBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "linkedBackendName") + +read, err := client.GetLinkedBackendForBuild(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetLinkedBackends` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.GetLinkedBackends(ctx, id)` can be used to do batched pagination +items, err := client.GetLinkedBackendsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetLinkedBackendsForBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +// alternatively `client.GetLinkedBackendsForBuild(ctx, id)` can be used to do batched pagination +items, err := client.GetLinkedBackendsForBuildComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSitePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "privateEndpointConnectionName") + +read, err := client.GetPrivateEndpointConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetPrivateEndpointConnectionList` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.GetPrivateEndpointConnectionList(ctx, id)` can be used to do batched pagination +items, err := client.GetPrivateEndpointConnectionListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetPrivateLinkResources` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +read, err := client.GetPrivateLinkResources(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +read, err := client.GetStaticSite(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +read, err := client.GetStaticSiteBuild(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetStaticSiteBuilds` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.GetStaticSiteBuilds(ctx, id)` can be used to do batched pagination +items, err := client.GetStaticSiteBuildsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetStaticSiteCustomDomain` + +```go +ctx := context.TODO() +id := staticsites.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "customDomainName") + +read, err := client.GetStaticSiteCustomDomain(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetStaticSitesByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.GetStaticSitesByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.GetStaticSitesByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetUserProvidedFunctionAppForStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "userProvidedFunctionAppName") + +read, err := client.GetUserProvidedFunctionAppForStaticSite(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetUserProvidedFunctionAppForStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "userProvidedFunctionAppName") + +read, err := client.GetUserProvidedFunctionAppForStaticSiteBuild(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.GetUserProvidedFunctionAppsForStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.GetUserProvidedFunctionAppsForStaticSite(ctx, id)` can be used to do batched pagination +items, err := client.GetUserProvidedFunctionAppsForStaticSiteComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.GetUserProvidedFunctionAppsForStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +// alternatively `client.GetUserProvidedFunctionAppsForStaticSiteBuild(ctx, id)` can be used to do batched pagination +items, err := client.GetUserProvidedFunctionAppsForStaticSiteBuildComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.LinkBackend` + +```go +ctx := context.TODO() +id := staticsites.NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "linkedBackendName") + +payload := staticsites.StaticSiteLinkedBackendARMResource{ + // ... +} + + +if err := client.LinkBackendThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.LinkBackendToBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "linkedBackendName") + +payload := staticsites.StaticSiteLinkedBackendARMResource{ + // ... +} + + +if err := client.LinkBackendToBuildThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.ListBasicAuth` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.ListBasicAuth(ctx, id)` can be used to do batched pagination +items, err := client.ListBasicAuthComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +read, err := client.ListStaticSiteAppSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteBuildAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +read, err := client.ListStaticSiteBuildAppSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteBuildFunctionAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +read, err := client.ListStaticSiteBuildFunctionAppSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteBuildFunctions` + +```go +ctx := context.TODO() +id := staticsites.NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + +// alternatively `client.ListStaticSiteBuildFunctions(ctx, id)` can be used to do batched pagination +items, err := client.ListStaticSiteBuildFunctionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteConfiguredRoles` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +read, err := client.ListStaticSiteConfiguredRoles(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteCustomDomains` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.ListStaticSiteCustomDomains(ctx, id)` can be used to do batched pagination +items, err := client.ListStaticSiteCustomDomainsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteFunctionAppSettings` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +read, err := client.ListStaticSiteFunctionAppSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteFunctions` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +// alternatively `client.ListStaticSiteFunctions(ctx, id)` can be used to do batched pagination +items, err := client.ListStaticSiteFunctionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteSecrets` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +read, err := client.ListStaticSiteSecrets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ListStaticSiteUsers` + +```go +ctx := context.TODO() +id := staticsites.NewAuthProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "authProviderName") + +// alternatively `client.ListStaticSiteUsers(ctx, id)` can be used to do batched pagination +items, err := client.ListStaticSiteUsersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `StaticSitesClient.PreviewWorkflow` + +```go +ctx := context.TODO() +id := staticsites.NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := staticsites.StaticSitesWorkflowPreviewRequest{ + // ... +} + + +read, err := client.PreviewWorkflow(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.RegisterUserProvidedFunctionAppWithStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "userProvidedFunctionAppName") + +payload := staticsites.StaticSiteUserProvidedFunctionAppARMResource{ + // ... +} + + +if err := client.RegisterUserProvidedFunctionAppWithStaticSiteThenPoll(ctx, id, payload, staticsites.DefaultRegisterUserProvidedFunctionAppWithStaticSiteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.RegisterUserProvidedFunctionAppWithStaticSiteBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "userProvidedFunctionAppName") + +payload := staticsites.StaticSiteUserProvidedFunctionAppARMResource{ + // ... +} + + +if err := client.RegisterUserProvidedFunctionAppWithStaticSiteBuildThenPoll(ctx, id, payload, staticsites.DefaultRegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.ResetStaticSiteApiKey` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +payload := staticsites.StaticSiteResetPropertiesARMResource{ + // ... +} + + +read, err := client.ResetStaticSiteApiKey(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UnlinkBackend` + +```go +ctx := context.TODO() +id := staticsites.NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "linkedBackendName") + +read, err := client.UnlinkBackend(ctx, id, staticsites.DefaultUnlinkBackendOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UnlinkBackendFromBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "linkedBackendName") + +read, err := client.UnlinkBackendFromBuild(ctx, id, staticsites.DefaultUnlinkBackendFromBuildOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UpdateBuildDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "databaseConnectionName") + +payload := staticsites.DatabaseConnectionPatchRequest{ + // ... +} + + +read, err := client.UpdateBuildDatabaseConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UpdateDatabaseConnection` + +```go +ctx := context.TODO() +id := staticsites.NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "databaseConnectionName") + +payload := staticsites.DatabaseConnectionPatchRequest{ + // ... +} + + +read, err := client.UpdateDatabaseConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UpdateStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + +payload := staticsites.StaticSitePatchResource{ + // ... +} + + +read, err := client.UpdateStaticSite(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.UpdateStaticSiteUser` + +```go +ctx := context.TODO() +id := staticsites.NewUserID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "authProviderName", "userName") + +payload := staticsites.StaticSiteUserARMResource{ + // ... +} + + +read, err := client.UpdateStaticSiteUser(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `StaticSitesClient.ValidateBackend` + +```go +ctx := context.TODO() +id := staticsites.NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "linkedBackendName") + +payload := staticsites.StaticSiteLinkedBackendARMResource{ + // ... +} + + +if err := client.ValidateBackendThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.ValidateBackendForBuild` + +```go +ctx := context.TODO() +id := staticsites.NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "linkedBackendName") + +payload := staticsites.StaticSiteLinkedBackendARMResource{ + // ... +} + + +if err := client.ValidateBackendForBuildThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `StaticSitesClient.ValidateCustomDomainCanBeAddedToStaticSite` + +```go +ctx := context.TODO() +id := staticsites.NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "customDomainName") + +payload := staticsites.StaticSiteCustomDomainRequestPropertiesARMResource{ + // ... +} + + +if err := client.ValidateCustomDomainCanBeAddedToStaticSiteThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/web/2024-11-01/staticsites/client.go b/resource-manager/web/2024-11-01/staticsites/client.go new file mode 100644 index 00000000000..1843789810a --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/client.go @@ -0,0 +1,26 @@ +package staticsites + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSitesClient struct { + Client *resourcemanager.Client +} + +func NewStaticSitesClientWithBaseURI(sdkApi sdkEnv.Api) (*StaticSitesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "staticsites", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating StaticSitesClient: %+v", err) + } + + return &StaticSitesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/constants.go b/resource-manager/web/2024-11-01/staticsites/constants.go new file mode 100644 index 00000000000..dfdde973015 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/constants.go @@ -0,0 +1,251 @@ +package staticsites + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BuildStatus string + +const ( + BuildStatusDeleting BuildStatus = "Deleting" + BuildStatusDeploying BuildStatus = "Deploying" + BuildStatusDetached BuildStatus = "Detached" + BuildStatusFailed BuildStatus = "Failed" + BuildStatusReady BuildStatus = "Ready" + BuildStatusUploading BuildStatus = "Uploading" + BuildStatusWaitingForDeployment BuildStatus = "WaitingForDeployment" +) + +func PossibleValuesForBuildStatus() []string { + return []string{ + string(BuildStatusDeleting), + string(BuildStatusDeploying), + string(BuildStatusDetached), + string(BuildStatusFailed), + string(BuildStatusReady), + string(BuildStatusUploading), + string(BuildStatusWaitingForDeployment), + } +} + +func (s *BuildStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBuildStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBuildStatus(input string) (*BuildStatus, error) { + vals := map[string]BuildStatus{ + "deleting": BuildStatusDeleting, + "deploying": BuildStatusDeploying, + "detached": BuildStatusDetached, + "failed": BuildStatusFailed, + "ready": BuildStatusReady, + "uploading": BuildStatusUploading, + "waitingfordeployment": BuildStatusWaitingForDeployment, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BuildStatus(input) + return &out, nil +} + +type CustomDomainStatus string + +const ( + CustomDomainStatusAdding CustomDomainStatus = "Adding" + CustomDomainStatusDeleting CustomDomainStatus = "Deleting" + CustomDomainStatusFailed CustomDomainStatus = "Failed" + CustomDomainStatusReady CustomDomainStatus = "Ready" + CustomDomainStatusRetrievingValidationToken CustomDomainStatus = "RetrievingValidationToken" + CustomDomainStatusUnhealthy CustomDomainStatus = "Unhealthy" + CustomDomainStatusValidating CustomDomainStatus = "Validating" +) + +func PossibleValuesForCustomDomainStatus() []string { + return []string{ + string(CustomDomainStatusAdding), + string(CustomDomainStatusDeleting), + string(CustomDomainStatusFailed), + string(CustomDomainStatusReady), + string(CustomDomainStatusRetrievingValidationToken), + string(CustomDomainStatusUnhealthy), + string(CustomDomainStatusValidating), + } +} + +func (s *CustomDomainStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomDomainStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomDomainStatus(input string) (*CustomDomainStatus, error) { + vals := map[string]CustomDomainStatus{ + "adding": CustomDomainStatusAdding, + "deleting": CustomDomainStatusDeleting, + "failed": CustomDomainStatusFailed, + "ready": CustomDomainStatusReady, + "retrievingvalidationtoken": CustomDomainStatusRetrievingValidationToken, + "unhealthy": CustomDomainStatusUnhealthy, + "validating": CustomDomainStatusValidating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomDomainStatus(input) + return &out, nil +} + +type EnterpriseGradeCdnStatus string + +const ( + EnterpriseGradeCdnStatusDisabled EnterpriseGradeCdnStatus = "Disabled" + EnterpriseGradeCdnStatusDisabling EnterpriseGradeCdnStatus = "Disabling" + EnterpriseGradeCdnStatusEnabled EnterpriseGradeCdnStatus = "Enabled" + EnterpriseGradeCdnStatusEnabling EnterpriseGradeCdnStatus = "Enabling" +) + +func PossibleValuesForEnterpriseGradeCdnStatus() []string { + return []string{ + string(EnterpriseGradeCdnStatusDisabled), + string(EnterpriseGradeCdnStatusDisabling), + string(EnterpriseGradeCdnStatusEnabled), + string(EnterpriseGradeCdnStatusEnabling), + } +} + +func (s *EnterpriseGradeCdnStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnterpriseGradeCdnStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnterpriseGradeCdnStatus(input string) (*EnterpriseGradeCdnStatus, error) { + vals := map[string]EnterpriseGradeCdnStatus{ + "disabled": EnterpriseGradeCdnStatusDisabled, + "disabling": EnterpriseGradeCdnStatusDisabling, + "enabled": EnterpriseGradeCdnStatusEnabled, + "enabling": EnterpriseGradeCdnStatusEnabling, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnterpriseGradeCdnStatus(input) + return &out, nil +} + +type StagingEnvironmentPolicy string + +const ( + StagingEnvironmentPolicyDisabled StagingEnvironmentPolicy = "Disabled" + StagingEnvironmentPolicyEnabled StagingEnvironmentPolicy = "Enabled" +) + +func PossibleValuesForStagingEnvironmentPolicy() []string { + return []string{ + string(StagingEnvironmentPolicyDisabled), + string(StagingEnvironmentPolicyEnabled), + } +} + +func (s *StagingEnvironmentPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStagingEnvironmentPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStagingEnvironmentPolicy(input string) (*StagingEnvironmentPolicy, error) { + vals := map[string]StagingEnvironmentPolicy{ + "disabled": StagingEnvironmentPolicyDisabled, + "enabled": StagingEnvironmentPolicyEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StagingEnvironmentPolicy(input) + return &out, nil +} + +type TriggerTypes string + +const ( + TriggerTypesHTTPTrigger TriggerTypes = "HttpTrigger" + TriggerTypesUnknown TriggerTypes = "Unknown" +) + +func PossibleValuesForTriggerTypes() []string { + return []string{ + string(TriggerTypesHTTPTrigger), + string(TriggerTypesUnknown), + } +} + +func (s *TriggerTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTriggerTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTriggerTypes(input string) (*TriggerTypes, error) { + vals := map[string]TriggerTypes{ + "httptrigger": TriggerTypesHTTPTrigger, + "unknown": TriggerTypesUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TriggerTypes(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_authprovider.go b/resource-manager/web/2024-11-01/staticsites/id_authprovider.go new file mode 100644 index 00000000000..73ad2ff2650 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_authprovider.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AuthProviderId{}) +} + +var _ resourceids.ResourceId = &AuthProviderId{} + +// AuthProviderId is a struct representing the Resource ID for a Auth Provider +type AuthProviderId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + AuthProviderName string +} + +// NewAuthProviderID returns a new AuthProviderId struct +func NewAuthProviderID(subscriptionId string, resourceGroupName string, staticSiteName string, authProviderName string) AuthProviderId { + return AuthProviderId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + AuthProviderName: authProviderName, + } +} + +// ParseAuthProviderID parses 'input' into a AuthProviderId +func ParseAuthProviderID(input string) (*AuthProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthProviderId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthProviderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAuthProviderIDInsensitively parses 'input' case-insensitively into a AuthProviderId +// note: this method should only be used for API response data and not user input +func ParseAuthProviderIDInsensitively(input string) (*AuthProviderId, error) { + parser := resourceids.NewParserFromResourceIdType(&AuthProviderId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AuthProviderId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AuthProviderId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.AuthProviderName, ok = input.Parsed["authProviderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "authProviderName", input) + } + + return nil +} + +// ValidateAuthProviderID checks that 'input' can be parsed as a Auth Provider ID +func ValidateAuthProviderID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseAuthProviderID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Auth Provider ID +func (id AuthProviderId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/authProviders/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.AuthProviderName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Auth Provider ID +func (id AuthProviderId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticAuthProviders", "authProviders", "authProviders"), + resourceids.UserSpecifiedSegment("authProviderName", "authProviderName"), + } +} + +// String returns a human-readable description of this Auth Provider ID +func (id AuthProviderId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Auth Provider Name: %q", id.AuthProviderName), + } + return fmt.Sprintf("Auth Provider (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_authprovider_test.go b/resource-manager/web/2024-11-01/staticsites/id_authprovider_test.go new file mode 100644 index 00000000000..8ea5e3431e0 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_authprovider_test.go @@ -0,0 +1,327 @@ +package staticsites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AuthProviderId{} + +func TestNewAuthProviderID(t *testing.T) { + id := NewAuthProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "authProviderName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.AuthProviderName != "authProviderName" { + t.Fatalf("Expected %q but got %q for Segment 'AuthProviderName'", id.AuthProviderName, "authProviderName") + } +} + +func TestFormatAuthProviderID(t *testing.T) { + actual := NewAuthProviderID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "authProviderName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAuthProviderID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthProviderId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName", + Expected: &AuthProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + AuthProviderName: "authProviderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthProviderID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.AuthProviderName != v.Expected.AuthProviderName { + t.Fatalf("Expected %q but got %q for AuthProviderName", v.Expected.AuthProviderName, actual.AuthProviderName) + } + + } +} + +func TestParseAuthProviderIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AuthProviderId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/aUtHpRoViDeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName", + Expected: &AuthProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + AuthProviderName: "authProviderName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/aUtHpRoViDeRs/aUtHpRoViDeRnAmE", + Expected: &AuthProviderId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + AuthProviderName: "aUtHpRoViDeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/aUtHpRoViDeRs/aUtHpRoViDeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAuthProviderIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.AuthProviderName != v.Expected.AuthProviderName { + t.Fatalf("Expected %q but got %q for AuthProviderName", v.Expected.AuthProviderName, actual.AuthProviderName) + } + + } +} + +func TestSegmentsForAuthProviderId(t *testing.T) { + segments := AuthProviderId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AuthProviderId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_build.go b/resource-manager/web/2024-11-01/staticsites/id_build.go new file mode 100644 index 00000000000..9b2d3b3a03d --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_build.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BuildId{}) +} + +var _ resourceids.ResourceId = &BuildId{} + +// BuildId is a struct representing the Resource ID for a Build +type BuildId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + BuildName string +} + +// NewBuildID returns a new BuildId struct +func NewBuildID(subscriptionId string, resourceGroupName string, staticSiteName string, buildName string) BuildId { + return BuildId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + BuildName: buildName, + } +} + +// ParseBuildID parses 'input' into a BuildId +func ParseBuildID(input string) (*BuildId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBuildIDInsensitively parses 'input' case-insensitively into a BuildId +// note: this method should only be used for API response data and not user input +func ParseBuildIDInsensitively(input string) (*BuildId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BuildId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.BuildName, ok = input.Parsed["buildName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "buildName", input) + } + + return nil +} + +// ValidateBuildID checks that 'input' can be parsed as a Build ID +func ValidateBuildID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBuildID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Build ID +func (id BuildId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/builds/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.BuildName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Build ID +func (id BuildId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticBuilds", "builds", "builds"), + resourceids.UserSpecifiedSegment("buildName", "buildName"), + } +} + +// String returns a human-readable description of this Build ID +func (id BuildId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Build Name: %q", id.BuildName), + } + return fmt.Sprintf("Build (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_build_test.go b/resource-manager/web/2024-11-01/staticsites/id_build_test.go new file mode 100644 index 00000000000..9f08be01439 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_build_test.go @@ -0,0 +1,327 @@ +package staticsites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BuildId{} + +func TestNewBuildID(t *testing.T) { + id := NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.BuildName != "buildName" { + t.Fatalf("Expected %q but got %q for Segment 'BuildName'", id.BuildName, "buildName") + } +} + +func TestFormatBuildID(t *testing.T) { + actual := NewBuildID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBuildID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName", + Expected: &BuildId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + BuildName: "buildName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + } +} + +func TestParseBuildIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName", + Expected: &BuildId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + BuildName: "buildName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe", + Expected: &BuildId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + BuildName: "bUiLdNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + } +} + +func TestSegmentsForBuildId(t *testing.T) { + segments := BuildId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BuildId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_builddatabaseconnection.go b/resource-manager/web/2024-11-01/staticsites/id_builddatabaseconnection.go new file mode 100644 index 00000000000..660071b7aab --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_builddatabaseconnection.go @@ -0,0 +1,148 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BuildDatabaseConnectionId{}) +} + +var _ resourceids.ResourceId = &BuildDatabaseConnectionId{} + +// BuildDatabaseConnectionId is a struct representing the Resource ID for a Build Database Connection +type BuildDatabaseConnectionId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + BuildName string + DatabaseConnectionName string +} + +// NewBuildDatabaseConnectionID returns a new BuildDatabaseConnectionId struct +func NewBuildDatabaseConnectionID(subscriptionId string, resourceGroupName string, staticSiteName string, buildName string, databaseConnectionName string) BuildDatabaseConnectionId { + return BuildDatabaseConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + BuildName: buildName, + DatabaseConnectionName: databaseConnectionName, + } +} + +// ParseBuildDatabaseConnectionID parses 'input' into a BuildDatabaseConnectionId +func ParseBuildDatabaseConnectionID(input string) (*BuildDatabaseConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildDatabaseConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildDatabaseConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBuildDatabaseConnectionIDInsensitively parses 'input' case-insensitively into a BuildDatabaseConnectionId +// note: this method should only be used for API response data and not user input +func ParseBuildDatabaseConnectionIDInsensitively(input string) (*BuildDatabaseConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildDatabaseConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildDatabaseConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BuildDatabaseConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.BuildName, ok = input.Parsed["buildName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "buildName", input) + } + + if id.DatabaseConnectionName, ok = input.Parsed["databaseConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseConnectionName", input) + } + + return nil +} + +// ValidateBuildDatabaseConnectionID checks that 'input' can be parsed as a Build Database Connection ID +func ValidateBuildDatabaseConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBuildDatabaseConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Build Database Connection ID +func (id BuildDatabaseConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/builds/%s/databaseConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.BuildName, id.DatabaseConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Build Database Connection ID +func (id BuildDatabaseConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticBuilds", "builds", "builds"), + resourceids.UserSpecifiedSegment("buildName", "buildName"), + resourceids.StaticSegment("staticDatabaseConnections", "databaseConnections", "databaseConnections"), + resourceids.UserSpecifiedSegment("databaseConnectionName", "databaseConnectionName"), + } +} + +// String returns a human-readable description of this Build Database Connection ID +func (id BuildDatabaseConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Build Name: %q", id.BuildName), + fmt.Sprintf("Database Connection Name: %q", id.DatabaseConnectionName), + } + return fmt.Sprintf("Build Database Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_builddatabaseconnection_test.go b/resource-manager/web/2024-11-01/staticsites/id_builddatabaseconnection_test.go new file mode 100644 index 00000000000..68f9cc60dd9 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_builddatabaseconnection_test.go @@ -0,0 +1,372 @@ +package staticsites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BuildDatabaseConnectionId{} + +func TestNewBuildDatabaseConnectionID(t *testing.T) { + id := NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "databaseConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.BuildName != "buildName" { + t.Fatalf("Expected %q but got %q for Segment 'BuildName'", id.BuildName, "buildName") + } + + if id.DatabaseConnectionName != "databaseConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseConnectionName'", id.DatabaseConnectionName, "databaseConnectionName") + } +} + +func TestFormatBuildDatabaseConnectionID(t *testing.T) { + actual := NewBuildDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "databaseConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/databaseConnections/databaseConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBuildDatabaseConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildDatabaseConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/databaseConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/databaseConnections/databaseConnectionName", + Expected: &BuildDatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + BuildName: "buildName", + DatabaseConnectionName: "databaseConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/databaseConnections/databaseConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildDatabaseConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.DatabaseConnectionName != v.Expected.DatabaseConnectionName { + t.Fatalf("Expected %q but got %q for DatabaseConnectionName", v.Expected.DatabaseConnectionName, actual.DatabaseConnectionName) + } + + } +} + +func TestParseBuildDatabaseConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildDatabaseConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/databaseConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/dAtAbAsEcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/databaseConnections/databaseConnectionName", + Expected: &BuildDatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + BuildName: "buildName", + DatabaseConnectionName: "databaseConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/databaseConnections/databaseConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/dAtAbAsEcOnNeCtIoNs/dAtAbAsEcOnNeCtIoNnAmE", + Expected: &BuildDatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + BuildName: "bUiLdNaMe", + DatabaseConnectionName: "dAtAbAsEcOnNeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/dAtAbAsEcOnNeCtIoNs/dAtAbAsEcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildDatabaseConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.DatabaseConnectionName != v.Expected.DatabaseConnectionName { + t.Fatalf("Expected %q but got %q for DatabaseConnectionName", v.Expected.DatabaseConnectionName, actual.DatabaseConnectionName) + } + + } +} + +func TestSegmentsForBuildDatabaseConnectionId(t *testing.T) { + segments := BuildDatabaseConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BuildDatabaseConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_buildlinkedbackend.go b/resource-manager/web/2024-11-01/staticsites/id_buildlinkedbackend.go new file mode 100644 index 00000000000..42b3fe8e789 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_buildlinkedbackend.go @@ -0,0 +1,148 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BuildLinkedBackendId{}) +} + +var _ resourceids.ResourceId = &BuildLinkedBackendId{} + +// BuildLinkedBackendId is a struct representing the Resource ID for a Build Linked Backend +type BuildLinkedBackendId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + BuildName string + LinkedBackendName string +} + +// NewBuildLinkedBackendID returns a new BuildLinkedBackendId struct +func NewBuildLinkedBackendID(subscriptionId string, resourceGroupName string, staticSiteName string, buildName string, linkedBackendName string) BuildLinkedBackendId { + return BuildLinkedBackendId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + BuildName: buildName, + LinkedBackendName: linkedBackendName, + } +} + +// ParseBuildLinkedBackendID parses 'input' into a BuildLinkedBackendId +func ParseBuildLinkedBackendID(input string) (*BuildLinkedBackendId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildLinkedBackendId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildLinkedBackendId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBuildLinkedBackendIDInsensitively parses 'input' case-insensitively into a BuildLinkedBackendId +// note: this method should only be used for API response data and not user input +func ParseBuildLinkedBackendIDInsensitively(input string) (*BuildLinkedBackendId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildLinkedBackendId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildLinkedBackendId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BuildLinkedBackendId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.BuildName, ok = input.Parsed["buildName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "buildName", input) + } + + if id.LinkedBackendName, ok = input.Parsed["linkedBackendName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "linkedBackendName", input) + } + + return nil +} + +// ValidateBuildLinkedBackendID checks that 'input' can be parsed as a Build Linked Backend ID +func ValidateBuildLinkedBackendID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBuildLinkedBackendID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Build Linked Backend ID +func (id BuildLinkedBackendId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/builds/%s/linkedBackends/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.BuildName, id.LinkedBackendName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Build Linked Backend ID +func (id BuildLinkedBackendId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticBuilds", "builds", "builds"), + resourceids.UserSpecifiedSegment("buildName", "buildName"), + resourceids.StaticSegment("staticLinkedBackends", "linkedBackends", "linkedBackends"), + resourceids.UserSpecifiedSegment("linkedBackendName", "linkedBackendName"), + } +} + +// String returns a human-readable description of this Build Linked Backend ID +func (id BuildLinkedBackendId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Build Name: %q", id.BuildName), + fmt.Sprintf("Linked Backend Name: %q", id.LinkedBackendName), + } + return fmt.Sprintf("Build Linked Backend (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_buildlinkedbackend_test.go b/resource-manager/web/2024-11-01/staticsites/id_buildlinkedbackend_test.go new file mode 100644 index 00000000000..e7a2cb9e253 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_buildlinkedbackend_test.go @@ -0,0 +1,372 @@ +package staticsites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BuildLinkedBackendId{} + +func TestNewBuildLinkedBackendID(t *testing.T) { + id := NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "linkedBackendName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.BuildName != "buildName" { + t.Fatalf("Expected %q but got %q for Segment 'BuildName'", id.BuildName, "buildName") + } + + if id.LinkedBackendName != "linkedBackendName" { + t.Fatalf("Expected %q but got %q for Segment 'LinkedBackendName'", id.LinkedBackendName, "linkedBackendName") + } +} + +func TestFormatBuildLinkedBackendID(t *testing.T) { + actual := NewBuildLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "linkedBackendName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/linkedBackends/linkedBackendName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBuildLinkedBackendID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildLinkedBackendId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/linkedBackends", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/linkedBackends/linkedBackendName", + Expected: &BuildLinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + BuildName: "buildName", + LinkedBackendName: "linkedBackendName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/linkedBackends/linkedBackendName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildLinkedBackendID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.LinkedBackendName != v.Expected.LinkedBackendName { + t.Fatalf("Expected %q but got %q for LinkedBackendName", v.Expected.LinkedBackendName, actual.LinkedBackendName) + } + + } +} + +func TestParseBuildLinkedBackendIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildLinkedBackendId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/linkedBackends", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/lInKeDbAcKeNdS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/linkedBackends/linkedBackendName", + Expected: &BuildLinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + BuildName: "buildName", + LinkedBackendName: "linkedBackendName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/linkedBackends/linkedBackendName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/lInKeDbAcKeNdS/lInKeDbAcKeNdNaMe", + Expected: &BuildLinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + BuildName: "bUiLdNaMe", + LinkedBackendName: "lInKeDbAcKeNdNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/lInKeDbAcKeNdS/lInKeDbAcKeNdNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildLinkedBackendIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.LinkedBackendName != v.Expected.LinkedBackendName { + t.Fatalf("Expected %q but got %q for LinkedBackendName", v.Expected.LinkedBackendName, actual.LinkedBackendName) + } + + } +} + +func TestSegmentsForBuildLinkedBackendId(t *testing.T) { + segments := BuildLinkedBackendId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BuildLinkedBackendId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_builduserprovidedfunctionapp.go b/resource-manager/web/2024-11-01/staticsites/id_builduserprovidedfunctionapp.go new file mode 100644 index 00000000000..23a557f57de --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_builduserprovidedfunctionapp.go @@ -0,0 +1,148 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BuildUserProvidedFunctionAppId{}) +} + +var _ resourceids.ResourceId = &BuildUserProvidedFunctionAppId{} + +// BuildUserProvidedFunctionAppId is a struct representing the Resource ID for a Build User Provided Function App +type BuildUserProvidedFunctionAppId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + BuildName string + UserProvidedFunctionAppName string +} + +// NewBuildUserProvidedFunctionAppID returns a new BuildUserProvidedFunctionAppId struct +func NewBuildUserProvidedFunctionAppID(subscriptionId string, resourceGroupName string, staticSiteName string, buildName string, userProvidedFunctionAppName string) BuildUserProvidedFunctionAppId { + return BuildUserProvidedFunctionAppId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + BuildName: buildName, + UserProvidedFunctionAppName: userProvidedFunctionAppName, + } +} + +// ParseBuildUserProvidedFunctionAppID parses 'input' into a BuildUserProvidedFunctionAppId +func ParseBuildUserProvidedFunctionAppID(input string) (*BuildUserProvidedFunctionAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildUserProvidedFunctionAppId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildUserProvidedFunctionAppId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBuildUserProvidedFunctionAppIDInsensitively parses 'input' case-insensitively into a BuildUserProvidedFunctionAppId +// note: this method should only be used for API response data and not user input +func ParseBuildUserProvidedFunctionAppIDInsensitively(input string) (*BuildUserProvidedFunctionAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&BuildUserProvidedFunctionAppId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BuildUserProvidedFunctionAppId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BuildUserProvidedFunctionAppId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.BuildName, ok = input.Parsed["buildName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "buildName", input) + } + + if id.UserProvidedFunctionAppName, ok = input.Parsed["userProvidedFunctionAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "userProvidedFunctionAppName", input) + } + + return nil +} + +// ValidateBuildUserProvidedFunctionAppID checks that 'input' can be parsed as a Build User Provided Function App ID +func ValidateBuildUserProvidedFunctionAppID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBuildUserProvidedFunctionAppID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Build User Provided Function App ID +func (id BuildUserProvidedFunctionAppId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/builds/%s/userProvidedFunctionApps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.BuildName, id.UserProvidedFunctionAppName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Build User Provided Function App ID +func (id BuildUserProvidedFunctionAppId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticBuilds", "builds", "builds"), + resourceids.UserSpecifiedSegment("buildName", "buildName"), + resourceids.StaticSegment("staticUserProvidedFunctionApps", "userProvidedFunctionApps", "userProvidedFunctionApps"), + resourceids.UserSpecifiedSegment("userProvidedFunctionAppName", "userProvidedFunctionAppName"), + } +} + +// String returns a human-readable description of this Build User Provided Function App ID +func (id BuildUserProvidedFunctionAppId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Build Name: %q", id.BuildName), + fmt.Sprintf("User Provided Function App Name: %q", id.UserProvidedFunctionAppName), + } + return fmt.Sprintf("Build User Provided Function App (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_builduserprovidedfunctionapp_test.go b/resource-manager/web/2024-11-01/staticsites/id_builduserprovidedfunctionapp_test.go new file mode 100644 index 00000000000..04e65c3a35b --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_builduserprovidedfunctionapp_test.go @@ -0,0 +1,372 @@ +package staticsites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BuildUserProvidedFunctionAppId{} + +func TestNewBuildUserProvidedFunctionAppID(t *testing.T) { + id := NewBuildUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "userProvidedFunctionAppName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.BuildName != "buildName" { + t.Fatalf("Expected %q but got %q for Segment 'BuildName'", id.BuildName, "buildName") + } + + if id.UserProvidedFunctionAppName != "userProvidedFunctionAppName" { + t.Fatalf("Expected %q but got %q for Segment 'UserProvidedFunctionAppName'", id.UserProvidedFunctionAppName, "userProvidedFunctionAppName") + } +} + +func TestFormatBuildUserProvidedFunctionAppID(t *testing.T) { + actual := NewBuildUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "buildName", "userProvidedFunctionAppName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/userProvidedFunctionApps/userProvidedFunctionAppName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBuildUserProvidedFunctionAppID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildUserProvidedFunctionAppId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/userProvidedFunctionApps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/userProvidedFunctionApps/userProvidedFunctionAppName", + Expected: &BuildUserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + BuildName: "buildName", + UserProvidedFunctionAppName: "userProvidedFunctionAppName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/userProvidedFunctionApps/userProvidedFunctionAppName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildUserProvidedFunctionAppID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.UserProvidedFunctionAppName != v.Expected.UserProvidedFunctionAppName { + t.Fatalf("Expected %q but got %q for UserProvidedFunctionAppName", v.Expected.UserProvidedFunctionAppName, actual.UserProvidedFunctionAppName) + } + + } +} + +func TestParseBuildUserProvidedFunctionAppIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BuildUserProvidedFunctionAppId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/userProvidedFunctionApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/uSeRpRoViDeDfUnCtIoNaPpS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/userProvidedFunctionApps/userProvidedFunctionAppName", + Expected: &BuildUserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + BuildName: "buildName", + UserProvidedFunctionAppName: "userProvidedFunctionAppName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/builds/buildName/userProvidedFunctionApps/userProvidedFunctionAppName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/uSeRpRoViDeDfUnCtIoNaPpS/uSeRpRoViDeDfUnCtIoNaPpNaMe", + Expected: &BuildUserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + BuildName: "bUiLdNaMe", + UserProvidedFunctionAppName: "uSeRpRoViDeDfUnCtIoNaPpNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/bUiLdS/bUiLdNaMe/uSeRpRoViDeDfUnCtIoNaPpS/uSeRpRoViDeDfUnCtIoNaPpNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBuildUserProvidedFunctionAppIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.BuildName != v.Expected.BuildName { + t.Fatalf("Expected %q but got %q for BuildName", v.Expected.BuildName, actual.BuildName) + } + + if actual.UserProvidedFunctionAppName != v.Expected.UserProvidedFunctionAppName { + t.Fatalf("Expected %q but got %q for UserProvidedFunctionAppName", v.Expected.UserProvidedFunctionAppName, actual.UserProvidedFunctionAppName) + } + + } +} + +func TestSegmentsForBuildUserProvidedFunctionAppId(t *testing.T) { + segments := BuildUserProvidedFunctionAppId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BuildUserProvidedFunctionAppId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_customdomain.go b/resource-manager/web/2024-11-01/staticsites/id_customdomain.go new file mode 100644 index 00000000000..52bb3f0abb2 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_customdomain.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CustomDomainId{}) +} + +var _ resourceids.ResourceId = &CustomDomainId{} + +// CustomDomainId is a struct representing the Resource ID for a Custom Domain +type CustomDomainId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + CustomDomainName string +} + +// NewCustomDomainID returns a new CustomDomainId struct +func NewCustomDomainID(subscriptionId string, resourceGroupName string, staticSiteName string, customDomainName string) CustomDomainId { + return CustomDomainId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + CustomDomainName: customDomainName, + } +} + +// ParseCustomDomainID parses 'input' into a CustomDomainId +func ParseCustomDomainID(input string) (*CustomDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomDomainId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomDomainId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCustomDomainIDInsensitively parses 'input' case-insensitively into a CustomDomainId +// note: this method should only be used for API response data and not user input +func ParseCustomDomainIDInsensitively(input string) (*CustomDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&CustomDomainId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CustomDomainId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CustomDomainId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.CustomDomainName, ok = input.Parsed["customDomainName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "customDomainName", input) + } + + return nil +} + +// ValidateCustomDomainID checks that 'input' can be parsed as a Custom Domain ID +func ValidateCustomDomainID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCustomDomainID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Custom Domain ID +func (id CustomDomainId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/customDomains/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.CustomDomainName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Custom Domain ID +func (id CustomDomainId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticCustomDomains", "customDomains", "customDomains"), + resourceids.UserSpecifiedSegment("customDomainName", "customDomainName"), + } +} + +// String returns a human-readable description of this Custom Domain ID +func (id CustomDomainId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Custom Domain Name: %q", id.CustomDomainName), + } + return fmt.Sprintf("Custom Domain (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_customdomain_test.go b/resource-manager/web/2024-11-01/staticsites/id_customdomain_test.go new file mode 100644 index 00000000000..64add194b56 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_customdomain_test.go @@ -0,0 +1,327 @@ +package staticsites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CustomDomainId{} + +func TestNewCustomDomainID(t *testing.T) { + id := NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "customDomainName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.CustomDomainName != "customDomainName" { + t.Fatalf("Expected %q but got %q for Segment 'CustomDomainName'", id.CustomDomainName, "customDomainName") + } +} + +func TestFormatCustomDomainID(t *testing.T) { + actual := NewCustomDomainID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "customDomainName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/customDomains/customDomainName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCustomDomainID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomDomainId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/customDomains", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/customDomains/customDomainName", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + CustomDomainName: "customDomainName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/customDomains/customDomainName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomDomainID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.CustomDomainName != v.Expected.CustomDomainName { + t.Fatalf("Expected %q but got %q for CustomDomainName", v.Expected.CustomDomainName, actual.CustomDomainName) + } + + } +} + +func TestParseCustomDomainIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CustomDomainId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/customDomains", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/cUsToMdOmAiNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/customDomains/customDomainName", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + CustomDomainName: "customDomainName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/customDomains/customDomainName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/cUsToMdOmAiNs/cUsToMdOmAiNnAmE", + Expected: &CustomDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + CustomDomainName: "cUsToMdOmAiNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/cUsToMdOmAiNs/cUsToMdOmAiNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCustomDomainIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.CustomDomainName != v.Expected.CustomDomainName { + t.Fatalf("Expected %q but got %q for CustomDomainName", v.Expected.CustomDomainName, actual.CustomDomainName) + } + + } +} + +func TestSegmentsForCustomDomainId(t *testing.T) { + segments := CustomDomainId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CustomDomainId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_databaseconnection.go b/resource-manager/web/2024-11-01/staticsites/id_databaseconnection.go new file mode 100644 index 00000000000..0646be22614 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_databaseconnection.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DatabaseConnectionId{}) +} + +var _ resourceids.ResourceId = &DatabaseConnectionId{} + +// DatabaseConnectionId is a struct representing the Resource ID for a Database Connection +type DatabaseConnectionId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + DatabaseConnectionName string +} + +// NewDatabaseConnectionID returns a new DatabaseConnectionId struct +func NewDatabaseConnectionID(subscriptionId string, resourceGroupName string, staticSiteName string, databaseConnectionName string) DatabaseConnectionId { + return DatabaseConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + DatabaseConnectionName: databaseConnectionName, + } +} + +// ParseDatabaseConnectionID parses 'input' into a DatabaseConnectionId +func ParseDatabaseConnectionID(input string) (*DatabaseConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDatabaseConnectionIDInsensitively parses 'input' case-insensitively into a DatabaseConnectionId +// note: this method should only be used for API response data and not user input +func ParseDatabaseConnectionIDInsensitively(input string) (*DatabaseConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&DatabaseConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DatabaseConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DatabaseConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.DatabaseConnectionName, ok = input.Parsed["databaseConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "databaseConnectionName", input) + } + + return nil +} + +// ValidateDatabaseConnectionID checks that 'input' can be parsed as a Database Connection ID +func ValidateDatabaseConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDatabaseConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Database Connection ID +func (id DatabaseConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/databaseConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.DatabaseConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Database Connection ID +func (id DatabaseConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticDatabaseConnections", "databaseConnections", "databaseConnections"), + resourceids.UserSpecifiedSegment("databaseConnectionName", "databaseConnectionName"), + } +} + +// String returns a human-readable description of this Database Connection ID +func (id DatabaseConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Database Connection Name: %q", id.DatabaseConnectionName), + } + return fmt.Sprintf("Database Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_databaseconnection_test.go b/resource-manager/web/2024-11-01/staticsites/id_databaseconnection_test.go new file mode 100644 index 00000000000..c91658ac616 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_databaseconnection_test.go @@ -0,0 +1,327 @@ +package staticsites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DatabaseConnectionId{} + +func TestNewDatabaseConnectionID(t *testing.T) { + id := NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "databaseConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.DatabaseConnectionName != "databaseConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'DatabaseConnectionName'", id.DatabaseConnectionName, "databaseConnectionName") + } +} + +func TestFormatDatabaseConnectionID(t *testing.T) { + actual := NewDatabaseConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "databaseConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/databaseConnections/databaseConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDatabaseConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/databaseConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/databaseConnections/databaseConnectionName", + Expected: &DatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + DatabaseConnectionName: "databaseConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/databaseConnections/databaseConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.DatabaseConnectionName != v.Expected.DatabaseConnectionName { + t.Fatalf("Expected %q but got %q for DatabaseConnectionName", v.Expected.DatabaseConnectionName, actual.DatabaseConnectionName) + } + + } +} + +func TestParseDatabaseConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DatabaseConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/databaseConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/dAtAbAsEcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/databaseConnections/databaseConnectionName", + Expected: &DatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + DatabaseConnectionName: "databaseConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/databaseConnections/databaseConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/dAtAbAsEcOnNeCtIoNs/dAtAbAsEcOnNeCtIoNnAmE", + Expected: &DatabaseConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + DatabaseConnectionName: "dAtAbAsEcOnNeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/dAtAbAsEcOnNeCtIoNs/dAtAbAsEcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDatabaseConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.DatabaseConnectionName != v.Expected.DatabaseConnectionName { + t.Fatalf("Expected %q but got %q for DatabaseConnectionName", v.Expected.DatabaseConnectionName, actual.DatabaseConnectionName) + } + + } +} + +func TestSegmentsForDatabaseConnectionId(t *testing.T) { + segments := DatabaseConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DatabaseConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_linkedbackend.go b/resource-manager/web/2024-11-01/staticsites/id_linkedbackend.go new file mode 100644 index 00000000000..2db02661f88 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_linkedbackend.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LinkedBackendId{}) +} + +var _ resourceids.ResourceId = &LinkedBackendId{} + +// LinkedBackendId is a struct representing the Resource ID for a Linked Backend +type LinkedBackendId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + LinkedBackendName string +} + +// NewLinkedBackendID returns a new LinkedBackendId struct +func NewLinkedBackendID(subscriptionId string, resourceGroupName string, staticSiteName string, linkedBackendName string) LinkedBackendId { + return LinkedBackendId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + LinkedBackendName: linkedBackendName, + } +} + +// ParseLinkedBackendID parses 'input' into a LinkedBackendId +func ParseLinkedBackendID(input string) (*LinkedBackendId, error) { + parser := resourceids.NewParserFromResourceIdType(&LinkedBackendId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LinkedBackendId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLinkedBackendIDInsensitively parses 'input' case-insensitively into a LinkedBackendId +// note: this method should only be used for API response data and not user input +func ParseLinkedBackendIDInsensitively(input string) (*LinkedBackendId, error) { + parser := resourceids.NewParserFromResourceIdType(&LinkedBackendId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LinkedBackendId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LinkedBackendId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.LinkedBackendName, ok = input.Parsed["linkedBackendName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "linkedBackendName", input) + } + + return nil +} + +// ValidateLinkedBackendID checks that 'input' can be parsed as a Linked Backend ID +func ValidateLinkedBackendID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLinkedBackendID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Linked Backend ID +func (id LinkedBackendId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/linkedBackends/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.LinkedBackendName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Linked Backend ID +func (id LinkedBackendId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticLinkedBackends", "linkedBackends", "linkedBackends"), + resourceids.UserSpecifiedSegment("linkedBackendName", "linkedBackendName"), + } +} + +// String returns a human-readable description of this Linked Backend ID +func (id LinkedBackendId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Linked Backend Name: %q", id.LinkedBackendName), + } + return fmt.Sprintf("Linked Backend (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_linkedbackend_test.go b/resource-manager/web/2024-11-01/staticsites/id_linkedbackend_test.go new file mode 100644 index 00000000000..bbbdc7a534f --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_linkedbackend_test.go @@ -0,0 +1,327 @@ +package staticsites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LinkedBackendId{} + +func TestNewLinkedBackendID(t *testing.T) { + id := NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "linkedBackendName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.LinkedBackendName != "linkedBackendName" { + t.Fatalf("Expected %q but got %q for Segment 'LinkedBackendName'", id.LinkedBackendName, "linkedBackendName") + } +} + +func TestFormatLinkedBackendID(t *testing.T) { + actual := NewLinkedBackendID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "linkedBackendName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/linkedBackends/linkedBackendName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLinkedBackendID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LinkedBackendId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/linkedBackends", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/linkedBackends/linkedBackendName", + Expected: &LinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + LinkedBackendName: "linkedBackendName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/linkedBackends/linkedBackendName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLinkedBackendID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.LinkedBackendName != v.Expected.LinkedBackendName { + t.Fatalf("Expected %q but got %q for LinkedBackendName", v.Expected.LinkedBackendName, actual.LinkedBackendName) + } + + } +} + +func TestParseLinkedBackendIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LinkedBackendId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/linkedBackends", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/lInKeDbAcKeNdS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/linkedBackends/linkedBackendName", + Expected: &LinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + LinkedBackendName: "linkedBackendName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/linkedBackends/linkedBackendName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/lInKeDbAcKeNdS/lInKeDbAcKeNdNaMe", + Expected: &LinkedBackendId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + LinkedBackendName: "lInKeDbAcKeNdNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/lInKeDbAcKeNdS/lInKeDbAcKeNdNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLinkedBackendIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.LinkedBackendName != v.Expected.LinkedBackendName { + t.Fatalf("Expected %q but got %q for LinkedBackendName", v.Expected.LinkedBackendName, actual.LinkedBackendName) + } + + } +} + +func TestSegmentsForLinkedBackendId(t *testing.T) { + segments := LinkedBackendId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LinkedBackendId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_providerlocation.go b/resource-manager/web/2024-11-01/staticsites/id_providerlocation.go new file mode 100644 index 00000000000..c53d10beaa5 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_providerlocation.go @@ -0,0 +1,121 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProviderLocationId{}) +} + +var _ resourceids.ResourceId = &ProviderLocationId{} + +// ProviderLocationId is a struct representing the Resource ID for a Provider Location +type ProviderLocationId struct { + SubscriptionId string + LocationName string +} + +// NewProviderLocationID returns a new ProviderLocationId struct +func NewProviderLocationID(subscriptionId string, locationName string) ProviderLocationId { + return ProviderLocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseProviderLocationID parses 'input' into a ProviderLocationId +func ParseProviderLocationID(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProviderLocationIDInsensitively parses 'input' case-insensitively into a ProviderLocationId +// note: this method should only be used for API response data and not user input +func ParseProviderLocationIDInsensitively(input string) (*ProviderLocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProviderLocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProviderLocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProviderLocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateProviderLocationID checks that 'input' can be parsed as a Provider Location ID +func ValidateProviderLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProviderLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Provider Location ID +func (id ProviderLocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.Web/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Provider Location ID +func (id ProviderLocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Provider Location ID +func (id ProviderLocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Provider Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_providerlocation_test.go b/resource-manager/web/2024-11-01/staticsites/id_providerlocation_test.go new file mode 100644 index 00000000000..e48b5f6c6d4 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_providerlocation_test.go @@ -0,0 +1,237 @@ +package staticsites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProviderLocationId{} + +func TestNewProviderLocationID(t *testing.T) { + id := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationName" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationName") + } +} + +func TestFormatProviderLocationID(t *testing.T) { + actual := NewProviderLocationID("12345678-1234-9876-4563-123456789012", "locationName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProviderLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseProviderLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProviderLocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.Web/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE", + Expected: &ProviderLocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.wEb/lOcAtIoNs/lOcAtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProviderLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForProviderLocationId(t *testing.T) { + segments := ProviderLocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProviderLocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_staticsite.go b/resource-manager/web/2024-11-01/staticsites/id_staticsite.go new file mode 100644 index 00000000000..5b7df0899c4 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_staticsite.go @@ -0,0 +1,130 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&StaticSiteId{}) +} + +var _ resourceids.ResourceId = &StaticSiteId{} + +// StaticSiteId is a struct representing the Resource ID for a Static Site +type StaticSiteId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string +} + +// NewStaticSiteID returns a new StaticSiteId struct +func NewStaticSiteID(subscriptionId string, resourceGroupName string, staticSiteName string) StaticSiteId { + return StaticSiteId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + } +} + +// ParseStaticSiteID parses 'input' into a StaticSiteId +func ParseStaticSiteID(input string) (*StaticSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&StaticSiteId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StaticSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStaticSiteIDInsensitively parses 'input' case-insensitively into a StaticSiteId +// note: this method should only be used for API response data and not user input +func ParseStaticSiteIDInsensitively(input string) (*StaticSiteId, error) { + parser := resourceids.NewParserFromResourceIdType(&StaticSiteId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StaticSiteId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StaticSiteId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + return nil +} + +// ValidateStaticSiteID checks that 'input' can be parsed as a Static Site ID +func ValidateStaticSiteID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseStaticSiteID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Static Site ID +func (id StaticSiteId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Static Site ID +func (id StaticSiteId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + } +} + +// String returns a human-readable description of this Static Site ID +func (id StaticSiteId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + } + return fmt.Sprintf("Static Site (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_staticsite_test.go b/resource-manager/web/2024-11-01/staticsites/id_staticsite_test.go new file mode 100644 index 00000000000..429bdfeaed4 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_staticsite_test.go @@ -0,0 +1,282 @@ +package staticsites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &StaticSiteId{} + +func TestNewStaticSiteID(t *testing.T) { + id := NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } +} + +func TestFormatStaticSiteID(t *testing.T) { + actual := NewStaticSiteID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStaticSiteID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StaticSiteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Expected: &StaticSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStaticSiteID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + } +} + +func TestParseStaticSiteIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StaticSiteId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Expected: &StaticSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Expected: &StaticSiteId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStaticSiteIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + } +} + +func TestSegmentsForStaticSiteId(t *testing.T) { + segments := StaticSiteId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StaticSiteId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_staticsiteprivateendpointconnection.go b/resource-manager/web/2024-11-01/staticsites/id_staticsiteprivateendpointconnection.go new file mode 100644 index 00000000000..8c4c4fd7cb9 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_staticsiteprivateendpointconnection.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&StaticSitePrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &StaticSitePrivateEndpointConnectionId{} + +// StaticSitePrivateEndpointConnectionId is a struct representing the Resource ID for a Static Site Private Endpoint Connection +type StaticSitePrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + PrivateEndpointConnectionName string +} + +// NewStaticSitePrivateEndpointConnectionID returns a new StaticSitePrivateEndpointConnectionId struct +func NewStaticSitePrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, staticSiteName string, privateEndpointConnectionName string) StaticSitePrivateEndpointConnectionId { + return StaticSitePrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParseStaticSitePrivateEndpointConnectionID parses 'input' into a StaticSitePrivateEndpointConnectionId +func ParseStaticSitePrivateEndpointConnectionID(input string) (*StaticSitePrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&StaticSitePrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StaticSitePrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseStaticSitePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a StaticSitePrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParseStaticSitePrivateEndpointConnectionIDInsensitively(input string) (*StaticSitePrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&StaticSitePrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := StaticSitePrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *StaticSitePrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidateStaticSitePrivateEndpointConnectionID checks that 'input' can be parsed as a Static Site Private Endpoint Connection ID +func ValidateStaticSitePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseStaticSitePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Static Site Private Endpoint Connection ID +func (id StaticSitePrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Static Site Private Endpoint Connection ID +func (id StaticSitePrivateEndpointConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Static Site Private Endpoint Connection ID +func (id StaticSitePrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Static Site Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_staticsiteprivateendpointconnection_test.go b/resource-manager/web/2024-11-01/staticsites/id_staticsiteprivateendpointconnection_test.go new file mode 100644 index 00000000000..aef661aa34c --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_staticsiteprivateendpointconnection_test.go @@ -0,0 +1,327 @@ +package staticsites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &StaticSitePrivateEndpointConnectionId{} + +func TestNewStaticSitePrivateEndpointConnectionID(t *testing.T) { + id := NewStaticSitePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "privateEndpointConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatStaticSitePrivateEndpointConnectionID(t *testing.T) { + actual := NewStaticSitePrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseStaticSitePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StaticSitePrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &StaticSitePrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStaticSitePrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParseStaticSitePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *StaticSitePrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &StaticSitePrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &StaticSitePrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseStaticSitePrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForStaticSitePrivateEndpointConnectionId(t *testing.T) { + segments := StaticSitePrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("StaticSitePrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_user.go b/resource-manager/web/2024-11-01/staticsites/id_user.go new file mode 100644 index 00000000000..fe210ef0473 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_user.go @@ -0,0 +1,148 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&UserId{}) +} + +var _ resourceids.ResourceId = &UserId{} + +// UserId is a struct representing the Resource ID for a User +type UserId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + AuthProviderName string + UserName string +} + +// NewUserID returns a new UserId struct +func NewUserID(subscriptionId string, resourceGroupName string, staticSiteName string, authProviderName string, userName string) UserId { + return UserId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + AuthProviderName: authProviderName, + UserName: userName, + } +} + +// ParseUserID parses 'input' into a UserId +func ParseUserID(input string) (*UserId, error) { + parser := resourceids.NewParserFromResourceIdType(&UserId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UserId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseUserIDInsensitively parses 'input' case-insensitively into a UserId +// note: this method should only be used for API response data and not user input +func ParseUserIDInsensitively(input string) (*UserId, error) { + parser := resourceids.NewParserFromResourceIdType(&UserId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UserId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *UserId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.AuthProviderName, ok = input.Parsed["authProviderName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "authProviderName", input) + } + + if id.UserName, ok = input.Parsed["userName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "userName", input) + } + + return nil +} + +// ValidateUserID checks that 'input' can be parsed as a User ID +func ValidateUserID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseUserID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted User ID +func (id UserId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/authProviders/%s/users/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.AuthProviderName, id.UserName) +} + +// Segments returns a slice of Resource ID Segments which comprise this User ID +func (id UserId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticAuthProviders", "authProviders", "authProviders"), + resourceids.UserSpecifiedSegment("authProviderName", "authProviderName"), + resourceids.StaticSegment("staticUsers", "users", "users"), + resourceids.UserSpecifiedSegment("userName", "userName"), + } +} + +// String returns a human-readable description of this User ID +func (id UserId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("Auth Provider Name: %q", id.AuthProviderName), + fmt.Sprintf("User Name: %q", id.UserName), + } + return fmt.Sprintf("User (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_user_test.go b/resource-manager/web/2024-11-01/staticsites/id_user_test.go new file mode 100644 index 00000000000..e79e3a28959 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_user_test.go @@ -0,0 +1,372 @@ +package staticsites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &UserId{} + +func TestNewUserID(t *testing.T) { + id := NewUserID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "authProviderName", "userName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.AuthProviderName != "authProviderName" { + t.Fatalf("Expected %q but got %q for Segment 'AuthProviderName'", id.AuthProviderName, "authProviderName") + } + + if id.UserName != "userName" { + t.Fatalf("Expected %q but got %q for Segment 'UserName'", id.UserName, "userName") + } +} + +func TestFormatUserID(t *testing.T) { + actual := NewUserID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "authProviderName", "userName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/users/userName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseUserID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UserId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/users", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/users/userName", + Expected: &UserId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + AuthProviderName: "authProviderName", + UserName: "userName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/users/userName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUserID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.AuthProviderName != v.Expected.AuthProviderName { + t.Fatalf("Expected %q but got %q for AuthProviderName", v.Expected.AuthProviderName, actual.AuthProviderName) + } + + if actual.UserName != v.Expected.UserName { + t.Fatalf("Expected %q but got %q for UserName", v.Expected.UserName, actual.UserName) + } + + } +} + +func TestParseUserIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UserId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/aUtHpRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/aUtHpRoViDeRs/aUtHpRoViDeRnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/users", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/aUtHpRoViDeRs/aUtHpRoViDeRnAmE/uSeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/users/userName", + Expected: &UserId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + AuthProviderName: "authProviderName", + UserName: "userName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/authProviders/authProviderName/users/userName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/aUtHpRoViDeRs/aUtHpRoViDeRnAmE/uSeRs/uSeRnAmE", + Expected: &UserId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + AuthProviderName: "aUtHpRoViDeRnAmE", + UserName: "uSeRnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/aUtHpRoViDeRs/aUtHpRoViDeRnAmE/uSeRs/uSeRnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUserIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.AuthProviderName != v.Expected.AuthProviderName { + t.Fatalf("Expected %q but got %q for AuthProviderName", v.Expected.AuthProviderName, actual.AuthProviderName) + } + + if actual.UserName != v.Expected.UserName { + t.Fatalf("Expected %q but got %q for UserName", v.Expected.UserName, actual.UserName) + } + + } +} + +func TestSegmentsForUserId(t *testing.T) { + segments := UserId{}.Segments() + if len(segments) == 0 { + t.Fatalf("UserId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_userprovidedfunctionapp.go b/resource-manager/web/2024-11-01/staticsites/id_userprovidedfunctionapp.go new file mode 100644 index 00000000000..ff361f6c538 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_userprovidedfunctionapp.go @@ -0,0 +1,139 @@ +package staticsites + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&UserProvidedFunctionAppId{}) +} + +var _ resourceids.ResourceId = &UserProvidedFunctionAppId{} + +// UserProvidedFunctionAppId is a struct representing the Resource ID for a User Provided Function App +type UserProvidedFunctionAppId struct { + SubscriptionId string + ResourceGroupName string + StaticSiteName string + UserProvidedFunctionAppName string +} + +// NewUserProvidedFunctionAppID returns a new UserProvidedFunctionAppId struct +func NewUserProvidedFunctionAppID(subscriptionId string, resourceGroupName string, staticSiteName string, userProvidedFunctionAppName string) UserProvidedFunctionAppId { + return UserProvidedFunctionAppId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + StaticSiteName: staticSiteName, + UserProvidedFunctionAppName: userProvidedFunctionAppName, + } +} + +// ParseUserProvidedFunctionAppID parses 'input' into a UserProvidedFunctionAppId +func ParseUserProvidedFunctionAppID(input string) (*UserProvidedFunctionAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&UserProvidedFunctionAppId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UserProvidedFunctionAppId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseUserProvidedFunctionAppIDInsensitively parses 'input' case-insensitively into a UserProvidedFunctionAppId +// note: this method should only be used for API response data and not user input +func ParseUserProvidedFunctionAppIDInsensitively(input string) (*UserProvidedFunctionAppId, error) { + parser := resourceids.NewParserFromResourceIdType(&UserProvidedFunctionAppId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := UserProvidedFunctionAppId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *UserProvidedFunctionAppId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.StaticSiteName, ok = input.Parsed["staticSiteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "staticSiteName", input) + } + + if id.UserProvidedFunctionAppName, ok = input.Parsed["userProvidedFunctionAppName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "userProvidedFunctionAppName", input) + } + + return nil +} + +// ValidateUserProvidedFunctionAppID checks that 'input' can be parsed as a User Provided Function App ID +func ValidateUserProvidedFunctionAppID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseUserProvidedFunctionAppID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted User Provided Function App ID +func (id UserProvidedFunctionAppId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/staticSites/%s/userProvidedFunctionApps/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.StaticSiteName, id.UserProvidedFunctionAppName) +} + +// Segments returns a slice of Resource ID Segments which comprise this User Provided Function App ID +func (id UserProvidedFunctionAppId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticStaticSites", "staticSites", "staticSites"), + resourceids.UserSpecifiedSegment("staticSiteName", "staticSiteName"), + resourceids.StaticSegment("staticUserProvidedFunctionApps", "userProvidedFunctionApps", "userProvidedFunctionApps"), + resourceids.UserSpecifiedSegment("userProvidedFunctionAppName", "userProvidedFunctionAppName"), + } +} + +// String returns a human-readable description of this User Provided Function App ID +func (id UserProvidedFunctionAppId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Static Site Name: %q", id.StaticSiteName), + fmt.Sprintf("User Provided Function App Name: %q", id.UserProvidedFunctionAppName), + } + return fmt.Sprintf("User Provided Function App (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/staticsites/id_userprovidedfunctionapp_test.go b/resource-manager/web/2024-11-01/staticsites/id_userprovidedfunctionapp_test.go new file mode 100644 index 00000000000..038fecd6ba1 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/id_userprovidedfunctionapp_test.go @@ -0,0 +1,327 @@ +package staticsites + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &UserProvidedFunctionAppId{} + +func TestNewUserProvidedFunctionAppID(t *testing.T) { + id := NewUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "userProvidedFunctionAppName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.StaticSiteName != "staticSiteName" { + t.Fatalf("Expected %q but got %q for Segment 'StaticSiteName'", id.StaticSiteName, "staticSiteName") + } + + if id.UserProvidedFunctionAppName != "userProvidedFunctionAppName" { + t.Fatalf("Expected %q but got %q for Segment 'UserProvidedFunctionAppName'", id.UserProvidedFunctionAppName, "userProvidedFunctionAppName") + } +} + +func TestFormatUserProvidedFunctionAppID(t *testing.T) { + actual := NewUserProvidedFunctionAppID("12345678-1234-9876-4563-123456789012", "example-resource-group", "staticSiteName", "userProvidedFunctionAppName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/userProvidedFunctionApps/userProvidedFunctionAppName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseUserProvidedFunctionAppID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UserProvidedFunctionAppId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/userProvidedFunctionApps", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/userProvidedFunctionApps/userProvidedFunctionAppName", + Expected: &UserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + UserProvidedFunctionAppName: "userProvidedFunctionAppName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/userProvidedFunctionApps/userProvidedFunctionAppName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUserProvidedFunctionAppID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.UserProvidedFunctionAppName != v.Expected.UserProvidedFunctionAppName { + t.Fatalf("Expected %q but got %q for UserProvidedFunctionAppName", v.Expected.UserProvidedFunctionAppName, actual.UserProvidedFunctionAppName) + } + + } +} + +func TestParseUserProvidedFunctionAppIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *UserProvidedFunctionAppId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/userProvidedFunctionApps", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/uSeRpRoViDeDfUnCtIoNaPpS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/userProvidedFunctionApps/userProvidedFunctionAppName", + Expected: &UserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + StaticSiteName: "staticSiteName", + UserProvidedFunctionAppName: "userProvidedFunctionAppName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/staticSites/staticSiteName/userProvidedFunctionApps/userProvidedFunctionAppName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/uSeRpRoViDeDfUnCtIoNaPpS/uSeRpRoViDeDfUnCtIoNaPpNaMe", + Expected: &UserProvidedFunctionAppId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + StaticSiteName: "sTaTiCsItEnAmE", + UserProvidedFunctionAppName: "uSeRpRoViDeDfUnCtIoNaPpNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sTaTiCsItEs/sTaTiCsItEnAmE/uSeRpRoViDeDfUnCtIoNaPpS/uSeRpRoViDeDfUnCtIoNaPpNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseUserProvidedFunctionAppIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.StaticSiteName != v.Expected.StaticSiteName { + t.Fatalf("Expected %q but got %q for StaticSiteName", v.Expected.StaticSiteName, actual.StaticSiteName) + } + + if actual.UserProvidedFunctionAppName != v.Expected.UserProvidedFunctionAppName { + t.Fatalf("Expected %q but got %q for UserProvidedFunctionAppName", v.Expected.UserProvidedFunctionAppName, actual.UserProvidedFunctionAppName) + } + + } +} + +func TestSegmentsForUserProvidedFunctionAppId(t *testing.T) { + segments := UserProvidedFunctionAppId{}.Segments() + if len(segments) == 0 { + t.Fatalf("UserProvidedFunctionAppId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_approveorrejectprivateendpointconnection.go b/resource-manager/web/2024-11-01/staticsites/method_approveorrejectprivateendpointconnection.go new file mode 100644 index 00000000000..b07e7684411 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_approveorrejectprivateendpointconnection.go @@ -0,0 +1,75 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApproveOrRejectPrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// ApproveOrRejectPrivateEndpointConnection ... +func (c StaticSitesClient) ApproveOrRejectPrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) (result ApproveOrRejectPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ApproveOrRejectPrivateEndpointConnectionThenPoll performs ApproveOrRejectPrivateEndpointConnection then polls until it's completed +func (c StaticSitesClient) ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx context.Context, id StaticSitePrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) error { + result, err := c.ApproveOrRejectPrivateEndpointConnection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_createorupdatebasicauth.go b/resource-manager/web/2024-11-01/staticsites/method_createorupdatebasicauth.go new file mode 100644 index 00000000000..e320de5ee8d --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_createorupdatebasicauth.go @@ -0,0 +1,58 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateBasicAuthOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteBasicAuthPropertiesARMResource +} + +// CreateOrUpdateBasicAuth ... +func (c StaticSitesClient) CreateOrUpdateBasicAuth(ctx context.Context, id StaticSiteId, input StaticSiteBasicAuthPropertiesARMResource) (result CreateOrUpdateBasicAuthOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicAuth/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteBasicAuthPropertiesARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_createorupdatebuilddatabaseconnection.go b/resource-manager/web/2024-11-01/staticsites/method_createorupdatebuilddatabaseconnection.go new file mode 100644 index 00000000000..577ea3e3a33 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_createorupdatebuilddatabaseconnection.go @@ -0,0 +1,57 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateBuildDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// CreateOrUpdateBuildDatabaseConnection ... +func (c StaticSitesClient) CreateOrUpdateBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId, input DatabaseConnection) (result CreateOrUpdateBuildDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DatabaseConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_createorupdatedatabaseconnection.go b/resource-manager/web/2024-11-01/staticsites/method_createorupdatedatabaseconnection.go new file mode 100644 index 00000000000..4e9d93d0c60 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_createorupdatedatabaseconnection.go @@ -0,0 +1,57 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// CreateOrUpdateDatabaseConnection ... +func (c StaticSitesClient) CreateOrUpdateDatabaseConnection(ctx context.Context, id DatabaseConnectionId, input DatabaseConnection) (result CreateOrUpdateDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DatabaseConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsite.go b/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsite.go new file mode 100644 index 00000000000..15bec306823 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsite.go @@ -0,0 +1,75 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteARMResource +} + +// CreateOrUpdateStaticSite ... +func (c StaticSitesClient) CreateOrUpdateStaticSite(ctx context.Context, id StaticSiteId, input StaticSiteARMResource) (result CreateOrUpdateStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateStaticSiteThenPoll performs CreateOrUpdateStaticSite then polls until it's completed +func (c StaticSitesClient) CreateOrUpdateStaticSiteThenPoll(ctx context.Context, id StaticSiteId, input StaticSiteARMResource) error { + result, err := c.CreateOrUpdateStaticSite(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsiteappsettings.go b/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsiteappsettings.go new file mode 100644 index 00000000000..7664955e4a5 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsiteappsettings.go @@ -0,0 +1,58 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateStaticSiteAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// CreateOrUpdateStaticSiteAppSettings ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteAppSettings(ctx context.Context, id StaticSiteId, input StringDictionary) (result CreateOrUpdateStaticSiteAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/appSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsitebuildappsettings.go b/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsitebuildappsettings.go new file mode 100644 index 00000000000..ea9eccbeb1d --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsitebuildappsettings.go @@ -0,0 +1,58 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateStaticSiteBuildAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// CreateOrUpdateStaticSiteBuildAppSettings ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteBuildAppSettings(ctx context.Context, id BuildId, input StringDictionary) (result CreateOrUpdateStaticSiteBuildAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/appSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsitebuildfunctionappsettings.go b/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsitebuildfunctionappsettings.go new file mode 100644 index 00000000000..6ccea1d9510 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsitebuildfunctionappsettings.go @@ -0,0 +1,58 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateStaticSiteBuildFunctionAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// CreateOrUpdateStaticSiteBuildFunctionAppSettings ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteBuildFunctionAppSettings(ctx context.Context, id BuildId, input StringDictionary) (result CreateOrUpdateStaticSiteBuildFunctionAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/functionAppSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsitecustomdomain.go b/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsitecustomdomain.go new file mode 100644 index 00000000000..77c06560af1 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsitecustomdomain.go @@ -0,0 +1,75 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateStaticSiteCustomDomainOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteCustomDomainOverviewARMResource +} + +// CreateOrUpdateStaticSiteCustomDomain ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteCustomDomain(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) (result CreateOrUpdateStaticSiteCustomDomainOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateStaticSiteCustomDomainThenPoll performs CreateOrUpdateStaticSiteCustomDomain then polls until it's completed +func (c StaticSitesClient) CreateOrUpdateStaticSiteCustomDomainThenPoll(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) error { + result, err := c.CreateOrUpdateStaticSiteCustomDomain(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateStaticSiteCustomDomain: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateStaticSiteCustomDomain: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsitefunctionappsettings.go b/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsitefunctionappsettings.go new file mode 100644 index 00000000000..8bc2ba7c3e0 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_createorupdatestaticsitefunctionappsettings.go @@ -0,0 +1,58 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateStaticSiteFunctionAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// CreateOrUpdateStaticSiteFunctionAppSettings ... +func (c StaticSitesClient) CreateOrUpdateStaticSiteFunctionAppSettings(ctx context.Context, id StaticSiteId, input StringDictionary) (result CreateOrUpdateStaticSiteFunctionAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/functionAppSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_createuserrolesinvitationlink.go b/resource-manager/web/2024-11-01/staticsites/method_createuserrolesinvitationlink.go new file mode 100644 index 00000000000..62bf2337cca --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_createuserrolesinvitationlink.go @@ -0,0 +1,58 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateUserRolesInvitationLinkOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserInvitationResponseResource +} + +// CreateUserRolesInvitationLink ... +func (c StaticSitesClient) CreateUserRolesInvitationLink(ctx context.Context, id StaticSiteId, input StaticSiteUserInvitationRequestResource) (result CreateUserRolesInvitationLinkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/createUserInvitation", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteUserInvitationResponseResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_createzipdeploymentforstaticsite.go b/resource-manager/web/2024-11-01/staticsites/method_createzipdeploymentforstaticsite.go new file mode 100644 index 00000000000..6dddfe32ead --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_createzipdeploymentforstaticsite.go @@ -0,0 +1,74 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateZipDeploymentForStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateZipDeploymentForStaticSite ... +func (c StaticSitesClient) CreateZipDeploymentForStaticSite(ctx context.Context, id StaticSiteId, input StaticSiteZipDeploymentARMResource) (result CreateZipDeploymentForStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/zipdeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateZipDeploymentForStaticSiteThenPoll performs CreateZipDeploymentForStaticSite then polls until it's completed +func (c StaticSitesClient) CreateZipDeploymentForStaticSiteThenPoll(ctx context.Context, id StaticSiteId, input StaticSiteZipDeploymentARMResource) error { + result, err := c.CreateZipDeploymentForStaticSite(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateZipDeploymentForStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateZipDeploymentForStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_createzipdeploymentforstaticsitebuild.go b/resource-manager/web/2024-11-01/staticsites/method_createzipdeploymentforstaticsitebuild.go new file mode 100644 index 00000000000..4b1ac38f9e9 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_createzipdeploymentforstaticsitebuild.go @@ -0,0 +1,74 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateZipDeploymentForStaticSiteBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// CreateZipDeploymentForStaticSiteBuild ... +func (c StaticSitesClient) CreateZipDeploymentForStaticSiteBuild(ctx context.Context, id BuildId, input StaticSiteZipDeploymentARMResource) (result CreateZipDeploymentForStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/zipdeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateZipDeploymentForStaticSiteBuildThenPoll performs CreateZipDeploymentForStaticSiteBuild then polls until it's completed +func (c StaticSitesClient) CreateZipDeploymentForStaticSiteBuildThenPoll(ctx context.Context, id BuildId, input StaticSiteZipDeploymentARMResource) error { + result, err := c.CreateZipDeploymentForStaticSiteBuild(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateZipDeploymentForStaticSiteBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateZipDeploymentForStaticSiteBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_deletebuilddatabaseconnection.go b/resource-manager/web/2024-11-01/staticsites/method_deletebuilddatabaseconnection.go new file mode 100644 index 00000000000..5a80028d137 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_deletebuilddatabaseconnection.go @@ -0,0 +1,47 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteBuildDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBuildDatabaseConnection ... +func (c StaticSitesClient) DeleteBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId) (result DeleteBuildDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_deletedatabaseconnection.go b/resource-manager/web/2024-11-01/staticsites/method_deletedatabaseconnection.go new file mode 100644 index 00000000000..7f0d6cc94aa --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_deletedatabaseconnection.go @@ -0,0 +1,47 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDatabaseConnection ... +func (c StaticSitesClient) DeleteDatabaseConnection(ctx context.Context, id DatabaseConnectionId) (result DeleteDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_deleteprivateendpointconnection.go b/resource-manager/web/2024-11-01/staticsites/method_deleteprivateendpointconnection.go new file mode 100644 index 00000000000..d632f3899b4 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_deleteprivateendpointconnection.go @@ -0,0 +1,72 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletePrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// DeletePrivateEndpointConnection ... +func (c StaticSitesClient) DeletePrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed +func (c StaticSitesClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id StaticSitePrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnection(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_deletestaticsite.go b/resource-manager/web/2024-11-01/staticsites/method_deletestaticsite.go new file mode 100644 index 00000000000..78d3bd0abf4 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_deletestaticsite.go @@ -0,0 +1,70 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteStaticSite ... +func (c StaticSitesClient) DeleteStaticSite(ctx context.Context, id StaticSiteId) (result DeleteStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteStaticSiteThenPoll performs DeleteStaticSite then polls until it's completed +func (c StaticSitesClient) DeleteStaticSiteThenPoll(ctx context.Context, id StaticSiteId) error { + result, err := c.DeleteStaticSite(ctx, id) + if err != nil { + return fmt.Errorf("performing DeleteStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_deletestaticsitebuild.go b/resource-manager/web/2024-11-01/staticsites/method_deletestaticsitebuild.go new file mode 100644 index 00000000000..a3fdbf84900 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_deletestaticsitebuild.go @@ -0,0 +1,71 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteStaticSiteBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteStaticSiteBuild ... +func (c StaticSitesClient) DeleteStaticSiteBuild(ctx context.Context, id BuildId) (result DeleteStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteStaticSiteBuildThenPoll performs DeleteStaticSiteBuild then polls until it's completed +func (c StaticSitesClient) DeleteStaticSiteBuildThenPoll(ctx context.Context, id BuildId) error { + result, err := c.DeleteStaticSiteBuild(ctx, id) + if err != nil { + return fmt.Errorf("performing DeleteStaticSiteBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteStaticSiteBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_deletestaticsitecustomdomain.go b/resource-manager/web/2024-11-01/staticsites/method_deletestaticsitecustomdomain.go new file mode 100644 index 00000000000..471bf713f5d --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_deletestaticsitecustomdomain.go @@ -0,0 +1,70 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteStaticSiteCustomDomainOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteStaticSiteCustomDomain ... +func (c StaticSitesClient) DeleteStaticSiteCustomDomain(ctx context.Context, id CustomDomainId) (result DeleteStaticSiteCustomDomainOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteStaticSiteCustomDomainThenPoll performs DeleteStaticSiteCustomDomain then polls until it's completed +func (c StaticSitesClient) DeleteStaticSiteCustomDomainThenPoll(ctx context.Context, id CustomDomainId) error { + result, err := c.DeleteStaticSiteCustomDomain(ctx, id) + if err != nil { + return fmt.Errorf("performing DeleteStaticSiteCustomDomain: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteStaticSiteCustomDomain: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_deletestaticsiteuser.go b/resource-manager/web/2024-11-01/staticsites/method_deletestaticsiteuser.go new file mode 100644 index 00000000000..e4799c87ddb --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_deletestaticsiteuser.go @@ -0,0 +1,46 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteStaticSiteUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteStaticSiteUser ... +func (c StaticSitesClient) DeleteStaticSiteUser(ctx context.Context, id UserId) (result DeleteStaticSiteUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_detachstaticsite.go b/resource-manager/web/2024-11-01/staticsites/method_detachstaticsite.go new file mode 100644 index 00000000000..00fa4ac9dd0 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_detachstaticsite.go @@ -0,0 +1,70 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetachStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DetachStaticSite ... +func (c StaticSitesClient) DetachStaticSite(ctx context.Context, id StaticSiteId) (result DetachStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/detach", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DetachStaticSiteThenPoll performs DetachStaticSite then polls until it's completed +func (c StaticSitesClient) DetachStaticSiteThenPoll(ctx context.Context, id StaticSiteId) error { + result, err := c.DetachStaticSite(ctx, id) + if err != nil { + return fmt.Errorf("performing DetachStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DetachStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_detachuserprovidedfunctionappfromstaticsite.go b/resource-manager/web/2024-11-01/staticsites/method_detachuserprovidedfunctionappfromstaticsite.go new file mode 100644 index 00000000000..b9a68ba826d --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_detachuserprovidedfunctionappfromstaticsite.go @@ -0,0 +1,47 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetachUserProvidedFunctionAppFromStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DetachUserProvidedFunctionAppFromStaticSite ... +func (c StaticSitesClient) DetachUserProvidedFunctionAppFromStaticSite(ctx context.Context, id UserProvidedFunctionAppId) (result DetachUserProvidedFunctionAppFromStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_detachuserprovidedfunctionappfromstaticsitebuild.go b/resource-manager/web/2024-11-01/staticsites/method_detachuserprovidedfunctionappfromstaticsitebuild.go new file mode 100644 index 00000000000..305f4802b1d --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_detachuserprovidedfunctionappfromstaticsitebuild.go @@ -0,0 +1,47 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DetachUserProvidedFunctionAppFromStaticSiteBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DetachUserProvidedFunctionAppFromStaticSiteBuild ... +func (c StaticSitesClient) DetachUserProvidedFunctionAppFromStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId) (result DetachUserProvidedFunctionAppFromStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getbasicauth.go b/resource-manager/web/2024-11-01/staticsites/method_getbasicauth.go new file mode 100644 index 00000000000..860b9bdbfd2 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getbasicauth.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBasicAuthOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteBasicAuthPropertiesARMResource +} + +// GetBasicAuth ... +func (c StaticSitesClient) GetBasicAuth(ctx context.Context, id StaticSiteId) (result GetBasicAuthOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicAuth/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteBasicAuthPropertiesARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getbuilddatabaseconnection.go b/resource-manager/web/2024-11-01/staticsites/method_getbuilddatabaseconnection.go new file mode 100644 index 00000000000..6d90dfd9ae3 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getbuilddatabaseconnection.go @@ -0,0 +1,53 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBuildDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// GetBuildDatabaseConnection ... +func (c StaticSitesClient) GetBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId) (result GetBuildDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DatabaseConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getbuilddatabaseconnections.go b/resource-manager/web/2024-11-01/staticsites/method_getbuilddatabaseconnections.go new file mode 100644 index 00000000000..7b74f18507d --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getbuilddatabaseconnections.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBuildDatabaseConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DatabaseConnection +} + +type GetBuildDatabaseConnectionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DatabaseConnection +} + +type GetBuildDatabaseConnectionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetBuildDatabaseConnectionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetBuildDatabaseConnections ... +func (c StaticSitesClient) GetBuildDatabaseConnections(ctx context.Context, id BuildId) (result GetBuildDatabaseConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetBuildDatabaseConnectionsCustomPager{}, + Path: fmt.Sprintf("%s/databaseConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DatabaseConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetBuildDatabaseConnectionsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetBuildDatabaseConnectionsComplete(ctx context.Context, id BuildId) (GetBuildDatabaseConnectionsCompleteResult, error) { + return c.GetBuildDatabaseConnectionsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) +} + +// GetBuildDatabaseConnectionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetBuildDatabaseConnectionsCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate DatabaseConnectionOperationPredicate) (result GetBuildDatabaseConnectionsCompleteResult, err error) { + items := make([]DatabaseConnection, 0) + + resp, err := c.GetBuildDatabaseConnections(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetBuildDatabaseConnectionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getbuilddatabaseconnectionswithdetails.go b/resource-manager/web/2024-11-01/staticsites/method_getbuilddatabaseconnectionswithdetails.go new file mode 100644 index 00000000000..dca1df6d320 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getbuilddatabaseconnectionswithdetails.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBuildDatabaseConnectionsWithDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DatabaseConnection +} + +type GetBuildDatabaseConnectionsWithDetailsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DatabaseConnection +} + +type GetBuildDatabaseConnectionsWithDetailsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetBuildDatabaseConnectionsWithDetailsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetBuildDatabaseConnectionsWithDetails ... +func (c StaticSitesClient) GetBuildDatabaseConnectionsWithDetails(ctx context.Context, id BuildId) (result GetBuildDatabaseConnectionsWithDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &GetBuildDatabaseConnectionsWithDetailsCustomPager{}, + Path: fmt.Sprintf("%s/showDatabaseConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DatabaseConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetBuildDatabaseConnectionsWithDetailsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetBuildDatabaseConnectionsWithDetailsComplete(ctx context.Context, id BuildId) (GetBuildDatabaseConnectionsWithDetailsCompleteResult, error) { + return c.GetBuildDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) +} + +// GetBuildDatabaseConnectionsWithDetailsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetBuildDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate DatabaseConnectionOperationPredicate) (result GetBuildDatabaseConnectionsWithDetailsCompleteResult, err error) { + items := make([]DatabaseConnection, 0) + + resp, err := c.GetBuildDatabaseConnectionsWithDetails(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetBuildDatabaseConnectionsWithDetailsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getbuilddatabaseconnectionwithdetails.go b/resource-manager/web/2024-11-01/staticsites/method_getbuilddatabaseconnectionwithdetails.go new file mode 100644 index 00000000000..c035b26d729 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getbuilddatabaseconnectionwithdetails.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBuildDatabaseConnectionWithDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// GetBuildDatabaseConnectionWithDetails ... +func (c StaticSitesClient) GetBuildDatabaseConnectionWithDetails(ctx context.Context, id BuildDatabaseConnectionId) (result GetBuildDatabaseConnectionWithDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/show", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DatabaseConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getdatabaseconnection.go b/resource-manager/web/2024-11-01/staticsites/method_getdatabaseconnection.go new file mode 100644 index 00000000000..ad1f59b58d4 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getdatabaseconnection.go @@ -0,0 +1,53 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// GetDatabaseConnection ... +func (c StaticSitesClient) GetDatabaseConnection(ctx context.Context, id DatabaseConnectionId) (result GetDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DatabaseConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getdatabaseconnections.go b/resource-manager/web/2024-11-01/staticsites/method_getdatabaseconnections.go new file mode 100644 index 00000000000..47dcec6884d --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getdatabaseconnections.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetDatabaseConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DatabaseConnection +} + +type GetDatabaseConnectionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DatabaseConnection +} + +type GetDatabaseConnectionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetDatabaseConnectionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetDatabaseConnections ... +func (c StaticSitesClient) GetDatabaseConnections(ctx context.Context, id StaticSiteId) (result GetDatabaseConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetDatabaseConnectionsCustomPager{}, + Path: fmt.Sprintf("%s/databaseConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DatabaseConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetDatabaseConnectionsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetDatabaseConnectionsComplete(ctx context.Context, id StaticSiteId) (GetDatabaseConnectionsCompleteResult, error) { + return c.GetDatabaseConnectionsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) +} + +// GetDatabaseConnectionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetDatabaseConnectionsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate DatabaseConnectionOperationPredicate) (result GetDatabaseConnectionsCompleteResult, err error) { + items := make([]DatabaseConnection, 0) + + resp, err := c.GetDatabaseConnections(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetDatabaseConnectionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getdatabaseconnectionswithdetails.go b/resource-manager/web/2024-11-01/staticsites/method_getdatabaseconnectionswithdetails.go new file mode 100644 index 00000000000..4b57d3116ee --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getdatabaseconnectionswithdetails.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetDatabaseConnectionsWithDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DatabaseConnection +} + +type GetDatabaseConnectionsWithDetailsCompleteResult struct { + LatestHttpResponse *http.Response + Items []DatabaseConnection +} + +type GetDatabaseConnectionsWithDetailsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetDatabaseConnectionsWithDetailsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetDatabaseConnectionsWithDetails ... +func (c StaticSitesClient) GetDatabaseConnectionsWithDetails(ctx context.Context, id StaticSiteId) (result GetDatabaseConnectionsWithDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &GetDatabaseConnectionsWithDetailsCustomPager{}, + Path: fmt.Sprintf("%s/showDatabaseConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DatabaseConnection `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetDatabaseConnectionsWithDetailsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetDatabaseConnectionsWithDetailsComplete(ctx context.Context, id StaticSiteId) (GetDatabaseConnectionsWithDetailsCompleteResult, error) { + return c.GetDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx, id, DatabaseConnectionOperationPredicate{}) +} + +// GetDatabaseConnectionsWithDetailsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetDatabaseConnectionsWithDetailsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate DatabaseConnectionOperationPredicate) (result GetDatabaseConnectionsWithDetailsCompleteResult, err error) { + items := make([]DatabaseConnection, 0) + + resp, err := c.GetDatabaseConnectionsWithDetails(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetDatabaseConnectionsWithDetailsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getdatabaseconnectionwithdetails.go b/resource-manager/web/2024-11-01/staticsites/method_getdatabaseconnectionwithdetails.go new file mode 100644 index 00000000000..349897ee72d --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getdatabaseconnectionwithdetails.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetDatabaseConnectionWithDetailsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// GetDatabaseConnectionWithDetails ... +func (c StaticSitesClient) GetDatabaseConnectionWithDetails(ctx context.Context, id DatabaseConnectionId) (result GetDatabaseConnectionWithDetailsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/show", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DatabaseConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getlinkedbackend.go b/resource-manager/web/2024-11-01/staticsites/method_getlinkedbackend.go new file mode 100644 index 00000000000..553c375e975 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getlinkedbackend.go @@ -0,0 +1,53 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetLinkedBackendOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteLinkedBackendARMResource +} + +// GetLinkedBackend ... +func (c StaticSitesClient) GetLinkedBackend(ctx context.Context, id LinkedBackendId) (result GetLinkedBackendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteLinkedBackendARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getlinkedbackendforbuild.go b/resource-manager/web/2024-11-01/staticsites/method_getlinkedbackendforbuild.go new file mode 100644 index 00000000000..5761fa2c83b --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getlinkedbackendforbuild.go @@ -0,0 +1,53 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetLinkedBackendForBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteLinkedBackendARMResource +} + +// GetLinkedBackendForBuild ... +func (c StaticSitesClient) GetLinkedBackendForBuild(ctx context.Context, id BuildLinkedBackendId) (result GetLinkedBackendForBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteLinkedBackendARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getlinkedbackends.go b/resource-manager/web/2024-11-01/staticsites/method_getlinkedbackends.go new file mode 100644 index 00000000000..8b45e6df96b --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getlinkedbackends.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetLinkedBackendsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteLinkedBackendARMResource +} + +type GetLinkedBackendsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteLinkedBackendARMResource +} + +type GetLinkedBackendsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetLinkedBackendsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetLinkedBackends ... +func (c StaticSitesClient) GetLinkedBackends(ctx context.Context, id StaticSiteId) (result GetLinkedBackendsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetLinkedBackendsCustomPager{}, + Path: fmt.Sprintf("%s/linkedBackends", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteLinkedBackendARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetLinkedBackendsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetLinkedBackendsComplete(ctx context.Context, id StaticSiteId) (GetLinkedBackendsCompleteResult, error) { + return c.GetLinkedBackendsCompleteMatchingPredicate(ctx, id, StaticSiteLinkedBackendARMResourceOperationPredicate{}) +} + +// GetLinkedBackendsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetLinkedBackendsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteLinkedBackendARMResourceOperationPredicate) (result GetLinkedBackendsCompleteResult, err error) { + items := make([]StaticSiteLinkedBackendARMResource, 0) + + resp, err := c.GetLinkedBackends(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetLinkedBackendsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getlinkedbackendsforbuild.go b/resource-manager/web/2024-11-01/staticsites/method_getlinkedbackendsforbuild.go new file mode 100644 index 00000000000..78d17e5d639 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getlinkedbackendsforbuild.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetLinkedBackendsForBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteLinkedBackendARMResource +} + +type GetLinkedBackendsForBuildCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteLinkedBackendARMResource +} + +type GetLinkedBackendsForBuildCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetLinkedBackendsForBuildCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetLinkedBackendsForBuild ... +func (c StaticSitesClient) GetLinkedBackendsForBuild(ctx context.Context, id BuildId) (result GetLinkedBackendsForBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetLinkedBackendsForBuildCustomPager{}, + Path: fmt.Sprintf("%s/linkedBackends", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteLinkedBackendARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetLinkedBackendsForBuildComplete retrieves all the results into a single object +func (c StaticSitesClient) GetLinkedBackendsForBuildComplete(ctx context.Context, id BuildId) (GetLinkedBackendsForBuildCompleteResult, error) { + return c.GetLinkedBackendsForBuildCompleteMatchingPredicate(ctx, id, StaticSiteLinkedBackendARMResourceOperationPredicate{}) +} + +// GetLinkedBackendsForBuildCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetLinkedBackendsForBuildCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate StaticSiteLinkedBackendARMResourceOperationPredicate) (result GetLinkedBackendsForBuildCompleteResult, err error) { + items := make([]StaticSiteLinkedBackendARMResource, 0) + + resp, err := c.GetLinkedBackendsForBuild(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetLinkedBackendsForBuildCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getprivateendpointconnection.go b/resource-manager/web/2024-11-01/staticsites/method_getprivateendpointconnection.go new file mode 100644 index 00000000000..0d198e2c428 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getprivateendpointconnection.go @@ -0,0 +1,53 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPrivateEndpointConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnection ... +func (c StaticSitesClient) GetPrivateEndpointConnection(ctx context.Context, id StaticSitePrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RemotePrivateEndpointConnectionARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getprivateendpointconnectionlist.go b/resource-manager/web/2024-11-01/staticsites/method_getprivateendpointconnectionlist.go new file mode 100644 index 00000000000..7de0a9af9fb --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getprivateendpointconnectionlist.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPrivateEndpointConnectionListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetPrivateEndpointConnectionListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetPrivateEndpointConnectionList ... +func (c StaticSitesClient) GetPrivateEndpointConnectionList(ctx context.Context, id StaticSiteId) (result GetPrivateEndpointConnectionListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetPrivateEndpointConnectionListCustomPager{}, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RemotePrivateEndpointConnectionARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetPrivateEndpointConnectionListComplete retrieves all the results into a single object +func (c StaticSitesClient) GetPrivateEndpointConnectionListComplete(ctx context.Context, id StaticSiteId) (GetPrivateEndpointConnectionListCompleteResult, error) { + return c.GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) +} + +// GetPrivateEndpointConnectionListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (result GetPrivateEndpointConnectionListCompleteResult, err error) { + items := make([]RemotePrivateEndpointConnectionARMResource, 0) + + resp, err := c.GetPrivateEndpointConnectionList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetPrivateEndpointConnectionListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getprivatelinkresources.go b/resource-manager/web/2024-11-01/staticsites/method_getprivatelinkresources.go new file mode 100644 index 00000000000..0234f35567a --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getprivatelinkresources.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesWrapper +} + +// GetPrivateLinkResources ... +func (c StaticSitesClient) GetPrivateLinkResources(ctx context.Context, id StaticSiteId) (result GetPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateLinkResourcesWrapper + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getstaticsite.go b/resource-manager/web/2024-11-01/staticsites/method_getstaticsite.go new file mode 100644 index 00000000000..f1a5134adf8 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getstaticsite.go @@ -0,0 +1,53 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteARMResource +} + +// GetStaticSite ... +func (c StaticSitesClient) GetStaticSite(ctx context.Context, id StaticSiteId) (result GetStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getstaticsitebuild.go b/resource-manager/web/2024-11-01/staticsites/method_getstaticsitebuild.go new file mode 100644 index 00000000000..980e9844cd4 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getstaticsitebuild.go @@ -0,0 +1,53 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetStaticSiteBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteBuildARMResource +} + +// GetStaticSiteBuild ... +func (c StaticSitesClient) GetStaticSiteBuild(ctx context.Context, id BuildId) (result GetStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteBuildARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getstaticsitebuilds.go b/resource-manager/web/2024-11-01/staticsites/method_getstaticsitebuilds.go new file mode 100644 index 00000000000..b3a188507cf --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getstaticsitebuilds.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetStaticSiteBuildsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteBuildARMResource +} + +type GetStaticSiteBuildsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteBuildARMResource +} + +type GetStaticSiteBuildsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetStaticSiteBuildsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetStaticSiteBuilds ... +func (c StaticSitesClient) GetStaticSiteBuilds(ctx context.Context, id StaticSiteId) (result GetStaticSiteBuildsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetStaticSiteBuildsCustomPager{}, + Path: fmt.Sprintf("%s/builds", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteBuildARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetStaticSiteBuildsComplete retrieves all the results into a single object +func (c StaticSitesClient) GetStaticSiteBuildsComplete(ctx context.Context, id StaticSiteId) (GetStaticSiteBuildsCompleteResult, error) { + return c.GetStaticSiteBuildsCompleteMatchingPredicate(ctx, id, StaticSiteBuildARMResourceOperationPredicate{}) +} + +// GetStaticSiteBuildsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetStaticSiteBuildsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteBuildARMResourceOperationPredicate) (result GetStaticSiteBuildsCompleteResult, err error) { + items := make([]StaticSiteBuildARMResource, 0) + + resp, err := c.GetStaticSiteBuilds(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetStaticSiteBuildsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getstaticsitecustomdomain.go b/resource-manager/web/2024-11-01/staticsites/method_getstaticsitecustomdomain.go new file mode 100644 index 00000000000..4f067b9c862 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getstaticsitecustomdomain.go @@ -0,0 +1,53 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetStaticSiteCustomDomainOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteCustomDomainOverviewARMResource +} + +// GetStaticSiteCustomDomain ... +func (c StaticSitesClient) GetStaticSiteCustomDomain(ctx context.Context, id CustomDomainId) (result GetStaticSiteCustomDomainOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteCustomDomainOverviewARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getstaticsitesbyresourcegroup.go b/resource-manager/web/2024-11-01/staticsites/method_getstaticsitesbyresourcegroup.go new file mode 100644 index 00000000000..6c479510d72 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getstaticsitesbyresourcegroup.go @@ -0,0 +1,106 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetStaticSitesByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteARMResource +} + +type GetStaticSitesByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteARMResource +} + +type GetStaticSitesByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetStaticSitesByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetStaticSitesByResourceGroup ... +func (c StaticSitesClient) GetStaticSitesByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result GetStaticSitesByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetStaticSitesByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/staticSites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetStaticSitesByResourceGroupComplete retrieves all the results into a single object +func (c StaticSitesClient) GetStaticSitesByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (GetStaticSitesByResourceGroupCompleteResult, error) { + return c.GetStaticSitesByResourceGroupCompleteMatchingPredicate(ctx, id, StaticSiteARMResourceOperationPredicate{}) +} + +// GetStaticSitesByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetStaticSitesByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate StaticSiteARMResourceOperationPredicate) (result GetStaticSitesByResourceGroupCompleteResult, err error) { + items := make([]StaticSiteARMResource, 0) + + resp, err := c.GetStaticSitesByResourceGroup(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetStaticSitesByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getuserprovidedfunctionappforstaticsite.go b/resource-manager/web/2024-11-01/staticsites/method_getuserprovidedfunctionappforstaticsite.go new file mode 100644 index 00000000000..0407b757d73 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getuserprovidedfunctionappforstaticsite.go @@ -0,0 +1,53 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetUserProvidedFunctionAppForStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserProvidedFunctionAppARMResource +} + +// GetUserProvidedFunctionAppForStaticSite ... +func (c StaticSitesClient) GetUserProvidedFunctionAppForStaticSite(ctx context.Context, id UserProvidedFunctionAppId) (result GetUserProvidedFunctionAppForStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteUserProvidedFunctionAppARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getuserprovidedfunctionappforstaticsitebuild.go b/resource-manager/web/2024-11-01/staticsites/method_getuserprovidedfunctionappforstaticsitebuild.go new file mode 100644 index 00000000000..6c737d6cde7 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getuserprovidedfunctionappforstaticsitebuild.go @@ -0,0 +1,53 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetUserProvidedFunctionAppForStaticSiteBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserProvidedFunctionAppARMResource +} + +// GetUserProvidedFunctionAppForStaticSiteBuild ... +func (c StaticSitesClient) GetUserProvidedFunctionAppForStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId) (result GetUserProvidedFunctionAppForStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteUserProvidedFunctionAppARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getuserprovidedfunctionappsforstaticsite.go b/resource-manager/web/2024-11-01/staticsites/method_getuserprovidedfunctionappsforstaticsite.go new file mode 100644 index 00000000000..800d5ab1d72 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getuserprovidedfunctionappsforstaticsite.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetUserProvidedFunctionAppsForStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteUserProvidedFunctionAppARMResource +} + +type GetUserProvidedFunctionAppsForStaticSiteCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteUserProvidedFunctionAppARMResource +} + +type GetUserProvidedFunctionAppsForStaticSiteCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetUserProvidedFunctionAppsForStaticSiteCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetUserProvidedFunctionAppsForStaticSite ... +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSite(ctx context.Context, id StaticSiteId) (result GetUserProvidedFunctionAppsForStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetUserProvidedFunctionAppsForStaticSiteCustomPager{}, + Path: fmt.Sprintf("%s/userProvidedFunctionApps", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteUserProvidedFunctionAppARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetUserProvidedFunctionAppsForStaticSiteComplete retrieves all the results into a single object +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteComplete(ctx context.Context, id StaticSiteId) (GetUserProvidedFunctionAppsForStaticSiteCompleteResult, error) { + return c.GetUserProvidedFunctionAppsForStaticSiteCompleteMatchingPredicate(ctx, id, StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate{}) +} + +// GetUserProvidedFunctionAppsForStaticSiteCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate) (result GetUserProvidedFunctionAppsForStaticSiteCompleteResult, err error) { + items := make([]StaticSiteUserProvidedFunctionAppARMResource, 0) + + resp, err := c.GetUserProvidedFunctionAppsForStaticSite(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetUserProvidedFunctionAppsForStaticSiteCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_getuserprovidedfunctionappsforstaticsitebuild.go b/resource-manager/web/2024-11-01/staticsites/method_getuserprovidedfunctionappsforstaticsitebuild.go new file mode 100644 index 00000000000..b86539d1801 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_getuserprovidedfunctionappsforstaticsitebuild.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetUserProvidedFunctionAppsForStaticSiteBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteUserProvidedFunctionAppARMResource +} + +type GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteUserProvidedFunctionAppARMResource +} + +type GetUserProvidedFunctionAppsForStaticSiteBuildCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetUserProvidedFunctionAppsForStaticSiteBuildCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetUserProvidedFunctionAppsForStaticSiteBuild ... +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteBuild(ctx context.Context, id BuildId) (result GetUserProvidedFunctionAppsForStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetUserProvidedFunctionAppsForStaticSiteBuildCustomPager{}, + Path: fmt.Sprintf("%s/userProvidedFunctionApps", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteUserProvidedFunctionAppARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetUserProvidedFunctionAppsForStaticSiteBuildComplete retrieves all the results into a single object +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteBuildComplete(ctx context.Context, id BuildId) (GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult, error) { + return c.GetUserProvidedFunctionAppsForStaticSiteBuildCompleteMatchingPredicate(ctx, id, StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate{}) +} + +// GetUserProvidedFunctionAppsForStaticSiteBuildCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) GetUserProvidedFunctionAppsForStaticSiteBuildCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate) (result GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult, err error) { + items := make([]StaticSiteUserProvidedFunctionAppARMResource, 0) + + resp, err := c.GetUserProvidedFunctionAppsForStaticSiteBuild(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetUserProvidedFunctionAppsForStaticSiteBuildCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_linkbackend.go b/resource-manager/web/2024-11-01/staticsites/method_linkbackend.go new file mode 100644 index 00000000000..a36f96d86fa --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_linkbackend.go @@ -0,0 +1,74 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinkBackendOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteLinkedBackendARMResource +} + +// LinkBackend ... +func (c StaticSitesClient) LinkBackend(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) (result LinkBackendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// LinkBackendThenPoll performs LinkBackend then polls until it's completed +func (c StaticSitesClient) LinkBackendThenPoll(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) error { + result, err := c.LinkBackend(ctx, id, input) + if err != nil { + return fmt.Errorf("performing LinkBackend: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after LinkBackend: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_linkbackendtobuild.go b/resource-manager/web/2024-11-01/staticsites/method_linkbackendtobuild.go new file mode 100644 index 00000000000..5e187571493 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_linkbackendtobuild.go @@ -0,0 +1,74 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinkBackendToBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteLinkedBackendARMResource +} + +// LinkBackendToBuild ... +func (c StaticSitesClient) LinkBackendToBuild(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) (result LinkBackendToBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// LinkBackendToBuildThenPoll performs LinkBackendToBuild then polls until it's completed +func (c StaticSitesClient) LinkBackendToBuildThenPoll(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) error { + result, err := c.LinkBackendToBuild(ctx, id, input) + if err != nil { + return fmt.Errorf("performing LinkBackendToBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after LinkBackendToBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_list.go b/resource-manager/web/2024-11-01/staticsites/method_list.go new file mode 100644 index 00000000000..e071040c10d --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_list.go @@ -0,0 +1,106 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteARMResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteARMResource +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c StaticSitesClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/staticSites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c StaticSitesClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, StaticSiteARMResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate StaticSiteARMResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]StaticSiteARMResource, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_listbasicauth.go b/resource-manager/web/2024-11-01/staticsites/method_listbasicauth.go new file mode 100644 index 00000000000..3c466f4f588 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_listbasicauth.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBasicAuthOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteBasicAuthPropertiesARMResource +} + +type ListBasicAuthCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteBasicAuthPropertiesARMResource +} + +type ListBasicAuthCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBasicAuthCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBasicAuth ... +func (c StaticSitesClient) ListBasicAuth(ctx context.Context, id StaticSiteId) (result ListBasicAuthOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBasicAuthCustomPager{}, + Path: fmt.Sprintf("%s/basicAuth", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteBasicAuthPropertiesARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBasicAuthComplete retrieves all the results into a single object +func (c StaticSitesClient) ListBasicAuthComplete(ctx context.Context, id StaticSiteId) (ListBasicAuthCompleteResult, error) { + return c.ListBasicAuthCompleteMatchingPredicate(ctx, id, StaticSiteBasicAuthPropertiesARMResourceOperationPredicate{}) +} + +// ListBasicAuthCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListBasicAuthCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteBasicAuthPropertiesARMResourceOperationPredicate) (result ListBasicAuthCompleteResult, err error) { + items := make([]StaticSiteBasicAuthPropertiesARMResource, 0) + + resp, err := c.ListBasicAuth(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBasicAuthCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_liststaticsiteappsettings.go b/resource-manager/web/2024-11-01/staticsites/method_liststaticsiteappsettings.go new file mode 100644 index 00000000000..af3f94e29fc --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_liststaticsiteappsettings.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListStaticSiteAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteAppSettings ... +func (c StaticSitesClient) ListStaticSiteAppSettings(ctx context.Context, id StaticSiteId) (result ListStaticSiteAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listAppSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_liststaticsitebuildappsettings.go b/resource-manager/web/2024-11-01/staticsites/method_liststaticsitebuildappsettings.go new file mode 100644 index 00000000000..b23b85384c4 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_liststaticsitebuildappsettings.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListStaticSiteBuildAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteBuildAppSettings ... +func (c StaticSitesClient) ListStaticSiteBuildAppSettings(ctx context.Context, id BuildId) (result ListStaticSiteBuildAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listAppSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_liststaticsitebuildfunctionappsettings.go b/resource-manager/web/2024-11-01/staticsites/method_liststaticsitebuildfunctionappsettings.go new file mode 100644 index 00000000000..220b09e2518 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_liststaticsitebuildfunctionappsettings.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListStaticSiteBuildFunctionAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteBuildFunctionAppSettings ... +func (c StaticSitesClient) ListStaticSiteBuildFunctionAppSettings(ctx context.Context, id BuildId) (result ListStaticSiteBuildFunctionAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listFunctionAppSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_liststaticsitebuildfunctions.go b/resource-manager/web/2024-11-01/staticsites/method_liststaticsitebuildfunctions.go new file mode 100644 index 00000000000..3f2f7d75e25 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_liststaticsitebuildfunctions.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListStaticSiteBuildFunctionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteFunctionOverviewARMResource +} + +type ListStaticSiteBuildFunctionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteFunctionOverviewARMResource +} + +type ListStaticSiteBuildFunctionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListStaticSiteBuildFunctionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListStaticSiteBuildFunctions ... +func (c StaticSitesClient) ListStaticSiteBuildFunctions(ctx context.Context, id BuildId) (result ListStaticSiteBuildFunctionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListStaticSiteBuildFunctionsCustomPager{}, + Path: fmt.Sprintf("%s/functions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteFunctionOverviewARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListStaticSiteBuildFunctionsComplete retrieves all the results into a single object +func (c StaticSitesClient) ListStaticSiteBuildFunctionsComplete(ctx context.Context, id BuildId) (ListStaticSiteBuildFunctionsCompleteResult, error) { + return c.ListStaticSiteBuildFunctionsCompleteMatchingPredicate(ctx, id, StaticSiteFunctionOverviewARMResourceOperationPredicate{}) +} + +// ListStaticSiteBuildFunctionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListStaticSiteBuildFunctionsCompleteMatchingPredicate(ctx context.Context, id BuildId, predicate StaticSiteFunctionOverviewARMResourceOperationPredicate) (result ListStaticSiteBuildFunctionsCompleteResult, err error) { + items := make([]StaticSiteFunctionOverviewARMResource, 0) + + resp, err := c.ListStaticSiteBuildFunctions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListStaticSiteBuildFunctionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_liststaticsiteconfiguredroles.go b/resource-manager/web/2024-11-01/staticsites/method_liststaticsiteconfiguredroles.go new file mode 100644 index 00000000000..ad252bdfded --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_liststaticsiteconfiguredroles.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListStaticSiteConfiguredRolesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringList +} + +// ListStaticSiteConfiguredRoles ... +func (c StaticSitesClient) ListStaticSiteConfiguredRoles(ctx context.Context, id StaticSiteId) (result ListStaticSiteConfiguredRolesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listConfiguredRoles", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringList + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_liststaticsitecustomdomains.go b/resource-manager/web/2024-11-01/staticsites/method_liststaticsitecustomdomains.go new file mode 100644 index 00000000000..da0d6cea4e9 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_liststaticsitecustomdomains.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListStaticSiteCustomDomainsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteCustomDomainOverviewARMResource +} + +type ListStaticSiteCustomDomainsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteCustomDomainOverviewARMResource +} + +type ListStaticSiteCustomDomainsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListStaticSiteCustomDomainsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListStaticSiteCustomDomains ... +func (c StaticSitesClient) ListStaticSiteCustomDomains(ctx context.Context, id StaticSiteId) (result ListStaticSiteCustomDomainsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListStaticSiteCustomDomainsCustomPager{}, + Path: fmt.Sprintf("%s/customDomains", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteCustomDomainOverviewARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListStaticSiteCustomDomainsComplete retrieves all the results into a single object +func (c StaticSitesClient) ListStaticSiteCustomDomainsComplete(ctx context.Context, id StaticSiteId) (ListStaticSiteCustomDomainsCompleteResult, error) { + return c.ListStaticSiteCustomDomainsCompleteMatchingPredicate(ctx, id, StaticSiteCustomDomainOverviewARMResourceOperationPredicate{}) +} + +// ListStaticSiteCustomDomainsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListStaticSiteCustomDomainsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteCustomDomainOverviewARMResourceOperationPredicate) (result ListStaticSiteCustomDomainsCompleteResult, err error) { + items := make([]StaticSiteCustomDomainOverviewARMResource, 0) + + resp, err := c.ListStaticSiteCustomDomains(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListStaticSiteCustomDomainsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_liststaticsitefunctionappsettings.go b/resource-manager/web/2024-11-01/staticsites/method_liststaticsitefunctionappsettings.go new file mode 100644 index 00000000000..9c4a10a187f --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_liststaticsitefunctionappsettings.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListStaticSiteFunctionAppSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteFunctionAppSettings ... +func (c StaticSitesClient) ListStaticSiteFunctionAppSettings(ctx context.Context, id StaticSiteId) (result ListStaticSiteFunctionAppSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listFunctionAppSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_liststaticsitefunctions.go b/resource-manager/web/2024-11-01/staticsites/method_liststaticsitefunctions.go new file mode 100644 index 00000000000..625443d50b3 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_liststaticsitefunctions.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListStaticSiteFunctionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteFunctionOverviewARMResource +} + +type ListStaticSiteFunctionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteFunctionOverviewARMResource +} + +type ListStaticSiteFunctionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListStaticSiteFunctionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListStaticSiteFunctions ... +func (c StaticSitesClient) ListStaticSiteFunctions(ctx context.Context, id StaticSiteId) (result ListStaticSiteFunctionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListStaticSiteFunctionsCustomPager{}, + Path: fmt.Sprintf("%s/functions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteFunctionOverviewARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListStaticSiteFunctionsComplete retrieves all the results into a single object +func (c StaticSitesClient) ListStaticSiteFunctionsComplete(ctx context.Context, id StaticSiteId) (ListStaticSiteFunctionsCompleteResult, error) { + return c.ListStaticSiteFunctionsCompleteMatchingPredicate(ctx, id, StaticSiteFunctionOverviewARMResourceOperationPredicate{}) +} + +// ListStaticSiteFunctionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListStaticSiteFunctionsCompleteMatchingPredicate(ctx context.Context, id StaticSiteId, predicate StaticSiteFunctionOverviewARMResourceOperationPredicate) (result ListStaticSiteFunctionsCompleteResult, err error) { + items := make([]StaticSiteFunctionOverviewARMResource, 0) + + resp, err := c.ListStaticSiteFunctions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListStaticSiteFunctionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_liststaticsitesecrets.go b/resource-manager/web/2024-11-01/staticsites/method_liststaticsitesecrets.go new file mode 100644 index 00000000000..f9ed5192106 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_liststaticsitesecrets.go @@ -0,0 +1,54 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListStaticSiteSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListStaticSiteSecrets ... +func (c StaticSitesClient) ListStaticSiteSecrets(ctx context.Context, id StaticSiteId) (result ListStaticSiteSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_liststaticsiteusers.go b/resource-manager/web/2024-11-01/staticsites/method_liststaticsiteusers.go new file mode 100644 index 00000000000..d711c5393b9 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_liststaticsiteusers.go @@ -0,0 +1,105 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListStaticSiteUsersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]StaticSiteUserARMResource +} + +type ListStaticSiteUsersCompleteResult struct { + LatestHttpResponse *http.Response + Items []StaticSiteUserARMResource +} + +type ListStaticSiteUsersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListStaticSiteUsersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListStaticSiteUsers ... +func (c StaticSitesClient) ListStaticSiteUsers(ctx context.Context, id AuthProviderId) (result ListStaticSiteUsersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListStaticSiteUsersCustomPager{}, + Path: fmt.Sprintf("%s/listUsers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]StaticSiteUserARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListStaticSiteUsersComplete retrieves all the results into a single object +func (c StaticSitesClient) ListStaticSiteUsersComplete(ctx context.Context, id AuthProviderId) (ListStaticSiteUsersCompleteResult, error) { + return c.ListStaticSiteUsersCompleteMatchingPredicate(ctx, id, StaticSiteUserARMResourceOperationPredicate{}) +} + +// ListStaticSiteUsersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c StaticSitesClient) ListStaticSiteUsersCompleteMatchingPredicate(ctx context.Context, id AuthProviderId, predicate StaticSiteUserARMResourceOperationPredicate) (result ListStaticSiteUsersCompleteResult, err error) { + items := make([]StaticSiteUserARMResource, 0) + + resp, err := c.ListStaticSiteUsers(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListStaticSiteUsersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_previewworkflow.go b/resource-manager/web/2024-11-01/staticsites/method_previewworkflow.go new file mode 100644 index 00000000000..2a34e3a3c41 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_previewworkflow.go @@ -0,0 +1,58 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PreviewWorkflowOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSitesWorkflowPreview +} + +// PreviewWorkflow ... +func (c StaticSitesClient) PreviewWorkflow(ctx context.Context, id ProviderLocationId, input StaticSitesWorkflowPreviewRequest) (result PreviewWorkflowOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/previewStaticSiteWorkflowFile", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSitesWorkflowPreview + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_registeruserprovidedfunctionappwithstaticsite.go b/resource-manager/web/2024-11-01/staticsites/method_registeruserprovidedfunctionappwithstaticsite.go new file mode 100644 index 00000000000..c210993e945 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_registeruserprovidedfunctionappwithstaticsite.go @@ -0,0 +1,104 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegisterUserProvidedFunctionAppWithStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserProvidedFunctionAppARMResource +} + +type RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions struct { + IsForced *bool +} + +func DefaultRegisterUserProvidedFunctionAppWithStaticSiteOperationOptions() RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions { + return RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions{} +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IsForced != nil { + out.Append("isForced", fmt.Sprintf("%v", *o.IsForced)) + } + return &out +} + +// RegisterUserProvidedFunctionAppWithStaticSite ... +func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSite(ctx context.Context, id UserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) (result RegisterUserProvidedFunctionAppWithStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RegisterUserProvidedFunctionAppWithStaticSiteThenPoll performs RegisterUserProvidedFunctionAppWithStaticSite then polls until it's completed +func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSiteThenPoll(ctx context.Context, id UserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteOperationOptions) error { + result, err := c.RegisterUserProvidedFunctionAppWithStaticSite(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing RegisterUserProvidedFunctionAppWithStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegisterUserProvidedFunctionAppWithStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_registeruserprovidedfunctionappwithstaticsitebuild.go b/resource-manager/web/2024-11-01/staticsites/method_registeruserprovidedfunctionappwithstaticsitebuild.go new file mode 100644 index 00000000000..2d4f13d5c79 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_registeruserprovidedfunctionappwithstaticsitebuild.go @@ -0,0 +1,104 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserProvidedFunctionAppARMResource +} + +type RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions struct { + IsForced *bool +} + +func DefaultRegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions() RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions { + return RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions{} +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IsForced != nil { + out.Append("isForced", fmt.Sprintf("%v", *o.IsForced)) + } + return &out +} + +// RegisterUserProvidedFunctionAppWithStaticSiteBuild ... +func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSiteBuild(ctx context.Context, id BuildUserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) (result RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RegisterUserProvidedFunctionAppWithStaticSiteBuildThenPoll performs RegisterUserProvidedFunctionAppWithStaticSiteBuild then polls until it's completed +func (c StaticSitesClient) RegisterUserProvidedFunctionAppWithStaticSiteBuildThenPoll(ctx context.Context, id BuildUserProvidedFunctionAppId, input StaticSiteUserProvidedFunctionAppARMResource, options RegisterUserProvidedFunctionAppWithStaticSiteBuildOperationOptions) error { + result, err := c.RegisterUserProvidedFunctionAppWithStaticSiteBuild(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing RegisterUserProvidedFunctionAppWithStaticSiteBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegisterUserProvidedFunctionAppWithStaticSiteBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_resetstaticsiteapikey.go b/resource-manager/web/2024-11-01/staticsites/method_resetstaticsiteapikey.go new file mode 100644 index 00000000000..722e36f78c6 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_resetstaticsiteapikey.go @@ -0,0 +1,51 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResetStaticSiteApiKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetStaticSiteApiKey ... +func (c StaticSitesClient) ResetStaticSiteApiKey(ctx context.Context, id StaticSiteId, input StaticSiteResetPropertiesARMResource) (result ResetStaticSiteApiKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetapikey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_unlinkbackend.go b/resource-manager/web/2024-11-01/staticsites/method_unlinkbackend.go new file mode 100644 index 00000000000..27575e98684 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_unlinkbackend.go @@ -0,0 +1,77 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnlinkBackendOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UnlinkBackendOperationOptions struct { + IsCleaningAuthConfig *bool +} + +func DefaultUnlinkBackendOperationOptions() UnlinkBackendOperationOptions { + return UnlinkBackendOperationOptions{} +} + +func (o UnlinkBackendOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o UnlinkBackendOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UnlinkBackendOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IsCleaningAuthConfig != nil { + out.Append("isCleaningAuthConfig", fmt.Sprintf("%v", *o.IsCleaningAuthConfig)) + } + return &out +} + +// UnlinkBackend ... +func (c StaticSitesClient) UnlinkBackend(ctx context.Context, id LinkedBackendId, options UnlinkBackendOperationOptions) (result UnlinkBackendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_unlinkbackendfrombuild.go b/resource-manager/web/2024-11-01/staticsites/method_unlinkbackendfrombuild.go new file mode 100644 index 00000000000..f6055b15e30 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_unlinkbackendfrombuild.go @@ -0,0 +1,77 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UnlinkBackendFromBuildOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type UnlinkBackendFromBuildOperationOptions struct { + IsCleaningAuthConfig *bool +} + +func DefaultUnlinkBackendFromBuildOperationOptions() UnlinkBackendFromBuildOperationOptions { + return UnlinkBackendFromBuildOperationOptions{} +} + +func (o UnlinkBackendFromBuildOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o UnlinkBackendFromBuildOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o UnlinkBackendFromBuildOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IsCleaningAuthConfig != nil { + out.Append("isCleaningAuthConfig", fmt.Sprintf("%v", *o.IsCleaningAuthConfig)) + } + return &out +} + +// UnlinkBackendFromBuild ... +func (c StaticSitesClient) UnlinkBackendFromBuild(ctx context.Context, id BuildLinkedBackendId, options UnlinkBackendFromBuildOperationOptions) (result UnlinkBackendFromBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_updatebuilddatabaseconnection.go b/resource-manager/web/2024-11-01/staticsites/method_updatebuilddatabaseconnection.go new file mode 100644 index 00000000000..2c78c742cf3 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_updatebuilddatabaseconnection.go @@ -0,0 +1,57 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateBuildDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// UpdateBuildDatabaseConnection ... +func (c StaticSitesClient) UpdateBuildDatabaseConnection(ctx context.Context, id BuildDatabaseConnectionId, input DatabaseConnectionPatchRequest) (result UpdateBuildDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DatabaseConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_updatedatabaseconnection.go b/resource-manager/web/2024-11-01/staticsites/method_updatedatabaseconnection.go new file mode 100644 index 00000000000..c2bab9a13a3 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_updatedatabaseconnection.go @@ -0,0 +1,57 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateDatabaseConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DatabaseConnection +} + +// UpdateDatabaseConnection ... +func (c StaticSitesClient) UpdateDatabaseConnection(ctx context.Context, id DatabaseConnectionId, input DatabaseConnectionPatchRequest) (result UpdateDatabaseConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DatabaseConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_updatestaticsite.go b/resource-manager/web/2024-11-01/staticsites/method_updatestaticsite.go new file mode 100644 index 00000000000..c1706e09ddb --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_updatestaticsite.go @@ -0,0 +1,58 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateStaticSiteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteARMResource +} + +// UpdateStaticSite ... +func (c StaticSitesClient) UpdateStaticSite(ctx context.Context, id StaticSiteId, input StaticSitePatchResource) (result UpdateStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_updatestaticsiteuser.go b/resource-manager/web/2024-11-01/staticsites/method_updatestaticsiteuser.go new file mode 100644 index 00000000000..7741cafbf21 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_updatestaticsiteuser.go @@ -0,0 +1,57 @@ +package staticsites + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateStaticSiteUserOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StaticSiteUserARMResource +} + +// UpdateStaticSiteUser ... +func (c StaticSitesClient) UpdateStaticSiteUser(ctx context.Context, id UserId, input StaticSiteUserARMResource) (result UpdateStaticSiteUserOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StaticSiteUserARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_validatebackend.go b/resource-manager/web/2024-11-01/staticsites/method_validatebackend.go new file mode 100644 index 00000000000..12aa25c2202 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_validatebackend.go @@ -0,0 +1,74 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateBackendOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ValidateBackend ... +func (c StaticSitesClient) ValidateBackend(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) (result ValidateBackendOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ValidateBackendThenPoll performs ValidateBackend then polls until it's completed +func (c StaticSitesClient) ValidateBackendThenPoll(ctx context.Context, id LinkedBackendId, input StaticSiteLinkedBackendARMResource) error { + result, err := c.ValidateBackend(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ValidateBackend: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ValidateBackend: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_validatebackendforbuild.go b/resource-manager/web/2024-11-01/staticsites/method_validatebackendforbuild.go new file mode 100644 index 00000000000..d703ff84c0b --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_validatebackendforbuild.go @@ -0,0 +1,74 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateBackendForBuildOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ValidateBackendForBuild ... +func (c StaticSitesClient) ValidateBackendForBuild(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) (result ValidateBackendForBuildOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ValidateBackendForBuildThenPoll performs ValidateBackendForBuild then polls until it's completed +func (c StaticSitesClient) ValidateBackendForBuildThenPoll(ctx context.Context, id BuildLinkedBackendId, input StaticSiteLinkedBackendARMResource) error { + result, err := c.ValidateBackendForBuild(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ValidateBackendForBuild: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ValidateBackendForBuild: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/method_validatecustomdomaincanbeaddedtostaticsite.go b/resource-manager/web/2024-11-01/staticsites/method_validatecustomdomaincanbeaddedtostaticsite.go new file mode 100644 index 00000000000..deda3155c42 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/method_validatecustomdomaincanbeaddedtostaticsite.go @@ -0,0 +1,74 @@ +package staticsites + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateCustomDomainCanBeAddedToStaticSiteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ValidateCustomDomainCanBeAddedToStaticSite ... +func (c StaticSitesClient) ValidateCustomDomainCanBeAddedToStaticSite(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) (result ValidateCustomDomainCanBeAddedToStaticSiteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ValidateCustomDomainCanBeAddedToStaticSiteThenPoll performs ValidateCustomDomainCanBeAddedToStaticSite then polls until it's completed +func (c StaticSitesClient) ValidateCustomDomainCanBeAddedToStaticSiteThenPoll(ctx context.Context, id CustomDomainId, input StaticSiteCustomDomainRequestPropertiesARMResource) error { + result, err := c.ValidateCustomDomainCanBeAddedToStaticSite(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ValidateCustomDomainCanBeAddedToStaticSite: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ValidateCustomDomainCanBeAddedToStaticSite: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_armidwrapper.go b/resource-manager/web/2024-11-01/staticsites/model_armidwrapper.go new file mode 100644 index 00000000000..c9987651a5f --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_armidwrapper.go @@ -0,0 +1,8 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArmIdWrapper struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_armplan.go b/resource-manager/web/2024-11-01/staticsites/model_armplan.go new file mode 100644 index 00000000000..2cb5352de6e --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_armplan.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArmPlan struct { + Name *string `json:"name,omitempty"` + Product *string `json:"product,omitempty"` + PromotionCode *string `json:"promotionCode,omitempty"` + Publisher *string `json:"publisher,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_capability.go b/resource-manager/web/2024-11-01/staticsites/model_capability.go new file mode 100644 index 00000000000..300bf980489 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_capability.go @@ -0,0 +1,10 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Capability struct { + Name *string `json:"name,omitempty"` + Reason *string `json:"reason,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_databaseconnection.go b/resource-manager/web/2024-11-01/staticsites/model_databaseconnection.go new file mode 100644 index 00000000000..cd069f365d4 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_databaseconnection.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnection struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DatabaseConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_databaseconnectionoverview.go b/resource-manager/web/2024-11-01/staticsites/model_databaseconnectionoverview.go new file mode 100644 index 00000000000..8597c4ff8b4 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_databaseconnectionoverview.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnectionOverview struct { + ConfigurationFiles *[]StaticSiteDatabaseConnectionConfigurationFileOverview `json:"configurationFiles,omitempty"` + ConnectionIdentity *string `json:"connectionIdentity,omitempty"` + Name *string `json:"name,omitempty"` + Region *string `json:"region,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_databaseconnectionpatchrequest.go b/resource-manager/web/2024-11-01/staticsites/model_databaseconnectionpatchrequest.go new file mode 100644 index 00000000000..493e3509268 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_databaseconnectionpatchrequest.go @@ -0,0 +1,8 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnectionPatchRequest struct { + Properties *DatabaseConnectionPatchRequestProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_databaseconnectionpatchrequestproperties.go b/resource-manager/web/2024-11-01/staticsites/model_databaseconnectionpatchrequestproperties.go new file mode 100644 index 00000000000..2b5eb824c26 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_databaseconnectionpatchrequestproperties.go @@ -0,0 +1,11 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnectionPatchRequestProperties struct { + ConnectionIdentity *string `json:"connectionIdentity,omitempty"` + ConnectionString *string `json:"connectionString,omitempty"` + Region *string `json:"region,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_databaseconnectionproperties.go b/resource-manager/web/2024-11-01/staticsites/model_databaseconnectionproperties.go new file mode 100644 index 00000000000..81aee01e533 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_databaseconnectionproperties.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnectionProperties struct { + ConfigurationFiles *[]StaticSiteDatabaseConnectionConfigurationFileOverview `json:"configurationFiles,omitempty"` + ConnectionIdentity *string `json:"connectionIdentity,omitempty"` + ConnectionString *string `json:"connectionString,omitempty"` + Region string `json:"region"` + ResourceId string `json:"resourceId"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_errorentity.go b/resource-manager/web/2024-11-01/staticsites/model_errorentity.go new file mode 100644 index 00000000000..6b726cb5492 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_errorentity.go @@ -0,0 +1,15 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorEntity struct { + Code *string `json:"code,omitempty"` + Details *[]ErrorEntity `json:"details,omitempty"` + ExtendedCode *string `json:"extendedCode,omitempty"` + InnerErrors *[]ErrorEntity `json:"innerErrors,omitempty"` + Message *string `json:"message,omitempty"` + MessageTemplate *string `json:"messageTemplate,omitempty"` + Parameters *[]string `json:"parameters,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_privatelinkconnectionstate.go b/resource-manager/web/2024-11-01/staticsites/model_privatelinkconnectionstate.go new file mode 100644 index 00000000000..bdfe81e8a98 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_privatelinkconnectionstate.go @@ -0,0 +1,10 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_privatelinkresource.go b/resource-manager/web/2024-11-01/staticsites/model_privatelinkresource.go new file mode 100644 index 00000000000..975df70d5c7 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_privatelinkresource.go @@ -0,0 +1,11 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id string `json:"id"` + Name string `json:"name"` + Properties PrivateLinkResourceProperties `json:"properties"` + Type string `json:"type"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_privatelinkresourceproperties.go b/resource-manager/web/2024-11-01/staticsites/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..8dacfc8b182 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_privatelinkresourceswrapper.go b/resource-manager/web/2024-11-01/staticsites/model_privatelinkresourceswrapper.go new file mode 100644 index 00000000000..2890dfe9e4a --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_privatelinkresourceswrapper.go @@ -0,0 +1,8 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesWrapper struct { + Value []PrivateLinkResource `json:"value"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_remoteprivateendpointconnection.go b/resource-manager/web/2024-11-01/staticsites/model_remoteprivateendpointconnection.go new file mode 100644 index 00000000000..2456e6e1d5b --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_remoteprivateendpointconnection.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RemotePrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_remoteprivateendpointconnectionarmresource.go b/resource-manager/web/2024-11-01/staticsites/model_remoteprivateendpointconnectionarmresource.go new file mode 100644 index 00000000000..708bf563a7f --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_remoteprivateendpointconnectionarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RemotePrivateEndpointConnectionARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_remoteprivateendpointconnectionarmresourceproperties.go b/resource-manager/web/2024-11-01/staticsites/model_remoteprivateendpointconnectionarmresourceproperties.go new file mode 100644 index 00000000000..75f3ef6233d --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_remoteprivateendpointconnectionarmresourceproperties.go @@ -0,0 +1,11 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResourceProperties struct { + IPAddresses *[]string `json:"ipAddresses,omitempty"` + PrivateEndpoint *ArmIdWrapper `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_remoteprivateendpointconnectionproperties.go b/resource-manager/web/2024-11-01/staticsites/model_remoteprivateendpointconnectionproperties.go new file mode 100644 index 00000000000..23d098fcaa6 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_remoteprivateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionProperties struct { + IPAddresses *[]string `json:"ipAddresses,omitempty"` + PrivateEndpoint *ArmIdWrapper `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_responsemessageenveloperemoteprivateendpointconnection.go b/resource-manager/web/2024-11-01/staticsites/model_responsemessageenveloperemoteprivateendpointconnection.go new file mode 100644 index 00000000000..54a231b3460 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_responsemessageenveloperemoteprivateendpointconnection.go @@ -0,0 +1,24 @@ +package staticsites + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResponseMessageEnvelopeRemotePrivateEndpointConnection struct { + Error *ErrorEntity `json:"error,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Plan *ArmPlan `json:"plan,omitempty"` + Properties *RemotePrivateEndpointConnection `json:"properties,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` + Status *string `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + Zones *zones.Schema `json:"zones,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_skucapacity.go b/resource-manager/web/2024-11-01/staticsites/model_skucapacity.go new file mode 100644 index 00000000000..d8cd9de7ec4 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_skucapacity.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuCapacity struct { + Default *int64 `json:"default,omitempty"` + ElasticMaximum *int64 `json:"elasticMaximum,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` + Minimum *int64 `json:"minimum,omitempty"` + ScaleType *string `json:"scaleType,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_skudescription.go b/resource-manager/web/2024-11-01/staticsites/model_skudescription.go new file mode 100644 index 00000000000..2e1e0cde311 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_skudescription.go @@ -0,0 +1,15 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuDescription struct { + Capabilities *[]Capability `json:"capabilities,omitempty"` + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Locations *[]string `json:"locations,omitempty"` + Name *string `json:"name,omitempty"` + Size *string `json:"size,omitempty"` + SkuCapacity *SkuCapacity `json:"skuCapacity,omitempty"` + Tier *string `json:"tier,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsite.go b/resource-manager/web/2024-11-01/staticsites/model_staticsite.go new file mode 100644 index 00000000000..04ffe0c1027 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsite.go @@ -0,0 +1,25 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSite struct { + AllowConfigFileUpdates *bool `json:"allowConfigFileUpdates,omitempty"` + Branch *string `json:"branch,omitempty"` + BuildProperties *StaticSiteBuildProperties `json:"buildProperties,omitempty"` + ContentDistributionEndpoint *string `json:"contentDistributionEndpoint,omitempty"` + CustomDomains *[]string `json:"customDomains,omitempty"` + DatabaseConnections *[]DatabaseConnectionOverview `json:"databaseConnections,omitempty"` + DefaultHostname *string `json:"defaultHostname,omitempty"` + EnterpriseGradeCdnStatus *EnterpriseGradeCdnStatus `json:"enterpriseGradeCdnStatus,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + LinkedBackends *[]StaticSiteLinkedBackend `json:"linkedBackends,omitempty"` + PrivateEndpointConnections *[]ResponseMessageEnvelopeRemotePrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + Provider *string `json:"provider,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + RepositoryToken *string `json:"repositoryToken,omitempty"` + RepositoryURL *string `json:"repositoryUrl,omitempty"` + StagingEnvironmentPolicy *StagingEnvironmentPolicy `json:"stagingEnvironmentPolicy,omitempty"` + TemplateProperties *StaticSiteTemplateOptions `json:"templateProperties,omitempty"` + UserProvidedFunctionApps *[]StaticSiteUserProvidedFunctionApp `json:"userProvidedFunctionApps,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitearmresource.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitearmresource.go new file mode 100644 index 00000000000..a54aa2362bb --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitearmresource.go @@ -0,0 +1,20 @@ +package staticsites + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteARMResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *StaticSite `json:"properties,omitempty"` + Sku *SkuDescription `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitebasicauthpropertiesarmresource.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitebasicauthpropertiesarmresource.go new file mode 100644 index 00000000000..bf58faf53d3 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitebasicauthpropertiesarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteBasicAuthPropertiesARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteBasicAuthPropertiesARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitebasicauthpropertiesarmresourceproperties.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitebasicauthpropertiesarmresourceproperties.go new file mode 100644 index 00000000000..e413aa4a9c5 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitebasicauthpropertiesarmresourceproperties.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteBasicAuthPropertiesARMResourceProperties struct { + ApplicableEnvironmentsMode string `json:"applicableEnvironmentsMode"` + Environments *[]string `json:"environments,omitempty"` + Password *string `json:"password,omitempty"` + SecretState *string `json:"secretState,omitempty"` + SecretURL *string `json:"secretUrl,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitebuildarmresource.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitebuildarmresource.go new file mode 100644 index 00000000000..332e5334386 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitebuildarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteBuildARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteBuildARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitebuildarmresourceproperties.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitebuildarmresourceproperties.go new file mode 100644 index 00000000000..50bbe9e5443 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitebuildarmresourceproperties.go @@ -0,0 +1,47 @@ +package staticsites + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteBuildARMResourceProperties struct { + BuildId *string `json:"buildId,omitempty"` + CreatedTimeUtc *string `json:"createdTimeUtc,omitempty"` + DatabaseConnections *[]DatabaseConnectionOverview `json:"databaseConnections,omitempty"` + Hostname *string `json:"hostname,omitempty"` + LastUpdatedOn *string `json:"lastUpdatedOn,omitempty"` + LinkedBackends *[]StaticSiteLinkedBackend `json:"linkedBackends,omitempty"` + PullRequestTitle *string `json:"pullRequestTitle,omitempty"` + SourceBranch *string `json:"sourceBranch,omitempty"` + Status *BuildStatus `json:"status,omitempty"` + UserProvidedFunctionApps *[]StaticSiteUserProvidedFunctionApp `json:"userProvidedFunctionApps,omitempty"` +} + +func (o *StaticSiteBuildARMResourceProperties) GetCreatedTimeUtcAsTime() (*time.Time, error) { + if o.CreatedTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteBuildARMResourceProperties) SetCreatedTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTimeUtc = &formatted +} + +func (o *StaticSiteBuildARMResourceProperties) GetLastUpdatedOnAsTime() (*time.Time, error) { + if o.LastUpdatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastUpdatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteBuildARMResourceProperties) SetLastUpdatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastUpdatedOn = &formatted +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitebuildproperties.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitebuildproperties.go new file mode 100644 index 00000000000..9dbe72ed06c --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitebuildproperties.go @@ -0,0 +1,15 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteBuildProperties struct { + ApiBuildCommand *string `json:"apiBuildCommand,omitempty"` + ApiLocation *string `json:"apiLocation,omitempty"` + AppArtifactLocation *string `json:"appArtifactLocation,omitempty"` + AppBuildCommand *string `json:"appBuildCommand,omitempty"` + AppLocation *string `json:"appLocation,omitempty"` + GitHubActionSecretNameOverride *string `json:"githubActionSecretNameOverride,omitempty"` + OutputLocation *string `json:"outputLocation,omitempty"` + SkipGithubActionWorkflowGeneration *bool `json:"skipGithubActionWorkflowGeneration,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitecustomdomainoverviewarmresource.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitecustomdomainoverviewarmresource.go new file mode 100644 index 00000000000..95f00a98762 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitecustomdomainoverviewarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteCustomDomainOverviewARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteCustomDomainOverviewARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitecustomdomainoverviewarmresourceproperties.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitecustomdomainoverviewarmresourceproperties.go new file mode 100644 index 00000000000..cc0b5c99274 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitecustomdomainoverviewarmresourceproperties.go @@ -0,0 +1,30 @@ +package staticsites + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteCustomDomainOverviewARMResourceProperties struct { + CreatedOn *string `json:"createdOn,omitempty"` + DomainName *string `json:"domainName,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + Status *CustomDomainStatus `json:"status,omitempty"` + ValidationToken *string `json:"validationToken,omitempty"` +} + +func (o *StaticSiteCustomDomainOverviewARMResourceProperties) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteCustomDomainOverviewARMResourceProperties) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresource.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresource.go new file mode 100644 index 00000000000..b790fc90f5d --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteCustomDomainRequestPropertiesARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteCustomDomainRequestPropertiesARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresourceproperties.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresourceproperties.go new file mode 100644 index 00000000000..e4510ee8855 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitecustomdomainrequestpropertiesarmresourceproperties.go @@ -0,0 +1,8 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteCustomDomainRequestPropertiesARMResourceProperties struct { + ValidationMethod *string `json:"validationMethod,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitedatabaseconnectionconfigurationfileoverview.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitedatabaseconnectionconfigurationfileoverview.go new file mode 100644 index 00000000000..0389a6f704c --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitedatabaseconnectionconfigurationfileoverview.go @@ -0,0 +1,10 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteDatabaseConnectionConfigurationFileOverview struct { + Contents *string `json:"contents,omitempty"` + FileName *string `json:"fileName,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitefunctionoverviewarmresource.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitefunctionoverviewarmresource.go new file mode 100644 index 00000000000..fa8ca3288d9 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitefunctionoverviewarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteFunctionOverviewARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteFunctionOverviewARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitefunctionoverviewarmresourceproperties.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitefunctionoverviewarmresourceproperties.go new file mode 100644 index 00000000000..46eeb330774 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitefunctionoverviewarmresourceproperties.go @@ -0,0 +1,9 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteFunctionOverviewARMResourceProperties struct { + FunctionName *string `json:"functionName,omitempty"` + TriggerType *TriggerTypes `json:"triggerType,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitelinkedbackend.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitelinkedbackend.go new file mode 100644 index 00000000000..52b103d13bc --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitelinkedbackend.go @@ -0,0 +1,29 @@ +package staticsites + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteLinkedBackend struct { + BackendResourceId *string `json:"backendResourceId,omitempty"` + CreatedOn *string `json:"createdOn,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + Region *string `json:"region,omitempty"` +} + +func (o *StaticSiteLinkedBackend) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteLinkedBackend) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitelinkedbackendarmresource.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitelinkedbackendarmresource.go new file mode 100644 index 00000000000..97ddc7ab2ac --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitelinkedbackendarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteLinkedBackendARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteLinkedBackendARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitelinkedbackendarmresourceproperties.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitelinkedbackendarmresourceproperties.go new file mode 100644 index 00000000000..5ec2c55c393 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitelinkedbackendarmresourceproperties.go @@ -0,0 +1,29 @@ +package staticsites + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteLinkedBackendARMResourceProperties struct { + BackendResourceId *string `json:"backendResourceId,omitempty"` + CreatedOn *string `json:"createdOn,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + Region *string `json:"region,omitempty"` +} + +func (o *StaticSiteLinkedBackendARMResourceProperties) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteLinkedBackendARMResourceProperties) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitepatchresource.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitepatchresource.go new file mode 100644 index 00000000000..6969a6ebae4 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitepatchresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSitePatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSite `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsiteresetpropertiesarmresource.go b/resource-manager/web/2024-11-01/staticsites/model_staticsiteresetpropertiesarmresource.go new file mode 100644 index 00000000000..53a0c64632a --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsiteresetpropertiesarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteResetPropertiesARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteResetPropertiesARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsiteresetpropertiesarmresourceproperties.go b/resource-manager/web/2024-11-01/staticsites/model_staticsiteresetpropertiesarmresourceproperties.go new file mode 100644 index 00000000000..87a927d3952 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsiteresetpropertiesarmresourceproperties.go @@ -0,0 +1,9 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteResetPropertiesARMResourceProperties struct { + RepositoryToken *string `json:"repositoryToken,omitempty"` + ShouldUpdateRepository *bool `json:"shouldUpdateRepository,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitesworkflowpreview.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitesworkflowpreview.go new file mode 100644 index 00000000000..01cca8f1d47 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitesworkflowpreview.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSitesWorkflowPreview struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSitesWorkflowPreviewProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitesworkflowpreviewproperties.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitesworkflowpreviewproperties.go new file mode 100644 index 00000000000..4e0aa482c92 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitesworkflowpreviewproperties.go @@ -0,0 +1,9 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSitesWorkflowPreviewProperties struct { + Contents *string `json:"contents,omitempty"` + Path *string `json:"path,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitesworkflowpreviewrequest.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitesworkflowpreviewrequest.go new file mode 100644 index 00000000000..c255ba00697 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitesworkflowpreviewrequest.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSitesWorkflowPreviewRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSitesWorkflowPreviewRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitesworkflowpreviewrequestproperties.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitesworkflowpreviewrequestproperties.go new file mode 100644 index 00000000000..c3d04f76a6d --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitesworkflowpreviewrequestproperties.go @@ -0,0 +1,10 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSitesWorkflowPreviewRequestProperties struct { + Branch *string `json:"branch,omitempty"` + BuildProperties *StaticSiteBuildProperties `json:"buildProperties,omitempty"` + RepositoryURL *string `json:"repositoryUrl,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitetemplateoptions.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitetemplateoptions.go new file mode 100644 index 00000000000..1f957ada652 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitetemplateoptions.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteTemplateOptions struct { + Description *string `json:"description,omitempty"` + IsPrivate *bool `json:"isPrivate,omitempty"` + Owner *string `json:"owner,omitempty"` + RepositoryName *string `json:"repositoryName,omitempty"` + TemplateRepositoryURL *string `json:"templateRepositoryUrl,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserarmresource.go b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserarmresource.go new file mode 100644 index 00000000000..296cf30c6f8 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteUserARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserarmresourceproperties.go b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserarmresourceproperties.go new file mode 100644 index 00000000000..1ee310fa773 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserarmresourceproperties.go @@ -0,0 +1,11 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserARMResourceProperties struct { + DisplayName *string `json:"displayName,omitempty"` + Provider *string `json:"provider,omitempty"` + Roles *string `json:"roles,omitempty"` + UserId *string `json:"userId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserinvitationrequestresource.go b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserinvitationrequestresource.go new file mode 100644 index 00000000000..d9d5ae47bdc --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserinvitationrequestresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserInvitationRequestResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteUserInvitationRequestResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserinvitationrequestresourceproperties.go b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserinvitationrequestresourceproperties.go new file mode 100644 index 00000000000..744a01b8f56 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserinvitationrequestresourceproperties.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserInvitationRequestResourceProperties struct { + Domain *string `json:"domain,omitempty"` + NumHoursToExpiration *int64 `json:"numHoursToExpiration,omitempty"` + Provider *string `json:"provider,omitempty"` + Roles *string `json:"roles,omitempty"` + UserDetails *string `json:"userDetails,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserinvitationresponseresource.go b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserinvitationresponseresource.go new file mode 100644 index 00000000000..1c89e5056c0 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserinvitationresponseresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserInvitationResponseResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteUserInvitationResponseResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserinvitationresponseresourceproperties.go b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserinvitationresponseresourceproperties.go new file mode 100644 index 00000000000..57c9a2fb872 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserinvitationresponseresourceproperties.go @@ -0,0 +1,27 @@ +package staticsites + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserInvitationResponseResourceProperties struct { + ExpiresOn *string `json:"expiresOn,omitempty"` + InvitationURL *string `json:"invitationUrl,omitempty"` +} + +func (o *StaticSiteUserInvitationResponseResourceProperties) GetExpiresOnAsTime() (*time.Time, error) { + if o.ExpiresOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiresOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteUserInvitationResponseResourceProperties) SetExpiresOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiresOn = &formatted +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserprovidedfunctionapp.go b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserprovidedfunctionapp.go new file mode 100644 index 00000000000..08c7d23a344 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserprovidedfunctionapp.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserProvidedFunctionApp struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteUserProvidedFunctionAppProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserprovidedfunctionapparmresource.go b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserprovidedfunctionapparmresource.go new file mode 100644 index 00000000000..c3a983f8eea --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserprovidedfunctionapparmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserProvidedFunctionAppARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteUserProvidedFunctionAppARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserprovidedfunctionapparmresourceproperties.go b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserprovidedfunctionapparmresourceproperties.go new file mode 100644 index 00000000000..5c3f5f4b629 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserprovidedfunctionapparmresourceproperties.go @@ -0,0 +1,28 @@ +package staticsites + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserProvidedFunctionAppARMResourceProperties struct { + CreatedOn *string `json:"createdOn,omitempty"` + FunctionAppRegion *string `json:"functionAppRegion,omitempty"` + FunctionAppResourceId *string `json:"functionAppResourceId,omitempty"` +} + +func (o *StaticSiteUserProvidedFunctionAppARMResourceProperties) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteUserProvidedFunctionAppARMResourceProperties) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserprovidedfunctionappproperties.go b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserprovidedfunctionappproperties.go new file mode 100644 index 00000000000..d1aa33d93e1 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsiteuserprovidedfunctionappproperties.go @@ -0,0 +1,28 @@ +package staticsites + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteUserProvidedFunctionAppProperties struct { + CreatedOn *string `json:"createdOn,omitempty"` + FunctionAppRegion *string `json:"functionAppRegion,omitempty"` + FunctionAppResourceId *string `json:"functionAppResourceId,omitempty"` +} + +func (o *StaticSiteUserProvidedFunctionAppProperties) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *StaticSiteUserProvidedFunctionAppProperties) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitezipdeployment.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitezipdeployment.go new file mode 100644 index 00000000000..e91994bd766 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitezipdeployment.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteZipDeployment struct { + ApiZipURL *string `json:"apiZipUrl,omitempty"` + AppZipURL *string `json:"appZipUrl,omitempty"` + DeploymentTitle *string `json:"deploymentTitle,omitempty"` + FunctionLanguage *string `json:"functionLanguage,omitempty"` + Provider *string `json:"provider,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_staticsitezipdeploymentarmresource.go b/resource-manager/web/2024-11-01/staticsites/model_staticsitezipdeploymentarmresource.go new file mode 100644 index 00000000000..f842a2730dc --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_staticsitezipdeploymentarmresource.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StaticSiteZipDeploymentARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StaticSiteZipDeployment `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_stringdictionary.go b/resource-manager/web/2024-11-01/staticsites/model_stringdictionary.go new file mode 100644 index 00000000000..71965903614 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_stringdictionary.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StringDictionary struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/model_stringlist.go b/resource-manager/web/2024-11-01/staticsites/model_stringlist.go new file mode 100644 index 00000000000..79987b1ea84 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/model_stringlist.go @@ -0,0 +1,12 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StringList struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *[]string `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/staticsites/predicates.go b/resource-manager/web/2024-11-01/staticsites/predicates.go new file mode 100644 index 00000000000..b27ed7b5388 --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/predicates.go @@ -0,0 +1,289 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseConnectionOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DatabaseConnectionOperationPredicate) Matches(input DatabaseConnection) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type RemotePrivateEndpointConnectionARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p RemotePrivateEndpointConnectionARMResourceOperationPredicate) Matches(input RemotePrivateEndpointConnectionARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type StaticSiteARMResourceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p StaticSiteARMResourceOperationPredicate) Matches(input StaticSiteARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type StaticSiteBasicAuthPropertiesARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteBasicAuthPropertiesARMResourceOperationPredicate) Matches(input StaticSiteBasicAuthPropertiesARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type StaticSiteBuildARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteBuildARMResourceOperationPredicate) Matches(input StaticSiteBuildARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type StaticSiteCustomDomainOverviewARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteCustomDomainOverviewARMResourceOperationPredicate) Matches(input StaticSiteCustomDomainOverviewARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type StaticSiteFunctionOverviewARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteFunctionOverviewARMResourceOperationPredicate) Matches(input StaticSiteFunctionOverviewARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type StaticSiteLinkedBackendARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteLinkedBackendARMResourceOperationPredicate) Matches(input StaticSiteLinkedBackendARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type StaticSiteUserARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteUserARMResourceOperationPredicate) Matches(input StaticSiteUserARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p StaticSiteUserProvidedFunctionAppARMResourceOperationPredicate) Matches(input StaticSiteUserProvidedFunctionAppARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/staticsites/version.go b/resource-manager/web/2024-11-01/staticsites/version.go new file mode 100644 index 00000000000..783a584968d --- /dev/null +++ b/resource-manager/web/2024-11-01/staticsites/version.go @@ -0,0 +1,10 @@ +package staticsites + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/staticsites/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/topleveldomains/README.md b/resource-manager/web/2024-11-01/topleveldomains/README.md new file mode 100644 index 00000000000..165ac35171a --- /dev/null +++ b/resource-manager/web/2024-11-01/topleveldomains/README.md @@ -0,0 +1,76 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/topleveldomains` Documentation + +The `topleveldomains` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/topleveldomains" +``` + + +### Client Initialization + +```go +client := topleveldomains.NewTopLevelDomainsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `TopLevelDomainsClient.Get` + +```go +ctx := context.TODO() +id := topleveldomains.NewTopLevelDomainID("12345678-1234-9876-4563-123456789012", "topLevelDomainName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `TopLevelDomainsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `TopLevelDomainsClient.ListAgreements` + +```go +ctx := context.TODO() +id := topleveldomains.NewTopLevelDomainID("12345678-1234-9876-4563-123456789012", "topLevelDomainName") + +payload := topleveldomains.TopLevelDomainAgreementOption{ + // ... +} + + +// alternatively `client.ListAgreements(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListAgreementsComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-11-01/topleveldomains/client.go b/resource-manager/web/2024-11-01/topleveldomains/client.go new file mode 100644 index 00000000000..73312d38791 --- /dev/null +++ b/resource-manager/web/2024-11-01/topleveldomains/client.go @@ -0,0 +1,26 @@ +package topleveldomains + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopLevelDomainsClient struct { + Client *resourcemanager.Client +} + +func NewTopLevelDomainsClientWithBaseURI(sdkApi sdkEnv.Api) (*TopLevelDomainsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "topleveldomains", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TopLevelDomainsClient: %+v", err) + } + + return &TopLevelDomainsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/topleveldomains/id_topleveldomain.go b/resource-manager/web/2024-11-01/topleveldomains/id_topleveldomain.go new file mode 100644 index 00000000000..de4d3235874 --- /dev/null +++ b/resource-manager/web/2024-11-01/topleveldomains/id_topleveldomain.go @@ -0,0 +1,121 @@ +package topleveldomains + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&TopLevelDomainId{}) +} + +var _ resourceids.ResourceId = &TopLevelDomainId{} + +// TopLevelDomainId is a struct representing the Resource ID for a Top Level Domain +type TopLevelDomainId struct { + SubscriptionId string + TopLevelDomainName string +} + +// NewTopLevelDomainID returns a new TopLevelDomainId struct +func NewTopLevelDomainID(subscriptionId string, topLevelDomainName string) TopLevelDomainId { + return TopLevelDomainId{ + SubscriptionId: subscriptionId, + TopLevelDomainName: topLevelDomainName, + } +} + +// ParseTopLevelDomainID parses 'input' into a TopLevelDomainId +func ParseTopLevelDomainID(input string) (*TopLevelDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&TopLevelDomainId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TopLevelDomainId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTopLevelDomainIDInsensitively parses 'input' case-insensitively into a TopLevelDomainId +// note: this method should only be used for API response data and not user input +func ParseTopLevelDomainIDInsensitively(input string) (*TopLevelDomainId, error) { + parser := resourceids.NewParserFromResourceIdType(&TopLevelDomainId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TopLevelDomainId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TopLevelDomainId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.TopLevelDomainName, ok = input.Parsed["topLevelDomainName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "topLevelDomainName", input) + } + + return nil +} + +// ValidateTopLevelDomainID checks that 'input' can be parsed as a Top Level Domain ID +func ValidateTopLevelDomainID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseTopLevelDomainID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Top Level Domain ID +func (id TopLevelDomainId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.DomainRegistration/topLevelDomains/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.TopLevelDomainName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Top Level Domain ID +func (id TopLevelDomainId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftDomainRegistration", "Microsoft.DomainRegistration", "Microsoft.DomainRegistration"), + resourceids.StaticSegment("staticTopLevelDomains", "topLevelDomains", "topLevelDomains"), + resourceids.UserSpecifiedSegment("topLevelDomainName", "topLevelDomainName"), + } +} + +// String returns a human-readable description of this Top Level Domain ID +func (id TopLevelDomainId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Top Level Domain Name: %q", id.TopLevelDomainName), + } + return fmt.Sprintf("Top Level Domain (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/topleveldomains/id_topleveldomain_test.go b/resource-manager/web/2024-11-01/topleveldomains/id_topleveldomain_test.go new file mode 100644 index 00000000000..11f286ac04e --- /dev/null +++ b/resource-manager/web/2024-11-01/topleveldomains/id_topleveldomain_test.go @@ -0,0 +1,237 @@ +package topleveldomains + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &TopLevelDomainId{} + +func TestNewTopLevelDomainID(t *testing.T) { + id := NewTopLevelDomainID("12345678-1234-9876-4563-123456789012", "topLevelDomainName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.TopLevelDomainName != "topLevelDomainName" { + t.Fatalf("Expected %q but got %q for Segment 'TopLevelDomainName'", id.TopLevelDomainName, "topLevelDomainName") + } +} + +func TestFormatTopLevelDomainID(t *testing.T) { + actual := NewTopLevelDomainID("12345678-1234-9876-4563-123456789012", "topLevelDomainName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains/topLevelDomainName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTopLevelDomainID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TopLevelDomainId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains/topLevelDomainName", + Expected: &TopLevelDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + TopLevelDomainName: "topLevelDomainName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains/topLevelDomainName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTopLevelDomainID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.TopLevelDomainName != v.Expected.TopLevelDomainName { + t.Fatalf("Expected %q but got %q for TopLevelDomainName", v.Expected.TopLevelDomainName, actual.TopLevelDomainName) + } + + } +} + +func TestParseTopLevelDomainIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TopLevelDomainId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/tOpLeVeLdOmAiNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains/topLevelDomainName", + Expected: &TopLevelDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + TopLevelDomainName: "topLevelDomainName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.DomainRegistration/topLevelDomains/topLevelDomainName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/tOpLeVeLdOmAiNs/tOpLeVeLdOmAiNnAmE", + Expected: &TopLevelDomainId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + TopLevelDomainName: "tOpLeVeLdOmAiNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.dOmAiNrEgIsTrAtIoN/tOpLeVeLdOmAiNs/tOpLeVeLdOmAiNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTopLevelDomainIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.TopLevelDomainName != v.Expected.TopLevelDomainName { + t.Fatalf("Expected %q but got %q for TopLevelDomainName", v.Expected.TopLevelDomainName, actual.TopLevelDomainName) + } + + } +} + +func TestSegmentsForTopLevelDomainId(t *testing.T) { + segments := TopLevelDomainId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TopLevelDomainId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/topleveldomains/method_get.go b/resource-manager/web/2024-11-01/topleveldomains/method_get.go new file mode 100644 index 00000000000..b9320d14b1f --- /dev/null +++ b/resource-manager/web/2024-11-01/topleveldomains/method_get.go @@ -0,0 +1,53 @@ +package topleveldomains + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TopLevelDomain +} + +// Get ... +func (c TopLevelDomainsClient) Get(ctx context.Context, id TopLevelDomainId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model TopLevelDomain + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/topleveldomains/method_list.go b/resource-manager/web/2024-11-01/topleveldomains/method_list.go new file mode 100644 index 00000000000..3047b40a525 --- /dev/null +++ b/resource-manager/web/2024-11-01/topleveldomains/method_list.go @@ -0,0 +1,106 @@ +package topleveldomains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TopLevelDomain +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []TopLevelDomain +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c TopLevelDomainsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.DomainRegistration/topLevelDomains", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TopLevelDomain `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c TopLevelDomainsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, TopLevelDomainOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TopLevelDomainsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate TopLevelDomainOperationPredicate) (result ListCompleteResult, err error) { + items := make([]TopLevelDomain, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/topleveldomains/method_listagreements.go b/resource-manager/web/2024-11-01/topleveldomains/method_listagreements.go new file mode 100644 index 00000000000..aef7718cae9 --- /dev/null +++ b/resource-manager/web/2024-11-01/topleveldomains/method_listagreements.go @@ -0,0 +1,105 @@ +package topleveldomains + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAgreementsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TldLegalAgreement +} + +type ListAgreementsCompleteResult struct { + LatestHttpResponse *http.Response + Items []TldLegalAgreement +} + +type ListAgreementsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListAgreementsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListAgreements ... +func (c TopLevelDomainsClient) ListAgreements(ctx context.Context, id TopLevelDomainId, input TopLevelDomainAgreementOption) (result ListAgreementsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListAgreementsCustomPager{}, + Path: fmt.Sprintf("%s/listAgreements", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TldLegalAgreement `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListAgreementsComplete retrieves all the results into a single object +func (c TopLevelDomainsClient) ListAgreementsComplete(ctx context.Context, id TopLevelDomainId, input TopLevelDomainAgreementOption) (ListAgreementsCompleteResult, error) { + return c.ListAgreementsCompleteMatchingPredicate(ctx, id, input, TldLegalAgreementOperationPredicate{}) +} + +// ListAgreementsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TopLevelDomainsClient) ListAgreementsCompleteMatchingPredicate(ctx context.Context, id TopLevelDomainId, input TopLevelDomainAgreementOption, predicate TldLegalAgreementOperationPredicate) (result ListAgreementsCompleteResult, err error) { + items := make([]TldLegalAgreement, 0) + + resp, err := c.ListAgreements(ctx, id, input) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListAgreementsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/topleveldomains/model_tldlegalagreement.go b/resource-manager/web/2024-11-01/topleveldomains/model_tldlegalagreement.go new file mode 100644 index 00000000000..7efd744d882 --- /dev/null +++ b/resource-manager/web/2024-11-01/topleveldomains/model_tldlegalagreement.go @@ -0,0 +1,11 @@ +package topleveldomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TldLegalAgreement struct { + AgreementKey string `json:"agreementKey"` + Content string `json:"content"` + Title string `json:"title"` + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/topleveldomains/model_topleveldomain.go b/resource-manager/web/2024-11-01/topleveldomains/model_topleveldomain.go new file mode 100644 index 00000000000..88855d8e294 --- /dev/null +++ b/resource-manager/web/2024-11-01/topleveldomains/model_topleveldomain.go @@ -0,0 +1,12 @@ +package topleveldomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopLevelDomain struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *TopLevelDomainProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/topleveldomains/model_topleveldomainagreementoption.go b/resource-manager/web/2024-11-01/topleveldomains/model_topleveldomainagreementoption.go new file mode 100644 index 00000000000..f39158b5cbc --- /dev/null +++ b/resource-manager/web/2024-11-01/topleveldomains/model_topleveldomainagreementoption.go @@ -0,0 +1,9 @@ +package topleveldomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopLevelDomainAgreementOption struct { + ForTransfer *bool `json:"forTransfer,omitempty"` + IncludePrivacy *bool `json:"includePrivacy,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/topleveldomains/model_topleveldomainproperties.go b/resource-manager/web/2024-11-01/topleveldomains/model_topleveldomainproperties.go new file mode 100644 index 00000000000..9e205230463 --- /dev/null +++ b/resource-manager/web/2024-11-01/topleveldomains/model_topleveldomainproperties.go @@ -0,0 +1,8 @@ +package topleveldomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TopLevelDomainProperties struct { + Privacy *bool `json:"privacy,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/topleveldomains/predicates.go b/resource-manager/web/2024-11-01/topleveldomains/predicates.go new file mode 100644 index 00000000000..a85c5378eeb --- /dev/null +++ b/resource-manager/web/2024-11-01/topleveldomains/predicates.go @@ -0,0 +1,60 @@ +package topleveldomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TldLegalAgreementOperationPredicate struct { + AgreementKey *string + Content *string + Title *string + Url *string +} + +func (p TldLegalAgreementOperationPredicate) Matches(input TldLegalAgreement) bool { + + if p.AgreementKey != nil && *p.AgreementKey != input.AgreementKey { + return false + } + + if p.Content != nil && *p.Content != input.Content { + return false + } + + if p.Title != nil && *p.Title != input.Title { + return false + } + + if p.Url != nil && (input.Url == nil || *p.Url != *input.Url) { + return false + } + + return true +} + +type TopLevelDomainOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p TopLevelDomainOperationPredicate) Matches(input TopLevelDomain) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/topleveldomains/version.go b/resource-manager/web/2024-11-01/topleveldomains/version.go new file mode 100644 index 00000000000..ea014259f75 --- /dev/null +++ b/resource-manager/web/2024-11-01/topleveldomains/version.go @@ -0,0 +1,10 @@ +package topleveldomains + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/topleveldomains/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/webapps/README.md b/resource-manager/web/2024-11-01/webapps/README.md new file mode 100644 index 00000000000..b7aafe31b3a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/README.md @@ -0,0 +1,7069 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/webapps` Documentation + +The `webapps` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/webapps" +``` + + +### Client Initialization + +```go +client := webapps.NewWebAppsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WebAppsClient.AddPremierAddOn` + +```go +ctx := context.TODO() +id := webapps.NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "premierAddonName") + +payload := webapps.PremierAddOn{ + // ... +} + + +read, err := client.AddPremierAddOn(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.AddPremierAddOnSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "premierAddonName") + +payload := webapps.PremierAddOn{ + // ... +} + + +read, err := client.AddPremierAddOnSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.AnalyzeCustomHostname` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.AnalyzeCustomHostname(ctx, id, webapps.DefaultAnalyzeCustomHostnameOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.AnalyzeCustomHostnameSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.AnalyzeCustomHostnameSlot(ctx, id, webapps.DefaultAnalyzeCustomHostnameSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ApplySlotConfigToProduction` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +read, err := client.ApplySlotConfigToProduction(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ApplySlotConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +read, err := client.ApplySlotConfigurationSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ApproveOrRejectPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := webapps.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "privateEndpointConnectionName") + +payload := webapps.RemotePrivateEndpointConnectionARMResource{ + // ... +} + + +if err := client.ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.ApproveOrRejectPrivateEndpointConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "privateEndpointConnectionName") + +payload := webapps.RemotePrivateEndpointConnectionARMResource{ + // ... +} + + +if err := client.ApproveOrRejectPrivateEndpointConnectionSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.Backup` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.Backup(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.BackupSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.BackupSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateDeployment` + +```go +ctx := context.TODO() +id := webapps.NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "deploymentName") + +payload := webapps.Deployment{ + // ... +} + + +read, err := client.CreateDeployment(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateDeploymentSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "deploymentName") + +payload := webapps.Deployment{ + // ... +} + + +read, err := client.CreateDeploymentSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateFunction` + +```go +ctx := context.TODO() +id := webapps.NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName") + +payload := webapps.FunctionEnvelope{ + // ... +} + + +if err := client.CreateFunctionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateInstanceFunctionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName") + +payload := webapps.FunctionEnvelope{ + // ... +} + + +if err := client.CreateInstanceFunctionSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateInstanceMSDeployOperation` + +```go +ctx := context.TODO() +id := webapps.NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId") + +payload := webapps.MSDeploy{ + // ... +} + + +if err := client.CreateInstanceMSDeployOperationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateInstanceMSDeployOperationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId") + +payload := webapps.MSDeploy{ + // ... +} + + +if err := client.CreateInstanceMSDeployOperationSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateMSDeployOperation` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.MSDeploy{ + // ... +} + + +if err := client.CreateMSDeployOperationThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateMSDeployOperationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.MSDeploy{ + // ... +} + + +if err := client.CreateMSDeployOperationSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateOneDeployOperation` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.CreateOneDeployOperation(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.Site{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SiteConfigResource{ + // ... +} + + +read, err := client.CreateOrUpdateConfiguration(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SiteConfigResource{ + // ... +} + + +read, err := client.CreateOrUpdateConfigurationSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateDomainOwnershipIdentifier` + +```go +ctx := context.TODO() +id := webapps.NewSiteDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "domainOwnershipIdentifierName") + +payload := webapps.Identifier{ + // ... +} + + +read, err := client.CreateOrUpdateDomainOwnershipIdentifier(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateDomainOwnershipIdentifierSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "domainOwnershipIdentifierName") + +payload := webapps.Identifier{ + // ... +} + + +read, err := client.CreateOrUpdateDomainOwnershipIdentifierSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateFunctionSecret` + +```go +ctx := context.TODO() +id := webapps.NewKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName", "keyName") + +payload := webapps.KeyInfo{ + // ... +} + + +read, err := client.CreateOrUpdateFunctionSecret(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateFunctionSecretSlot` + +```go +ctx := context.TODO() +id := webapps.NewFunctionKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName", "keyName") + +payload := webapps.KeyInfo{ + // ... +} + + +read, err := client.CreateOrUpdateFunctionSecretSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHostNameBinding` + +```go +ctx := context.TODO() +id := webapps.NewHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hostNameBindingName") + +payload := webapps.HostNameBinding{ + // ... +} + + +read, err := client.CreateOrUpdateHostNameBinding(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHostNameBindingSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hostNameBindingName") + +payload := webapps.HostNameBinding{ + // ... +} + + +read, err := client.CreateOrUpdateHostNameBindingSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHostSecret` + +```go +ctx := context.TODO() +id := webapps.NewDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "defaultName", "keyName") + +payload := webapps.KeyInfo{ + // ... +} + + +read, err := client.CreateOrUpdateHostSecret(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHostSecretSlot` + +```go +ctx := context.TODO() +id := webapps.NewHostDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "defaultName", "keyName") + +payload := webapps.KeyInfo{ + // ... +} + + +read, err := client.CreateOrUpdateHostSecretSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHybridConnection` + +```go +ctx := context.TODO() +id := webapps.NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionNamespaceName", "relayName") + +payload := webapps.HybridConnection{ + // ... +} + + +read, err := client.CreateOrUpdateHybridConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateHybridConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionNamespaceName", "relayName") + +payload := webapps.HybridConnection{ + // ... +} + + +read, err := client.CreateOrUpdateHybridConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdatePublicCertificate` + +```go +ctx := context.TODO() +id := webapps.NewPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "publicCertificateName") + +payload := webapps.PublicCertificate{ + // ... +} + + +read, err := client.CreateOrUpdatePublicCertificate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdatePublicCertificateSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "publicCertificateName") + +payload := webapps.PublicCertificate{ + // ... +} + + +read, err := client.CreateOrUpdatePublicCertificateSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateRelayServiceConnection` + +```go +ctx := context.TODO() +id := webapps.NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionName") + +payload := webapps.RelayServiceConnectionEntity{ + // ... +} + + +read, err := client.CreateOrUpdateRelayServiceConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateRelayServiceConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionName") + +payload := webapps.RelayServiceConnectionEntity{ + // ... +} + + +read, err := client.CreateOrUpdateRelayServiceConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSiteContainer` + +```go +ctx := context.TODO() +id := webapps.NewSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "sitecontainerName") + +payload := webapps.SiteContainer{ + // ... +} + + +read, err := client.CreateOrUpdateSiteContainer(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSiteContainerSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "sitecontainerName") + +payload := webapps.SiteContainer{ + // ... +} + + +read, err := client.CreateOrUpdateSiteContainerSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.Site{ + // ... +} + + +if err := client.CreateOrUpdateSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSourceControl` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SiteSourceControl{ + // ... +} + + +if err := client.CreateOrUpdateSourceControlThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSourceControlSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SiteSourceControl{ + // ... +} + + +if err := client.CreateOrUpdateSourceControlSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SwiftVirtualNetwork{ + // ... +} + + +read, err := client.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SwiftVirtualNetwork{ + // ... +} + + +read, err := client.CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateVnetConnection` + +```go +ctx := context.TODO() +id := webapps.NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName") + +payload := webapps.VnetInfoResource{ + // ... +} + + +read, err := client.CreateOrUpdateVnetConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateVnetConnectionGateway` + +```go +ctx := context.TODO() +id := webapps.NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName", "gatewayName") + +payload := webapps.VnetGateway{ + // ... +} + + +read, err := client.CreateOrUpdateVnetConnectionGateway(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateVnetConnectionGatewaySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName", "gatewayName") + +payload := webapps.VnetGateway{ + // ... +} + + +read, err := client.CreateOrUpdateVnetConnectionGatewaySlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.CreateOrUpdateVnetConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName") + +payload := webapps.VnetInfoResource{ + // ... +} + + +read, err := client.CreateOrUpdateVnetConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.Delete(ctx, id, webapps.DefaultDeleteOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteBackup` + +```go +ctx := context.TODO() +id := webapps.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "backupId") + +read, err := client.DeleteBackup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteBackupConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.DeleteBackupConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteBackupConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.DeleteBackupConfigurationSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteBackupSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "backupId") + +read, err := client.DeleteBackupSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteContinuousWebJob` + +```go +ctx := context.TODO() +id := webapps.NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "continuousWebJobName") + +read, err := client.DeleteContinuousWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteContinuousWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "continuousWebJobName") + +read, err := client.DeleteContinuousWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteDeployment` + +```go +ctx := context.TODO() +id := webapps.NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "deploymentName") + +read, err := client.DeleteDeployment(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteDeploymentSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "deploymentName") + +read, err := client.DeleteDeploymentSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteDomainOwnershipIdentifier` + +```go +ctx := context.TODO() +id := webapps.NewSiteDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "domainOwnershipIdentifierName") + +read, err := client.DeleteDomainOwnershipIdentifier(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteDomainOwnershipIdentifierSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "domainOwnershipIdentifierName") + +read, err := client.DeleteDomainOwnershipIdentifierSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteFunction` + +```go +ctx := context.TODO() +id := webapps.NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName") + +read, err := client.DeleteFunction(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteFunctionSecret` + +```go +ctx := context.TODO() +id := webapps.NewKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName", "keyName") + +read, err := client.DeleteFunctionSecret(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteFunctionSecretSlot` + +```go +ctx := context.TODO() +id := webapps.NewFunctionKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName", "keyName") + +read, err := client.DeleteFunctionSecretSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHostNameBinding` + +```go +ctx := context.TODO() +id := webapps.NewHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hostNameBindingName") + +read, err := client.DeleteHostNameBinding(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHostNameBindingSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hostNameBindingName") + +read, err := client.DeleteHostNameBindingSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHostSecret` + +```go +ctx := context.TODO() +id := webapps.NewDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "defaultName", "keyName") + +read, err := client.DeleteHostSecret(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHostSecretSlot` + +```go +ctx := context.TODO() +id := webapps.NewHostDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "defaultName", "keyName") + +read, err := client.DeleteHostSecretSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHybridConnection` + +```go +ctx := context.TODO() +id := webapps.NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionNamespaceName", "relayName") + +read, err := client.DeleteHybridConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteHybridConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionNamespaceName", "relayName") + +read, err := client.DeleteHybridConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteInstanceFunctionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName") + +read, err := client.DeleteInstanceFunctionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteInstanceProcess` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId") + +read, err := client.DeleteInstanceProcess(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteInstanceProcessSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId") + +read, err := client.DeleteInstanceProcessSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeletePremierAddOn` + +```go +ctx := context.TODO() +id := webapps.NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "premierAddonName") + +read, err := client.DeletePremierAddOn(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeletePremierAddOnSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "premierAddonName") + +read, err := client.DeletePremierAddOnSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeletePrivateEndpointConnection` + +```go +ctx := context.TODO() +id := webapps.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "privateEndpointConnectionName") + +if err := client.DeletePrivateEndpointConnectionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.DeletePrivateEndpointConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "privateEndpointConnectionName") + +if err := client.DeletePrivateEndpointConnectionSlotThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.DeleteProcess` + +```go +ctx := context.TODO() +id := webapps.NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId") + +read, err := client.DeleteProcess(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteProcessSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId") + +read, err := client.DeleteProcessSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeletePublicCertificate` + +```go +ctx := context.TODO() +id := webapps.NewPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "publicCertificateName") + +read, err := client.DeletePublicCertificate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeletePublicCertificateSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "publicCertificateName") + +read, err := client.DeletePublicCertificateSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteRelayServiceConnection` + +```go +ctx := context.TODO() +id := webapps.NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionName") + +read, err := client.DeleteRelayServiceConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteRelayServiceConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionName") + +read, err := client.DeleteRelayServiceConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSiteContainer` + +```go +ctx := context.TODO() +id := webapps.NewSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "sitecontainerName") + +read, err := client.DeleteSiteContainer(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSiteContainerSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "sitecontainerName") + +read, err := client.DeleteSiteContainerSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSiteExtension` + +```go +ctx := context.TODO() +id := webapps.NewSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "siteExtensionId") + +read, err := client.DeleteSiteExtension(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSiteExtensionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "siteExtensionId") + +read, err := client.DeleteSiteExtensionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.DeleteSlot(ctx, id, webapps.DefaultDeleteSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSourceControl` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.DeleteSourceControl(ctx, id, webapps.DefaultDeleteSourceControlOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSourceControlSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.DeleteSourceControlSlot(ctx, id, webapps.DefaultDeleteSourceControlSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSwiftVirtualNetwork` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.DeleteSwiftVirtualNetwork(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteSwiftVirtualNetworkSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.DeleteSwiftVirtualNetworkSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteTriggeredWebJob` + +```go +ctx := context.TODO() +id := webapps.NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName") + +read, err := client.DeleteTriggeredWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteTriggeredWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName") + +read, err := client.DeleteTriggeredWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteVnetConnection` + +```go +ctx := context.TODO() +id := webapps.NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName") + +read, err := client.DeleteVnetConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeleteVnetConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName") + +read, err := client.DeleteVnetConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeployWorkflowArtifacts` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.WorkflowArtifacts{ + // ... +} + + +read, err := client.DeployWorkflowArtifacts(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DeployWorkflowArtifactsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.WorkflowArtifacts{ + // ... +} + + +read, err := client.DeployWorkflowArtifactsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DiscoverBackup` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.RestoreRequest{ + // ... +} + + +read, err := client.DiscoverBackup(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.DiscoverBackupSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.RestoreRequest{ + // ... +} + + +read, err := client.DiscoverBackupSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GenerateNewSitePublishingPassword` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GenerateNewSitePublishingPassword(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GenerateNewSitePublishingPasswordSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GenerateNewSitePublishingPasswordSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAppSettingKeyVaultReference` + +```go +ctx := context.TODO() +id := webapps.NewAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "appSettingKey") + +read, err := client.GetAppSettingKeyVaultReference(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAppSettingKeyVaultReferenceSlot` + +```go +ctx := context.TODO() +id := webapps.NewConfigReferenceAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "appSettingKey") + +read, err := client.GetAppSettingKeyVaultReferenceSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAppSettingsKeyVaultReferences` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.GetAppSettingsKeyVaultReferences(ctx, id)` can be used to do batched pagination +items, err := client.GetAppSettingsKeyVaultReferencesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetAppSettingsKeyVaultReferencesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.GetAppSettingsKeyVaultReferencesSlot(ctx, id)` can be used to do batched pagination +items, err := client.GetAppSettingsKeyVaultReferencesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetAuthSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetAuthSettingsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettingsV2` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetAuthSettingsV2(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettingsV2Slot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetAuthSettingsV2Slot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettingsV2WithoutSecrets` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetAuthSettingsV2WithoutSecrets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetAuthSettingsV2WithoutSecretsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetAuthSettingsV2WithoutSecretsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetBackupConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetBackupConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetBackupConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetBackupConfigurationSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetBackupStatus` + +```go +ctx := context.TODO() +id := webapps.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "backupId") + +read, err := client.GetBackupStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetBackupStatusSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "backupId") + +read, err := client.GetBackupStatusSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetConfigurationSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetConfigurationSnapshot` + +```go +ctx := context.TODO() +id := webapps.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "snapshotId") + +read, err := client.GetConfigurationSnapshot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetConfigurationSnapshotSlot` + +```go +ctx := context.TODO() +id := webapps.NewWebSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "snapshotId") + +read, err := client.GetConfigurationSnapshotSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetContainerLogsZip` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetContainerLogsZip(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetContainerLogsZipSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetContainerLogsZipSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetContinuousWebJob` + +```go +ctx := context.TODO() +id := webapps.NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "continuousWebJobName") + +read, err := client.GetContinuousWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetContinuousWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "continuousWebJobName") + +read, err := client.GetContinuousWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDeployment` + +```go +ctx := context.TODO() +id := webapps.NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "deploymentName") + +read, err := client.GetDeployment(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDeploymentSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "deploymentName") + +read, err := client.GetDeploymentSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDiagnosticLogsConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetDiagnosticLogsConfiguration(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDiagnosticLogsConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetDiagnosticLogsConfigurationSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDomainOwnershipIdentifier` + +```go +ctx := context.TODO() +id := webapps.NewSiteDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "domainOwnershipIdentifierName") + +read, err := client.GetDomainOwnershipIdentifier(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetDomainOwnershipIdentifierSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "domainOwnershipIdentifierName") + +read, err := client.GetDomainOwnershipIdentifierSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetFtpAllowed` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetFtpAllowed(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetFtpAllowedSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetFtpAllowedSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetFunction` + +```go +ctx := context.TODO() +id := webapps.NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName") + +read, err := client.GetFunction(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetFunctionsAdminToken` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetFunctionsAdminToken(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetFunctionsAdminTokenSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetFunctionsAdminTokenSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetHostNameBinding` + +```go +ctx := context.TODO() +id := webapps.NewHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hostNameBindingName") + +read, err := client.GetHostNameBinding(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetHostNameBindingSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hostNameBindingName") + +read, err := client.GetHostNameBindingSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetHybridConnection` + +```go +ctx := context.TODO() +id := webapps.NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionNamespaceName", "relayName") + +read, err := client.GetHybridConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetHybridConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionNamespaceName", "relayName") + +read, err := client.GetHybridConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceFunctionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName") + +read, err := client.GetInstanceFunctionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceInfo` + +```go +ctx := context.TODO() +id := webapps.NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId") + +read, err := client.GetInstanceInfo(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceInfoSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId") + +read, err := client.GetInstanceInfoSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceMSDeployLog` + +```go +ctx := context.TODO() +id := webapps.NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId") + +read, err := client.GetInstanceMSDeployLog(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceMSDeployLogSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId") + +read, err := client.GetInstanceMSDeployLogSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceMsDeployStatus` + +```go +ctx := context.TODO() +id := webapps.NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId") + +read, err := client.GetInstanceMsDeployStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceMsDeployStatusSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId") + +read, err := client.GetInstanceMsDeployStatusSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcess` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId") + +read, err := client.GetInstanceProcess(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcessDump` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId") + +read, err := client.GetInstanceProcessDump(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcessDumpSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId") + +read, err := client.GetInstanceProcessDumpSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcessModule` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId", "moduleName") + +read, err := client.GetInstanceProcessModule(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcessModuleSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId", "moduleName") + +read, err := client.GetInstanceProcessModuleSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceProcessSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId") + +read, err := client.GetInstanceProcessSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetInstanceWorkflowSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "workflowName") + +read, err := client.GetInstanceWorkflowSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMSDeployLog` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetMSDeployLog(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMSDeployLogSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetMSDeployLogSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMSDeployStatus` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetMSDeployStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMSDeployStatusSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetMSDeployStatusSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMigrateMySqlStatus` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetMigrateMySqlStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetMigrateMySqlStatusSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetMigrateMySqlStatusSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetNetworkTraces` + +```go +ctx := context.TODO() +id := webapps.NewNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "operationId") + +read, err := client.GetNetworkTraces(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetNetworkTracesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "operationId") + +read, err := client.GetNetworkTracesSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetNetworkTracesSlotV2` + +```go +ctx := context.TODO() +id := webapps.NewSiteSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "operationId") + +read, err := client.GetNetworkTracesSlotV2(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetNetworkTracesV2` + +```go +ctx := context.TODO() +id := webapps.NewSiteNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "operationId") + +read, err := client.GetNetworkTracesV2(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetOneDeployStatus` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetOneDeployStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPremierAddOn` + +```go +ctx := context.TODO() +id := webapps.NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "premierAddonName") + +read, err := client.GetPremierAddOn(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPremierAddOnSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "premierAddonName") + +read, err := client.GetPremierAddOnSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateAccess` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetPrivateAccess(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateAccessSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetPrivateAccessSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateEndpointConnection` + +```go +ctx := context.TODO() +id := webapps.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "privateEndpointConnectionName") + +read, err := client.GetPrivateEndpointConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateEndpointConnectionList` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.GetPrivateEndpointConnectionList(ctx, id)` can be used to do batched pagination +items, err := client.GetPrivateEndpointConnectionListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateEndpointConnectionListSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.GetPrivateEndpointConnectionListSlot(ctx, id)` can be used to do batched pagination +items, err := client.GetPrivateEndpointConnectionListSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateEndpointConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "privateEndpointConnectionName") + +read, err := client.GetPrivateEndpointConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateLinkResources` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetPrivateLinkResources(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPrivateLinkResourcesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetPrivateLinkResourcesSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcess` + +```go +ctx := context.TODO() +id := webapps.NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId") + +read, err := client.GetProcess(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcessDump` + +```go +ctx := context.TODO() +id := webapps.NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId") + +read, err := client.GetProcessDump(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcessDumpSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId") + +read, err := client.GetProcessDumpSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcessModule` + +```go +ctx := context.TODO() +id := webapps.NewModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId", "moduleName") + +read, err := client.GetProcessModule(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcessModuleSlot` + +```go +ctx := context.TODO() +id := webapps.NewProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId", "moduleName") + +read, err := client.GetProcessModuleSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetProcessSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId") + +read, err := client.GetProcessSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPublicCertificate` + +```go +ctx := context.TODO() +id := webapps.NewPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "publicCertificateName") + +read, err := client.GetPublicCertificate(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetPublicCertificateSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "publicCertificateName") + +read, err := client.GetPublicCertificateSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetRelayServiceConnection` + +```go +ctx := context.TODO() +id := webapps.NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionName") + +read, err := client.GetRelayServiceConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetRelayServiceConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionName") + +read, err := client.GetRelayServiceConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetScmAllowed` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetScmAllowed(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetScmAllowedSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetScmAllowedSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteConnectionStringKeyVaultReference` + +```go +ctx := context.TODO() +id := webapps.NewConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "connectionStringKey") + +read, err := client.GetSiteConnectionStringKeyVaultReference(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteConnectionStringKeyVaultReferenceSlot` + +```go +ctx := context.TODO() +id := webapps.NewConfigReferenceConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "connectionStringKey") + +read, err := client.GetSiteConnectionStringKeyVaultReferenceSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteConnectionStringKeyVaultReferences` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.GetSiteConnectionStringKeyVaultReferences(ctx, id)` can be used to do batched pagination +items, err := client.GetSiteConnectionStringKeyVaultReferencesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetSiteConnectionStringKeyVaultReferencesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.GetSiteConnectionStringKeyVaultReferencesSlot(ctx, id)` can be used to do batched pagination +items, err := client.GetSiteConnectionStringKeyVaultReferencesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.GetSiteContainer` + +```go +ctx := context.TODO() +id := webapps.NewSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "sitecontainerName") + +read, err := client.GetSiteContainer(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteContainerSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "sitecontainerName") + +read, err := client.GetSiteContainerSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteExtension` + +```go +ctx := context.TODO() +id := webapps.NewSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "siteExtensionId") + +read, err := client.GetSiteExtension(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSiteExtensionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "siteExtensionId") + +read, err := client.GetSiteExtensionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSitePhpErrorLogFlag` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetSitePhpErrorLogFlag(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSitePhpErrorLogFlagSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetSitePhpErrorLogFlagSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSourceControl` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetSourceControl(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSourceControlSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetSourceControlSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSwiftVirtualNetworkConnection` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetSwiftVirtualNetworkConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetSwiftVirtualNetworkConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetSwiftVirtualNetworkConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetTriggeredWebJob` + +```go +ctx := context.TODO() +id := webapps.NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName") + +read, err := client.GetTriggeredWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetTriggeredWebJobHistory` + +```go +ctx := context.TODO() +id := webapps.NewHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName", "historyName") + +read, err := client.GetTriggeredWebJobHistory(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetTriggeredWebJobHistorySlot` + +```go +ctx := context.TODO() +id := webapps.NewTriggeredWebJobHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName", "historyName") + +read, err := client.GetTriggeredWebJobHistorySlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetTriggeredWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName") + +read, err := client.GetTriggeredWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetVnetConnection` + +```go +ctx := context.TODO() +id := webapps.NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName") + +read, err := client.GetVnetConnection(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetVnetConnectionGateway` + +```go +ctx := context.TODO() +id := webapps.NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName", "gatewayName") + +read, err := client.GetVnetConnectionGateway(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetVnetConnectionGatewaySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName", "gatewayName") + +read, err := client.GetVnetConnectionGatewaySlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetVnetConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName") + +read, err := client.GetVnetConnectionSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetWebJob` + +```go +ctx := context.TODO() +id := webapps.NewWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "webJobName") + +read, err := client.GetWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "webJobName") + +read, err := client.GetWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetWebSiteContainerLogs` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.GetWebSiteContainerLogs(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetWebSiteContainerLogsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.GetWebSiteContainerLogsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.GetWorkflow` + +```go +ctx := context.TODO() +id := webapps.NewWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + +read, err := client.GetWorkflow(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.InstallSiteExtension` + +```go +ctx := context.TODO() +id := webapps.NewSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "siteExtensionId") + +if err := client.InstallSiteExtensionThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.InstallSiteExtensionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "siteExtensionId") + +if err := client.InstallSiteExtensionSlotThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.IsCloneable` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.IsCloneable(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.IsCloneableSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.IsCloneableSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListApplicationSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListApplicationSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListApplicationSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListApplicationSettingsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListAzureStorageAccounts` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListAzureStorageAccounts(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListAzureStorageAccountsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListAzureStorageAccountsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListBackupStatusSecrets` + +```go +ctx := context.TODO() +id := webapps.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "backupId") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.ListBackupStatusSecrets(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListBackupStatusSecretsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "backupId") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.ListBackupStatusSecretsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListBackups` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListBackups(ctx, id)` can be used to do batched pagination +items, err := client.ListBackupsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListBackupsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListBackupsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListBackupsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListBasicPublishingCredentialsPolicies` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListBasicPublishingCredentialsPolicies(ctx, id)` can be used to do batched pagination +items, err := client.ListBasicPublishingCredentialsPoliciesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListBasicPublishingCredentialsPoliciesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListBasicPublishingCredentialsPoliciesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListBasicPublishingCredentialsPoliciesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id, webapps.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id, webapps.DefaultListByResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListConfigurationSnapshotInfo` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListConfigurationSnapshotInfo(ctx, id)` can be used to do batched pagination +items, err := client.ListConfigurationSnapshotInfoComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListConfigurationSnapshotInfoSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListConfigurationSnapshotInfoSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListConfigurationSnapshotInfoSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListConfigurations` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListConfigurations(ctx, id)` can be used to do batched pagination +items, err := client.ListConfigurationsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListConfigurationsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListConfigurationsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListConfigurationsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListConnectionStrings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListConnectionStrings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListConnectionStringsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListConnectionStringsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListContinuousWebJobs` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListContinuousWebJobs(ctx, id)` can be used to do batched pagination +items, err := client.ListContinuousWebJobsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListContinuousWebJobsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListContinuousWebJobsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListContinuousWebJobsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListDeploymentLog` + +```go +ctx := context.TODO() +id := webapps.NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "deploymentName") + +read, err := client.ListDeploymentLog(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListDeploymentLogSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "deploymentName") + +read, err := client.ListDeploymentLogSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListDeployments` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListDeployments(ctx, id)` can be used to do batched pagination +items, err := client.ListDeploymentsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListDeploymentsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListDeploymentsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListDeploymentsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListDomainOwnershipIdentifiers` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListDomainOwnershipIdentifiers(ctx, id)` can be used to do batched pagination +items, err := client.ListDomainOwnershipIdentifiersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListDomainOwnershipIdentifiersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListDomainOwnershipIdentifiersSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListDomainOwnershipIdentifiersSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListFunctionKeys` + +```go +ctx := context.TODO() +id := webapps.NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName") + +read, err := client.ListFunctionKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListFunctionKeysSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName") + +read, err := client.ListFunctionKeysSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListFunctionSecrets` + +```go +ctx := context.TODO() +id := webapps.NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName") + +read, err := client.ListFunctionSecrets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListFunctionSecretsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName") + +read, err := client.ListFunctionSecretsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListFunctions` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListFunctions(ctx, id)` can be used to do batched pagination +items, err := client.ListFunctionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListHostKeys` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListHostKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListHostKeysSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListHostKeysSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListHostNameBindings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListHostNameBindings(ctx, id)` can be used to do batched pagination +items, err := client.ListHostNameBindingsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListHostNameBindingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListHostNameBindingsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListHostNameBindingsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListHybridConnections` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListHybridConnections(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListHybridConnectionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListHybridConnectionsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceFunctionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListInstanceFunctionsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceFunctionsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceIdentifiers` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListInstanceIdentifiers(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceIdentifiersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceIdentifiersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListInstanceIdentifiersSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceIdentifiersSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcessModules` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId") + +// alternatively `client.ListInstanceProcessModules(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessModulesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcessModulesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId") + +// alternatively `client.ListInstanceProcessModulesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessModulesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcessThreads` + +```go +ctx := context.TODO() +id := webapps.NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId") + +// alternatively `client.ListInstanceProcessThreads(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessThreadsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcessThreadsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId") + +// alternatively `client.ListInstanceProcessThreadsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessThreadsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcesses` + +```go +ctx := context.TODO() +id := webapps.NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId") + +// alternatively `client.ListInstanceProcesses(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceProcessesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId") + +// alternatively `client.ListInstanceProcessesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceProcessesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListInstanceWorkflowsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListInstanceWorkflowsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListInstanceWorkflowsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListMetadata` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListMetadata(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListMetadataSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListMetadataSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListNetworkFeatures` + +```go +ctx := context.TODO() +id := webapps.NewNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "networkFeatureName") + +read, err := client.ListNetworkFeatures(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListNetworkFeaturesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "networkFeatureName") + +read, err := client.ListNetworkFeaturesSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListPerfMonCounters` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListPerfMonCounters(ctx, id, webapps.DefaultListPerfMonCountersOperationOptions())` can be used to do batched pagination +items, err := client.ListPerfMonCountersComplete(ctx, id, webapps.DefaultListPerfMonCountersOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListPerfMonCountersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListPerfMonCountersSlot(ctx, id, webapps.DefaultListPerfMonCountersSlotOperationOptions())` can be used to do batched pagination +items, err := client.ListPerfMonCountersSlotComplete(ctx, id, webapps.DefaultListPerfMonCountersSlotOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListPremierAddOns` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListPremierAddOns(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListPremierAddOnsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListPremierAddOnsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListProcessModules` + +```go +ctx := context.TODO() +id := webapps.NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId") + +// alternatively `client.ListProcessModules(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessModulesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProcessModulesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId") + +// alternatively `client.ListProcessModulesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessModulesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProcessThreads` + +```go +ctx := context.TODO() +id := webapps.NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId") + +// alternatively `client.ListProcessThreads(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessThreadsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProcessThreadsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId") + +// alternatively `client.ListProcessThreadsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessThreadsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProcesses` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListProcesses(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProcessesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListProcessesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListProcessesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListProductionSiteDeploymentStatuses` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListProductionSiteDeploymentStatuses(ctx, id)` can be used to do batched pagination +items, err := client.ListProductionSiteDeploymentStatusesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListPublicCertificates` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListPublicCertificates(ctx, id)` can be used to do batched pagination +items, err := client.ListPublicCertificatesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListPublicCertificatesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListPublicCertificatesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListPublicCertificatesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListPublishingCredentials` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +if err := client.ListPublishingCredentialsThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.ListPublishingCredentialsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +if err := client.ListPublishingCredentialsSlotThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.ListPublishingProfileXmlWithSecrets` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.CsmPublishingProfileOptions{ + // ... +} + + +read, err := client.ListPublishingProfileXmlWithSecrets(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListPublishingProfileXmlWithSecretsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.CsmPublishingProfileOptions{ + // ... +} + + +read, err := client.ListPublishingProfileXmlWithSecretsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListRelayServiceConnections` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListRelayServiceConnections(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListRelayServiceConnectionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListRelayServiceConnectionsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSiteBackups` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListSiteBackups(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteBackupsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSiteBackupsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListSiteBackupsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteBackupsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSiteContainers` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListSiteContainers(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteContainersComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSiteContainersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListSiteContainersSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteContainersSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSiteExtensions` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListSiteExtensions(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteExtensionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSiteExtensionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListSiteExtensionsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSiteExtensionsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSitePushSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListSitePushSettings(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSitePushSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListSitePushSettingsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSlotConfigurationNames` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListSlotConfigurationNames(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSlotDifferencesFromProduction` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +// alternatively `client.ListSlotDifferencesFromProduction(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListSlotDifferencesFromProductionComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSlotDifferencesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +// alternatively `client.ListSlotDifferencesSlot(ctx, id, payload)` can be used to do batched pagination +items, err := client.ListSlotDifferencesSlotComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSlotSiteDeploymentStatusesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListSlotSiteDeploymentStatusesSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSlotSiteDeploymentStatusesSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSlots` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListSlots(ctx, id)` can be used to do batched pagination +items, err := client.ListSlotsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSnapshots` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListSnapshots(ctx, id)` can be used to do batched pagination +items, err := client.ListSnapshotsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSnapshotsFromDRSecondary` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListSnapshotsFromDRSecondary(ctx, id)` can be used to do batched pagination +items, err := client.ListSnapshotsFromDRSecondaryComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSnapshotsFromDRSecondarySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListSnapshotsFromDRSecondarySlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSnapshotsFromDRSecondarySlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSnapshotsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListSnapshotsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListSnapshotsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListSyncFunctionTriggers` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListSyncFunctionTriggers(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSyncFunctionTriggersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListSyncFunctionTriggersSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSyncStatus` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListSyncStatus(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListSyncStatusSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListSyncStatusSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListTriggeredWebJobHistory` + +```go +ctx := context.TODO() +id := webapps.NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName") + +// alternatively `client.ListTriggeredWebJobHistory(ctx, id)` can be used to do batched pagination +items, err := client.ListTriggeredWebJobHistoryComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListTriggeredWebJobHistorySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName") + +// alternatively `client.ListTriggeredWebJobHistorySlot(ctx, id)` can be used to do batched pagination +items, err := client.ListTriggeredWebJobHistorySlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListTriggeredWebJobs` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListTriggeredWebJobs(ctx, id)` can be used to do batched pagination +items, err := client.ListTriggeredWebJobsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListTriggeredWebJobsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListTriggeredWebJobsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListTriggeredWebJobsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListUsages` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListUsages(ctx, id, webapps.DefaultListUsagesOperationOptions())` can be used to do batched pagination +items, err := client.ListUsagesComplete(ctx, id, webapps.DefaultListUsagesOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListUsagesSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListUsagesSlot(ctx, id, webapps.DefaultListUsagesSlotOperationOptions())` can be used to do batched pagination +items, err := client.ListUsagesSlotComplete(ctx, id, webapps.DefaultListUsagesSlotOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListVnetConnections` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListVnetConnections(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListVnetConnectionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListVnetConnectionsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListWebJobs` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListWebJobs(ctx, id)` can be used to do batched pagination +items, err := client.ListWebJobsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListWebJobsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +// alternatively `client.ListWebJobsSlot(ctx, id)` can be used to do batched pagination +items, err := client.ListWebJobsSlotComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListWorkflows` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +// alternatively `client.ListWorkflows(ctx, id)` can be used to do batched pagination +items, err := client.ListWorkflowsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WebAppsClient.ListWorkflowsConnections` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ListWorkflowsConnections(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ListWorkflowsConnectionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ListWorkflowsConnectionsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.MigrateMySql` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.MigrateMySqlRequest{ + // ... +} + + +if err := client.MigrateMySqlThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.MigrateStorage` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.StorageMigrationOptions{ + // ... +} + + +if err := client.MigrateStorageThenPoll(ctx, id, payload, webapps.DefaultMigrateStorageOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.PutPrivateAccessVnet` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.PrivateAccess{ + // ... +} + + +read, err := client.PutPrivateAccessVnet(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.PutPrivateAccessVnetSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.PrivateAccess{ + // ... +} + + +read, err := client.PutPrivateAccessVnetSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.RecoverSiteConfigurationSnapshot` + +```go +ctx := context.TODO() +id := webapps.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "snapshotId") + +read, err := client.RecoverSiteConfigurationSnapshot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.RecoverSiteConfigurationSnapshotSlot` + +```go +ctx := context.TODO() +id := webapps.NewWebSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "snapshotId") + +read, err := client.RecoverSiteConfigurationSnapshotSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ResetProductionSlotConfig` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.ResetProductionSlotConfig(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.ResetSlotConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.ResetSlotConfigurationSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Restart` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.Restart(ctx, id, webapps.DefaultRestartOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.RestartSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.RestartSlot(ctx, id, webapps.DefaultRestartSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Restore` + +```go +ctx := context.TODO() +id := webapps.NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "backupId") + +payload := webapps.RestoreRequest{ + // ... +} + + +if err := client.RestoreThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreFromBackupBlob` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.RestoreRequest{ + // ... +} + + +if err := client.RestoreFromBackupBlobThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreFromBackupBlobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.RestoreRequest{ + // ... +} + + +if err := client.RestoreFromBackupBlobSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreFromDeletedApp` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.DeletedAppRestoreRequest{ + // ... +} + + +if err := client.RestoreFromDeletedAppThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreFromDeletedAppSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.DeletedAppRestoreRequest{ + // ... +} + + +if err := client.RestoreFromDeletedAppSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "backupId") + +payload := webapps.RestoreRequest{ + // ... +} + + +if err := client.RestoreSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreSnapshot` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SnapshotRestoreRequest{ + // ... +} + + +if err := client.RestoreSnapshotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RestoreSnapshotSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SnapshotRestoreRequest{ + // ... +} + + +if err := client.RestoreSnapshotSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.RunTriggeredWebJob` + +```go +ctx := context.TODO() +id := webapps.NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName") + +read, err := client.RunTriggeredWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.RunTriggeredWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName") + +read, err := client.RunTriggeredWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Start` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.Start(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StartContinuousWebJob` + +```go +ctx := context.TODO() +id := webapps.NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "continuousWebJobName") + +read, err := client.StartContinuousWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StartContinuousWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "continuousWebJobName") + +read, err := client.StartContinuousWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StartNetworkTrace` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +if err := client.StartNetworkTraceThenPoll(ctx, id, webapps.DefaultStartNetworkTraceOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.StartNetworkTraceSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +if err := client.StartNetworkTraceSlotThenPoll(ctx, id, webapps.DefaultStartNetworkTraceSlotOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.StartSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.StartSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StartWebSiteNetworkTrace` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.StartWebSiteNetworkTrace(ctx, id, webapps.DefaultStartWebSiteNetworkTraceOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StartWebSiteNetworkTraceOperation` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +if err := client.StartWebSiteNetworkTraceOperationThenPoll(ctx, id, webapps.DefaultStartWebSiteNetworkTraceOperationOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.StartWebSiteNetworkTraceOperationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +if err := client.StartWebSiteNetworkTraceOperationSlotThenPoll(ctx, id, webapps.DefaultStartWebSiteNetworkTraceOperationSlotOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.StartWebSiteNetworkTraceSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.StartWebSiteNetworkTraceSlot(ctx, id, webapps.DefaultStartWebSiteNetworkTraceSlotOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Stop` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.Stop(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopContinuousWebJob` + +```go +ctx := context.TODO() +id := webapps.NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "continuousWebJobName") + +read, err := client.StopContinuousWebJob(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopContinuousWebJobSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "continuousWebJobName") + +read, err := client.StopContinuousWebJobSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopNetworkTrace` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.StopNetworkTrace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopNetworkTraceSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.StopNetworkTraceSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.StopSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopWebSiteNetworkTrace` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.StopWebSiteNetworkTrace(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.StopWebSiteNetworkTraceSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.StopWebSiteNetworkTraceSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SwapSlotSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +if err := client.SwapSlotSlotThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.SwapSlotWithProduction` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.CsmSlotEntity{ + // ... +} + + +if err := client.SwapSlotWithProductionThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WebAppsClient.SyncFunctionTriggers` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.SyncFunctionTriggers(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SyncFunctionTriggersSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.SyncFunctionTriggersSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SyncFunctions` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.SyncFunctions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SyncFunctionsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.SyncFunctionsSlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SyncRepository` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.SyncRepository(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.SyncRepositorySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +read, err := client.SyncRepositorySlot(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.Update` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SitePatchResource{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateApplicationSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.StringDictionary{ + // ... +} + + +read, err := client.UpdateApplicationSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateApplicationSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.StringDictionary{ + // ... +} + + +read, err := client.UpdateApplicationSettingsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAuthSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SiteAuthSettings{ + // ... +} + + +read, err := client.UpdateAuthSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAuthSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SiteAuthSettings{ + // ... +} + + +read, err := client.UpdateAuthSettingsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAuthSettingsV2` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SiteAuthSettingsV2{ + // ... +} + + +read, err := client.UpdateAuthSettingsV2(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAuthSettingsV2Slot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SiteAuthSettingsV2{ + // ... +} + + +read, err := client.UpdateAuthSettingsV2Slot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAzureStorageAccounts` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.AzureStoragePropertyDictionaryResource{ + // ... +} + + +read, err := client.UpdateAzureStorageAccounts(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateAzureStorageAccountsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.AzureStoragePropertyDictionaryResource{ + // ... +} + + +read, err := client.UpdateAzureStorageAccountsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateBackupConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.UpdateBackupConfiguration(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateBackupConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.BackupRequest{ + // ... +} + + +read, err := client.UpdateBackupConfigurationSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateConfiguration` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SiteConfigResource{ + // ... +} + + +read, err := client.UpdateConfiguration(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateConfigurationSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SiteConfigResource{ + // ... +} + + +read, err := client.UpdateConfigurationSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateConnectionStrings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.ConnectionStringDictionary{ + // ... +} + + +read, err := client.UpdateConnectionStrings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateConnectionStringsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.ConnectionStringDictionary{ + // ... +} + + +read, err := client.UpdateConnectionStringsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateDiagnosticLogsConfig` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SiteLogsConfig{ + // ... +} + + +read, err := client.UpdateDiagnosticLogsConfig(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateDiagnosticLogsConfigSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SiteLogsConfig{ + // ... +} + + +read, err := client.UpdateDiagnosticLogsConfigSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateDomainOwnershipIdentifier` + +```go +ctx := context.TODO() +id := webapps.NewSiteDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "domainOwnershipIdentifierName") + +payload := webapps.Identifier{ + // ... +} + + +read, err := client.UpdateDomainOwnershipIdentifier(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateDomainOwnershipIdentifierSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "domainOwnershipIdentifierName") + +payload := webapps.Identifier{ + // ... +} + + +read, err := client.UpdateDomainOwnershipIdentifierSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateFtpAllowed` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.CsmPublishingCredentialsPoliciesEntity{ + // ... +} + + +read, err := client.UpdateFtpAllowed(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateFtpAllowedSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.CsmPublishingCredentialsPoliciesEntity{ + // ... +} + + +read, err := client.UpdateFtpAllowedSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateHybridConnection` + +```go +ctx := context.TODO() +id := webapps.NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionNamespaceName", "relayName") + +payload := webapps.HybridConnection{ + // ... +} + + +read, err := client.UpdateHybridConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateHybridConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionNamespaceName", "relayName") + +payload := webapps.HybridConnection{ + // ... +} + + +read, err := client.UpdateHybridConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateMachineKey` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +read, err := client.UpdateMachineKey(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateMetadata` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.StringDictionary{ + // ... +} + + +read, err := client.UpdateMetadata(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateMetadataSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.StringDictionary{ + // ... +} + + +read, err := client.UpdateMetadataSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdatePremierAddOn` + +```go +ctx := context.TODO() +id := webapps.NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "premierAddonName") + +payload := webapps.PremierAddOnPatchResource{ + // ... +} + + +read, err := client.UpdatePremierAddOn(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdatePremierAddOnSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "premierAddonName") + +payload := webapps.PremierAddOnPatchResource{ + // ... +} + + +read, err := client.UpdatePremierAddOnSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateRelayServiceConnection` + +```go +ctx := context.TODO() +id := webapps.NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionName") + +payload := webapps.RelayServiceConnectionEntity{ + // ... +} + + +read, err := client.UpdateRelayServiceConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateRelayServiceConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionName") + +payload := webapps.RelayServiceConnectionEntity{ + // ... +} + + +read, err := client.UpdateRelayServiceConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateScmAllowed` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.CsmPublishingCredentialsPoliciesEntity{ + // ... +} + + +read, err := client.UpdateScmAllowed(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateScmAllowedSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.CsmPublishingCredentialsPoliciesEntity{ + // ... +} + + +read, err := client.UpdateScmAllowedSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSitePushSettings` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.PushSettings{ + // ... +} + + +read, err := client.UpdateSitePushSettings(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSitePushSettingsSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.PushSettings{ + // ... +} + + +read, err := client.UpdateSitePushSettingsSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SitePatchResource{ + // ... +} + + +read, err := client.UpdateSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSlotConfigurationNames` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SlotConfigNamesResource{ + // ... +} + + +read, err := client.UpdateSlotConfigurationNames(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSourceControl` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SiteSourceControl{ + // ... +} + + +read, err := client.UpdateSourceControl(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSourceControlSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SiteSourceControl{ + // ... +} + + +read, err := client.UpdateSourceControlSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSwiftVirtualNetworkConnectionWithCheck` + +```go +ctx := context.TODO() +id := commonids.NewAppServiceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName") + +payload := webapps.SwiftVirtualNetwork{ + // ... +} + + +read, err := client.UpdateSwiftVirtualNetworkConnectionWithCheck(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateSwiftVirtualNetworkConnectionWithCheckSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + +payload := webapps.SwiftVirtualNetwork{ + // ... +} + + +read, err := client.UpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateVnetConnection` + +```go +ctx := context.TODO() +id := webapps.NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName") + +payload := webapps.VnetInfoResource{ + // ... +} + + +read, err := client.UpdateVnetConnection(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateVnetConnectionGateway` + +```go +ctx := context.TODO() +id := webapps.NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName", "gatewayName") + +payload := webapps.VnetGateway{ + // ... +} + + +read, err := client.UpdateVnetConnectionGateway(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateVnetConnectionGatewaySlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName", "gatewayName") + +payload := webapps.VnetGateway{ + // ... +} + + +read, err := client.UpdateVnetConnectionGatewaySlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WebAppsClient.UpdateVnetConnectionSlot` + +```go +ctx := context.TODO() +id := webapps.NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName") + +payload := webapps.VnetInfoResource{ + // ... +} + + +read, err := client.UpdateVnetConnectionSlot(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-11-01/webapps/client.go b/resource-manager/web/2024-11-01/webapps/client.go new file mode 100644 index 00000000000..cfd22cd9b25 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/client.go @@ -0,0 +1,26 @@ +package webapps + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebAppsClient struct { + Client *resourcemanager.Client +} + +func NewWebAppsClientWithBaseURI(sdkApi sdkEnv.Api) (*WebAppsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "webapps", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WebAppsClient: %+v", err) + } + + return &WebAppsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/webapps/constants.go b/resource-manager/web/2024-11-01/webapps/constants.go new file mode 100644 index 00000000000..53593142f69 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/constants.go @@ -0,0 +1,2819 @@ +package webapps + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthType string + +const ( + AuthTypeAnonymous AuthType = "Anonymous" + AuthTypeSystemIdentity AuthType = "SystemIdentity" + AuthTypeUserAssigned AuthType = "UserAssigned" + AuthTypeUserCredentials AuthType = "UserCredentials" +) + +func PossibleValuesForAuthType() []string { + return []string{ + string(AuthTypeAnonymous), + string(AuthTypeSystemIdentity), + string(AuthTypeUserAssigned), + string(AuthTypeUserCredentials), + } +} + +func (s *AuthType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthType(input string) (*AuthType, error) { + vals := map[string]AuthType{ + "anonymous": AuthTypeAnonymous, + "systemidentity": AuthTypeSystemIdentity, + "userassigned": AuthTypeUserAssigned, + "usercredentials": AuthTypeUserCredentials, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthType(input) + return &out, nil +} + +type AuthenticationType string + +const ( + AuthenticationTypeStorageAccountConnectionString AuthenticationType = "StorageAccountConnectionString" + AuthenticationTypeSystemAssignedIdentity AuthenticationType = "SystemAssignedIdentity" + AuthenticationTypeUserAssignedIdentity AuthenticationType = "UserAssignedIdentity" +) + +func PossibleValuesForAuthenticationType() []string { + return []string{ + string(AuthenticationTypeStorageAccountConnectionString), + string(AuthenticationTypeSystemAssignedIdentity), + string(AuthenticationTypeUserAssignedIdentity), + } +} + +func (s *AuthenticationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationType(input string) (*AuthenticationType, error) { + vals := map[string]AuthenticationType{ + "storageaccountconnectionstring": AuthenticationTypeStorageAccountConnectionString, + "systemassignedidentity": AuthenticationTypeSystemAssignedIdentity, + "userassignedidentity": AuthenticationTypeUserAssignedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationType(input) + return &out, nil +} + +type AutoGeneratedDomainNameLabelScope string + +const ( + AutoGeneratedDomainNameLabelScopeNoReuse AutoGeneratedDomainNameLabelScope = "NoReuse" + AutoGeneratedDomainNameLabelScopeResourceGroupReuse AutoGeneratedDomainNameLabelScope = "ResourceGroupReuse" + AutoGeneratedDomainNameLabelScopeSubscriptionReuse AutoGeneratedDomainNameLabelScope = "SubscriptionReuse" + AutoGeneratedDomainNameLabelScopeTenantReuse AutoGeneratedDomainNameLabelScope = "TenantReuse" +) + +func PossibleValuesForAutoGeneratedDomainNameLabelScope() []string { + return []string{ + string(AutoGeneratedDomainNameLabelScopeNoReuse), + string(AutoGeneratedDomainNameLabelScopeResourceGroupReuse), + string(AutoGeneratedDomainNameLabelScopeSubscriptionReuse), + string(AutoGeneratedDomainNameLabelScopeTenantReuse), + } +} + +func (s *AutoGeneratedDomainNameLabelScope) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoGeneratedDomainNameLabelScope(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoGeneratedDomainNameLabelScope(input string) (*AutoGeneratedDomainNameLabelScope, error) { + vals := map[string]AutoGeneratedDomainNameLabelScope{ + "noreuse": AutoGeneratedDomainNameLabelScopeNoReuse, + "resourcegroupreuse": AutoGeneratedDomainNameLabelScopeResourceGroupReuse, + "subscriptionreuse": AutoGeneratedDomainNameLabelScopeSubscriptionReuse, + "tenantreuse": AutoGeneratedDomainNameLabelScopeTenantReuse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoGeneratedDomainNameLabelScope(input) + return &out, nil +} + +type AutoHealActionType string + +const ( + AutoHealActionTypeCustomAction AutoHealActionType = "CustomAction" + AutoHealActionTypeLogEvent AutoHealActionType = "LogEvent" + AutoHealActionTypeRecycle AutoHealActionType = "Recycle" +) + +func PossibleValuesForAutoHealActionType() []string { + return []string{ + string(AutoHealActionTypeCustomAction), + string(AutoHealActionTypeLogEvent), + string(AutoHealActionTypeRecycle), + } +} + +func (s *AutoHealActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoHealActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoHealActionType(input string) (*AutoHealActionType, error) { + vals := map[string]AutoHealActionType{ + "customaction": AutoHealActionTypeCustomAction, + "logevent": AutoHealActionTypeLogEvent, + "recycle": AutoHealActionTypeRecycle, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoHealActionType(input) + return &out, nil +} + +type AzureResourceType string + +const ( + AzureResourceTypeTrafficManager AzureResourceType = "TrafficManager" + AzureResourceTypeWebsite AzureResourceType = "Website" +) + +func PossibleValuesForAzureResourceType() []string { + return []string{ + string(AzureResourceTypeTrafficManager), + string(AzureResourceTypeWebsite), + } +} + +func (s *AzureResourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureResourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureResourceType(input string) (*AzureResourceType, error) { + vals := map[string]AzureResourceType{ + "trafficmanager": AzureResourceTypeTrafficManager, + "website": AzureResourceTypeWebsite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureResourceType(input) + return &out, nil +} + +type AzureStorageProtocol string + +const ( + AzureStorageProtocolHTTP AzureStorageProtocol = "Http" + AzureStorageProtocolNfs AzureStorageProtocol = "Nfs" + AzureStorageProtocolSmb AzureStorageProtocol = "Smb" +) + +func PossibleValuesForAzureStorageProtocol() []string { + return []string{ + string(AzureStorageProtocolHTTP), + string(AzureStorageProtocolNfs), + string(AzureStorageProtocolSmb), + } +} + +func (s *AzureStorageProtocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageProtocol(input string) (*AzureStorageProtocol, error) { + vals := map[string]AzureStorageProtocol{ + "http": AzureStorageProtocolHTTP, + "nfs": AzureStorageProtocolNfs, + "smb": AzureStorageProtocolSmb, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageProtocol(input) + return &out, nil +} + +type AzureStorageState string + +const ( + AzureStorageStateInvalidCredentials AzureStorageState = "InvalidCredentials" + AzureStorageStateInvalidShare AzureStorageState = "InvalidShare" + AzureStorageStateNotValidated AzureStorageState = "NotValidated" + AzureStorageStateOk AzureStorageState = "Ok" +) + +func PossibleValuesForAzureStorageState() []string { + return []string{ + string(AzureStorageStateInvalidCredentials), + string(AzureStorageStateInvalidShare), + string(AzureStorageStateNotValidated), + string(AzureStorageStateOk), + } +} + +func (s *AzureStorageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageState(input string) (*AzureStorageState, error) { + vals := map[string]AzureStorageState{ + "invalidcredentials": AzureStorageStateInvalidCredentials, + "invalidshare": AzureStorageStateInvalidShare, + "notvalidated": AzureStorageStateNotValidated, + "ok": AzureStorageStateOk, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageState(input) + return &out, nil +} + +type AzureStorageType string + +const ( + AzureStorageTypeAzureBlob AzureStorageType = "AzureBlob" + AzureStorageTypeAzureFiles AzureStorageType = "AzureFiles" +) + +func PossibleValuesForAzureStorageType() []string { + return []string{ + string(AzureStorageTypeAzureBlob), + string(AzureStorageTypeAzureFiles), + } +} + +func (s *AzureStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureStorageType(input string) (*AzureStorageType, error) { + vals := map[string]AzureStorageType{ + "azureblob": AzureStorageTypeAzureBlob, + "azurefiles": AzureStorageTypeAzureFiles, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureStorageType(input) + return &out, nil +} + +type BackupItemStatus string + +const ( + BackupItemStatusCreated BackupItemStatus = "Created" + BackupItemStatusDeleteFailed BackupItemStatus = "DeleteFailed" + BackupItemStatusDeleteInProgress BackupItemStatus = "DeleteInProgress" + BackupItemStatusDeleted BackupItemStatus = "Deleted" + BackupItemStatusFailed BackupItemStatus = "Failed" + BackupItemStatusInProgress BackupItemStatus = "InProgress" + BackupItemStatusPartiallySucceeded BackupItemStatus = "PartiallySucceeded" + BackupItemStatusSkipped BackupItemStatus = "Skipped" + BackupItemStatusSucceeded BackupItemStatus = "Succeeded" + BackupItemStatusTimedOut BackupItemStatus = "TimedOut" +) + +func PossibleValuesForBackupItemStatus() []string { + return []string{ + string(BackupItemStatusCreated), + string(BackupItemStatusDeleteFailed), + string(BackupItemStatusDeleteInProgress), + string(BackupItemStatusDeleted), + string(BackupItemStatusFailed), + string(BackupItemStatusInProgress), + string(BackupItemStatusPartiallySucceeded), + string(BackupItemStatusSkipped), + string(BackupItemStatusSucceeded), + string(BackupItemStatusTimedOut), + } +} + +func (s *BackupItemStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupItemStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupItemStatus(input string) (*BackupItemStatus, error) { + vals := map[string]BackupItemStatus{ + "created": BackupItemStatusCreated, + "deletefailed": BackupItemStatusDeleteFailed, + "deleteinprogress": BackupItemStatusDeleteInProgress, + "deleted": BackupItemStatusDeleted, + "failed": BackupItemStatusFailed, + "inprogress": BackupItemStatusInProgress, + "partiallysucceeded": BackupItemStatusPartiallySucceeded, + "skipped": BackupItemStatusSkipped, + "succeeded": BackupItemStatusSucceeded, + "timedout": BackupItemStatusTimedOut, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupItemStatus(input) + return &out, nil +} + +type BackupRestoreOperationType string + +const ( + BackupRestoreOperationTypeClone BackupRestoreOperationType = "Clone" + BackupRestoreOperationTypeCloudFS BackupRestoreOperationType = "CloudFS" + BackupRestoreOperationTypeDefault BackupRestoreOperationType = "Default" + BackupRestoreOperationTypeRelocation BackupRestoreOperationType = "Relocation" + BackupRestoreOperationTypeSnapshot BackupRestoreOperationType = "Snapshot" +) + +func PossibleValuesForBackupRestoreOperationType() []string { + return []string{ + string(BackupRestoreOperationTypeClone), + string(BackupRestoreOperationTypeCloudFS), + string(BackupRestoreOperationTypeDefault), + string(BackupRestoreOperationTypeRelocation), + string(BackupRestoreOperationTypeSnapshot), + } +} + +func (s *BackupRestoreOperationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackupRestoreOperationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackupRestoreOperationType(input string) (*BackupRestoreOperationType, error) { + vals := map[string]BackupRestoreOperationType{ + "clone": BackupRestoreOperationTypeClone, + "cloudfs": BackupRestoreOperationTypeCloudFS, + "default": BackupRestoreOperationTypeDefault, + "relocation": BackupRestoreOperationTypeRelocation, + "snapshot": BackupRestoreOperationTypeSnapshot, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackupRestoreOperationType(input) + return &out, nil +} + +type BuiltInAuthenticationProvider string + +const ( + BuiltInAuthenticationProviderAzureActiveDirectory BuiltInAuthenticationProvider = "AzureActiveDirectory" + BuiltInAuthenticationProviderFacebook BuiltInAuthenticationProvider = "Facebook" + BuiltInAuthenticationProviderGithub BuiltInAuthenticationProvider = "Github" + BuiltInAuthenticationProviderGoogle BuiltInAuthenticationProvider = "Google" + BuiltInAuthenticationProviderMicrosoftAccount BuiltInAuthenticationProvider = "MicrosoftAccount" + BuiltInAuthenticationProviderTwitter BuiltInAuthenticationProvider = "Twitter" +) + +func PossibleValuesForBuiltInAuthenticationProvider() []string { + return []string{ + string(BuiltInAuthenticationProviderAzureActiveDirectory), + string(BuiltInAuthenticationProviderFacebook), + string(BuiltInAuthenticationProviderGithub), + string(BuiltInAuthenticationProviderGoogle), + string(BuiltInAuthenticationProviderMicrosoftAccount), + string(BuiltInAuthenticationProviderTwitter), + } +} + +func (s *BuiltInAuthenticationProvider) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBuiltInAuthenticationProvider(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBuiltInAuthenticationProvider(input string) (*BuiltInAuthenticationProvider, error) { + vals := map[string]BuiltInAuthenticationProvider{ + "azureactivedirectory": BuiltInAuthenticationProviderAzureActiveDirectory, + "facebook": BuiltInAuthenticationProviderFacebook, + "github": BuiltInAuthenticationProviderGithub, + "google": BuiltInAuthenticationProviderGoogle, + "microsoftaccount": BuiltInAuthenticationProviderMicrosoftAccount, + "twitter": BuiltInAuthenticationProviderTwitter, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BuiltInAuthenticationProvider(input) + return &out, nil +} + +type ClientCertMode string + +const ( + ClientCertModeOptional ClientCertMode = "Optional" + ClientCertModeOptionalInteractiveUser ClientCertMode = "OptionalInteractiveUser" + ClientCertModeRequired ClientCertMode = "Required" +) + +func PossibleValuesForClientCertMode() []string { + return []string{ + string(ClientCertModeOptional), + string(ClientCertModeOptionalInteractiveUser), + string(ClientCertModeRequired), + } +} + +func (s *ClientCertMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientCertMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClientCertMode(input string) (*ClientCertMode, error) { + vals := map[string]ClientCertMode{ + "optional": ClientCertModeOptional, + "optionalinteractiveuser": ClientCertModeOptionalInteractiveUser, + "required": ClientCertModeRequired, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClientCertMode(input) + return &out, nil +} + +type ClientCredentialMethod string + +const ( + ClientCredentialMethodClientSecretPost ClientCredentialMethod = "ClientSecretPost" +) + +func PossibleValuesForClientCredentialMethod() []string { + return []string{ + string(ClientCredentialMethodClientSecretPost), + } +} + +func (s *ClientCredentialMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClientCredentialMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClientCredentialMethod(input string) (*ClientCredentialMethod, error) { + vals := map[string]ClientCredentialMethod{ + "clientsecretpost": ClientCredentialMethodClientSecretPost, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClientCredentialMethod(input) + return &out, nil +} + +type CloneAbilityResult string + +const ( + CloneAbilityResultCloneable CloneAbilityResult = "Cloneable" + CloneAbilityResultNotCloneable CloneAbilityResult = "NotCloneable" + CloneAbilityResultPartiallyCloneable CloneAbilityResult = "PartiallyCloneable" +) + +func PossibleValuesForCloneAbilityResult() []string { + return []string{ + string(CloneAbilityResultCloneable), + string(CloneAbilityResultNotCloneable), + string(CloneAbilityResultPartiallyCloneable), + } +} + +func (s *CloneAbilityResult) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCloneAbilityResult(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCloneAbilityResult(input string) (*CloneAbilityResult, error) { + vals := map[string]CloneAbilityResult{ + "cloneable": CloneAbilityResultCloneable, + "notcloneable": CloneAbilityResultNotCloneable, + "partiallycloneable": CloneAbilityResultPartiallyCloneable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CloneAbilityResult(input) + return &out, nil +} + +type ConfigReferenceSource string + +const ( + ConfigReferenceSourceKeyVault ConfigReferenceSource = "KeyVault" +) + +func PossibleValuesForConfigReferenceSource() []string { + return []string{ + string(ConfigReferenceSourceKeyVault), + } +} + +func (s *ConfigReferenceSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConfigReferenceSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConfigReferenceSource(input string) (*ConfigReferenceSource, error) { + vals := map[string]ConfigReferenceSource{ + "keyvault": ConfigReferenceSourceKeyVault, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConfigReferenceSource(input) + return &out, nil +} + +type ConnectionStringType string + +const ( + ConnectionStringTypeApiHub ConnectionStringType = "ApiHub" + ConnectionStringTypeCustom ConnectionStringType = "Custom" + ConnectionStringTypeDocDb ConnectionStringType = "DocDb" + ConnectionStringTypeEventHub ConnectionStringType = "EventHub" + ConnectionStringTypeMySql ConnectionStringType = "MySql" + ConnectionStringTypeNotificationHub ConnectionStringType = "NotificationHub" + ConnectionStringTypePostgreSQL ConnectionStringType = "PostgreSQL" + ConnectionStringTypeRedisCache ConnectionStringType = "RedisCache" + ConnectionStringTypeSQLAzure ConnectionStringType = "SQLAzure" + ConnectionStringTypeSQLServer ConnectionStringType = "SQLServer" + ConnectionStringTypeServiceBus ConnectionStringType = "ServiceBus" +) + +func PossibleValuesForConnectionStringType() []string { + return []string{ + string(ConnectionStringTypeApiHub), + string(ConnectionStringTypeCustom), + string(ConnectionStringTypeDocDb), + string(ConnectionStringTypeEventHub), + string(ConnectionStringTypeMySql), + string(ConnectionStringTypeNotificationHub), + string(ConnectionStringTypePostgreSQL), + string(ConnectionStringTypeRedisCache), + string(ConnectionStringTypeSQLAzure), + string(ConnectionStringTypeSQLServer), + string(ConnectionStringTypeServiceBus), + } +} + +func (s *ConnectionStringType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionStringType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionStringType(input string) (*ConnectionStringType, error) { + vals := map[string]ConnectionStringType{ + "apihub": ConnectionStringTypeApiHub, + "custom": ConnectionStringTypeCustom, + "docdb": ConnectionStringTypeDocDb, + "eventhub": ConnectionStringTypeEventHub, + "mysql": ConnectionStringTypeMySql, + "notificationhub": ConnectionStringTypeNotificationHub, + "postgresql": ConnectionStringTypePostgreSQL, + "rediscache": ConnectionStringTypeRedisCache, + "sqlazure": ConnectionStringTypeSQLAzure, + "sqlserver": ConnectionStringTypeSQLServer, + "servicebus": ConnectionStringTypeServiceBus, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionStringType(input) + return &out, nil +} + +type ContinuousWebJobStatus string + +const ( + ContinuousWebJobStatusInitializing ContinuousWebJobStatus = "Initializing" + ContinuousWebJobStatusPendingRestart ContinuousWebJobStatus = "PendingRestart" + ContinuousWebJobStatusRunning ContinuousWebJobStatus = "Running" + ContinuousWebJobStatusStarting ContinuousWebJobStatus = "Starting" + ContinuousWebJobStatusStopped ContinuousWebJobStatus = "Stopped" +) + +func PossibleValuesForContinuousWebJobStatus() []string { + return []string{ + string(ContinuousWebJobStatusInitializing), + string(ContinuousWebJobStatusPendingRestart), + string(ContinuousWebJobStatusRunning), + string(ContinuousWebJobStatusStarting), + string(ContinuousWebJobStatusStopped), + } +} + +func (s *ContinuousWebJobStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContinuousWebJobStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseContinuousWebJobStatus(input string) (*ContinuousWebJobStatus, error) { + vals := map[string]ContinuousWebJobStatus{ + "initializing": ContinuousWebJobStatusInitializing, + "pendingrestart": ContinuousWebJobStatusPendingRestart, + "running": ContinuousWebJobStatusRunning, + "starting": ContinuousWebJobStatusStarting, + "stopped": ContinuousWebJobStatusStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ContinuousWebJobStatus(input) + return &out, nil +} + +type CookieExpirationConvention string + +const ( + CookieExpirationConventionFixedTime CookieExpirationConvention = "FixedTime" + CookieExpirationConventionIdentityProviderDerived CookieExpirationConvention = "IdentityProviderDerived" +) + +func PossibleValuesForCookieExpirationConvention() []string { + return []string{ + string(CookieExpirationConventionFixedTime), + string(CookieExpirationConventionIdentityProviderDerived), + } +} + +func (s *CookieExpirationConvention) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCookieExpirationConvention(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCookieExpirationConvention(input string) (*CookieExpirationConvention, error) { + vals := map[string]CookieExpirationConvention{ + "fixedtime": CookieExpirationConventionFixedTime, + "identityproviderderived": CookieExpirationConventionIdentityProviderDerived, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CookieExpirationConvention(input) + return &out, nil +} + +type CustomHostNameDnsRecordType string + +const ( + CustomHostNameDnsRecordTypeA CustomHostNameDnsRecordType = "A" + CustomHostNameDnsRecordTypeCName CustomHostNameDnsRecordType = "CName" +) + +func PossibleValuesForCustomHostNameDnsRecordType() []string { + return []string{ + string(CustomHostNameDnsRecordTypeA), + string(CustomHostNameDnsRecordTypeCName), + } +} + +func (s *CustomHostNameDnsRecordType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCustomHostNameDnsRecordType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCustomHostNameDnsRecordType(input string) (*CustomHostNameDnsRecordType, error) { + vals := map[string]CustomHostNameDnsRecordType{ + "a": CustomHostNameDnsRecordTypeA, + "cname": CustomHostNameDnsRecordTypeCName, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CustomHostNameDnsRecordType(input) + return &out, nil +} + +type DaprLogLevel string + +const ( + DaprLogLevelDebug DaprLogLevel = "debug" + DaprLogLevelError DaprLogLevel = "error" + DaprLogLevelInfo DaprLogLevel = "info" + DaprLogLevelWarn DaprLogLevel = "warn" +) + +func PossibleValuesForDaprLogLevel() []string { + return []string{ + string(DaprLogLevelDebug), + string(DaprLogLevelError), + string(DaprLogLevelInfo), + string(DaprLogLevelWarn), + } +} + +func (s *DaprLogLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDaprLogLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDaprLogLevel(input string) (*DaprLogLevel, error) { + vals := map[string]DaprLogLevel{ + "debug": DaprLogLevelDebug, + "error": DaprLogLevelError, + "info": DaprLogLevelInfo, + "warn": DaprLogLevelWarn, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DaprLogLevel(input) + return &out, nil +} + +type DatabaseType string + +const ( + DatabaseTypeLocalMySql DatabaseType = "LocalMySql" + DatabaseTypeMySql DatabaseType = "MySql" + DatabaseTypePostgreSql DatabaseType = "PostgreSql" + DatabaseTypeSqlAzure DatabaseType = "SqlAzure" +) + +func PossibleValuesForDatabaseType() []string { + return []string{ + string(DatabaseTypeLocalMySql), + string(DatabaseTypeMySql), + string(DatabaseTypePostgreSql), + string(DatabaseTypeSqlAzure), + } +} + +func (s *DatabaseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDatabaseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDatabaseType(input string) (*DatabaseType, error) { + vals := map[string]DatabaseType{ + "localmysql": DatabaseTypeLocalMySql, + "mysql": DatabaseTypeMySql, + "postgresql": DatabaseTypePostgreSql, + "sqlazure": DatabaseTypeSqlAzure, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DatabaseType(input) + return &out, nil +} + +type DefaultAction string + +const ( + DefaultActionAllow DefaultAction = "Allow" + DefaultActionDeny DefaultAction = "Deny" +) + +func PossibleValuesForDefaultAction() []string { + return []string{ + string(DefaultActionAllow), + string(DefaultActionDeny), + } +} + +func (s *DefaultAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDefaultAction(input string) (*DefaultAction, error) { + vals := map[string]DefaultAction{ + "allow": DefaultActionAllow, + "deny": DefaultActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DefaultAction(input) + return &out, nil +} + +type DeploymentBuildStatus string + +const ( + DeploymentBuildStatusBuildAborted DeploymentBuildStatus = "BuildAborted" + DeploymentBuildStatusBuildFailed DeploymentBuildStatus = "BuildFailed" + DeploymentBuildStatusBuildInProgress DeploymentBuildStatus = "BuildInProgress" + DeploymentBuildStatusBuildPending DeploymentBuildStatus = "BuildPending" + DeploymentBuildStatusBuildRequestReceived DeploymentBuildStatus = "BuildRequestReceived" + DeploymentBuildStatusBuildSuccessful DeploymentBuildStatus = "BuildSuccessful" + DeploymentBuildStatusPostBuildRestartRequired DeploymentBuildStatus = "PostBuildRestartRequired" + DeploymentBuildStatusRuntimeFailed DeploymentBuildStatus = "RuntimeFailed" + DeploymentBuildStatusRuntimeStarting DeploymentBuildStatus = "RuntimeStarting" + DeploymentBuildStatusRuntimeSuccessful DeploymentBuildStatus = "RuntimeSuccessful" + DeploymentBuildStatusStartPolling DeploymentBuildStatus = "StartPolling" + DeploymentBuildStatusStartPollingWithRestart DeploymentBuildStatus = "StartPollingWithRestart" + DeploymentBuildStatusTimedOut DeploymentBuildStatus = "TimedOut" +) + +func PossibleValuesForDeploymentBuildStatus() []string { + return []string{ + string(DeploymentBuildStatusBuildAborted), + string(DeploymentBuildStatusBuildFailed), + string(DeploymentBuildStatusBuildInProgress), + string(DeploymentBuildStatusBuildPending), + string(DeploymentBuildStatusBuildRequestReceived), + string(DeploymentBuildStatusBuildSuccessful), + string(DeploymentBuildStatusPostBuildRestartRequired), + string(DeploymentBuildStatusRuntimeFailed), + string(DeploymentBuildStatusRuntimeStarting), + string(DeploymentBuildStatusRuntimeSuccessful), + string(DeploymentBuildStatusStartPolling), + string(DeploymentBuildStatusStartPollingWithRestart), + string(DeploymentBuildStatusTimedOut), + } +} + +func (s *DeploymentBuildStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeploymentBuildStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeploymentBuildStatus(input string) (*DeploymentBuildStatus, error) { + vals := map[string]DeploymentBuildStatus{ + "buildaborted": DeploymentBuildStatusBuildAborted, + "buildfailed": DeploymentBuildStatusBuildFailed, + "buildinprogress": DeploymentBuildStatusBuildInProgress, + "buildpending": DeploymentBuildStatusBuildPending, + "buildrequestreceived": DeploymentBuildStatusBuildRequestReceived, + "buildsuccessful": DeploymentBuildStatusBuildSuccessful, + "postbuildrestartrequired": DeploymentBuildStatusPostBuildRestartRequired, + "runtimefailed": DeploymentBuildStatusRuntimeFailed, + "runtimestarting": DeploymentBuildStatusRuntimeStarting, + "runtimesuccessful": DeploymentBuildStatusRuntimeSuccessful, + "startpolling": DeploymentBuildStatusStartPolling, + "startpollingwithrestart": DeploymentBuildStatusStartPollingWithRestart, + "timedout": DeploymentBuildStatusTimedOut, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeploymentBuildStatus(input) + return &out, nil +} + +type DnsVerificationTestResult string + +const ( + DnsVerificationTestResultFailed DnsVerificationTestResult = "Failed" + DnsVerificationTestResultPassed DnsVerificationTestResult = "Passed" + DnsVerificationTestResultSkipped DnsVerificationTestResult = "Skipped" +) + +func PossibleValuesForDnsVerificationTestResult() []string { + return []string{ + string(DnsVerificationTestResultFailed), + string(DnsVerificationTestResultPassed), + string(DnsVerificationTestResultSkipped), + } +} + +func (s *DnsVerificationTestResult) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDnsVerificationTestResult(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDnsVerificationTestResult(input string) (*DnsVerificationTestResult, error) { + vals := map[string]DnsVerificationTestResult{ + "failed": DnsVerificationTestResultFailed, + "passed": DnsVerificationTestResultPassed, + "skipped": DnsVerificationTestResultSkipped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DnsVerificationTestResult(input) + return &out, nil +} + +type ForwardProxyConvention string + +const ( + ForwardProxyConventionCustom ForwardProxyConvention = "Custom" + ForwardProxyConventionNoProxy ForwardProxyConvention = "NoProxy" + ForwardProxyConventionStandard ForwardProxyConvention = "Standard" +) + +func PossibleValuesForForwardProxyConvention() []string { + return []string{ + string(ForwardProxyConventionCustom), + string(ForwardProxyConventionNoProxy), + string(ForwardProxyConventionStandard), + } +} + +func (s *ForwardProxyConvention) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseForwardProxyConvention(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseForwardProxyConvention(input string) (*ForwardProxyConvention, error) { + vals := map[string]ForwardProxyConvention{ + "custom": ForwardProxyConventionCustom, + "noproxy": ForwardProxyConventionNoProxy, + "standard": ForwardProxyConventionStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ForwardProxyConvention(input) + return &out, nil +} + +type FrequencyUnit string + +const ( + FrequencyUnitDay FrequencyUnit = "Day" + FrequencyUnitHour FrequencyUnit = "Hour" +) + +func PossibleValuesForFrequencyUnit() []string { + return []string{ + string(FrequencyUnitDay), + string(FrequencyUnitHour), + } +} + +func (s *FrequencyUnit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFrequencyUnit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFrequencyUnit(input string) (*FrequencyUnit, error) { + vals := map[string]FrequencyUnit{ + "day": FrequencyUnitDay, + "hour": FrequencyUnitHour, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FrequencyUnit(input) + return &out, nil +} + +type FtpsState string + +const ( + FtpsStateAllAllowed FtpsState = "AllAllowed" + FtpsStateDisabled FtpsState = "Disabled" + FtpsStateFtpsOnly FtpsState = "FtpsOnly" +) + +func PossibleValuesForFtpsState() []string { + return []string{ + string(FtpsStateAllAllowed), + string(FtpsStateDisabled), + string(FtpsStateFtpsOnly), + } +} + +func (s *FtpsState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFtpsState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFtpsState(input string) (*FtpsState, error) { + vals := map[string]FtpsState{ + "allallowed": FtpsStateAllAllowed, + "disabled": FtpsStateDisabled, + "ftpsonly": FtpsStateFtpsOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FtpsState(input) + return &out, nil +} + +type FunctionsDeploymentStorageType string + +const ( + FunctionsDeploymentStorageTypeBlobContainer FunctionsDeploymentStorageType = "blobContainer" +) + +func PossibleValuesForFunctionsDeploymentStorageType() []string { + return []string{ + string(FunctionsDeploymentStorageTypeBlobContainer), + } +} + +func (s *FunctionsDeploymentStorageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFunctionsDeploymentStorageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFunctionsDeploymentStorageType(input string) (*FunctionsDeploymentStorageType, error) { + vals := map[string]FunctionsDeploymentStorageType{ + "blobcontainer": FunctionsDeploymentStorageTypeBlobContainer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FunctionsDeploymentStorageType(input) + return &out, nil +} + +type HostNameType string + +const ( + HostNameTypeManaged HostNameType = "Managed" + HostNameTypeVerified HostNameType = "Verified" +) + +func PossibleValuesForHostNameType() []string { + return []string{ + string(HostNameTypeManaged), + string(HostNameTypeVerified), + } +} + +func (s *HostNameType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostNameType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostNameType(input string) (*HostNameType, error) { + vals := map[string]HostNameType{ + "managed": HostNameTypeManaged, + "verified": HostNameTypeVerified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostNameType(input) + return &out, nil +} + +type HostType string + +const ( + HostTypeRepository HostType = "Repository" + HostTypeStandard HostType = "Standard" +) + +func PossibleValuesForHostType() []string { + return []string{ + string(HostTypeRepository), + string(HostTypeStandard), + } +} + +func (s *HostType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseHostType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseHostType(input string) (*HostType, error) { + vals := map[string]HostType{ + "repository": HostTypeRepository, + "standard": HostTypeStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := HostType(input) + return &out, nil +} + +type IPFilterTag string + +const ( + IPFilterTagDefault IPFilterTag = "Default" + IPFilterTagServiceTag IPFilterTag = "ServiceTag" + IPFilterTagXffProxy IPFilterTag = "XffProxy" +) + +func PossibleValuesForIPFilterTag() []string { + return []string{ + string(IPFilterTagDefault), + string(IPFilterTagServiceTag), + string(IPFilterTagXffProxy), + } +} + +func (s *IPFilterTag) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFilterTag(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPFilterTag(input string) (*IPFilterTag, error) { + vals := map[string]IPFilterTag{ + "default": IPFilterTagDefault, + "servicetag": IPFilterTagServiceTag, + "xffproxy": IPFilterTagXffProxy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPFilterTag(input) + return &out, nil +} + +type IPMode string + +const ( + IPModeIPvFour IPMode = "IPv4" + IPModeIPvFourAndIPvSix IPMode = "IPv4AndIPv6" + IPModeIPvSix IPMode = "IPv6" +) + +func PossibleValuesForIPMode() []string { + return []string{ + string(IPModeIPvFour), + string(IPModeIPvFourAndIPvSix), + string(IPModeIPvSix), + } +} + +func (s *IPMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPMode(input string) (*IPMode, error) { + vals := map[string]IPMode{ + "ipv4": IPModeIPvFour, + "ipv4andipv6": IPModeIPvFourAndIPvSix, + "ipv6": IPModeIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPMode(input) + return &out, nil +} + +type LogLevel string + +const ( + LogLevelError LogLevel = "Error" + LogLevelInformation LogLevel = "Information" + LogLevelOff LogLevel = "Off" + LogLevelVerbose LogLevel = "Verbose" + LogLevelWarning LogLevel = "Warning" +) + +func PossibleValuesForLogLevel() []string { + return []string{ + string(LogLevelError), + string(LogLevelInformation), + string(LogLevelOff), + string(LogLevelVerbose), + string(LogLevelWarning), + } +} + +func (s *LogLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLogLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLogLevel(input string) (*LogLevel, error) { + vals := map[string]LogLevel{ + "error": LogLevelError, + "information": LogLevelInformation, + "off": LogLevelOff, + "verbose": LogLevelVerbose, + "warning": LogLevelWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LogLevel(input) + return &out, nil +} + +type MSDeployLogEntryType string + +const ( + MSDeployLogEntryTypeError MSDeployLogEntryType = "Error" + MSDeployLogEntryTypeMessage MSDeployLogEntryType = "Message" + MSDeployLogEntryTypeWarning MSDeployLogEntryType = "Warning" +) + +func PossibleValuesForMSDeployLogEntryType() []string { + return []string{ + string(MSDeployLogEntryTypeError), + string(MSDeployLogEntryTypeMessage), + string(MSDeployLogEntryTypeWarning), + } +} + +func (s *MSDeployLogEntryType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMSDeployLogEntryType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMSDeployLogEntryType(input string) (*MSDeployLogEntryType, error) { + vals := map[string]MSDeployLogEntryType{ + "error": MSDeployLogEntryTypeError, + "message": MSDeployLogEntryTypeMessage, + "warning": MSDeployLogEntryTypeWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MSDeployLogEntryType(input) + return &out, nil +} + +type MSDeployProvisioningState string + +const ( + MSDeployProvisioningStateAccepted MSDeployProvisioningState = "accepted" + MSDeployProvisioningStateCanceled MSDeployProvisioningState = "canceled" + MSDeployProvisioningStateFailed MSDeployProvisioningState = "failed" + MSDeployProvisioningStateRunning MSDeployProvisioningState = "running" + MSDeployProvisioningStateSucceeded MSDeployProvisioningState = "succeeded" +) + +func PossibleValuesForMSDeployProvisioningState() []string { + return []string{ + string(MSDeployProvisioningStateAccepted), + string(MSDeployProvisioningStateCanceled), + string(MSDeployProvisioningStateFailed), + string(MSDeployProvisioningStateRunning), + string(MSDeployProvisioningStateSucceeded), + } +} + +func (s *MSDeployProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMSDeployProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMSDeployProvisioningState(input string) (*MSDeployProvisioningState, error) { + vals := map[string]MSDeployProvisioningState{ + "accepted": MSDeployProvisioningStateAccepted, + "canceled": MSDeployProvisioningStateCanceled, + "failed": MSDeployProvisioningStateFailed, + "running": MSDeployProvisioningStateRunning, + "succeeded": MSDeployProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MSDeployProvisioningState(input) + return &out, nil +} + +type ManagedPipelineMode string + +const ( + ManagedPipelineModeClassic ManagedPipelineMode = "Classic" + ManagedPipelineModeIntegrated ManagedPipelineMode = "Integrated" +) + +func PossibleValuesForManagedPipelineMode() []string { + return []string{ + string(ManagedPipelineModeClassic), + string(ManagedPipelineModeIntegrated), + } +} + +func (s *ManagedPipelineMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedPipelineMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedPipelineMode(input string) (*ManagedPipelineMode, error) { + vals := map[string]ManagedPipelineMode{ + "classic": ManagedPipelineModeClassic, + "integrated": ManagedPipelineModeIntegrated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedPipelineMode(input) + return &out, nil +} + +type MySqlMigrationType string + +const ( + MySqlMigrationTypeLocalToRemote MySqlMigrationType = "LocalToRemote" + MySqlMigrationTypeRemoteToLocal MySqlMigrationType = "RemoteToLocal" +) + +func PossibleValuesForMySqlMigrationType() []string { + return []string{ + string(MySqlMigrationTypeLocalToRemote), + string(MySqlMigrationTypeRemoteToLocal), + } +} + +func (s *MySqlMigrationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMySqlMigrationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMySqlMigrationType(input string) (*MySqlMigrationType, error) { + vals := map[string]MySqlMigrationType{ + "localtoremote": MySqlMigrationTypeLocalToRemote, + "remotetolocal": MySqlMigrationTypeRemoteToLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MySqlMigrationType(input) + return &out, nil +} + +type OperationStatus string + +const ( + OperationStatusCreated OperationStatus = "Created" + OperationStatusFailed OperationStatus = "Failed" + OperationStatusInProgress OperationStatus = "InProgress" + OperationStatusSucceeded OperationStatus = "Succeeded" + OperationStatusTimedOut OperationStatus = "TimedOut" +) + +func PossibleValuesForOperationStatus() []string { + return []string{ + string(OperationStatusCreated), + string(OperationStatusFailed), + string(OperationStatusInProgress), + string(OperationStatusSucceeded), + string(OperationStatusTimedOut), + } +} + +func (s *OperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperationStatus(input string) (*OperationStatus, error) { + vals := map[string]OperationStatus{ + "created": OperationStatusCreated, + "failed": OperationStatusFailed, + "inprogress": OperationStatusInProgress, + "succeeded": OperationStatusSucceeded, + "timedout": OperationStatusTimedOut, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationStatus(input) + return &out, nil +} + +type PublicCertificateLocation string + +const ( + PublicCertificateLocationCurrentUserMy PublicCertificateLocation = "CurrentUserMy" + PublicCertificateLocationLocalMachineMy PublicCertificateLocation = "LocalMachineMy" + PublicCertificateLocationUnknown PublicCertificateLocation = "Unknown" +) + +func PossibleValuesForPublicCertificateLocation() []string { + return []string{ + string(PublicCertificateLocationCurrentUserMy), + string(PublicCertificateLocationLocalMachineMy), + string(PublicCertificateLocationUnknown), + } +} + +func (s *PublicCertificateLocation) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicCertificateLocation(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicCertificateLocation(input string) (*PublicCertificateLocation, error) { + vals := map[string]PublicCertificateLocation{ + "currentusermy": PublicCertificateLocationCurrentUserMy, + "localmachinemy": PublicCertificateLocationLocalMachineMy, + "unknown": PublicCertificateLocationUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicCertificateLocation(input) + return &out, nil +} + +type PublishingProfileFormat string + +const ( + PublishingProfileFormatFileZillaThree PublishingProfileFormat = "FileZilla3" + PublishingProfileFormatFtp PublishingProfileFormat = "Ftp" + PublishingProfileFormatWebDeploy PublishingProfileFormat = "WebDeploy" +) + +func PossibleValuesForPublishingProfileFormat() []string { + return []string{ + string(PublishingProfileFormatFileZillaThree), + string(PublishingProfileFormatFtp), + string(PublishingProfileFormatWebDeploy), + } +} + +func (s *PublishingProfileFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublishingProfileFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublishingProfileFormat(input string) (*PublishingProfileFormat, error) { + vals := map[string]PublishingProfileFormat{ + "filezilla3": PublishingProfileFormatFileZillaThree, + "ftp": PublishingProfileFormatFtp, + "webdeploy": PublishingProfileFormatWebDeploy, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublishingProfileFormat(input) + return &out, nil +} + +type RedundancyMode string + +const ( + RedundancyModeActiveActive RedundancyMode = "ActiveActive" + RedundancyModeFailover RedundancyMode = "Failover" + RedundancyModeGeoRedundant RedundancyMode = "GeoRedundant" + RedundancyModeManual RedundancyMode = "Manual" + RedundancyModeNone RedundancyMode = "None" +) + +func PossibleValuesForRedundancyMode() []string { + return []string{ + string(RedundancyModeActiveActive), + string(RedundancyModeFailover), + string(RedundancyModeGeoRedundant), + string(RedundancyModeManual), + string(RedundancyModeNone), + } +} + +func (s *RedundancyMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRedundancyMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRedundancyMode(input string) (*RedundancyMode, error) { + vals := map[string]RedundancyMode{ + "activeactive": RedundancyModeActiveActive, + "failover": RedundancyModeFailover, + "georedundant": RedundancyModeGeoRedundant, + "manual": RedundancyModeManual, + "none": RedundancyModeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RedundancyMode(input) + return &out, nil +} + +type ResolveStatus string + +const ( + ResolveStatusAccessToKeyVaultDenied ResolveStatus = "AccessToKeyVaultDenied" + ResolveStatusFetchTimedOut ResolveStatus = "FetchTimedOut" + ResolveStatusInitialized ResolveStatus = "Initialized" + ResolveStatusInvalidSyntax ResolveStatus = "InvalidSyntax" + ResolveStatusMSINotEnabled ResolveStatus = "MSINotEnabled" + ResolveStatusOtherReasons ResolveStatus = "OtherReasons" + ResolveStatusResolved ResolveStatus = "Resolved" + ResolveStatusSecretNotFound ResolveStatus = "SecretNotFound" + ResolveStatusSecretVersionNotFound ResolveStatus = "SecretVersionNotFound" + ResolveStatusUnauthorizedClient ResolveStatus = "UnauthorizedClient" + ResolveStatusVaultNotFound ResolveStatus = "VaultNotFound" +) + +func PossibleValuesForResolveStatus() []string { + return []string{ + string(ResolveStatusAccessToKeyVaultDenied), + string(ResolveStatusFetchTimedOut), + string(ResolveStatusInitialized), + string(ResolveStatusInvalidSyntax), + string(ResolveStatusMSINotEnabled), + string(ResolveStatusOtherReasons), + string(ResolveStatusResolved), + string(ResolveStatusSecretNotFound), + string(ResolveStatusSecretVersionNotFound), + string(ResolveStatusUnauthorizedClient), + string(ResolveStatusVaultNotFound), + } +} + +func (s *ResolveStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseResolveStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseResolveStatus(input string) (*ResolveStatus, error) { + vals := map[string]ResolveStatus{ + "accesstokeyvaultdenied": ResolveStatusAccessToKeyVaultDenied, + "fetchtimedout": ResolveStatusFetchTimedOut, + "initialized": ResolveStatusInitialized, + "invalidsyntax": ResolveStatusInvalidSyntax, + "msinotenabled": ResolveStatusMSINotEnabled, + "otherreasons": ResolveStatusOtherReasons, + "resolved": ResolveStatusResolved, + "secretnotfound": ResolveStatusSecretNotFound, + "secretversionnotfound": ResolveStatusSecretVersionNotFound, + "unauthorizedclient": ResolveStatusUnauthorizedClient, + "vaultnotfound": ResolveStatusVaultNotFound, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ResolveStatus(input) + return &out, nil +} + +type RouteType string + +const ( + RouteTypeDefault RouteType = "DEFAULT" + RouteTypeINHERITED RouteType = "INHERITED" + RouteTypeSTATIC RouteType = "STATIC" +) + +func PossibleValuesForRouteType() []string { + return []string{ + string(RouteTypeDefault), + string(RouteTypeINHERITED), + string(RouteTypeSTATIC), + } +} + +func (s *RouteType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRouteType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRouteType(input string) (*RouteType, error) { + vals := map[string]RouteType{ + "default": RouteTypeDefault, + "inherited": RouteTypeINHERITED, + "static": RouteTypeSTATIC, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RouteType(input) + return &out, nil +} + +type RuntimeName string + +const ( + RuntimeNameCustom RuntimeName = "custom" + RuntimeNameDotnetNegativeisolated RuntimeName = "dotnet-isolated" + RuntimeNameJava RuntimeName = "java" + RuntimeNameNode RuntimeName = "node" + RuntimeNamePowershell RuntimeName = "powershell" + RuntimeNamePython RuntimeName = "python" +) + +func PossibleValuesForRuntimeName() []string { + return []string{ + string(RuntimeNameCustom), + string(RuntimeNameDotnetNegativeisolated), + string(RuntimeNameJava), + string(RuntimeNameNode), + string(RuntimeNamePowershell), + string(RuntimeNamePython), + } +} + +func (s *RuntimeName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuntimeName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuntimeName(input string) (*RuntimeName, error) { + vals := map[string]RuntimeName{ + "custom": RuntimeNameCustom, + "dotnet-isolated": RuntimeNameDotnetNegativeisolated, + "java": RuntimeNameJava, + "node": RuntimeNameNode, + "powershell": RuntimeNamePowershell, + "python": RuntimeNamePython, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuntimeName(input) + return &out, nil +} + +type ScmType string + +const ( + ScmTypeBitbucketGit ScmType = "BitbucketGit" + ScmTypeBitbucketHg ScmType = "BitbucketHg" + ScmTypeCodePlexGit ScmType = "CodePlexGit" + ScmTypeCodePlexHg ScmType = "CodePlexHg" + ScmTypeDropbox ScmType = "Dropbox" + ScmTypeExternalGit ScmType = "ExternalGit" + ScmTypeExternalHg ScmType = "ExternalHg" + ScmTypeGitHub ScmType = "GitHub" + ScmTypeLocalGit ScmType = "LocalGit" + ScmTypeNone ScmType = "None" + ScmTypeOneDrive ScmType = "OneDrive" + ScmTypeTfs ScmType = "Tfs" + ScmTypeVSO ScmType = "VSO" + ScmTypeVSTSRM ScmType = "VSTSRM" +) + +func PossibleValuesForScmType() []string { + return []string{ + string(ScmTypeBitbucketGit), + string(ScmTypeBitbucketHg), + string(ScmTypeCodePlexGit), + string(ScmTypeCodePlexHg), + string(ScmTypeDropbox), + string(ScmTypeExternalGit), + string(ScmTypeExternalHg), + string(ScmTypeGitHub), + string(ScmTypeLocalGit), + string(ScmTypeNone), + string(ScmTypeOneDrive), + string(ScmTypeTfs), + string(ScmTypeVSO), + string(ScmTypeVSTSRM), + } +} + +func (s *ScmType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScmType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScmType(input string) (*ScmType, error) { + vals := map[string]ScmType{ + "bitbucketgit": ScmTypeBitbucketGit, + "bitbuckethg": ScmTypeBitbucketHg, + "codeplexgit": ScmTypeCodePlexGit, + "codeplexhg": ScmTypeCodePlexHg, + "dropbox": ScmTypeDropbox, + "externalgit": ScmTypeExternalGit, + "externalhg": ScmTypeExternalHg, + "github": ScmTypeGitHub, + "localgit": ScmTypeLocalGit, + "none": ScmTypeNone, + "onedrive": ScmTypeOneDrive, + "tfs": ScmTypeTfs, + "vso": ScmTypeVSO, + "vstsrm": ScmTypeVSTSRM, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScmType(input) + return &out, nil +} + +type SiteAvailabilityState string + +const ( + SiteAvailabilityStateDisasterRecoveryMode SiteAvailabilityState = "DisasterRecoveryMode" + SiteAvailabilityStateLimited SiteAvailabilityState = "Limited" + SiteAvailabilityStateNormal SiteAvailabilityState = "Normal" +) + +func PossibleValuesForSiteAvailabilityState() []string { + return []string{ + string(SiteAvailabilityStateDisasterRecoveryMode), + string(SiteAvailabilityStateLimited), + string(SiteAvailabilityStateNormal), + } +} + +func (s *SiteAvailabilityState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteAvailabilityState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteAvailabilityState(input string) (*SiteAvailabilityState, error) { + vals := map[string]SiteAvailabilityState{ + "disasterrecoverymode": SiteAvailabilityStateDisasterRecoveryMode, + "limited": SiteAvailabilityStateLimited, + "normal": SiteAvailabilityStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteAvailabilityState(input) + return &out, nil +} + +type SiteExtensionType string + +const ( + SiteExtensionTypeGallery SiteExtensionType = "Gallery" + SiteExtensionTypeWebRoot SiteExtensionType = "WebRoot" +) + +func PossibleValuesForSiteExtensionType() []string { + return []string{ + string(SiteExtensionTypeGallery), + string(SiteExtensionTypeWebRoot), + } +} + +func (s *SiteExtensionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteExtensionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteExtensionType(input string) (*SiteExtensionType, error) { + vals := map[string]SiteExtensionType{ + "gallery": SiteExtensionTypeGallery, + "webroot": SiteExtensionTypeWebRoot, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteExtensionType(input) + return &out, nil +} + +type SiteLoadBalancing string + +const ( + SiteLoadBalancingLeastRequests SiteLoadBalancing = "LeastRequests" + SiteLoadBalancingLeastRequestsWithTieBreaker SiteLoadBalancing = "LeastRequestsWithTieBreaker" + SiteLoadBalancingLeastResponseTime SiteLoadBalancing = "LeastResponseTime" + SiteLoadBalancingPerSiteRoundRobin SiteLoadBalancing = "PerSiteRoundRobin" + SiteLoadBalancingRequestHash SiteLoadBalancing = "RequestHash" + SiteLoadBalancingWeightedRoundRobin SiteLoadBalancing = "WeightedRoundRobin" + SiteLoadBalancingWeightedTotalTraffic SiteLoadBalancing = "WeightedTotalTraffic" +) + +func PossibleValuesForSiteLoadBalancing() []string { + return []string{ + string(SiteLoadBalancingLeastRequests), + string(SiteLoadBalancingLeastRequestsWithTieBreaker), + string(SiteLoadBalancingLeastResponseTime), + string(SiteLoadBalancingPerSiteRoundRobin), + string(SiteLoadBalancingRequestHash), + string(SiteLoadBalancingWeightedRoundRobin), + string(SiteLoadBalancingWeightedTotalTraffic), + } +} + +func (s *SiteLoadBalancing) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteLoadBalancing(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteLoadBalancing(input string) (*SiteLoadBalancing, error) { + vals := map[string]SiteLoadBalancing{ + "leastrequests": SiteLoadBalancingLeastRequests, + "leastrequestswithtiebreaker": SiteLoadBalancingLeastRequestsWithTieBreaker, + "leastresponsetime": SiteLoadBalancingLeastResponseTime, + "persiteroundrobin": SiteLoadBalancingPerSiteRoundRobin, + "requesthash": SiteLoadBalancingRequestHash, + "weightedroundrobin": SiteLoadBalancingWeightedRoundRobin, + "weightedtotaltraffic": SiteLoadBalancingWeightedTotalTraffic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteLoadBalancing(input) + return &out, nil +} + +type SiteRuntimeState string + +const ( + SiteRuntimeStateREADY SiteRuntimeState = "READY" + SiteRuntimeStateSTOPPED SiteRuntimeState = "STOPPED" + SiteRuntimeStateUNKNOWN SiteRuntimeState = "UNKNOWN" +) + +func PossibleValuesForSiteRuntimeState() []string { + return []string{ + string(SiteRuntimeStateREADY), + string(SiteRuntimeStateSTOPPED), + string(SiteRuntimeStateUNKNOWN), + } +} + +func (s *SiteRuntimeState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSiteRuntimeState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSiteRuntimeState(input string) (*SiteRuntimeState, error) { + vals := map[string]SiteRuntimeState{ + "ready": SiteRuntimeStateREADY, + "stopped": SiteRuntimeStateSTOPPED, + "unknown": SiteRuntimeStateUNKNOWN, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SiteRuntimeState(input) + return &out, nil +} + +type SslState string + +const ( + SslStateDisabled SslState = "Disabled" + SslStateIPBasedEnabled SslState = "IpBasedEnabled" + SslStateSniEnabled SslState = "SniEnabled" +) + +func PossibleValuesForSslState() []string { + return []string{ + string(SslStateDisabled), + string(SslStateIPBasedEnabled), + string(SslStateSniEnabled), + } +} + +func (s *SslState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSslState(input string) (*SslState, error) { + vals := map[string]SslState{ + "disabled": SslStateDisabled, + "ipbasedenabled": SslStateIPBasedEnabled, + "snienabled": SslStateSniEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SslState(input) + return &out, nil +} + +type SupportedTlsVersions string + +const ( + SupportedTlsVersionsOnePointOne SupportedTlsVersions = "1.1" + SupportedTlsVersionsOnePointThree SupportedTlsVersions = "1.3" + SupportedTlsVersionsOnePointTwo SupportedTlsVersions = "1.2" + SupportedTlsVersionsOnePointZero SupportedTlsVersions = "1.0" +) + +func PossibleValuesForSupportedTlsVersions() []string { + return []string{ + string(SupportedTlsVersionsOnePointOne), + string(SupportedTlsVersionsOnePointThree), + string(SupportedTlsVersionsOnePointTwo), + string(SupportedTlsVersionsOnePointZero), + } +} + +func (s *SupportedTlsVersions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSupportedTlsVersions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSupportedTlsVersions(input string) (*SupportedTlsVersions, error) { + vals := map[string]SupportedTlsVersions{ + "1.1": SupportedTlsVersionsOnePointOne, + "1.3": SupportedTlsVersionsOnePointThree, + "1.2": SupportedTlsVersionsOnePointTwo, + "1.0": SupportedTlsVersionsOnePointZero, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SupportedTlsVersions(input) + return &out, nil +} + +type TlsCipherSuites string + +const ( + TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_AES_128_GCM_SHA256" + TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" + TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_128_GCM_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix TlsCipherSuites = "TLS_RSA_WITH_AES_256_CBC_SHA256" + TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour TlsCipherSuites = "TLS_RSA_WITH_AES_256_GCM_SHA384" +) + +func PossibleValuesForTlsCipherSuites() []string { + return []string{ + string(TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour), + string(TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix), + string(TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour), + } +} + +func (s *TlsCipherSuites) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTlsCipherSuites(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTlsCipherSuites(input string) (*TlsCipherSuites, error) { + vals := map[string]TlsCipherSuites{ + "tls_aes_128_gcm_sha256": TlsCipherSuitesTLSAESOneTwoEightGCMSHATwoFiveSix, + "tls_aes_256_gcm_sha384": TlsCipherSuitesTLSAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_ecdsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHEECDSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_ecdsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHEECDSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHA, + "tls_ecdhe_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSECDHERSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_ecdhe_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHA, + "tls_ecdhe_rsa_with_aes_256_cbc_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixCBCSHAThreeEightFour, + "tls_ecdhe_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSECDHERSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + "tls_rsa_with_aes_128_cbc_sha": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHA, + "tls_rsa_with_aes_128_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightCBCSHATwoFiveSix, + "tls_rsa_with_aes_128_gcm_sha256": TlsCipherSuitesTLSRSAWITHAESOneTwoEightGCMSHATwoFiveSix, + "tls_rsa_with_aes_256_cbc_sha": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHA, + "tls_rsa_with_aes_256_cbc_sha256": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixCBCSHATwoFiveSix, + "tls_rsa_with_aes_256_gcm_sha384": TlsCipherSuitesTLSRSAWITHAESTwoFiveSixGCMSHAThreeEightFour, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TlsCipherSuites(input) + return &out, nil +} + +type TriggeredWebJobStatus string + +const ( + TriggeredWebJobStatusError TriggeredWebJobStatus = "Error" + TriggeredWebJobStatusFailed TriggeredWebJobStatus = "Failed" + TriggeredWebJobStatusSuccess TriggeredWebJobStatus = "Success" +) + +func PossibleValuesForTriggeredWebJobStatus() []string { + return []string{ + string(TriggeredWebJobStatusError), + string(TriggeredWebJobStatusFailed), + string(TriggeredWebJobStatusSuccess), + } +} + +func (s *TriggeredWebJobStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTriggeredWebJobStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTriggeredWebJobStatus(input string) (*TriggeredWebJobStatus, error) { + vals := map[string]TriggeredWebJobStatus{ + "error": TriggeredWebJobStatusError, + "failed": TriggeredWebJobStatusFailed, + "success": TriggeredWebJobStatusSuccess, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TriggeredWebJobStatus(input) + return &out, nil +} + +type UnauthenticatedClientAction string + +const ( + UnauthenticatedClientActionAllowAnonymous UnauthenticatedClientAction = "AllowAnonymous" + UnauthenticatedClientActionRedirectToLoginPage UnauthenticatedClientAction = "RedirectToLoginPage" +) + +func PossibleValuesForUnauthenticatedClientAction() []string { + return []string{ + string(UnauthenticatedClientActionAllowAnonymous), + string(UnauthenticatedClientActionRedirectToLoginPage), + } +} + +func (s *UnauthenticatedClientAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUnauthenticatedClientAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUnauthenticatedClientAction(input string) (*UnauthenticatedClientAction, error) { + vals := map[string]UnauthenticatedClientAction{ + "allowanonymous": UnauthenticatedClientActionAllowAnonymous, + "redirecttologinpage": UnauthenticatedClientActionRedirectToLoginPage, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UnauthenticatedClientAction(input) + return &out, nil +} + +type UnauthenticatedClientActionV2 string + +const ( + UnauthenticatedClientActionV2AllowAnonymous UnauthenticatedClientActionV2 = "AllowAnonymous" + UnauthenticatedClientActionV2RedirectToLoginPage UnauthenticatedClientActionV2 = "RedirectToLoginPage" + UnauthenticatedClientActionV2ReturnFourZeroOne UnauthenticatedClientActionV2 = "Return401" + UnauthenticatedClientActionV2ReturnFourZeroThree UnauthenticatedClientActionV2 = "Return403" +) + +func PossibleValuesForUnauthenticatedClientActionV2() []string { + return []string{ + string(UnauthenticatedClientActionV2AllowAnonymous), + string(UnauthenticatedClientActionV2RedirectToLoginPage), + string(UnauthenticatedClientActionV2ReturnFourZeroOne), + string(UnauthenticatedClientActionV2ReturnFourZeroThree), + } +} + +func (s *UnauthenticatedClientActionV2) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUnauthenticatedClientActionV2(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUnauthenticatedClientActionV2(input string) (*UnauthenticatedClientActionV2, error) { + vals := map[string]UnauthenticatedClientActionV2{ + "allowanonymous": UnauthenticatedClientActionV2AllowAnonymous, + "redirecttologinpage": UnauthenticatedClientActionV2RedirectToLoginPage, + "return401": UnauthenticatedClientActionV2ReturnFourZeroOne, + "return403": UnauthenticatedClientActionV2ReturnFourZeroThree, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UnauthenticatedClientActionV2(input) + return &out, nil +} + +type UsageState string + +const ( + UsageStateExceeded UsageState = "Exceeded" + UsageStateNormal UsageState = "Normal" +) + +func PossibleValuesForUsageState() []string { + return []string{ + string(UsageStateExceeded), + string(UsageStateNormal), + } +} + +func (s *UsageState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUsageState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUsageState(input string) (*UsageState, error) { + vals := map[string]UsageState{ + "exceeded": UsageStateExceeded, + "normal": UsageStateNormal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UsageState(input) + return &out, nil +} + +type WebJobType string + +const ( + WebJobTypeContinuous WebJobType = "Continuous" + WebJobTypeTriggered WebJobType = "Triggered" +) + +func PossibleValuesForWebJobType() []string { + return []string{ + string(WebJobTypeContinuous), + string(WebJobTypeTriggered), + } +} + +func (s *WebJobType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebJobType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebJobType(input string) (*WebJobType, error) { + vals := map[string]WebJobType{ + "continuous": WebJobTypeContinuous, + "triggered": WebJobTypeTriggered, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebJobType(input) + return &out, nil +} + +type WorkflowHealthState string + +const ( + WorkflowHealthStateHealthy WorkflowHealthState = "Healthy" + WorkflowHealthStateNotSpecified WorkflowHealthState = "NotSpecified" + WorkflowHealthStateUnhealthy WorkflowHealthState = "Unhealthy" + WorkflowHealthStateUnknown WorkflowHealthState = "Unknown" +) + +func PossibleValuesForWorkflowHealthState() []string { + return []string{ + string(WorkflowHealthStateHealthy), + string(WorkflowHealthStateNotSpecified), + string(WorkflowHealthStateUnhealthy), + string(WorkflowHealthStateUnknown), + } +} + +func (s *WorkflowHealthState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowHealthState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowHealthState(input string) (*WorkflowHealthState, error) { + vals := map[string]WorkflowHealthState{ + "healthy": WorkflowHealthStateHealthy, + "notspecified": WorkflowHealthStateNotSpecified, + "unhealthy": WorkflowHealthStateUnhealthy, + "unknown": WorkflowHealthStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowHealthState(input) + return &out, nil +} + +type WorkflowState string + +const ( + WorkflowStateCompleted WorkflowState = "Completed" + WorkflowStateDeleted WorkflowState = "Deleted" + WorkflowStateDisabled WorkflowState = "Disabled" + WorkflowStateEnabled WorkflowState = "Enabled" + WorkflowStateNotSpecified WorkflowState = "NotSpecified" + WorkflowStateSuspended WorkflowState = "Suspended" +) + +func PossibleValuesForWorkflowState() []string { + return []string{ + string(WorkflowStateCompleted), + string(WorkflowStateDeleted), + string(WorkflowStateDisabled), + string(WorkflowStateEnabled), + string(WorkflowStateNotSpecified), + string(WorkflowStateSuspended), + } +} + +func (s *WorkflowState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowState(input string) (*WorkflowState, error) { + vals := map[string]WorkflowState{ + "completed": WorkflowStateCompleted, + "deleted": WorkflowStateDeleted, + "disabled": WorkflowStateDisabled, + "enabled": WorkflowStateEnabled, + "notspecified": WorkflowStateNotSpecified, + "suspended": WorkflowStateSuspended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowState(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/webapps/id_appsetting.go b/resource-manager/web/2024-11-01/webapps/id_appsetting.go new file mode 100644 index 00000000000..ecd9386b62d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_appsetting.go @@ -0,0 +1,141 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AppSettingId{}) +} + +var _ resourceids.ResourceId = &AppSettingId{} + +// AppSettingId is a struct representing the Resource ID for a App Setting +type AppSettingId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + AppSettingKey string +} + +// NewAppSettingID returns a new AppSettingId struct +func NewAppSettingID(subscriptionId string, resourceGroupName string, siteName string, appSettingKey string) AppSettingId { + return AppSettingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + AppSettingKey: appSettingKey, + } +} + +// ParseAppSettingID parses 'input' into a AppSettingId +func ParseAppSettingID(input string) (*AppSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&AppSettingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AppSettingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAppSettingIDInsensitively parses 'input' case-insensitively into a AppSettingId +// note: this method should only be used for API response data and not user input +func ParseAppSettingIDInsensitively(input string) (*AppSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&AppSettingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AppSettingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AppSettingId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.AppSettingKey, ok = input.Parsed["appSettingKey"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "appSettingKey", input) + } + + return nil +} + +// ValidateAppSettingID checks that 'input' can be parsed as a App Setting ID +func ValidateAppSettingID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseAppSettingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted App Setting ID +func (id AppSettingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/config/configReferences/appSettings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.AppSettingKey) +} + +// Segments returns a slice of Resource ID Segments which comprise this App Setting ID +func (id AppSettingId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticConfigReferences", "configReferences", "configReferences"), + resourceids.StaticSegment("staticAppSettings", "appSettings", "appSettings"), + resourceids.UserSpecifiedSegment("appSettingKey", "appSettingKey"), + } +} + +// String returns a human-readable description of this App Setting ID +func (id AppSettingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("App Setting Key: %q", id.AppSettingKey), + } + return fmt.Sprintf("App Setting (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_appsetting_test.go b/resource-manager/web/2024-11-01/webapps/id_appsetting_test.go new file mode 100644 index 00000000000..b7bbe12fe12 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_appsetting_test.go @@ -0,0 +1,357 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AppSettingId{} + +func TestNewAppSettingID(t *testing.T) { + id := NewAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "appSettingKey") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.AppSettingKey != "appSettingKey" { + t.Fatalf("Expected %q but got %q for Segment 'AppSettingKey'", id.AppSettingKey, "appSettingKey") + } +} + +func TestFormatAppSettingID(t *testing.T) { + actual := NewAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "appSettingKey").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/appSettings/appSettingKey" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAppSettingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AppSettingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/appSettings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/appSettings/appSettingKey", + Expected: &AppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + AppSettingKey: "appSettingKey", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/appSettings/appSettingKey/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAppSettingID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.AppSettingKey != v.Expected.AppSettingKey { + t.Fatalf("Expected %q but got %q for AppSettingKey", v.Expected.AppSettingKey, actual.AppSettingKey) + } + + } +} + +func TestParseAppSettingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AppSettingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/cOnFiGrEfErEnCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/appSettings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/appSettings/appSettingKey", + Expected: &AppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + AppSettingKey: "appSettingKey", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/appSettings/appSettingKey/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs/aPpSeTtInGkEy", + Expected: &AppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + AppSettingKey: "aPpSeTtInGkEy", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs/aPpSeTtInGkEy/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAppSettingIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.AppSettingKey != v.Expected.AppSettingKey { + t.Fatalf("Expected %q but got %q for AppSettingKey", v.Expected.AppSettingKey, actual.AppSettingKey) + } + + } +} + +func TestSegmentsForAppSettingId(t *testing.T) { + segments := AppSettingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AppSettingId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_backup.go b/resource-manager/web/2024-11-01/webapps/id_backup.go new file mode 100644 index 00000000000..84ecf422bfb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_backup.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BackupId{}) +} + +var _ resourceids.ResourceId = &BackupId{} + +// BackupId is a struct representing the Resource ID for a Backup +type BackupId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + BackupId string +} + +// NewBackupID returns a new BackupId struct +func NewBackupID(subscriptionId string, resourceGroupName string, siteName string, backupId string) BackupId { + return BackupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + BackupId: backupId, + } +} + +// ParseBackupID parses 'input' into a BackupId +func ParseBackupID(input string) (*BackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBackupIDInsensitively parses 'input' case-insensitively into a BackupId +// note: this method should only be used for API response data and not user input +func ParseBackupIDInsensitively(input string) (*BackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&BackupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BackupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BackupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.BackupId, ok = input.Parsed["backupId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupId", input) + } + + return nil +} + +// ValidateBackupID checks that 'input' can be parsed as a Backup ID +func ValidateBackupID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBackupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Backup ID +func (id BackupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/backups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.BackupId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Backup ID +func (id BackupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticBackups", "backups", "backups"), + resourceids.UserSpecifiedSegment("backupId", "backupId"), + } +} + +// String returns a human-readable description of this Backup ID +func (id BackupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Backup: %q", id.BackupId), + } + return fmt.Sprintf("Backup (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_backup_test.go b/resource-manager/web/2024-11-01/webapps/id_backup_test.go new file mode 100644 index 00000000000..5e0f8fc3dab --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_backup_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BackupId{} + +func TestNewBackupID(t *testing.T) { + id := NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "backupId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.BackupId != "backupId" { + t.Fatalf("Expected %q but got %q for Segment 'BackupId'", id.BackupId, "backupId") + } +} + +func TestFormatBackupID(t *testing.T) { + actual := NewBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "backupId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/backups/backupId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBackupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/backups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/backups/backupId", + Expected: &BackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + BackupId: "backupId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/backups/backupId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.BackupId != v.Expected.BackupId { + t.Fatalf("Expected %q but got %q for BackupId", v.Expected.BackupId, actual.BackupId) + } + + } +} + +func TestParseBackupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BackupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/backups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/bAcKuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/backups/backupId", + Expected: &BackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + BackupId: "backupId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/backups/backupId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/bAcKuPs/bAcKuPiD", + Expected: &BackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + BackupId: "bAcKuPiD", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/bAcKuPs/bAcKuPiD/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBackupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.BackupId != v.Expected.BackupId { + t.Fatalf("Expected %q but got %q for BackupId", v.Expected.BackupId, actual.BackupId) + } + + } +} + +func TestSegmentsForBackupId(t *testing.T) { + segments := BackupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BackupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_configreferenceappsetting.go b/resource-manager/web/2024-11-01/webapps/id_configreferenceappsetting.go new file mode 100644 index 00000000000..0be15f20c3d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_configreferenceappsetting.go @@ -0,0 +1,150 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConfigReferenceAppSettingId{}) +} + +var _ resourceids.ResourceId = &ConfigReferenceAppSettingId{} + +// ConfigReferenceAppSettingId is a struct representing the Resource ID for a Config Reference App Setting +type ConfigReferenceAppSettingId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + AppSettingKey string +} + +// NewConfigReferenceAppSettingID returns a new ConfigReferenceAppSettingId struct +func NewConfigReferenceAppSettingID(subscriptionId string, resourceGroupName string, siteName string, slotName string, appSettingKey string) ConfigReferenceAppSettingId { + return ConfigReferenceAppSettingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + AppSettingKey: appSettingKey, + } +} + +// ParseConfigReferenceAppSettingID parses 'input' into a ConfigReferenceAppSettingId +func ParseConfigReferenceAppSettingID(input string) (*ConfigReferenceAppSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigReferenceAppSettingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigReferenceAppSettingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConfigReferenceAppSettingIDInsensitively parses 'input' case-insensitively into a ConfigReferenceAppSettingId +// note: this method should only be used for API response data and not user input +func ParseConfigReferenceAppSettingIDInsensitively(input string) (*ConfigReferenceAppSettingId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigReferenceAppSettingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigReferenceAppSettingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConfigReferenceAppSettingId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.AppSettingKey, ok = input.Parsed["appSettingKey"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "appSettingKey", input) + } + + return nil +} + +// ValidateConfigReferenceAppSettingID checks that 'input' can be parsed as a Config Reference App Setting ID +func ValidateConfigReferenceAppSettingID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseConfigReferenceAppSettingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Config Reference App Setting ID +func (id ConfigReferenceAppSettingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/config/configReferences/appSettings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.AppSettingKey) +} + +// Segments returns a slice of Resource ID Segments which comprise this Config Reference App Setting ID +func (id ConfigReferenceAppSettingId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticConfigReferences", "configReferences", "configReferences"), + resourceids.StaticSegment("staticAppSettings", "appSettings", "appSettings"), + resourceids.UserSpecifiedSegment("appSettingKey", "appSettingKey"), + } +} + +// String returns a human-readable description of this Config Reference App Setting ID +func (id ConfigReferenceAppSettingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("App Setting Key: %q", id.AppSettingKey), + } + return fmt.Sprintf("Config Reference App Setting (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_configreferenceappsetting_test.go b/resource-manager/web/2024-11-01/webapps/id_configreferenceappsetting_test.go new file mode 100644 index 00000000000..1b5073a3b78 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_configreferenceappsetting_test.go @@ -0,0 +1,402 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ConfigReferenceAppSettingId{} + +func TestNewConfigReferenceAppSettingID(t *testing.T) { + id := NewConfigReferenceAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "appSettingKey") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.AppSettingKey != "appSettingKey" { + t.Fatalf("Expected %q but got %q for Segment 'AppSettingKey'", id.AppSettingKey, "appSettingKey") + } +} + +func TestFormatConfigReferenceAppSettingID(t *testing.T) { + actual := NewConfigReferenceAppSettingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "appSettingKey").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/appSettings/appSettingKey" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConfigReferenceAppSettingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigReferenceAppSettingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/appSettings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/appSettings/appSettingKey", + Expected: &ConfigReferenceAppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + AppSettingKey: "appSettingKey", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/appSettings/appSettingKey/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigReferenceAppSettingID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.AppSettingKey != v.Expected.AppSettingKey { + t.Fatalf("Expected %q but got %q for AppSettingKey", v.Expected.AppSettingKey, actual.AppSettingKey) + } + + } +} + +func TestParseConfigReferenceAppSettingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigReferenceAppSettingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/cOnFiGrEfErEnCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/appSettings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/appSettings/appSettingKey", + Expected: &ConfigReferenceAppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + AppSettingKey: "appSettingKey", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/appSettings/appSettingKey/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs/aPpSeTtInGkEy", + Expected: &ConfigReferenceAppSettingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + AppSettingKey: "aPpSeTtInGkEy", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/cOnFiGrEfErEnCeS/aPpSeTtInGs/aPpSeTtInGkEy/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigReferenceAppSettingIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.AppSettingKey != v.Expected.AppSettingKey { + t.Fatalf("Expected %q but got %q for AppSettingKey", v.Expected.AppSettingKey, actual.AppSettingKey) + } + + } +} + +func TestSegmentsForConfigReferenceAppSettingId(t *testing.T) { + segments := ConfigReferenceAppSettingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConfigReferenceAppSettingId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_configreferenceconnectionstring.go b/resource-manager/web/2024-11-01/webapps/id_configreferenceconnectionstring.go new file mode 100644 index 00000000000..63353893f7d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_configreferenceconnectionstring.go @@ -0,0 +1,150 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConfigReferenceConnectionStringId{}) +} + +var _ resourceids.ResourceId = &ConfigReferenceConnectionStringId{} + +// ConfigReferenceConnectionStringId is a struct representing the Resource ID for a Config Reference Connection String +type ConfigReferenceConnectionStringId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + ConnectionStringKey string +} + +// NewConfigReferenceConnectionStringID returns a new ConfigReferenceConnectionStringId struct +func NewConfigReferenceConnectionStringID(subscriptionId string, resourceGroupName string, siteName string, slotName string, connectionStringKey string) ConfigReferenceConnectionStringId { + return ConfigReferenceConnectionStringId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + ConnectionStringKey: connectionStringKey, + } +} + +// ParseConfigReferenceConnectionStringID parses 'input' into a ConfigReferenceConnectionStringId +func ParseConfigReferenceConnectionStringID(input string) (*ConfigReferenceConnectionStringId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigReferenceConnectionStringId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigReferenceConnectionStringId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConfigReferenceConnectionStringIDInsensitively parses 'input' case-insensitively into a ConfigReferenceConnectionStringId +// note: this method should only be used for API response data and not user input +func ParseConfigReferenceConnectionStringIDInsensitively(input string) (*ConfigReferenceConnectionStringId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConfigReferenceConnectionStringId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConfigReferenceConnectionStringId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConfigReferenceConnectionStringId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.ConnectionStringKey, ok = input.Parsed["connectionStringKey"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectionStringKey", input) + } + + return nil +} + +// ValidateConfigReferenceConnectionStringID checks that 'input' can be parsed as a Config Reference Connection String ID +func ValidateConfigReferenceConnectionStringID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseConfigReferenceConnectionStringID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Config Reference Connection String ID +func (id ConfigReferenceConnectionStringId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/config/configReferences/connectionStrings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.ConnectionStringKey) +} + +// Segments returns a slice of Resource ID Segments which comprise this Config Reference Connection String ID +func (id ConfigReferenceConnectionStringId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticConfigReferences", "configReferences", "configReferences"), + resourceids.StaticSegment("staticConnectionStrings", "connectionStrings", "connectionStrings"), + resourceids.UserSpecifiedSegment("connectionStringKey", "connectionStringKey"), + } +} + +// String returns a human-readable description of this Config Reference Connection String ID +func (id ConfigReferenceConnectionStringId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Connection String Key: %q", id.ConnectionStringKey), + } + return fmt.Sprintf("Config Reference Connection String (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_configreferenceconnectionstring_test.go b/resource-manager/web/2024-11-01/webapps/id_configreferenceconnectionstring_test.go new file mode 100644 index 00000000000..a18b81f139f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_configreferenceconnectionstring_test.go @@ -0,0 +1,402 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ConfigReferenceConnectionStringId{} + +func TestNewConfigReferenceConnectionStringID(t *testing.T) { + id := NewConfigReferenceConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "connectionStringKey") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.ConnectionStringKey != "connectionStringKey" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectionStringKey'", id.ConnectionStringKey, "connectionStringKey") + } +} + +func TestFormatConfigReferenceConnectionStringID(t *testing.T) { + actual := NewConfigReferenceConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "connectionStringKey").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/connectionStrings/connectionStringKey" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConfigReferenceConnectionStringID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigReferenceConnectionStringId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/connectionStrings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/connectionStrings/connectionStringKey", + Expected: &ConfigReferenceConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + ConnectionStringKey: "connectionStringKey", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/connectionStrings/connectionStringKey/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigReferenceConnectionStringID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ConnectionStringKey != v.Expected.ConnectionStringKey { + t.Fatalf("Expected %q but got %q for ConnectionStringKey", v.Expected.ConnectionStringKey, actual.ConnectionStringKey) + } + + } +} + +func TestParseConfigReferenceConnectionStringIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConfigReferenceConnectionStringId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/cOnFiGrEfErEnCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/connectionStrings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/connectionStrings/connectionStringKey", + Expected: &ConfigReferenceConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + ConnectionStringKey: "connectionStringKey", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/configReferences/connectionStrings/connectionStringKey/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs/cOnNeCtIoNsTrInGkEy", + Expected: &ConfigReferenceConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + ConnectionStringKey: "cOnNeCtIoNsTrInGkEy", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs/cOnNeCtIoNsTrInGkEy/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConfigReferenceConnectionStringIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ConnectionStringKey != v.Expected.ConnectionStringKey { + t.Fatalf("Expected %q but got %q for ConnectionStringKey", v.Expected.ConnectionStringKey, actual.ConnectionStringKey) + } + + } +} + +func TestSegmentsForConfigReferenceConnectionStringId(t *testing.T) { + segments := ConfigReferenceConnectionStringId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConfigReferenceConnectionStringId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_connectionstring.go b/resource-manager/web/2024-11-01/webapps/id_connectionstring.go new file mode 100644 index 00000000000..5282e76e282 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_connectionstring.go @@ -0,0 +1,141 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConnectionStringId{}) +} + +var _ resourceids.ResourceId = &ConnectionStringId{} + +// ConnectionStringId is a struct representing the Resource ID for a Connection String +type ConnectionStringId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + ConnectionStringKey string +} + +// NewConnectionStringID returns a new ConnectionStringId struct +func NewConnectionStringID(subscriptionId string, resourceGroupName string, siteName string, connectionStringKey string) ConnectionStringId { + return ConnectionStringId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + ConnectionStringKey: connectionStringKey, + } +} + +// ParseConnectionStringID parses 'input' into a ConnectionStringId +func ParseConnectionStringID(input string) (*ConnectionStringId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectionStringId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectionStringId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConnectionStringIDInsensitively parses 'input' case-insensitively into a ConnectionStringId +// note: this method should only be used for API response data and not user input +func ParseConnectionStringIDInsensitively(input string) (*ConnectionStringId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectionStringId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectionStringId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConnectionStringId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.ConnectionStringKey, ok = input.Parsed["connectionStringKey"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectionStringKey", input) + } + + return nil +} + +// ValidateConnectionStringID checks that 'input' can be parsed as a Connection String ID +func ValidateConnectionStringID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseConnectionStringID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Connection String ID +func (id ConnectionStringId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/config/configReferences/connectionStrings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.ConnectionStringKey) +} + +// Segments returns a slice of Resource ID Segments which comprise this Connection String ID +func (id ConnectionStringId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticConfigReferences", "configReferences", "configReferences"), + resourceids.StaticSegment("staticConnectionStrings", "connectionStrings", "connectionStrings"), + resourceids.UserSpecifiedSegment("connectionStringKey", "connectionStringKey"), + } +} + +// String returns a human-readable description of this Connection String ID +func (id ConnectionStringId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Connection String Key: %q", id.ConnectionStringKey), + } + return fmt.Sprintf("Connection String (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_connectionstring_test.go b/resource-manager/web/2024-11-01/webapps/id_connectionstring_test.go new file mode 100644 index 00000000000..c4310a2bd0d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_connectionstring_test.go @@ -0,0 +1,357 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ConnectionStringId{} + +func TestNewConnectionStringID(t *testing.T) { + id := NewConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "connectionStringKey") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.ConnectionStringKey != "connectionStringKey" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectionStringKey'", id.ConnectionStringKey, "connectionStringKey") + } +} + +func TestFormatConnectionStringID(t *testing.T) { + actual := NewConnectionStringID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "connectionStringKey").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/connectionStrings/connectionStringKey" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConnectionStringID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectionStringId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/connectionStrings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/connectionStrings/connectionStringKey", + Expected: &ConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + ConnectionStringKey: "connectionStringKey", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/connectionStrings/connectionStringKey/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectionStringID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ConnectionStringKey != v.Expected.ConnectionStringKey { + t.Fatalf("Expected %q but got %q for ConnectionStringKey", v.Expected.ConnectionStringKey, actual.ConnectionStringKey) + } + + } +} + +func TestParseConnectionStringIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectionStringId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/cOnFiGrEfErEnCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/connectionStrings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/connectionStrings/connectionStringKey", + Expected: &ConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + ConnectionStringKey: "connectionStringKey", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/configReferences/connectionStrings/connectionStringKey/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs/cOnNeCtIoNsTrInGkEy", + Expected: &ConnectionStringId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + ConnectionStringKey: "cOnNeCtIoNsTrInGkEy", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/cOnFiGrEfErEnCeS/cOnNeCtIoNsTrInGs/cOnNeCtIoNsTrInGkEy/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectionStringIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ConnectionStringKey != v.Expected.ConnectionStringKey { + t.Fatalf("Expected %q but got %q for ConnectionStringKey", v.Expected.ConnectionStringKey, actual.ConnectionStringKey) + } + + } +} + +func TestSegmentsForConnectionStringId(t *testing.T) { + segments := ConnectionStringId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConnectionStringId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_continuouswebjob.go b/resource-manager/web/2024-11-01/webapps/id_continuouswebjob.go new file mode 100644 index 00000000000..b25215a56ac --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_continuouswebjob.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ContinuousWebJobId{}) +} + +var _ resourceids.ResourceId = &ContinuousWebJobId{} + +// ContinuousWebJobId is a struct representing the Resource ID for a Continuous Web Job +type ContinuousWebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + ContinuousWebJobName string +} + +// NewContinuousWebJobID returns a new ContinuousWebJobId struct +func NewContinuousWebJobID(subscriptionId string, resourceGroupName string, siteName string, continuousWebJobName string) ContinuousWebJobId { + return ContinuousWebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + ContinuousWebJobName: continuousWebJobName, + } +} + +// ParseContinuousWebJobID parses 'input' into a ContinuousWebJobId +func ParseContinuousWebJobID(input string) (*ContinuousWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContinuousWebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContinuousWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseContinuousWebJobIDInsensitively parses 'input' case-insensitively into a ContinuousWebJobId +// note: this method should only be used for API response data and not user input +func ParseContinuousWebJobIDInsensitively(input string) (*ContinuousWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&ContinuousWebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ContinuousWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ContinuousWebJobId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.ContinuousWebJobName, ok = input.Parsed["continuousWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "continuousWebJobName", input) + } + + return nil +} + +// ValidateContinuousWebJobID checks that 'input' can be parsed as a Continuous Web Job ID +func ValidateContinuousWebJobID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseContinuousWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Continuous Web Job ID +func (id ContinuousWebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/continuousWebJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.ContinuousWebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Continuous Web Job ID +func (id ContinuousWebJobId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticContinuousWebJobs", "continuousWebJobs", "continuousWebJobs"), + resourceids.UserSpecifiedSegment("continuousWebJobName", "continuousWebJobName"), + } +} + +// String returns a human-readable description of this Continuous Web Job ID +func (id ContinuousWebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Continuous Web Job Name: %q", id.ContinuousWebJobName), + } + return fmt.Sprintf("Continuous Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_continuouswebjob_test.go b/resource-manager/web/2024-11-01/webapps/id_continuouswebjob_test.go new file mode 100644 index 00000000000..9dbfdc97ffc --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_continuouswebjob_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ContinuousWebJobId{} + +func TestNewContinuousWebJobID(t *testing.T) { + id := NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "continuousWebJobName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.ContinuousWebJobName != "continuousWebJobName" { + t.Fatalf("Expected %q but got %q for Segment 'ContinuousWebJobName'", id.ContinuousWebJobName, "continuousWebJobName") + } +} + +func TestFormatContinuousWebJobID(t *testing.T) { + actual := NewContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "continuousWebJobName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/continuousWebJobs/continuousWebJobName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseContinuousWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContinuousWebJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/continuousWebJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/continuousWebJobs/continuousWebJobName", + Expected: &ContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + ContinuousWebJobName: "continuousWebJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/continuousWebJobs/continuousWebJobName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContinuousWebJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ContinuousWebJobName != v.Expected.ContinuousWebJobName { + t.Fatalf("Expected %q but got %q for ContinuousWebJobName", v.Expected.ContinuousWebJobName, actual.ContinuousWebJobName) + } + + } +} + +func TestParseContinuousWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ContinuousWebJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/continuousWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnTiNuOuSwEbJoBs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/continuousWebJobs/continuousWebJobName", + Expected: &ContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + ContinuousWebJobName: "continuousWebJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/continuousWebJobs/continuousWebJobName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnTiNuOuSwEbJoBs/cOnTiNuOuSwEbJoBnAmE", + Expected: &ContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + ContinuousWebJobName: "cOnTiNuOuSwEbJoBnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnTiNuOuSwEbJoBs/cOnTiNuOuSwEbJoBnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseContinuousWebJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ContinuousWebJobName != v.Expected.ContinuousWebJobName { + t.Fatalf("Expected %q but got %q for ContinuousWebJobName", v.Expected.ContinuousWebJobName, actual.ContinuousWebJobName) + } + + } +} + +func TestSegmentsForContinuousWebJobId(t *testing.T) { + segments := ContinuousWebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ContinuousWebJobId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_default.go b/resource-manager/web/2024-11-01/webapps/id_default.go new file mode 100644 index 00000000000..82b1628663d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_default.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DefaultId{}) +} + +var _ resourceids.ResourceId = &DefaultId{} + +// DefaultId is a struct representing the Resource ID for a Default +type DefaultId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DefaultName string + KeyName string +} + +// NewDefaultID returns a new DefaultId struct +func NewDefaultID(subscriptionId string, resourceGroupName string, siteName string, defaultName string, keyName string) DefaultId { + return DefaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DefaultName: defaultName, + KeyName: keyName, + } +} + +// ParseDefaultID parses 'input' into a DefaultId +func ParseDefaultID(input string) (*DefaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&DefaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DefaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDefaultIDInsensitively parses 'input' case-insensitively into a DefaultId +// note: this method should only be used for API response data and not user input +func ParseDefaultIDInsensitively(input string) (*DefaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&DefaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DefaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DefaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DefaultName, ok = input.Parsed["defaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "defaultName", input) + } + + if id.KeyName, ok = input.Parsed["keyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "keyName", input) + } + + return nil +} + +// ValidateDefaultID checks that 'input' can be parsed as a Default ID +func ValidateDefaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDefaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Default ID +func (id DefaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/host/default/%s/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DefaultName, id.KeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Default ID +func (id DefaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHost", "host", "host"), + resourceids.StaticSegment("staticDefault", "default", "default"), + resourceids.UserSpecifiedSegment("defaultName", "defaultName"), + resourceids.UserSpecifiedSegment("keyName", "keyName"), + } +} + +// String returns a human-readable description of this Default ID +func (id DefaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Default Name: %q", id.DefaultName), + fmt.Sprintf("Key Name: %q", id.KeyName), + } + return fmt.Sprintf("Default (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_default_test.go b/resource-manager/web/2024-11-01/webapps/id_default_test.go new file mode 100644 index 00000000000..fb8f07676f0 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_default_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DefaultId{} + +func TestNewDefaultID(t *testing.T) { + id := NewDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "defaultName", "keyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.DefaultName != "defaultName" { + t.Fatalf("Expected %q but got %q for Segment 'DefaultName'", id.DefaultName, "defaultName") + } + + if id.KeyName != "keyName" { + t.Fatalf("Expected %q but got %q for Segment 'KeyName'", id.KeyName, "keyName") + } +} + +func TestFormatDefaultID(t *testing.T) { + actual := NewDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "defaultName", "keyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default/defaultName/keyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDefaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DefaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default/defaultName", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default/defaultName/keyName", + Expected: &DefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DefaultName: "defaultName", + KeyName: "keyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default/defaultName/keyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDefaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DefaultName != v.Expected.DefaultName { + t.Fatalf("Expected %q but got %q for DefaultName", v.Expected.DefaultName, actual.DefaultName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestParseDefaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DefaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsT/dEfAuLt", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default/defaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsT/dEfAuLt/dEfAuLtNaMe", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default/defaultName/keyName", + Expected: &DefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DefaultName: "defaultName", + KeyName: "keyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/host/default/defaultName/keyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsT/dEfAuLt/dEfAuLtNaMe/kEyNaMe", + Expected: &DefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + DefaultName: "dEfAuLtNaMe", + KeyName: "kEyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsT/dEfAuLt/dEfAuLtNaMe/kEyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDefaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DefaultName != v.Expected.DefaultName { + t.Fatalf("Expected %q but got %q for DefaultName", v.Expected.DefaultName, actual.DefaultName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestSegmentsForDefaultId(t *testing.T) { + segments := DefaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DefaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_deployment.go b/resource-manager/web/2024-11-01/webapps/id_deployment.go new file mode 100644 index 00000000000..6b9e4f1fdf3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_deployment.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DeploymentId{}) +} + +var _ resourceids.ResourceId = &DeploymentId{} + +// DeploymentId is a struct representing the Resource ID for a Deployment +type DeploymentId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DeploymentName string +} + +// NewDeploymentID returns a new DeploymentId struct +func NewDeploymentID(subscriptionId string, resourceGroupName string, siteName string, deploymentName string) DeploymentId { + return DeploymentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DeploymentName: deploymentName, + } +} + +// ParseDeploymentID parses 'input' into a DeploymentId +func ParseDeploymentID(input string) (*DeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeploymentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDeploymentIDInsensitively parses 'input' case-insensitively into a DeploymentId +// note: this method should only be used for API response data and not user input +func ParseDeploymentIDInsensitively(input string) (*DeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeploymentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DeploymentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DeploymentName, ok = input.Parsed["deploymentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deploymentName", input) + } + + return nil +} + +// ValidateDeploymentID checks that 'input' can be parsed as a Deployment ID +func ValidateDeploymentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDeploymentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Deployment ID +func (id DeploymentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/deployments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DeploymentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Deployment ID +func (id DeploymentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticDeployments", "deployments", "deployments"), + resourceids.UserSpecifiedSegment("deploymentName", "deploymentName"), + } +} + +// String returns a human-readable description of this Deployment ID +func (id DeploymentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Deployment Name: %q", id.DeploymentName), + } + return fmt.Sprintf("Deployment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_deployment_test.go b/resource-manager/web/2024-11-01/webapps/id_deployment_test.go new file mode 100644 index 00000000000..01e80a6d68b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_deployment_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DeploymentId{} + +func TestNewDeploymentID(t *testing.T) { + id := NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "deploymentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.DeploymentName != "deploymentName" { + t.Fatalf("Expected %q but got %q for Segment 'DeploymentName'", id.DeploymentName, "deploymentName") + } +} + +func TestFormatDeploymentID(t *testing.T) { + actual := NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "deploymentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/deployments/deploymentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDeploymentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeploymentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/deployments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/deployments/deploymentName", + Expected: &DeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DeploymentName: "deploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/deployments/deploymentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeploymentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DeploymentName != v.Expected.DeploymentName { + t.Fatalf("Expected %q but got %q for DeploymentName", v.Expected.DeploymentName, actual.DeploymentName) + } + + } +} + +func TestParseDeploymentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeploymentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/deployments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dEpLoYmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/deployments/deploymentName", + Expected: &DeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DeploymentName: "deploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/deployments/deploymentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dEpLoYmEnTs/dEpLoYmEnTnAmE", + Expected: &DeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + DeploymentName: "dEpLoYmEnTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dEpLoYmEnTs/dEpLoYmEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeploymentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DeploymentName != v.Expected.DeploymentName { + t.Fatalf("Expected %q but got %q for DeploymentName", v.Expected.DeploymentName, actual.DeploymentName) + } + + } +} + +func TestSegmentsForDeploymentId(t *testing.T) { + segments := DeploymentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DeploymentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_function.go b/resource-manager/web/2024-11-01/webapps/id_function.go new file mode 100644 index 00000000000..f616aeae83a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_function.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&FunctionId{}) +} + +var _ resourceids.ResourceId = &FunctionId{} + +// FunctionId is a struct representing the Resource ID for a Function +type FunctionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + FunctionName string +} + +// NewFunctionID returns a new FunctionId struct +func NewFunctionID(subscriptionId string, resourceGroupName string, siteName string, functionName string) FunctionId { + return FunctionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + FunctionName: functionName, + } +} + +// ParseFunctionID parses 'input' into a FunctionId +func ParseFunctionID(input string) (*FunctionId, error) { + parser := resourceids.NewParserFromResourceIdType(&FunctionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FunctionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFunctionIDInsensitively parses 'input' case-insensitively into a FunctionId +// note: this method should only be used for API response data and not user input +func ParseFunctionIDInsensitively(input string) (*FunctionId, error) { + parser := resourceids.NewParserFromResourceIdType(&FunctionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FunctionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FunctionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.FunctionName, ok = input.Parsed["functionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "functionName", input) + } + + return nil +} + +// ValidateFunctionID checks that 'input' can be parsed as a Function ID +func ValidateFunctionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseFunctionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Function ID +func (id FunctionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/functions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.FunctionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Function ID +func (id FunctionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticFunctions", "functions", "functions"), + resourceids.UserSpecifiedSegment("functionName", "functionName"), + } +} + +// String returns a human-readable description of this Function ID +func (id FunctionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Function Name: %q", id.FunctionName), + } + return fmt.Sprintf("Function (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_function_test.go b/resource-manager/web/2024-11-01/webapps/id_function_test.go new file mode 100644 index 00000000000..647ee45180b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_function_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &FunctionId{} + +func TestNewFunctionID(t *testing.T) { + id := NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.FunctionName != "functionName" { + t.Fatalf("Expected %q but got %q for Segment 'FunctionName'", id.FunctionName, "functionName") + } +} + +func TestFormatFunctionID(t *testing.T) { + actual := NewFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFunctionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FunctionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName", + Expected: &FunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + FunctionName: "functionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFunctionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + } +} + +func TestParseFunctionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FunctionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/fUnCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName", + Expected: &FunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + FunctionName: "functionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/fUnCtIoNs/fUnCtIoNnAmE", + Expected: &FunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + FunctionName: "fUnCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/fUnCtIoNs/fUnCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFunctionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + } +} + +func TestSegmentsForFunctionId(t *testing.T) { + segments := FunctionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FunctionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_functionkey.go b/resource-manager/web/2024-11-01/webapps/id_functionkey.go new file mode 100644 index 00000000000..2c5e6ac58da --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_functionkey.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&FunctionKeyId{}) +} + +var _ resourceids.ResourceId = &FunctionKeyId{} + +// FunctionKeyId is a struct representing the Resource ID for a Function Key +type FunctionKeyId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + FunctionName string + KeyName string +} + +// NewFunctionKeyID returns a new FunctionKeyId struct +func NewFunctionKeyID(subscriptionId string, resourceGroupName string, siteName string, slotName string, functionName string, keyName string) FunctionKeyId { + return FunctionKeyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + FunctionName: functionName, + KeyName: keyName, + } +} + +// ParseFunctionKeyID parses 'input' into a FunctionKeyId +func ParseFunctionKeyID(input string) (*FunctionKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&FunctionKeyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FunctionKeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFunctionKeyIDInsensitively parses 'input' case-insensitively into a FunctionKeyId +// note: this method should only be used for API response data and not user input +func ParseFunctionKeyIDInsensitively(input string) (*FunctionKeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&FunctionKeyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FunctionKeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FunctionKeyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.FunctionName, ok = input.Parsed["functionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "functionName", input) + } + + if id.KeyName, ok = input.Parsed["keyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "keyName", input) + } + + return nil +} + +// ValidateFunctionKeyID checks that 'input' can be parsed as a Function Key ID +func ValidateFunctionKeyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseFunctionKeyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Function Key ID +func (id FunctionKeyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/functions/%s/keys/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.FunctionName, id.KeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Function Key ID +func (id FunctionKeyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticFunctions", "functions", "functions"), + resourceids.UserSpecifiedSegment("functionName", "functionName"), + resourceids.StaticSegment("staticKeys", "keys", "keys"), + resourceids.UserSpecifiedSegment("keyName", "keyName"), + } +} + +// String returns a human-readable description of this Function Key ID +func (id FunctionKeyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Function Name: %q", id.FunctionName), + fmt.Sprintf("Key Name: %q", id.KeyName), + } + return fmt.Sprintf("Function Key (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_functionkey_test.go b/resource-manager/web/2024-11-01/webapps/id_functionkey_test.go new file mode 100644 index 00000000000..d5c2d17970d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_functionkey_test.go @@ -0,0 +1,417 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &FunctionKeyId{} + +func TestNewFunctionKeyID(t *testing.T) { + id := NewFunctionKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName", "keyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.FunctionName != "functionName" { + t.Fatalf("Expected %q but got %q for Segment 'FunctionName'", id.FunctionName, "functionName") + } + + if id.KeyName != "keyName" { + t.Fatalf("Expected %q but got %q for Segment 'KeyName'", id.KeyName, "keyName") + } +} + +func TestFormatFunctionKeyID(t *testing.T) { + actual := NewFunctionKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName", "keyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/keys/keyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFunctionKeyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FunctionKeyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/keys", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/keys/keyName", + Expected: &FunctionKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + FunctionName: "functionName", + KeyName: "keyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/keys/keyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFunctionKeyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestParseFunctionKeyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FunctionKeyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/fUnCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/fUnCtIoNs/fUnCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/keys", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/fUnCtIoNs/fUnCtIoNnAmE/kEyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/keys/keyName", + Expected: &FunctionKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + FunctionName: "functionName", + KeyName: "keyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/keys/keyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/fUnCtIoNs/fUnCtIoNnAmE/kEyS/kEyNaMe", + Expected: &FunctionKeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + FunctionName: "fUnCtIoNnAmE", + KeyName: "kEyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/fUnCtIoNs/fUnCtIoNnAmE/kEyS/kEyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFunctionKeyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestSegmentsForFunctionKeyId(t *testing.T) { + segments := FunctionKeyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FunctionKeyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_gateway.go b/resource-manager/web/2024-11-01/webapps/id_gateway.go new file mode 100644 index 00000000000..0d5dc900e0d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_gateway.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&GatewayId{}) +} + +var _ resourceids.ResourceId = &GatewayId{} + +// GatewayId is a struct representing the Resource ID for a Gateway +type GatewayId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + VirtualNetworkConnectionName string + GatewayName string +} + +// NewGatewayID returns a new GatewayId struct +func NewGatewayID(subscriptionId string, resourceGroupName string, siteName string, virtualNetworkConnectionName string, gatewayName string) GatewayId { + return GatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + GatewayName: gatewayName, + } +} + +// ParseGatewayID parses 'input' into a GatewayId +func ParseGatewayID(input string) (*GatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&GatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseGatewayIDInsensitively parses 'input' case-insensitively into a GatewayId +// note: this method should only be used for API response data and not user input +func ParseGatewayIDInsensitively(input string) (*GatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&GatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *GatewayId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + if id.GatewayName, ok = input.Parsed["gatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "gatewayName", input) + } + + return nil +} + +// ValidateGatewayID checks that 'input' can be parsed as a Gateway ID +func ValidateGatewayID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Gateway ID +func (id GatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/virtualNetworkConnections/%s/gateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.VirtualNetworkConnectionName, id.GatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Gateway ID +func (id GatewayId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionName"), + resourceids.StaticSegment("staticGateways", "gateways", "gateways"), + resourceids.UserSpecifiedSegment("gatewayName", "gatewayName"), + } +} + +// String returns a human-readable description of this Gateway ID +func (id GatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + fmt.Sprintf("Gateway Name: %q", id.GatewayName), + } + return fmt.Sprintf("Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_gateway_test.go b/resource-manager/web/2024-11-01/webapps/id_gateway_test.go new file mode 100644 index 00000000000..7bbd4aac0a9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_gateway_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &GatewayId{} + +func TestNewGatewayID(t *testing.T) { + id := NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName", "gatewayName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionName") + } + + if id.GatewayName != "gatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'GatewayName'", id.GatewayName, "gatewayName") + } +} + +func TestFormatGatewayID(t *testing.T) { + actual := NewGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName", "gatewayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/gateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName", + Expected: &GatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + GatewayName: "gatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGatewayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestParseGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/gateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName", + Expected: &GatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + GatewayName: "gatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS/gAtEwAyNaMe", + Expected: &GatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + GatewayName: "gAtEwAyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS/gAtEwAyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGatewayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestSegmentsForGatewayId(t *testing.T) { + segments := GatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("GatewayId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_history.go b/resource-manager/web/2024-11-01/webapps/id_history.go new file mode 100644 index 00000000000..c1cc260d497 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_history.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HistoryId{}) +} + +var _ resourceids.ResourceId = &HistoryId{} + +// HistoryId is a struct representing the Resource ID for a History +type HistoryId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + TriggeredWebJobName string + HistoryName string +} + +// NewHistoryID returns a new HistoryId struct +func NewHistoryID(subscriptionId string, resourceGroupName string, siteName string, triggeredWebJobName string, historyName string) HistoryId { + return HistoryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + TriggeredWebJobName: triggeredWebJobName, + HistoryName: historyName, + } +} + +// ParseHistoryID parses 'input' into a HistoryId +func ParseHistoryID(input string) (*HistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&HistoryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HistoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHistoryIDInsensitively parses 'input' case-insensitively into a HistoryId +// note: this method should only be used for API response data and not user input +func ParseHistoryIDInsensitively(input string) (*HistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&HistoryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HistoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HistoryId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.TriggeredWebJobName, ok = input.Parsed["triggeredWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggeredWebJobName", input) + } + + if id.HistoryName, ok = input.Parsed["historyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "historyName", input) + } + + return nil +} + +// ValidateHistoryID checks that 'input' can be parsed as a History ID +func ValidateHistoryID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHistoryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted History ID +func (id HistoryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/triggeredWebJobs/%s/history/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.TriggeredWebJobName, id.HistoryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this History ID +func (id HistoryId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticTriggeredWebJobs", "triggeredWebJobs", "triggeredWebJobs"), + resourceids.UserSpecifiedSegment("triggeredWebJobName", "triggeredWebJobName"), + resourceids.StaticSegment("staticHistory", "history", "history"), + resourceids.UserSpecifiedSegment("historyName", "historyName"), + } +} + +// String returns a human-readable description of this History ID +func (id HistoryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Triggered Web Job Name: %q", id.TriggeredWebJobName), + fmt.Sprintf("History Name: %q", id.HistoryName), + } + return fmt.Sprintf("History (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_history_test.go b/resource-manager/web/2024-11-01/webapps/id_history_test.go new file mode 100644 index 00000000000..d3d2ed22f07 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_history_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HistoryId{} + +func TestNewHistoryID(t *testing.T) { + id := NewHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName", "historyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.TriggeredWebJobName != "triggeredWebJobName" { + t.Fatalf("Expected %q but got %q for Segment 'TriggeredWebJobName'", id.TriggeredWebJobName, "triggeredWebJobName") + } + + if id.HistoryName != "historyName" { + t.Fatalf("Expected %q but got %q for Segment 'HistoryName'", id.HistoryName, "historyName") + } +} + +func TestFormatHistoryID(t *testing.T) { + actual := NewHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName", "historyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/history/historyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHistoryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HistoryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/history", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/history/historyName", + Expected: &HistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + TriggeredWebJobName: "triggeredWebJobName", + HistoryName: "historyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/history/historyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHistoryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestParseHistoryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HistoryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/tRiGgErEdWeBjObS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/history", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe/hIsToRy", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/history/historyName", + Expected: &HistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + TriggeredWebJobName: "triggeredWebJobName", + HistoryName: "historyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/history/historyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe/hIsToRy/hIsToRyNaMe", + Expected: &HistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + TriggeredWebJobName: "tRiGgErEdWeBjObNaMe", + HistoryName: "hIsToRyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe/hIsToRy/hIsToRyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHistoryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestSegmentsForHistoryId(t *testing.T) { + segments := HistoryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HistoryId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_hostdefault.go b/resource-manager/web/2024-11-01/webapps/id_hostdefault.go new file mode 100644 index 00000000000..d02b1ff58fb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_hostdefault.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostDefaultId{}) +} + +var _ resourceids.ResourceId = &HostDefaultId{} + +// HostDefaultId is a struct representing the Resource ID for a Host Default +type HostDefaultId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DefaultName string + KeyName string +} + +// NewHostDefaultID returns a new HostDefaultId struct +func NewHostDefaultID(subscriptionId string, resourceGroupName string, siteName string, slotName string, defaultName string, keyName string) HostDefaultId { + return HostDefaultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DefaultName: defaultName, + KeyName: keyName, + } +} + +// ParseHostDefaultID parses 'input' into a HostDefaultId +func ParseHostDefaultID(input string) (*HostDefaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostDefaultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostDefaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostDefaultIDInsensitively parses 'input' case-insensitively into a HostDefaultId +// note: this method should only be used for API response data and not user input +func ParseHostDefaultIDInsensitively(input string) (*HostDefaultId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostDefaultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostDefaultId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostDefaultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DefaultName, ok = input.Parsed["defaultName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "defaultName", input) + } + + if id.KeyName, ok = input.Parsed["keyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "keyName", input) + } + + return nil +} + +// ValidateHostDefaultID checks that 'input' can be parsed as a Host Default ID +func ValidateHostDefaultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostDefaultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Default ID +func (id HostDefaultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/host/default/%s/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DefaultName, id.KeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Default ID +func (id HostDefaultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticHost", "host", "host"), + resourceids.StaticSegment("staticDefault", "default", "default"), + resourceids.UserSpecifiedSegment("defaultName", "defaultName"), + resourceids.UserSpecifiedSegment("keyName", "keyName"), + } +} + +// String returns a human-readable description of this Host Default ID +func (id HostDefaultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Default Name: %q", id.DefaultName), + fmt.Sprintf("Key Name: %q", id.KeyName), + } + return fmt.Sprintf("Host Default (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_hostdefault_test.go b/resource-manager/web/2024-11-01/webapps/id_hostdefault_test.go new file mode 100644 index 00000000000..4f3bb7c417c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_hostdefault_test.go @@ -0,0 +1,417 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostDefaultId{} + +func TestNewHostDefaultID(t *testing.T) { + id := NewHostDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "defaultName", "keyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.DefaultName != "defaultName" { + t.Fatalf("Expected %q but got %q for Segment 'DefaultName'", id.DefaultName, "defaultName") + } + + if id.KeyName != "keyName" { + t.Fatalf("Expected %q but got %q for Segment 'KeyName'", id.KeyName, "keyName") + } +} + +func TestFormatHostDefaultID(t *testing.T) { + actual := NewHostDefaultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "defaultName", "keyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default/defaultName/keyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostDefaultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostDefaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default/defaultName", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default/defaultName/keyName", + Expected: &HostDefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DefaultName: "defaultName", + KeyName: "keyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default/defaultName/keyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostDefaultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DefaultName != v.Expected.DefaultName { + t.Fatalf("Expected %q but got %q for DefaultName", v.Expected.DefaultName, actual.DefaultName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestParseHostDefaultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostDefaultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hOsT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hOsT/dEfAuLt", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default/defaultName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hOsT/dEfAuLt/dEfAuLtNaMe", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default/defaultName/keyName", + Expected: &HostDefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DefaultName: "defaultName", + KeyName: "keyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/host/default/defaultName/keyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hOsT/dEfAuLt/dEfAuLtNaMe/kEyNaMe", + Expected: &HostDefaultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + DefaultName: "dEfAuLtNaMe", + KeyName: "kEyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hOsT/dEfAuLt/dEfAuLtNaMe/kEyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostDefaultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DefaultName != v.Expected.DefaultName { + t.Fatalf("Expected %q but got %q for DefaultName", v.Expected.DefaultName, actual.DefaultName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestSegmentsForHostDefaultId(t *testing.T) { + segments := HostDefaultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostDefaultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_hostnamebinding.go b/resource-manager/web/2024-11-01/webapps/id_hostnamebinding.go new file mode 100644 index 00000000000..56a4b8e3fba --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_hostnamebinding.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HostNameBindingId{}) +} + +var _ resourceids.ResourceId = &HostNameBindingId{} + +// HostNameBindingId is a struct representing the Resource ID for a Host Name Binding +type HostNameBindingId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + HostNameBindingName string +} + +// NewHostNameBindingID returns a new HostNameBindingId struct +func NewHostNameBindingID(subscriptionId string, resourceGroupName string, siteName string, hostNameBindingName string) HostNameBindingId { + return HostNameBindingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + HostNameBindingName: hostNameBindingName, + } +} + +// ParseHostNameBindingID parses 'input' into a HostNameBindingId +func ParseHostNameBindingID(input string) (*HostNameBindingId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostNameBindingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostNameBindingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHostNameBindingIDInsensitively parses 'input' case-insensitively into a HostNameBindingId +// note: this method should only be used for API response data and not user input +func ParseHostNameBindingIDInsensitively(input string) (*HostNameBindingId, error) { + parser := resourceids.NewParserFromResourceIdType(&HostNameBindingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HostNameBindingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HostNameBindingId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.HostNameBindingName, ok = input.Parsed["hostNameBindingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostNameBindingName", input) + } + + return nil +} + +// ValidateHostNameBindingID checks that 'input' can be parsed as a Host Name Binding ID +func ValidateHostNameBindingID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHostNameBindingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Host Name Binding ID +func (id HostNameBindingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostNameBindings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.HostNameBindingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Host Name Binding ID +func (id HostNameBindingId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostNameBindings", "hostNameBindings", "hostNameBindings"), + resourceids.UserSpecifiedSegment("hostNameBindingName", "hostNameBindingName"), + } +} + +// String returns a human-readable description of this Host Name Binding ID +func (id HostNameBindingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Host Name Binding Name: %q", id.HostNameBindingName), + } + return fmt.Sprintf("Host Name Binding (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_hostnamebinding_test.go b/resource-manager/web/2024-11-01/webapps/id_hostnamebinding_test.go new file mode 100644 index 00000000000..a3b55f6e522 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_hostnamebinding_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HostNameBindingId{} + +func TestNewHostNameBindingID(t *testing.T) { + id := NewHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hostNameBindingName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.HostNameBindingName != "hostNameBindingName" { + t.Fatalf("Expected %q but got %q for Segment 'HostNameBindingName'", id.HostNameBindingName, "hostNameBindingName") + } +} + +func TestFormatHostNameBindingID(t *testing.T) { + actual := NewHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hostNameBindingName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostNameBindings/hostNameBindingName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHostNameBindingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostNameBindingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostNameBindings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostNameBindings/hostNameBindingName", + Expected: &HostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + HostNameBindingName: "hostNameBindingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostNameBindings/hostNameBindingName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostNameBindingID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HostNameBindingName != v.Expected.HostNameBindingName { + t.Fatalf("Expected %q but got %q for HostNameBindingName", v.Expected.HostNameBindingName, actual.HostNameBindingName) + } + + } +} + +func TestParseHostNameBindingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HostNameBindingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostNameBindings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTnAmEbInDiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostNameBindings/hostNameBindingName", + Expected: &HostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + HostNameBindingName: "hostNameBindingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostNameBindings/hostNameBindingName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTnAmEbInDiNgS/hOsTnAmEbInDiNgNaMe", + Expected: &HostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + HostNameBindingName: "hOsTnAmEbInDiNgNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTnAmEbInDiNgS/hOsTnAmEbInDiNgNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHostNameBindingIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HostNameBindingName != v.Expected.HostNameBindingName { + t.Fatalf("Expected %q but got %q for HostNameBindingName", v.Expected.HostNameBindingName, actual.HostNameBindingName) + } + + } +} + +func TestSegmentsForHostNameBindingId(t *testing.T) { + segments := HostNameBindingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HostNameBindingId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_hybridconnection.go b/resource-manager/web/2024-11-01/webapps/id_hybridconnection.go new file mode 100644 index 00000000000..643e1f811d9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_hybridconnection.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&HybridConnectionId{}) +} + +var _ resourceids.ResourceId = &HybridConnectionId{} + +// HybridConnectionId is a struct representing the Resource ID for a Hybrid Connection +type HybridConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + HybridConnectionName string +} + +// NewHybridConnectionID returns a new HybridConnectionId struct +func NewHybridConnectionID(subscriptionId string, resourceGroupName string, siteName string, hybridConnectionName string) HybridConnectionId { + return HybridConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + HybridConnectionName: hybridConnectionName, + } +} + +// ParseHybridConnectionID parses 'input' into a HybridConnectionId +func ParseHybridConnectionID(input string) (*HybridConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&HybridConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HybridConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseHybridConnectionIDInsensitively parses 'input' case-insensitively into a HybridConnectionId +// note: this method should only be used for API response data and not user input +func ParseHybridConnectionIDInsensitively(input string) (*HybridConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&HybridConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := HybridConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *HybridConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.HybridConnectionName, ok = input.Parsed["hybridConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hybridConnectionName", input) + } + + return nil +} + +// ValidateHybridConnectionID checks that 'input' can be parsed as a Hybrid Connection ID +func ValidateHybridConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseHybridConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Hybrid Connection ID +func (id HybridConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hybridConnection/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.HybridConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Hybrid Connection ID +func (id HybridConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHybridConnection", "hybridConnection", "hybridConnection"), + resourceids.UserSpecifiedSegment("hybridConnectionName", "hybridConnectionName"), + } +} + +// String returns a human-readable description of this Hybrid Connection ID +func (id HybridConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Hybrid Connection Name: %q", id.HybridConnectionName), + } + return fmt.Sprintf("Hybrid Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_hybridconnection_test.go b/resource-manager/web/2024-11-01/webapps/id_hybridconnection_test.go new file mode 100644 index 00000000000..db79679c1a3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_hybridconnection_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &HybridConnectionId{} + +func TestNewHybridConnectionID(t *testing.T) { + id := NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.HybridConnectionName != "hybridConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'HybridConnectionName'", id.HybridConnectionName, "hybridConnectionName") + } +} + +func TestFormatHybridConnectionID(t *testing.T) { + actual := NewHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnection/hybridConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseHybridConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HybridConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnection", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnection/hybridConnectionName", + Expected: &HybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + HybridConnectionName: "hybridConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnection/hybridConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHybridConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HybridConnectionName != v.Expected.HybridConnectionName { + t.Fatalf("Expected %q but got %q for HybridConnectionName", v.Expected.HybridConnectionName, actual.HybridConnectionName) + } + + } +} + +func TestParseHybridConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *HybridConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hYbRiDcOnNeCtIoN", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnection/hybridConnectionName", + Expected: &HybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + HybridConnectionName: "hybridConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnection/hybridConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hYbRiDcOnNeCtIoN/hYbRiDcOnNeCtIoNnAmE", + Expected: &HybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + HybridConnectionName: "hYbRiDcOnNeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hYbRiDcOnNeCtIoN/hYbRiDcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseHybridConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HybridConnectionName != v.Expected.HybridConnectionName { + t.Fatalf("Expected %q but got %q for HybridConnectionName", v.Expected.HybridConnectionName, actual.HybridConnectionName) + } + + } +} + +func TestSegmentsForHybridConnectionId(t *testing.T) { + segments := HybridConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("HybridConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_instance.go b/resource-manager/web/2024-11-01/webapps/id_instance.go new file mode 100644 index 00000000000..f43fc67da55 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_instance.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&InstanceId{}) +} + +var _ resourceids.ResourceId = &InstanceId{} + +// InstanceId is a struct representing the Resource ID for a Instance +type InstanceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + InstanceId string +} + +// NewInstanceID returns a new InstanceId struct +func NewInstanceID(subscriptionId string, resourceGroupName string, siteName string, instanceId string) InstanceId { + return InstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + InstanceId: instanceId, + } +} + +// ParseInstanceID parses 'input' into a InstanceId +func ParseInstanceID(input string) (*InstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseInstanceIDInsensitively parses 'input' case-insensitively into a InstanceId +// note: this method should only be used for API response data and not user input +func ParseInstanceIDInsensitively(input string) (*InstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *InstanceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + return nil +} + +// ValidateInstanceID checks that 'input' can be parsed as a Instance ID +func ValidateInstanceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Instance ID +func (id InstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/instances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.InstanceId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Instance ID +func (id InstanceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceId"), + } +} + +// String returns a human-readable description of this Instance ID +func (id InstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Instance: %q", id.InstanceId), + } + return fmt.Sprintf("Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_instance_test.go b/resource-manager/web/2024-11-01/webapps/id_instance_test.go new file mode 100644 index 00000000000..34b663d63cc --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_instance_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &InstanceId{} + +func TestNewInstanceID(t *testing.T) { + id := NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.InstanceId != "instanceId" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceId") + } +} + +func TestFormatInstanceID(t *testing.T) { + actual := NewInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId", + Expected: &InstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + InstanceId: "instanceId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + } +} + +func TestParseInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId", + Expected: &InstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + InstanceId: "instanceId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD", + Expected: &InstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + InstanceId: "iNsTaNcEiD", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + } +} + +func TestSegmentsForInstanceId(t *testing.T) { + segments := InstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("InstanceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_instanceprocess.go b/resource-manager/web/2024-11-01/webapps/id_instanceprocess.go new file mode 100644 index 00000000000..86610e6df3c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_instanceprocess.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&InstanceProcessId{}) +} + +var _ resourceids.ResourceId = &InstanceProcessId{} + +// InstanceProcessId is a struct representing the Resource ID for a Instance Process +type InstanceProcessId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + InstanceId string + ProcessId string +} + +// NewInstanceProcessID returns a new InstanceProcessId struct +func NewInstanceProcessID(subscriptionId string, resourceGroupName string, siteName string, instanceId string, processId string) InstanceProcessId { + return InstanceProcessId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + InstanceId: instanceId, + ProcessId: processId, + } +} + +// ParseInstanceProcessID parses 'input' into a InstanceProcessId +func ParseInstanceProcessID(input string) (*InstanceProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceProcessId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceProcessId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseInstanceProcessIDInsensitively parses 'input' case-insensitively into a InstanceProcessId +// note: this method should only be used for API response data and not user input +func ParseInstanceProcessIDInsensitively(input string) (*InstanceProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceProcessId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceProcessId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *InstanceProcessId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + return nil +} + +// ValidateInstanceProcessID checks that 'input' can be parsed as a Instance Process ID +func ValidateInstanceProcessID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseInstanceProcessID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Instance Process ID +func (id InstanceProcessId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/instances/%s/processes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.InstanceId, id.ProcessId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Instance Process ID +func (id InstanceProcessId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceId"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processId"), + } +} + +// String returns a human-readable description of this Instance Process ID +func (id InstanceProcessId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Instance: %q", id.InstanceId), + fmt.Sprintf("Process: %q", id.ProcessId), + } + return fmt.Sprintf("Instance Process (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_instanceprocess_test.go b/resource-manager/web/2024-11-01/webapps/id_instanceprocess_test.go new file mode 100644 index 00000000000..dbfed807250 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_instanceprocess_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &InstanceProcessId{} + +func TestNewInstanceProcessID(t *testing.T) { + id := NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.InstanceId != "instanceId" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceId") + } + + if id.ProcessId != "processId" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processId") + } +} + +func TestFormatInstanceProcessID(t *testing.T) { + actual := NewInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseInstanceProcessID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceProcessId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId", + Expected: &InstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + InstanceId: "instanceId", + ProcessId: "processId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceProcessID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestParseInstanceProcessIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceProcessId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId", + Expected: &InstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + InstanceId: "instanceId", + ProcessId: "processId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId", + Expected: &InstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + InstanceId: "iNsTaNcEiD", + ProcessId: "pRoCeSsId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceProcessIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestSegmentsForInstanceProcessId(t *testing.T) { + segments := InstanceProcessId{}.Segments() + if len(segments) == 0 { + t.Fatalf("InstanceProcessId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_instanceprocessmodule.go b/resource-manager/web/2024-11-01/webapps/id_instanceprocessmodule.go new file mode 100644 index 00000000000..28225e030f5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_instanceprocessmodule.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&InstanceProcessModuleId{}) +} + +var _ resourceids.ResourceId = &InstanceProcessModuleId{} + +// InstanceProcessModuleId is a struct representing the Resource ID for a Instance Process Module +type InstanceProcessModuleId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + InstanceId string + ProcessId string + ModuleName string +} + +// NewInstanceProcessModuleID returns a new InstanceProcessModuleId struct +func NewInstanceProcessModuleID(subscriptionId string, resourceGroupName string, siteName string, instanceId string, processId string, moduleName string) InstanceProcessModuleId { + return InstanceProcessModuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + InstanceId: instanceId, + ProcessId: processId, + ModuleName: moduleName, + } +} + +// ParseInstanceProcessModuleID parses 'input' into a InstanceProcessModuleId +func ParseInstanceProcessModuleID(input string) (*InstanceProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceProcessModuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceProcessModuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseInstanceProcessModuleIDInsensitively parses 'input' case-insensitively into a InstanceProcessModuleId +// note: this method should only be used for API response data and not user input +func ParseInstanceProcessModuleIDInsensitively(input string) (*InstanceProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&InstanceProcessModuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := InstanceProcessModuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *InstanceProcessModuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + if id.ModuleName, ok = input.Parsed["moduleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "moduleName", input) + } + + return nil +} + +// ValidateInstanceProcessModuleID checks that 'input' can be parsed as a Instance Process Module ID +func ValidateInstanceProcessModuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseInstanceProcessModuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Instance Process Module ID +func (id InstanceProcessModuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/instances/%s/processes/%s/modules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.InstanceId, id.ProcessId, id.ModuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Instance Process Module ID +func (id InstanceProcessModuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceId"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processId"), + resourceids.StaticSegment("staticModules", "modules", "modules"), + resourceids.UserSpecifiedSegment("moduleName", "moduleName"), + } +} + +// String returns a human-readable description of this Instance Process Module ID +func (id InstanceProcessModuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Instance: %q", id.InstanceId), + fmt.Sprintf("Process: %q", id.ProcessId), + fmt.Sprintf("Module Name: %q", id.ModuleName), + } + return fmt.Sprintf("Instance Process Module (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_instanceprocessmodule_test.go b/resource-manager/web/2024-11-01/webapps/id_instanceprocessmodule_test.go new file mode 100644 index 00000000000..7e118c5f387 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_instanceprocessmodule_test.go @@ -0,0 +1,417 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &InstanceProcessModuleId{} + +func TestNewInstanceProcessModuleID(t *testing.T) { + id := NewInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId", "moduleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.InstanceId != "instanceId" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceId") + } + + if id.ProcessId != "processId" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processId") + } + + if id.ModuleName != "moduleName" { + t.Fatalf("Expected %q but got %q for Segment 'ModuleName'", id.ModuleName, "moduleName") + } +} + +func TestFormatInstanceProcessModuleID(t *testing.T) { + actual := NewInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "instanceId", "processId", "moduleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/modules/moduleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseInstanceProcessModuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceProcessModuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/modules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/modules/moduleName", + Expected: &InstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + InstanceId: "instanceId", + ProcessId: "processId", + ModuleName: "moduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/modules/moduleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceProcessModuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestParseInstanceProcessModuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *InstanceProcessModuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/modules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId/mOdUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/modules/moduleName", + Expected: &InstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + InstanceId: "instanceId", + ProcessId: "processId", + ModuleName: "moduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/instances/instanceId/processes/processId/modules/moduleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId/mOdUlEs/mOdUlEnAmE", + Expected: &InstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + InstanceId: "iNsTaNcEiD", + ProcessId: "pRoCeSsId", + ModuleName: "mOdUlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId/mOdUlEs/mOdUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseInstanceProcessModuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestSegmentsForInstanceProcessModuleId(t *testing.T) { + segments := InstanceProcessModuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("InstanceProcessModuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_key.go b/resource-manager/web/2024-11-01/webapps/id_key.go new file mode 100644 index 00000000000..ca9170618d4 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_key.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&KeyId{}) +} + +var _ resourceids.ResourceId = &KeyId{} + +// KeyId is a struct representing the Resource ID for a Key +type KeyId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + FunctionName string + KeyName string +} + +// NewKeyID returns a new KeyId struct +func NewKeyID(subscriptionId string, resourceGroupName string, siteName string, functionName string, keyName string) KeyId { + return KeyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + FunctionName: functionName, + KeyName: keyName, + } +} + +// ParseKeyID parses 'input' into a KeyId +func ParseKeyID(input string) (*KeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&KeyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseKeyIDInsensitively parses 'input' case-insensitively into a KeyId +// note: this method should only be used for API response data and not user input +func ParseKeyIDInsensitively(input string) (*KeyId, error) { + parser := resourceids.NewParserFromResourceIdType(&KeyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := KeyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *KeyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.FunctionName, ok = input.Parsed["functionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "functionName", input) + } + + if id.KeyName, ok = input.Parsed["keyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "keyName", input) + } + + return nil +} + +// ValidateKeyID checks that 'input' can be parsed as a Key ID +func ValidateKeyID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseKeyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Key ID +func (id KeyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/functions/%s/keys/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.FunctionName, id.KeyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Key ID +func (id KeyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticFunctions", "functions", "functions"), + resourceids.UserSpecifiedSegment("functionName", "functionName"), + resourceids.StaticSegment("staticKeys", "keys", "keys"), + resourceids.UserSpecifiedSegment("keyName", "keyName"), + } +} + +// String returns a human-readable description of this Key ID +func (id KeyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Function Name: %q", id.FunctionName), + fmt.Sprintf("Key Name: %q", id.KeyName), + } + return fmt.Sprintf("Key (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_key_test.go b/resource-manager/web/2024-11-01/webapps/id_key_test.go new file mode 100644 index 00000000000..0d951499006 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_key_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &KeyId{} + +func TestNewKeyID(t *testing.T) { + id := NewKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName", "keyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.FunctionName != "functionName" { + t.Fatalf("Expected %q but got %q for Segment 'FunctionName'", id.FunctionName, "functionName") + } + + if id.KeyName != "keyName" { + t.Fatalf("Expected %q but got %q for Segment 'KeyName'", id.KeyName, "keyName") + } +} + +func TestFormatKeyID(t *testing.T) { + actual := NewKeyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "functionName", "keyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/keys/keyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseKeyID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KeyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/keys", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/keys/keyName", + Expected: &KeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + FunctionName: "functionName", + KeyName: "keyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/keys/keyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKeyID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestParseKeyIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *KeyId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/fUnCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/fUnCtIoNs/fUnCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/keys", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/fUnCtIoNs/fUnCtIoNnAmE/kEyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/keys/keyName", + Expected: &KeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + FunctionName: "functionName", + KeyName: "keyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/functions/functionName/keys/keyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/fUnCtIoNs/fUnCtIoNnAmE/kEyS/kEyNaMe", + Expected: &KeyId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + FunctionName: "fUnCtIoNnAmE", + KeyName: "kEyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/fUnCtIoNs/fUnCtIoNnAmE/kEyS/kEyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseKeyIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + if actual.KeyName != v.Expected.KeyName { + t.Fatalf("Expected %q but got %q for KeyName", v.Expected.KeyName, actual.KeyName) + } + + } +} + +func TestSegmentsForKeyId(t *testing.T) { + segments := KeyId{}.Segments() + if len(segments) == 0 { + t.Fatalf("KeyId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_module.go b/resource-manager/web/2024-11-01/webapps/id_module.go new file mode 100644 index 00000000000..88421388b85 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_module.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ModuleId{}) +} + +var _ resourceids.ResourceId = &ModuleId{} + +// ModuleId is a struct representing the Resource ID for a Module +type ModuleId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + ProcessId string + ModuleName string +} + +// NewModuleID returns a new ModuleId struct +func NewModuleID(subscriptionId string, resourceGroupName string, siteName string, processId string, moduleName string) ModuleId { + return ModuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + ProcessId: processId, + ModuleName: moduleName, + } +} + +// ParseModuleID parses 'input' into a ModuleId +func ParseModuleID(input string) (*ModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&ModuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ModuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseModuleIDInsensitively parses 'input' case-insensitively into a ModuleId +// note: this method should only be used for API response data and not user input +func ParseModuleIDInsensitively(input string) (*ModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&ModuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ModuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ModuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + if id.ModuleName, ok = input.Parsed["moduleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "moduleName", input) + } + + return nil +} + +// ValidateModuleID checks that 'input' can be parsed as a Module ID +func ValidateModuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseModuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Module ID +func (id ModuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/processes/%s/modules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.ProcessId, id.ModuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Module ID +func (id ModuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processId"), + resourceids.StaticSegment("staticModules", "modules", "modules"), + resourceids.UserSpecifiedSegment("moduleName", "moduleName"), + } +} + +// String returns a human-readable description of this Module ID +func (id ModuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Process: %q", id.ProcessId), + fmt.Sprintf("Module Name: %q", id.ModuleName), + } + return fmt.Sprintf("Module (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_module_test.go b/resource-manager/web/2024-11-01/webapps/id_module_test.go new file mode 100644 index 00000000000..d5e57223ef0 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_module_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ModuleId{} + +func TestNewModuleID(t *testing.T) { + id := NewModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId", "moduleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.ProcessId != "processId" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processId") + } + + if id.ModuleName != "moduleName" { + t.Fatalf("Expected %q but got %q for Segment 'ModuleName'", id.ModuleName, "moduleName") + } +} + +func TestFormatModuleID(t *testing.T) { + actual := NewModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId", "moduleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/modules/moduleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseModuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ModuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/modules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/modules/moduleName", + Expected: &ModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + ProcessId: "processId", + ModuleName: "moduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/modules/moduleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseModuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestParseModuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ModuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRoCeSsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRoCeSsEs/pRoCeSsId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/modules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRoCeSsEs/pRoCeSsId/mOdUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/modules/moduleName", + Expected: &ModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + ProcessId: "processId", + ModuleName: "moduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/modules/moduleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRoCeSsEs/pRoCeSsId/mOdUlEs/mOdUlEnAmE", + Expected: &ModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + ProcessId: "pRoCeSsId", + ModuleName: "mOdUlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRoCeSsEs/pRoCeSsId/mOdUlEs/mOdUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseModuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestSegmentsForModuleId(t *testing.T) { + segments := ModuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ModuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_networkfeature.go b/resource-manager/web/2024-11-01/webapps/id_networkfeature.go new file mode 100644 index 00000000000..dc1966efd90 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_networkfeature.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkFeatureId{}) +} + +var _ resourceids.ResourceId = &NetworkFeatureId{} + +// NetworkFeatureId is a struct representing the Resource ID for a Network Feature +type NetworkFeatureId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + NetworkFeatureName string +} + +// NewNetworkFeatureID returns a new NetworkFeatureId struct +func NewNetworkFeatureID(subscriptionId string, resourceGroupName string, siteName string, networkFeatureName string) NetworkFeatureId { + return NetworkFeatureId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + NetworkFeatureName: networkFeatureName, + } +} + +// ParseNetworkFeatureID parses 'input' into a NetworkFeatureId +func ParseNetworkFeatureID(input string) (*NetworkFeatureId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkFeatureId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkFeatureId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkFeatureIDInsensitively parses 'input' case-insensitively into a NetworkFeatureId +// note: this method should only be used for API response data and not user input +func ParseNetworkFeatureIDInsensitively(input string) (*NetworkFeatureId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkFeatureId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkFeatureId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkFeatureId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.NetworkFeatureName, ok = input.Parsed["networkFeatureName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkFeatureName", input) + } + + return nil +} + +// ValidateNetworkFeatureID checks that 'input' can be parsed as a Network Feature ID +func ValidateNetworkFeatureID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkFeatureID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Feature ID +func (id NetworkFeatureId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/networkFeatures/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.NetworkFeatureName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Feature ID +func (id NetworkFeatureId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticNetworkFeatures", "networkFeatures", "networkFeatures"), + resourceids.UserSpecifiedSegment("networkFeatureName", "networkFeatureName"), + } +} + +// String returns a human-readable description of this Network Feature ID +func (id NetworkFeatureId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Network Feature Name: %q", id.NetworkFeatureName), + } + return fmt.Sprintf("Network Feature (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_networkfeature_test.go b/resource-manager/web/2024-11-01/webapps/id_networkfeature_test.go new file mode 100644 index 00000000000..1c1bafc5113 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_networkfeature_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkFeatureId{} + +func TestNewNetworkFeatureID(t *testing.T) { + id := NewNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "networkFeatureName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.NetworkFeatureName != "networkFeatureName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkFeatureName'", id.NetworkFeatureName, "networkFeatureName") + } +} + +func TestFormatNetworkFeatureID(t *testing.T) { + actual := NewNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "networkFeatureName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkFeatures/networkFeatureName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkFeatureID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkFeatureId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkFeatures", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkFeatures/networkFeatureName", + Expected: &NetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + NetworkFeatureName: "networkFeatureName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkFeatures/networkFeatureName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkFeatureID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.NetworkFeatureName != v.Expected.NetworkFeatureName { + t.Fatalf("Expected %q but got %q for NetworkFeatureName", v.Expected.NetworkFeatureName, actual.NetworkFeatureName) + } + + } +} + +func TestParseNetworkFeatureIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkFeatureId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkFeatures", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/nEtWoRkFeAtUrEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkFeatures/networkFeatureName", + Expected: &NetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + NetworkFeatureName: "networkFeatureName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkFeatures/networkFeatureName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/nEtWoRkFeAtUrEs/nEtWoRkFeAtUrEnAmE", + Expected: &NetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + NetworkFeatureName: "nEtWoRkFeAtUrEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/nEtWoRkFeAtUrEs/nEtWoRkFeAtUrEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkFeatureIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.NetworkFeatureName != v.Expected.NetworkFeatureName { + t.Fatalf("Expected %q but got %q for NetworkFeatureName", v.Expected.NetworkFeatureName, actual.NetworkFeatureName) + } + + } +} + +func TestSegmentsForNetworkFeatureId(t *testing.T) { + segments := NetworkFeatureId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkFeatureId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_networktrace.go b/resource-manager/web/2024-11-01/webapps/id_networktrace.go new file mode 100644 index 00000000000..d7b89a69dd1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_networktrace.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&NetworkTraceId{}) +} + +var _ resourceids.ResourceId = &NetworkTraceId{} + +// NetworkTraceId is a struct representing the Resource ID for a Network Trace +type NetworkTraceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + OperationId string +} + +// NewNetworkTraceID returns a new NetworkTraceId struct +func NewNetworkTraceID(subscriptionId string, resourceGroupName string, siteName string, operationId string) NetworkTraceId { + return NetworkTraceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + OperationId: operationId, + } +} + +// ParseNetworkTraceID parses 'input' into a NetworkTraceId +func ParseNetworkTraceID(input string) (*NetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkTraceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkTraceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseNetworkTraceIDInsensitively parses 'input' case-insensitively into a NetworkTraceId +// note: this method should only be used for API response data and not user input +func ParseNetworkTraceIDInsensitively(input string) (*NetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&NetworkTraceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := NetworkTraceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *NetworkTraceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.OperationId, ok = input.Parsed["operationId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "operationId", input) + } + + return nil +} + +// ValidateNetworkTraceID checks that 'input' can be parsed as a Network Trace ID +func ValidateNetworkTraceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseNetworkTraceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Network Trace ID +func (id NetworkTraceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/networkTrace/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.OperationId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Network Trace ID +func (id NetworkTraceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticNetworkTrace", "networkTrace", "networkTrace"), + resourceids.UserSpecifiedSegment("operationId", "operationId"), + } +} + +// String returns a human-readable description of this Network Trace ID +func (id NetworkTraceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Operation: %q", id.OperationId), + } + return fmt.Sprintf("Network Trace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_networktrace_test.go b/resource-manager/web/2024-11-01/webapps/id_networktrace_test.go new file mode 100644 index 00000000000..2ca9e11dd67 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_networktrace_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &NetworkTraceId{} + +func TestNewNetworkTraceID(t *testing.T) { + id := NewNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "operationId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.OperationId != "operationId" { + t.Fatalf("Expected %q but got %q for Segment 'OperationId'", id.OperationId, "operationId") + } +} + +func TestFormatNetworkTraceID(t *testing.T) { + actual := NewNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "operationId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTrace/operationId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseNetworkTraceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkTraceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTrace", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTrace/operationId", + Expected: &NetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + OperationId: "operationId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTrace/operationId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkTraceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestParseNetworkTraceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *NetworkTraceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTrace", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/nEtWoRkTrAcE", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTrace/operationId", + Expected: &NetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + OperationId: "operationId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTrace/operationId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/nEtWoRkTrAcE/oPeRaTiOnId", + Expected: &NetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + OperationId: "oPeRaTiOnId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/nEtWoRkTrAcE/oPeRaTiOnId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseNetworkTraceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestSegmentsForNetworkTraceId(t *testing.T) { + segments := NetworkTraceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("NetworkTraceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_premieraddon.go b/resource-manager/web/2024-11-01/webapps/id_premieraddon.go new file mode 100644 index 00000000000..e2a7b5cf220 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_premieraddon.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PremierAddonId{}) +} + +var _ resourceids.ResourceId = &PremierAddonId{} + +// PremierAddonId is a struct representing the Resource ID for a Premier Addon +type PremierAddonId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + PremierAddonName string +} + +// NewPremierAddonID returns a new PremierAddonId struct +func NewPremierAddonID(subscriptionId string, resourceGroupName string, siteName string, premierAddonName string) PremierAddonId { + return PremierAddonId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + PremierAddonName: premierAddonName, + } +} + +// ParsePremierAddonID parses 'input' into a PremierAddonId +func ParsePremierAddonID(input string) (*PremierAddonId, error) { + parser := resourceids.NewParserFromResourceIdType(&PremierAddonId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PremierAddonId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePremierAddonIDInsensitively parses 'input' case-insensitively into a PremierAddonId +// note: this method should only be used for API response data and not user input +func ParsePremierAddonIDInsensitively(input string) (*PremierAddonId, error) { + parser := resourceids.NewParserFromResourceIdType(&PremierAddonId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PremierAddonId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PremierAddonId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.PremierAddonName, ok = input.Parsed["premierAddonName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "premierAddonName", input) + } + + return nil +} + +// ValidatePremierAddonID checks that 'input' can be parsed as a Premier Addon ID +func ValidatePremierAddonID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePremierAddonID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Premier Addon ID +func (id PremierAddonId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/premierAddons/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.PremierAddonName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Premier Addon ID +func (id PremierAddonId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticPremierAddons", "premierAddons", "premierAddons"), + resourceids.UserSpecifiedSegment("premierAddonName", "premierAddonName"), + } +} + +// String returns a human-readable description of this Premier Addon ID +func (id PremierAddonId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Premier Addon Name: %q", id.PremierAddonName), + } + return fmt.Sprintf("Premier Addon (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_premieraddon_test.go b/resource-manager/web/2024-11-01/webapps/id_premieraddon_test.go new file mode 100644 index 00000000000..2c292945ce2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_premieraddon_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PremierAddonId{} + +func TestNewPremierAddonID(t *testing.T) { + id := NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "premierAddonName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.PremierAddonName != "premierAddonName" { + t.Fatalf("Expected %q but got %q for Segment 'PremierAddonName'", id.PremierAddonName, "premierAddonName") + } +} + +func TestFormatPremierAddonID(t *testing.T) { + actual := NewPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "premierAddonName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/premierAddons/premierAddonName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePremierAddonID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PremierAddonId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/premierAddons", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/premierAddons/premierAddonName", + Expected: &PremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + PremierAddonName: "premierAddonName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/premierAddons/premierAddonName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePremierAddonID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PremierAddonName != v.Expected.PremierAddonName { + t.Fatalf("Expected %q but got %q for PremierAddonName", v.Expected.PremierAddonName, actual.PremierAddonName) + } + + } +} + +func TestParsePremierAddonIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PremierAddonId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/premierAddons", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pReMiErAdDoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/premierAddons/premierAddonName", + Expected: &PremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + PremierAddonName: "premierAddonName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/premierAddons/premierAddonName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pReMiErAdDoNs/pReMiErAdDoNnAmE", + Expected: &PremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + PremierAddonName: "pReMiErAdDoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pReMiErAdDoNs/pReMiErAdDoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePremierAddonIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PremierAddonName != v.Expected.PremierAddonName { + t.Fatalf("Expected %q but got %q for PremierAddonName", v.Expected.PremierAddonName, actual.PremierAddonName) + } + + } +} + +func TestSegmentsForPremierAddonId(t *testing.T) { + segments := PremierAddonId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PremierAddonId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_privateendpointconnection.go b/resource-manager/web/2024-11-01/webapps/id_privateendpointconnection.go new file mode 100644 index 00000000000..c7d9dfbd7e0 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, siteName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_privateendpointconnection_test.go b/resource-manager/web/2024-11-01/webapps/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..b8561c67c85 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "privateEndpointConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_process.go b/resource-manager/web/2024-11-01/webapps/id_process.go new file mode 100644 index 00000000000..4bd04a2dc5a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_process.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProcessId{}) +} + +var _ resourceids.ResourceId = &ProcessId{} + +// ProcessId is a struct representing the Resource ID for a Process +type ProcessId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + ProcessId string +} + +// NewProcessID returns a new ProcessId struct +func NewProcessID(subscriptionId string, resourceGroupName string, siteName string, processId string) ProcessId { + return ProcessId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + ProcessId: processId, + } +} + +// ParseProcessID parses 'input' into a ProcessId +func ParseProcessID(input string) (*ProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProcessId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProcessId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProcessIDInsensitively parses 'input' case-insensitively into a ProcessId +// note: this method should only be used for API response data and not user input +func ParseProcessIDInsensitively(input string) (*ProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProcessId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProcessId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProcessId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + return nil +} + +// ValidateProcessID checks that 'input' can be parsed as a Process ID +func ValidateProcessID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProcessID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Process ID +func (id ProcessId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/processes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.ProcessId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Process ID +func (id ProcessId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processId"), + } +} + +// String returns a human-readable description of this Process ID +func (id ProcessId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Process: %q", id.ProcessId), + } + return fmt.Sprintf("Process (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_process_test.go b/resource-manager/web/2024-11-01/webapps/id_process_test.go new file mode 100644 index 00000000000..01626642762 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_process_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProcessId{} + +func TestNewProcessID(t *testing.T) { + id := NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.ProcessId != "processId" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processId") + } +} + +func TestFormatProcessID(t *testing.T) { + actual := NewProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "processId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProcessID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProcessId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId", + Expected: &ProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + ProcessId: "processId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProcessID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestParseProcessIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProcessId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRoCeSsEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId", + Expected: &ProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + ProcessId: "processId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/processes/processId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRoCeSsEs/pRoCeSsId", + Expected: &ProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + ProcessId: "pRoCeSsId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pRoCeSsEs/pRoCeSsId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProcessIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestSegmentsForProcessId(t *testing.T) { + segments := ProcessId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProcessId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_processmodule.go b/resource-manager/web/2024-11-01/webapps/id_processmodule.go new file mode 100644 index 00000000000..5219175f699 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_processmodule.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ProcessModuleId{}) +} + +var _ resourceids.ResourceId = &ProcessModuleId{} + +// ProcessModuleId is a struct representing the Resource ID for a Process Module +type ProcessModuleId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + ProcessId string + ModuleName string +} + +// NewProcessModuleID returns a new ProcessModuleId struct +func NewProcessModuleID(subscriptionId string, resourceGroupName string, siteName string, slotName string, processId string, moduleName string) ProcessModuleId { + return ProcessModuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + ProcessId: processId, + ModuleName: moduleName, + } +} + +// ParseProcessModuleID parses 'input' into a ProcessModuleId +func ParseProcessModuleID(input string) (*ProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProcessModuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProcessModuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseProcessModuleIDInsensitively parses 'input' case-insensitively into a ProcessModuleId +// note: this method should only be used for API response data and not user input +func ParseProcessModuleIDInsensitively(input string) (*ProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&ProcessModuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ProcessModuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ProcessModuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + if id.ModuleName, ok = input.Parsed["moduleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "moduleName", input) + } + + return nil +} + +// ValidateProcessModuleID checks that 'input' can be parsed as a Process Module ID +func ValidateProcessModuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseProcessModuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Process Module ID +func (id ProcessModuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/processes/%s/modules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.ProcessId, id.ModuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Process Module ID +func (id ProcessModuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processId"), + resourceids.StaticSegment("staticModules", "modules", "modules"), + resourceids.UserSpecifiedSegment("moduleName", "moduleName"), + } +} + +// String returns a human-readable description of this Process Module ID +func (id ProcessModuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Process: %q", id.ProcessId), + fmt.Sprintf("Module Name: %q", id.ModuleName), + } + return fmt.Sprintf("Process Module (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_processmodule_test.go b/resource-manager/web/2024-11-01/webapps/id_processmodule_test.go new file mode 100644 index 00000000000..de7af2c9000 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_processmodule_test.go @@ -0,0 +1,417 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ProcessModuleId{} + +func TestNewProcessModuleID(t *testing.T) { + id := NewProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId", "moduleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.ProcessId != "processId" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processId") + } + + if id.ModuleName != "moduleName" { + t.Fatalf("Expected %q but got %q for Segment 'ModuleName'", id.ModuleName, "moduleName") + } +} + +func TestFormatProcessModuleID(t *testing.T) { + actual := NewProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId", "moduleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/modules/moduleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseProcessModuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProcessModuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/modules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/modules/moduleName", + Expected: &ProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + ProcessId: "processId", + ModuleName: "moduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/modules/moduleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProcessModuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestParseProcessModuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ProcessModuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRoCeSsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRoCeSsEs/pRoCeSsId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/modules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRoCeSsEs/pRoCeSsId/mOdUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/modules/moduleName", + Expected: &ProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + ProcessId: "processId", + ModuleName: "moduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/modules/moduleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRoCeSsEs/pRoCeSsId/mOdUlEs/mOdUlEnAmE", + Expected: &ProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + ProcessId: "pRoCeSsId", + ModuleName: "mOdUlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRoCeSsEs/pRoCeSsId/mOdUlEs/mOdUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseProcessModuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestSegmentsForProcessModuleId(t *testing.T) { + segments := ProcessModuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ProcessModuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_publiccertificate.go b/resource-manager/web/2024-11-01/webapps/id_publiccertificate.go new file mode 100644 index 00000000000..ab810e6cab6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_publiccertificate.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PublicCertificateId{}) +} + +var _ resourceids.ResourceId = &PublicCertificateId{} + +// PublicCertificateId is a struct representing the Resource ID for a Public Certificate +type PublicCertificateId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + PublicCertificateName string +} + +// NewPublicCertificateID returns a new PublicCertificateId struct +func NewPublicCertificateID(subscriptionId string, resourceGroupName string, siteName string, publicCertificateName string) PublicCertificateId { + return PublicCertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + PublicCertificateName: publicCertificateName, + } +} + +// ParsePublicCertificateID parses 'input' into a PublicCertificateId +func ParsePublicCertificateID(input string) (*PublicCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&PublicCertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PublicCertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePublicCertificateIDInsensitively parses 'input' case-insensitively into a PublicCertificateId +// note: this method should only be used for API response data and not user input +func ParsePublicCertificateIDInsensitively(input string) (*PublicCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&PublicCertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PublicCertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PublicCertificateId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.PublicCertificateName, ok = input.Parsed["publicCertificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "publicCertificateName", input) + } + + return nil +} + +// ValidatePublicCertificateID checks that 'input' can be parsed as a Public Certificate ID +func ValidatePublicCertificateID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePublicCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Public Certificate ID +func (id PublicCertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/publicCertificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.PublicCertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Public Certificate ID +func (id PublicCertificateId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticPublicCertificates", "publicCertificates", "publicCertificates"), + resourceids.UserSpecifiedSegment("publicCertificateName", "publicCertificateName"), + } +} + +// String returns a human-readable description of this Public Certificate ID +func (id PublicCertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Public Certificate Name: %q", id.PublicCertificateName), + } + return fmt.Sprintf("Public Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_publiccertificate_test.go b/resource-manager/web/2024-11-01/webapps/id_publiccertificate_test.go new file mode 100644 index 00000000000..947dd952615 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_publiccertificate_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PublicCertificateId{} + +func TestNewPublicCertificateID(t *testing.T) { + id := NewPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "publicCertificateName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.PublicCertificateName != "publicCertificateName" { + t.Fatalf("Expected %q but got %q for Segment 'PublicCertificateName'", id.PublicCertificateName, "publicCertificateName") + } +} + +func TestFormatPublicCertificateID(t *testing.T) { + actual := NewPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "publicCertificateName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/publicCertificates/publicCertificateName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePublicCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PublicCertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/publicCertificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/publicCertificates/publicCertificateName", + Expected: &PublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + PublicCertificateName: "publicCertificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/publicCertificates/publicCertificateName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePublicCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PublicCertificateName != v.Expected.PublicCertificateName { + t.Fatalf("Expected %q but got %q for PublicCertificateName", v.Expected.PublicCertificateName, actual.PublicCertificateName) + } + + } +} + +func TestParsePublicCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PublicCertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/publicCertificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pUbLiCcErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/publicCertificates/publicCertificateName", + Expected: &PublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + PublicCertificateName: "publicCertificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/publicCertificates/publicCertificateName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pUbLiCcErTiFiCaTeS/pUbLiCcErTiFiCaTeNaMe", + Expected: &PublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + PublicCertificateName: "pUbLiCcErTiFiCaTeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/pUbLiCcErTiFiCaTeS/pUbLiCcErTiFiCaTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePublicCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.PublicCertificateName != v.Expected.PublicCertificateName { + t.Fatalf("Expected %q but got %q for PublicCertificateName", v.Expected.PublicCertificateName, actual.PublicCertificateName) + } + + } +} + +func TestSegmentsForPublicCertificateId(t *testing.T) { + segments := PublicCertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PublicCertificateId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_relay.go b/resource-manager/web/2024-11-01/webapps/id_relay.go new file mode 100644 index 00000000000..4af77542a26 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_relay.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RelayId{}) +} + +var _ resourceids.ResourceId = &RelayId{} + +// RelayId is a struct representing the Resource ID for a Relay +type RelayId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + HybridConnectionNamespaceName string + RelayName string +} + +// NewRelayID returns a new RelayId struct +func NewRelayID(subscriptionId string, resourceGroupName string, siteName string, hybridConnectionNamespaceName string, relayName string) RelayId { + return RelayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + HybridConnectionNamespaceName: hybridConnectionNamespaceName, + RelayName: relayName, + } +} + +// ParseRelayID parses 'input' into a RelayId +func ParseRelayID(input string) (*RelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&RelayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RelayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRelayIDInsensitively parses 'input' case-insensitively into a RelayId +// note: this method should only be used for API response data and not user input +func ParseRelayIDInsensitively(input string) (*RelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&RelayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RelayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RelayId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.HybridConnectionNamespaceName, ok = input.Parsed["hybridConnectionNamespaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hybridConnectionNamespaceName", input) + } + + if id.RelayName, ok = input.Parsed["relayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "relayName", input) + } + + return nil +} + +// ValidateRelayID checks that 'input' can be parsed as a Relay ID +func ValidateRelayID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRelayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Relay ID +func (id RelayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hybridConnectionNamespaces/%s/relays/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.HybridConnectionNamespaceName, id.RelayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Relay ID +func (id RelayId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHybridConnectionNamespaces", "hybridConnectionNamespaces", "hybridConnectionNamespaces"), + resourceids.UserSpecifiedSegment("hybridConnectionNamespaceName", "hybridConnectionNamespaceName"), + resourceids.StaticSegment("staticRelays", "relays", "relays"), + resourceids.UserSpecifiedSegment("relayName", "relayName"), + } +} + +// String returns a human-readable description of this Relay ID +func (id RelayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Hybrid Connection Namespace Name: %q", id.HybridConnectionNamespaceName), + fmt.Sprintf("Relay Name: %q", id.RelayName), + } + return fmt.Sprintf("Relay (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_relay_test.go b/resource-manager/web/2024-11-01/webapps/id_relay_test.go new file mode 100644 index 00000000000..b0ca40050e1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_relay_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RelayId{} + +func TestNewRelayID(t *testing.T) { + id := NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionNamespaceName", "relayName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.HybridConnectionNamespaceName != "hybridConnectionNamespaceName" { + t.Fatalf("Expected %q but got %q for Segment 'HybridConnectionNamespaceName'", id.HybridConnectionNamespaceName, "hybridConnectionNamespaceName") + } + + if id.RelayName != "relayName" { + t.Fatalf("Expected %q but got %q for Segment 'RelayName'", id.RelayName, "relayName") + } +} + +func TestFormatRelayID(t *testing.T) { + actual := NewRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "hybridConnectionNamespaceName", "relayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRelayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RelayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName", + Expected: &RelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + HybridConnectionNamespaceName: "hybridConnectionNamespaceName", + RelayName: "relayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRelayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestParseRelayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RelayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName", + Expected: &RelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + HybridConnectionNamespaceName: "hybridConnectionNamespaceName", + RelayName: "relayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS/rElAyNaMe", + Expected: &RelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + HybridConnectionNamespaceName: "hYbRiDcOnNeCtIoNnAmEsPaCeNaMe", + RelayName: "rElAyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS/rElAyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRelayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestSegmentsForRelayId(t *testing.T) { + segments := RelayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RelayId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_sitecontainer.go b/resource-manager/web/2024-11-01/webapps/id_sitecontainer.go new file mode 100644 index 00000000000..a6f2cf8a06c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_sitecontainer.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SitecontainerId{}) +} + +var _ resourceids.ResourceId = &SitecontainerId{} + +// SitecontainerId is a struct representing the Resource ID for a Sitecontainer +type SitecontainerId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SitecontainerName string +} + +// NewSitecontainerID returns a new SitecontainerId struct +func NewSitecontainerID(subscriptionId string, resourceGroupName string, siteName string, sitecontainerName string) SitecontainerId { + return SitecontainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SitecontainerName: sitecontainerName, + } +} + +// ParseSitecontainerID parses 'input' into a SitecontainerId +func ParseSitecontainerID(input string) (*SitecontainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&SitecontainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SitecontainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSitecontainerIDInsensitively parses 'input' case-insensitively into a SitecontainerId +// note: this method should only be used for API response data and not user input +func ParseSitecontainerIDInsensitively(input string) (*SitecontainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&SitecontainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SitecontainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SitecontainerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SitecontainerName, ok = input.Parsed["sitecontainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sitecontainerName", input) + } + + return nil +} + +// ValidateSitecontainerID checks that 'input' can be parsed as a Sitecontainer ID +func ValidateSitecontainerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSitecontainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Sitecontainer ID +func (id SitecontainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/sitecontainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SitecontainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Sitecontainer ID +func (id SitecontainerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSitecontainers", "sitecontainers", "sitecontainers"), + resourceids.UserSpecifiedSegment("sitecontainerName", "sitecontainerName"), + } +} + +// String returns a human-readable description of this Sitecontainer ID +func (id SitecontainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Sitecontainer Name: %q", id.SitecontainerName), + } + return fmt.Sprintf("Sitecontainer (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_sitecontainer_test.go b/resource-manager/web/2024-11-01/webapps/id_sitecontainer_test.go new file mode 100644 index 00000000000..cded30dec5d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_sitecontainer_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SitecontainerId{} + +func TestNewSitecontainerID(t *testing.T) { + id := NewSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "sitecontainerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SitecontainerName != "sitecontainerName" { + t.Fatalf("Expected %q but got %q for Segment 'SitecontainerName'", id.SitecontainerName, "sitecontainerName") + } +} + +func TestFormatSitecontainerID(t *testing.T) { + actual := NewSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "sitecontainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/sitecontainers/sitecontainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSitecontainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SitecontainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/sitecontainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/sitecontainers/sitecontainerName", + Expected: &SitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SitecontainerName: "sitecontainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/sitecontainers/sitecontainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSitecontainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SitecontainerName != v.Expected.SitecontainerName { + t.Fatalf("Expected %q but got %q for SitecontainerName", v.Expected.SitecontainerName, actual.SitecontainerName) + } + + } +} + +func TestParseSitecontainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SitecontainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/sitecontainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sItEcOnTaInErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/sitecontainers/sitecontainerName", + Expected: &SitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SitecontainerName: "sitecontainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/sitecontainers/sitecontainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sItEcOnTaInErS/sItEcOnTaInErNaMe", + Expected: &SitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SitecontainerName: "sItEcOnTaInErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sItEcOnTaInErS/sItEcOnTaInErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSitecontainerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SitecontainerName != v.Expected.SitecontainerName { + t.Fatalf("Expected %q but got %q for SitecontainerName", v.Expected.SitecontainerName, actual.SitecontainerName) + } + + } +} + +func TestSegmentsForSitecontainerId(t *testing.T) { + segments := SitecontainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SitecontainerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_sitedomainownershipidentifier.go b/resource-manager/web/2024-11-01/webapps/id_sitedomainownershipidentifier.go new file mode 100644 index 00000000000..ff59f8417f2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_sitedomainownershipidentifier.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SiteDomainOwnershipIdentifierId{}) +} + +var _ resourceids.ResourceId = &SiteDomainOwnershipIdentifierId{} + +// SiteDomainOwnershipIdentifierId is a struct representing the Resource ID for a Site Domain Ownership Identifier +type SiteDomainOwnershipIdentifierId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + DomainOwnershipIdentifierName string +} + +// NewSiteDomainOwnershipIdentifierID returns a new SiteDomainOwnershipIdentifierId struct +func NewSiteDomainOwnershipIdentifierID(subscriptionId string, resourceGroupName string, siteName string, domainOwnershipIdentifierName string) SiteDomainOwnershipIdentifierId { + return SiteDomainOwnershipIdentifierId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + DomainOwnershipIdentifierName: domainOwnershipIdentifierName, + } +} + +// ParseSiteDomainOwnershipIdentifierID parses 'input' into a SiteDomainOwnershipIdentifierId +func ParseSiteDomainOwnershipIdentifierID(input string) (*SiteDomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteDomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteDomainOwnershipIdentifierId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSiteDomainOwnershipIdentifierIDInsensitively parses 'input' case-insensitively into a SiteDomainOwnershipIdentifierId +// note: this method should only be used for API response data and not user input +func ParseSiteDomainOwnershipIdentifierIDInsensitively(input string) (*SiteDomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteDomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteDomainOwnershipIdentifierId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SiteDomainOwnershipIdentifierId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.DomainOwnershipIdentifierName, ok = input.Parsed["domainOwnershipIdentifierName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "domainOwnershipIdentifierName", input) + } + + return nil +} + +// ValidateSiteDomainOwnershipIdentifierID checks that 'input' can be parsed as a Site Domain Ownership Identifier ID +func ValidateSiteDomainOwnershipIdentifierID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSiteDomainOwnershipIdentifierID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Site Domain Ownership Identifier ID +func (id SiteDomainOwnershipIdentifierId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/domainOwnershipIdentifiers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.DomainOwnershipIdentifierName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Site Domain Ownership Identifier ID +func (id SiteDomainOwnershipIdentifierId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticDomainOwnershipIdentifiers", "domainOwnershipIdentifiers", "domainOwnershipIdentifiers"), + resourceids.UserSpecifiedSegment("domainOwnershipIdentifierName", "domainOwnershipIdentifierName"), + } +} + +// String returns a human-readable description of this Site Domain Ownership Identifier ID +func (id SiteDomainOwnershipIdentifierId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Domain Ownership Identifier Name: %q", id.DomainOwnershipIdentifierName), + } + return fmt.Sprintf("Site Domain Ownership Identifier (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_sitedomainownershipidentifier_test.go b/resource-manager/web/2024-11-01/webapps/id_sitedomainownershipidentifier_test.go new file mode 100644 index 00000000000..db628c3f6c2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_sitedomainownershipidentifier_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SiteDomainOwnershipIdentifierId{} + +func TestNewSiteDomainOwnershipIdentifierID(t *testing.T) { + id := NewSiteDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "domainOwnershipIdentifierName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.DomainOwnershipIdentifierName != "domainOwnershipIdentifierName" { + t.Fatalf("Expected %q but got %q for Segment 'DomainOwnershipIdentifierName'", id.DomainOwnershipIdentifierName, "domainOwnershipIdentifierName") + } +} + +func TestFormatSiteDomainOwnershipIdentifierID(t *testing.T) { + actual := NewSiteDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "domainOwnershipIdentifierName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/domainOwnershipIdentifiers/domainOwnershipIdentifierName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSiteDomainOwnershipIdentifierID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteDomainOwnershipIdentifierId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/domainOwnershipIdentifiers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/domainOwnershipIdentifiers/domainOwnershipIdentifierName", + Expected: &SiteDomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/domainOwnershipIdentifiers/domainOwnershipIdentifierName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteDomainOwnershipIdentifierID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestParseSiteDomainOwnershipIdentifierIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteDomainOwnershipIdentifierId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/domainOwnershipIdentifiers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dOmAiNoWnErShIpIdEnTiFiErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/domainOwnershipIdentifiers/domainOwnershipIdentifierName", + Expected: &SiteDomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/domainOwnershipIdentifiers/domainOwnershipIdentifierName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErNaMe", + Expected: &SiteDomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + DomainOwnershipIdentifierName: "dOmAiNoWnErShIpIdEnTiFiErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteDomainOwnershipIdentifierIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestSegmentsForSiteDomainOwnershipIdentifierId(t *testing.T) { + segments := SiteDomainOwnershipIdentifierId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SiteDomainOwnershipIdentifierId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_siteextension.go b/resource-manager/web/2024-11-01/webapps/id_siteextension.go new file mode 100644 index 00000000000..40c85eb38fe --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_siteextension.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SiteExtensionId{}) +} + +var _ resourceids.ResourceId = &SiteExtensionId{} + +// SiteExtensionId is a struct representing the Resource ID for a Site Extension +type SiteExtensionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SiteExtensionId string +} + +// NewSiteExtensionID returns a new SiteExtensionId struct +func NewSiteExtensionID(subscriptionId string, resourceGroupName string, siteName string, siteExtensionId string) SiteExtensionId { + return SiteExtensionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SiteExtensionId: siteExtensionId, + } +} + +// ParseSiteExtensionID parses 'input' into a SiteExtensionId +func ParseSiteExtensionID(input string) (*SiteExtensionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteExtensionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteExtensionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSiteExtensionIDInsensitively parses 'input' case-insensitively into a SiteExtensionId +// note: this method should only be used for API response data and not user input +func ParseSiteExtensionIDInsensitively(input string) (*SiteExtensionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteExtensionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteExtensionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SiteExtensionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SiteExtensionId, ok = input.Parsed["siteExtensionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteExtensionId", input) + } + + return nil +} + +// ValidateSiteExtensionID checks that 'input' can be parsed as a Site Extension ID +func ValidateSiteExtensionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSiteExtensionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Site Extension ID +func (id SiteExtensionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/siteExtensions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SiteExtensionId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Site Extension ID +func (id SiteExtensionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSiteExtensions", "siteExtensions", "siteExtensions"), + resourceids.UserSpecifiedSegment("siteExtensionId", "siteExtensionId"), + } +} + +// String returns a human-readable description of this Site Extension ID +func (id SiteExtensionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Site Extension: %q", id.SiteExtensionId), + } + return fmt.Sprintf("Site Extension (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_siteextension_test.go b/resource-manager/web/2024-11-01/webapps/id_siteextension_test.go new file mode 100644 index 00000000000..32a89aa57ab --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_siteextension_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SiteExtensionId{} + +func TestNewSiteExtensionID(t *testing.T) { + id := NewSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "siteExtensionId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SiteExtensionId != "siteExtensionId" { + t.Fatalf("Expected %q but got %q for Segment 'SiteExtensionId'", id.SiteExtensionId, "siteExtensionId") + } +} + +func TestFormatSiteExtensionID(t *testing.T) { + actual := NewSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "siteExtensionId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/siteExtensions/siteExtensionId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSiteExtensionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteExtensionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/siteExtensions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/siteExtensions/siteExtensionId", + Expected: &SiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SiteExtensionId: "siteExtensionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/siteExtensions/siteExtensionId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteExtensionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SiteExtensionId != v.Expected.SiteExtensionId { + t.Fatalf("Expected %q but got %q for SiteExtensionId", v.Expected.SiteExtensionId, actual.SiteExtensionId) + } + + } +} + +func TestParseSiteExtensionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteExtensionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/siteExtensions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sItEeXtEnSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/siteExtensions/siteExtensionId", + Expected: &SiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SiteExtensionId: "siteExtensionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/siteExtensions/siteExtensionId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sItEeXtEnSiOnS/sItEeXtEnSiOnId", + Expected: &SiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SiteExtensionId: "sItEeXtEnSiOnId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sItEeXtEnSiOnS/sItEeXtEnSiOnId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteExtensionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SiteExtensionId != v.Expected.SiteExtensionId { + t.Fatalf("Expected %q but got %q for SiteExtensionId", v.Expected.SiteExtensionId, actual.SiteExtensionId) + } + + } +} + +func TestSegmentsForSiteExtensionId(t *testing.T) { + segments := SiteExtensionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SiteExtensionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_sitenetworktrace.go b/resource-manager/web/2024-11-01/webapps/id_sitenetworktrace.go new file mode 100644 index 00000000000..3274d10301d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_sitenetworktrace.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SiteNetworkTraceId{}) +} + +var _ resourceids.ResourceId = &SiteNetworkTraceId{} + +// SiteNetworkTraceId is a struct representing the Resource ID for a Site Network Trace +type SiteNetworkTraceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + OperationId string +} + +// NewSiteNetworkTraceID returns a new SiteNetworkTraceId struct +func NewSiteNetworkTraceID(subscriptionId string, resourceGroupName string, siteName string, operationId string) SiteNetworkTraceId { + return SiteNetworkTraceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + OperationId: operationId, + } +} + +// ParseSiteNetworkTraceID parses 'input' into a SiteNetworkTraceId +func ParseSiteNetworkTraceID(input string) (*SiteNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteNetworkTraceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteNetworkTraceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSiteNetworkTraceIDInsensitively parses 'input' case-insensitively into a SiteNetworkTraceId +// note: this method should only be used for API response data and not user input +func ParseSiteNetworkTraceIDInsensitively(input string) (*SiteNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteNetworkTraceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteNetworkTraceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SiteNetworkTraceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.OperationId, ok = input.Parsed["operationId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "operationId", input) + } + + return nil +} + +// ValidateSiteNetworkTraceID checks that 'input' can be parsed as a Site Network Trace ID +func ValidateSiteNetworkTraceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSiteNetworkTraceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Site Network Trace ID +func (id SiteNetworkTraceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/networkTraces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.OperationId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Site Network Trace ID +func (id SiteNetworkTraceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticNetworkTraces", "networkTraces", "networkTraces"), + resourceids.UserSpecifiedSegment("operationId", "operationId"), + } +} + +// String returns a human-readable description of this Site Network Trace ID +func (id SiteNetworkTraceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Operation: %q", id.OperationId), + } + return fmt.Sprintf("Site Network Trace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_sitenetworktrace_test.go b/resource-manager/web/2024-11-01/webapps/id_sitenetworktrace_test.go new file mode 100644 index 00000000000..92c51e2118f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_sitenetworktrace_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SiteNetworkTraceId{} + +func TestNewSiteNetworkTraceID(t *testing.T) { + id := NewSiteNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "operationId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.OperationId != "operationId" { + t.Fatalf("Expected %q but got %q for Segment 'OperationId'", id.OperationId, "operationId") + } +} + +func TestFormatSiteNetworkTraceID(t *testing.T) { + actual := NewSiteNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "operationId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTraces/operationId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSiteNetworkTraceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteNetworkTraceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTraces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTraces/operationId", + Expected: &SiteNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + OperationId: "operationId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTraces/operationId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteNetworkTraceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestParseSiteNetworkTraceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteNetworkTraceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTraces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/nEtWoRkTrAcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTraces/operationId", + Expected: &SiteNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + OperationId: "operationId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/networkTraces/operationId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/nEtWoRkTrAcEs/oPeRaTiOnId", + Expected: &SiteNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + OperationId: "oPeRaTiOnId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/nEtWoRkTrAcEs/oPeRaTiOnId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteNetworkTraceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestSegmentsForSiteNetworkTraceId(t *testing.T) { + segments := SiteNetworkTraceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SiteNetworkTraceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_siteslotnetworktrace.go b/resource-manager/web/2024-11-01/webapps/id_siteslotnetworktrace.go new file mode 100644 index 00000000000..23fbbbb9eab --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_siteslotnetworktrace.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SiteSlotNetworkTraceId{}) +} + +var _ resourceids.ResourceId = &SiteSlotNetworkTraceId{} + +// SiteSlotNetworkTraceId is a struct representing the Resource ID for a Site Slot Network Trace +type SiteSlotNetworkTraceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + OperationId string +} + +// NewSiteSlotNetworkTraceID returns a new SiteSlotNetworkTraceId struct +func NewSiteSlotNetworkTraceID(subscriptionId string, resourceGroupName string, siteName string, slotName string, operationId string) SiteSlotNetworkTraceId { + return SiteSlotNetworkTraceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + OperationId: operationId, + } +} + +// ParseSiteSlotNetworkTraceID parses 'input' into a SiteSlotNetworkTraceId +func ParseSiteSlotNetworkTraceID(input string) (*SiteSlotNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteSlotNetworkTraceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteSlotNetworkTraceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSiteSlotNetworkTraceIDInsensitively parses 'input' case-insensitively into a SiteSlotNetworkTraceId +// note: this method should only be used for API response data and not user input +func ParseSiteSlotNetworkTraceIDInsensitively(input string) (*SiteSlotNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SiteSlotNetworkTraceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SiteSlotNetworkTraceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SiteSlotNetworkTraceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.OperationId, ok = input.Parsed["operationId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "operationId", input) + } + + return nil +} + +// ValidateSiteSlotNetworkTraceID checks that 'input' can be parsed as a Site Slot Network Trace ID +func ValidateSiteSlotNetworkTraceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSiteSlotNetworkTraceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Site Slot Network Trace ID +func (id SiteSlotNetworkTraceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/networkTraces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.OperationId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Site Slot Network Trace ID +func (id SiteSlotNetworkTraceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticNetworkTraces", "networkTraces", "networkTraces"), + resourceids.UserSpecifiedSegment("operationId", "operationId"), + } +} + +// String returns a human-readable description of this Site Slot Network Trace ID +func (id SiteSlotNetworkTraceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Operation: %q", id.OperationId), + } + return fmt.Sprintf("Site Slot Network Trace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_siteslotnetworktrace_test.go b/resource-manager/web/2024-11-01/webapps/id_siteslotnetworktrace_test.go new file mode 100644 index 00000000000..33e3ff66202 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_siteslotnetworktrace_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SiteSlotNetworkTraceId{} + +func TestNewSiteSlotNetworkTraceID(t *testing.T) { + id := NewSiteSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "operationId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.OperationId != "operationId" { + t.Fatalf("Expected %q but got %q for Segment 'OperationId'", id.OperationId, "operationId") + } +} + +func TestFormatSiteSlotNetworkTraceID(t *testing.T) { + actual := NewSiteSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "operationId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTraces/operationId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSiteSlotNetworkTraceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteSlotNetworkTraceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTraces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTraces/operationId", + Expected: &SiteSlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + OperationId: "operationId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTraces/operationId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteSlotNetworkTraceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestParseSiteSlotNetworkTraceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SiteSlotNetworkTraceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTraces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkTrAcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTraces/operationId", + Expected: &SiteSlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + OperationId: "operationId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTraces/operationId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkTrAcEs/oPeRaTiOnId", + Expected: &SiteSlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + OperationId: "oPeRaTiOnId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkTrAcEs/oPeRaTiOnId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSiteSlotNetworkTraceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestSegmentsForSiteSlotNetworkTraceId(t *testing.T) { + segments := SiteSlotNetworkTraceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SiteSlotNetworkTraceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slot.go b/resource-manager/web/2024-11-01/webapps/id_slot.go new file mode 100644 index 00000000000..620b8a931e0 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slot.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotId{}) +} + +var _ resourceids.ResourceId = &SlotId{} + +// SlotId is a struct representing the Resource ID for a Slot +type SlotId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string +} + +// NewSlotID returns a new SlotId struct +func NewSlotID(subscriptionId string, resourceGroupName string, siteName string, slotName string) SlotId { + return SlotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + } +} + +// ParseSlotID parses 'input' into a SlotId +func ParseSlotID(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotIDInsensitively parses 'input' case-insensitively into a SlotId +// note: this method should only be used for API response data and not user input +func ParseSlotIDInsensitively(input string) (*SlotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + return nil +} + +// ValidateSlotID checks that 'input' can be parsed as a Slot ID +func ValidateSlotID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot ID +func (id SlotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot ID +func (id SlotId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + } +} + +// String returns a human-readable description of this Slot ID +func (id SlotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + } + return fmt.Sprintf("Slot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slot_test.go b/resource-manager/web/2024-11-01/webapps/id_slot_test.go new file mode 100644 index 00000000000..4ef0619f083 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slot_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotId{} + +func TestNewSlotID(t *testing.T) { + id := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } +} + +func TestFormatSlotID(t *testing.T) { + actual := NewSlotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestParseSlotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Expected: &SlotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + } +} + +func TestSegmentsForSlotId(t *testing.T) { + segments := SlotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotbackup.go b/resource-manager/web/2024-11-01/webapps/id_slotbackup.go new file mode 100644 index 00000000000..1aa5199ef05 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotbackup.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotBackupId{}) +} + +var _ resourceids.ResourceId = &SlotBackupId{} + +// SlotBackupId is a struct representing the Resource ID for a Slot Backup +type SlotBackupId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + BackupId string +} + +// NewSlotBackupID returns a new SlotBackupId struct +func NewSlotBackupID(subscriptionId string, resourceGroupName string, siteName string, slotName string, backupId string) SlotBackupId { + return SlotBackupId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + BackupId: backupId, + } +} + +// ParseSlotBackupID parses 'input' into a SlotBackupId +func ParseSlotBackupID(input string) (*SlotBackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotBackupId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotBackupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotBackupIDInsensitively parses 'input' case-insensitively into a SlotBackupId +// note: this method should only be used for API response data and not user input +func ParseSlotBackupIDInsensitively(input string) (*SlotBackupId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotBackupId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotBackupId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotBackupId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.BackupId, ok = input.Parsed["backupId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "backupId", input) + } + + return nil +} + +// ValidateSlotBackupID checks that 'input' can be parsed as a Slot Backup ID +func ValidateSlotBackupID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotBackupID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Backup ID +func (id SlotBackupId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/backups/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.BackupId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Backup ID +func (id SlotBackupId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticBackups", "backups", "backups"), + resourceids.UserSpecifiedSegment("backupId", "backupId"), + } +} + +// String returns a human-readable description of this Slot Backup ID +func (id SlotBackupId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Backup: %q", id.BackupId), + } + return fmt.Sprintf("Slot Backup (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotbackup_test.go b/resource-manager/web/2024-11-01/webapps/id_slotbackup_test.go new file mode 100644 index 00000000000..56eb5f5933f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotbackup_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotBackupId{} + +func TestNewSlotBackupID(t *testing.T) { + id := NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "backupId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.BackupId != "backupId" { + t.Fatalf("Expected %q but got %q for Segment 'BackupId'", id.BackupId, "backupId") + } +} + +func TestFormatSlotBackupID(t *testing.T) { + actual := NewSlotBackupID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "backupId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/backups/backupId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotBackupID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotBackupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/backups", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/backups/backupId", + Expected: &SlotBackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + BackupId: "backupId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/backups/backupId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotBackupID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.BackupId != v.Expected.BackupId { + t.Fatalf("Expected %q but got %q for BackupId", v.Expected.BackupId, actual.BackupId) + } + + } +} + +func TestParseSlotBackupIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotBackupId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/backups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/bAcKuPs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/backups/backupId", + Expected: &SlotBackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + BackupId: "backupId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/backups/backupId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/bAcKuPs/bAcKuPiD", + Expected: &SlotBackupId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + BackupId: "bAcKuPiD", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/bAcKuPs/bAcKuPiD/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotBackupIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.BackupId != v.Expected.BackupId { + t.Fatalf("Expected %q but got %q for BackupId", v.Expected.BackupId, actual.BackupId) + } + + } +} + +func TestSegmentsForSlotBackupId(t *testing.T) { + segments := SlotBackupId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotBackupId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotcontinuouswebjob.go b/resource-manager/web/2024-11-01/webapps/id_slotcontinuouswebjob.go new file mode 100644 index 00000000000..6ca39c98b2e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotcontinuouswebjob.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotContinuousWebJobId{}) +} + +var _ resourceids.ResourceId = &SlotContinuousWebJobId{} + +// SlotContinuousWebJobId is a struct representing the Resource ID for a Slot Continuous Web Job +type SlotContinuousWebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + ContinuousWebJobName string +} + +// NewSlotContinuousWebJobID returns a new SlotContinuousWebJobId struct +func NewSlotContinuousWebJobID(subscriptionId string, resourceGroupName string, siteName string, slotName string, continuousWebJobName string) SlotContinuousWebJobId { + return SlotContinuousWebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + ContinuousWebJobName: continuousWebJobName, + } +} + +// ParseSlotContinuousWebJobID parses 'input' into a SlotContinuousWebJobId +func ParseSlotContinuousWebJobID(input string) (*SlotContinuousWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotContinuousWebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotContinuousWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotContinuousWebJobIDInsensitively parses 'input' case-insensitively into a SlotContinuousWebJobId +// note: this method should only be used for API response data and not user input +func ParseSlotContinuousWebJobIDInsensitively(input string) (*SlotContinuousWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotContinuousWebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotContinuousWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotContinuousWebJobId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.ContinuousWebJobName, ok = input.Parsed["continuousWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "continuousWebJobName", input) + } + + return nil +} + +// ValidateSlotContinuousWebJobID checks that 'input' can be parsed as a Slot Continuous Web Job ID +func ValidateSlotContinuousWebJobID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotContinuousWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Continuous Web Job ID +func (id SlotContinuousWebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/continuousWebJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.ContinuousWebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Continuous Web Job ID +func (id SlotContinuousWebJobId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticContinuousWebJobs", "continuousWebJobs", "continuousWebJobs"), + resourceids.UserSpecifiedSegment("continuousWebJobName", "continuousWebJobName"), + } +} + +// String returns a human-readable description of this Slot Continuous Web Job ID +func (id SlotContinuousWebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Continuous Web Job Name: %q", id.ContinuousWebJobName), + } + return fmt.Sprintf("Slot Continuous Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotcontinuouswebjob_test.go b/resource-manager/web/2024-11-01/webapps/id_slotcontinuouswebjob_test.go new file mode 100644 index 00000000000..94be6b075f1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotcontinuouswebjob_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotContinuousWebJobId{} + +func TestNewSlotContinuousWebJobID(t *testing.T) { + id := NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "continuousWebJobName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.ContinuousWebJobName != "continuousWebJobName" { + t.Fatalf("Expected %q but got %q for Segment 'ContinuousWebJobName'", id.ContinuousWebJobName, "continuousWebJobName") + } +} + +func TestFormatSlotContinuousWebJobID(t *testing.T) { + actual := NewSlotContinuousWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "continuousWebJobName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/continuousWebJobs/continuousWebJobName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotContinuousWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotContinuousWebJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/continuousWebJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/continuousWebJobs/continuousWebJobName", + Expected: &SlotContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + ContinuousWebJobName: "continuousWebJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/continuousWebJobs/continuousWebJobName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotContinuousWebJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ContinuousWebJobName != v.Expected.ContinuousWebJobName { + t.Fatalf("Expected %q but got %q for ContinuousWebJobName", v.Expected.ContinuousWebJobName, actual.ContinuousWebJobName) + } + + } +} + +func TestParseSlotContinuousWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotContinuousWebJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/continuousWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnTiNuOuSwEbJoBs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/continuousWebJobs/continuousWebJobName", + Expected: &SlotContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + ContinuousWebJobName: "continuousWebJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/continuousWebJobs/continuousWebJobName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnTiNuOuSwEbJoBs/cOnTiNuOuSwEbJoBnAmE", + Expected: &SlotContinuousWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + ContinuousWebJobName: "cOnTiNuOuSwEbJoBnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnTiNuOuSwEbJoBs/cOnTiNuOuSwEbJoBnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotContinuousWebJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ContinuousWebJobName != v.Expected.ContinuousWebJobName { + t.Fatalf("Expected %q but got %q for ContinuousWebJobName", v.Expected.ContinuousWebJobName, actual.ContinuousWebJobName) + } + + } +} + +func TestSegmentsForSlotContinuousWebJobId(t *testing.T) { + segments := SlotContinuousWebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotContinuousWebJobId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotdeployment.go b/resource-manager/web/2024-11-01/webapps/id_slotdeployment.go new file mode 100644 index 00000000000..fe789dce200 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotdeployment.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotDeploymentId{}) +} + +var _ resourceids.ResourceId = &SlotDeploymentId{} + +// SlotDeploymentId is a struct representing the Resource ID for a Slot Deployment +type SlotDeploymentId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DeploymentName string +} + +// NewSlotDeploymentID returns a new SlotDeploymentId struct +func NewSlotDeploymentID(subscriptionId string, resourceGroupName string, siteName string, slotName string, deploymentName string) SlotDeploymentId { + return SlotDeploymentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DeploymentName: deploymentName, + } +} + +// ParseSlotDeploymentID parses 'input' into a SlotDeploymentId +func ParseSlotDeploymentID(input string) (*SlotDeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDeploymentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotDeploymentIDInsensitively parses 'input' case-insensitively into a SlotDeploymentId +// note: this method should only be used for API response data and not user input +func ParseSlotDeploymentIDInsensitively(input string) (*SlotDeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDeploymentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotDeploymentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DeploymentName, ok = input.Parsed["deploymentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deploymentName", input) + } + + return nil +} + +// ValidateSlotDeploymentID checks that 'input' can be parsed as a Slot Deployment ID +func ValidateSlotDeploymentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotDeploymentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Deployment ID +func (id SlotDeploymentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/deployments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DeploymentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Deployment ID +func (id SlotDeploymentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticDeployments", "deployments", "deployments"), + resourceids.UserSpecifiedSegment("deploymentName", "deploymentName"), + } +} + +// String returns a human-readable description of this Slot Deployment ID +func (id SlotDeploymentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Deployment Name: %q", id.DeploymentName), + } + return fmt.Sprintf("Slot Deployment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotdeployment_test.go b/resource-manager/web/2024-11-01/webapps/id_slotdeployment_test.go new file mode 100644 index 00000000000..2ddd1a03e78 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotdeployment_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotDeploymentId{} + +func TestNewSlotDeploymentID(t *testing.T) { + id := NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "deploymentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.DeploymentName != "deploymentName" { + t.Fatalf("Expected %q but got %q for Segment 'DeploymentName'", id.DeploymentName, "deploymentName") + } +} + +func TestFormatSlotDeploymentID(t *testing.T) { + actual := NewSlotDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "deploymentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/deployments/deploymentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotDeploymentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDeploymentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/deployments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/deployments/deploymentName", + Expected: &SlotDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DeploymentName: "deploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/deployments/deploymentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDeploymentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DeploymentName != v.Expected.DeploymentName { + t.Fatalf("Expected %q but got %q for DeploymentName", v.Expected.DeploymentName, actual.DeploymentName) + } + + } +} + +func TestParseSlotDeploymentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDeploymentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/deployments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dEpLoYmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/deployments/deploymentName", + Expected: &SlotDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DeploymentName: "deploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/deployments/deploymentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dEpLoYmEnTs/dEpLoYmEnTnAmE", + Expected: &SlotDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + DeploymentName: "dEpLoYmEnTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dEpLoYmEnTs/dEpLoYmEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDeploymentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DeploymentName != v.Expected.DeploymentName { + t.Fatalf("Expected %q but got %q for DeploymentName", v.Expected.DeploymentName, actual.DeploymentName) + } + + } +} + +func TestSegmentsForSlotDeploymentId(t *testing.T) { + segments := SlotDeploymentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotDeploymentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotdomainownershipidentifier.go b/resource-manager/web/2024-11-01/webapps/id_slotdomainownershipidentifier.go new file mode 100644 index 00000000000..1dbb4307122 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotdomainownershipidentifier.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotDomainOwnershipIdentifierId{}) +} + +var _ resourceids.ResourceId = &SlotDomainOwnershipIdentifierId{} + +// SlotDomainOwnershipIdentifierId is a struct representing the Resource ID for a Slot Domain Ownership Identifier +type SlotDomainOwnershipIdentifierId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + DomainOwnershipIdentifierName string +} + +// NewSlotDomainOwnershipIdentifierID returns a new SlotDomainOwnershipIdentifierId struct +func NewSlotDomainOwnershipIdentifierID(subscriptionId string, resourceGroupName string, siteName string, slotName string, domainOwnershipIdentifierName string) SlotDomainOwnershipIdentifierId { + return SlotDomainOwnershipIdentifierId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + DomainOwnershipIdentifierName: domainOwnershipIdentifierName, + } +} + +// ParseSlotDomainOwnershipIdentifierID parses 'input' into a SlotDomainOwnershipIdentifierId +func ParseSlotDomainOwnershipIdentifierID(input string) (*SlotDomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDomainOwnershipIdentifierId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotDomainOwnershipIdentifierIDInsensitively parses 'input' case-insensitively into a SlotDomainOwnershipIdentifierId +// note: this method should only be used for API response data and not user input +func ParseSlotDomainOwnershipIdentifierIDInsensitively(input string) (*SlotDomainOwnershipIdentifierId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotDomainOwnershipIdentifierId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotDomainOwnershipIdentifierId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotDomainOwnershipIdentifierId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.DomainOwnershipIdentifierName, ok = input.Parsed["domainOwnershipIdentifierName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "domainOwnershipIdentifierName", input) + } + + return nil +} + +// ValidateSlotDomainOwnershipIdentifierID checks that 'input' can be parsed as a Slot Domain Ownership Identifier ID +func ValidateSlotDomainOwnershipIdentifierID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotDomainOwnershipIdentifierID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Domain Ownership Identifier ID +func (id SlotDomainOwnershipIdentifierId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/domainOwnershipIdentifiers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.DomainOwnershipIdentifierName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Domain Ownership Identifier ID +func (id SlotDomainOwnershipIdentifierId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticDomainOwnershipIdentifiers", "domainOwnershipIdentifiers", "domainOwnershipIdentifiers"), + resourceids.UserSpecifiedSegment("domainOwnershipIdentifierName", "domainOwnershipIdentifierName"), + } +} + +// String returns a human-readable description of this Slot Domain Ownership Identifier ID +func (id SlotDomainOwnershipIdentifierId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Domain Ownership Identifier Name: %q", id.DomainOwnershipIdentifierName), + } + return fmt.Sprintf("Slot Domain Ownership Identifier (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotdomainownershipidentifier_test.go b/resource-manager/web/2024-11-01/webapps/id_slotdomainownershipidentifier_test.go new file mode 100644 index 00000000000..7be0f127472 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotdomainownershipidentifier_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotDomainOwnershipIdentifierId{} + +func TestNewSlotDomainOwnershipIdentifierID(t *testing.T) { + id := NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "domainOwnershipIdentifierName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.DomainOwnershipIdentifierName != "domainOwnershipIdentifierName" { + t.Fatalf("Expected %q but got %q for Segment 'DomainOwnershipIdentifierName'", id.DomainOwnershipIdentifierName, "domainOwnershipIdentifierName") + } +} + +func TestFormatSlotDomainOwnershipIdentifierID(t *testing.T) { + actual := NewSlotDomainOwnershipIdentifierID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "domainOwnershipIdentifierName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/domainOwnershipIdentifiers/domainOwnershipIdentifierName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotDomainOwnershipIdentifierID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDomainOwnershipIdentifierId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/domainOwnershipIdentifiers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/domainOwnershipIdentifiers/domainOwnershipIdentifierName", + Expected: &SlotDomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/domainOwnershipIdentifiers/domainOwnershipIdentifierName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDomainOwnershipIdentifierID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestParseSlotDomainOwnershipIdentifierIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotDomainOwnershipIdentifierId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/domainOwnershipIdentifiers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dOmAiNoWnErShIpIdEnTiFiErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/domainOwnershipIdentifiers/domainOwnershipIdentifierName", + Expected: &SlotDomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + DomainOwnershipIdentifierName: "domainOwnershipIdentifierName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/domainOwnershipIdentifiers/domainOwnershipIdentifierName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErNaMe", + Expected: &SlotDomainOwnershipIdentifierId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + DomainOwnershipIdentifierName: "dOmAiNoWnErShIpIdEnTiFiErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/dOmAiNoWnErShIpIdEnTiFiErS/dOmAiNoWnErShIpIdEnTiFiErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotDomainOwnershipIdentifierIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.DomainOwnershipIdentifierName != v.Expected.DomainOwnershipIdentifierName { + t.Fatalf("Expected %q but got %q for DomainOwnershipIdentifierName", v.Expected.DomainOwnershipIdentifierName, actual.DomainOwnershipIdentifierName) + } + + } +} + +func TestSegmentsForSlotDomainOwnershipIdentifierId(t *testing.T) { + segments := SlotDomainOwnershipIdentifierId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotDomainOwnershipIdentifierId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotfunction.go b/resource-manager/web/2024-11-01/webapps/id_slotfunction.go new file mode 100644 index 00000000000..2f9cba6eccc --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotfunction.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotFunctionId{}) +} + +var _ resourceids.ResourceId = &SlotFunctionId{} + +// SlotFunctionId is a struct representing the Resource ID for a Slot Function +type SlotFunctionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + FunctionName string +} + +// NewSlotFunctionID returns a new SlotFunctionId struct +func NewSlotFunctionID(subscriptionId string, resourceGroupName string, siteName string, slotName string, functionName string) SlotFunctionId { + return SlotFunctionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + FunctionName: functionName, + } +} + +// ParseSlotFunctionID parses 'input' into a SlotFunctionId +func ParseSlotFunctionID(input string) (*SlotFunctionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotFunctionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotFunctionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotFunctionIDInsensitively parses 'input' case-insensitively into a SlotFunctionId +// note: this method should only be used for API response data and not user input +func ParseSlotFunctionIDInsensitively(input string) (*SlotFunctionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotFunctionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotFunctionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotFunctionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.FunctionName, ok = input.Parsed["functionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "functionName", input) + } + + return nil +} + +// ValidateSlotFunctionID checks that 'input' can be parsed as a Slot Function ID +func ValidateSlotFunctionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotFunctionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Function ID +func (id SlotFunctionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/functions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.FunctionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Function ID +func (id SlotFunctionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticFunctions", "functions", "functions"), + resourceids.UserSpecifiedSegment("functionName", "functionName"), + } +} + +// String returns a human-readable description of this Slot Function ID +func (id SlotFunctionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Function Name: %q", id.FunctionName), + } + return fmt.Sprintf("Slot Function (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotfunction_test.go b/resource-manager/web/2024-11-01/webapps/id_slotfunction_test.go new file mode 100644 index 00000000000..10315a35c83 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotfunction_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotFunctionId{} + +func TestNewSlotFunctionID(t *testing.T) { + id := NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.FunctionName != "functionName" { + t.Fatalf("Expected %q but got %q for Segment 'FunctionName'", id.FunctionName, "functionName") + } +} + +func TestFormatSlotFunctionID(t *testing.T) { + actual := NewSlotFunctionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "functionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotFunctionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotFunctionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName", + Expected: &SlotFunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + FunctionName: "functionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotFunctionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + } +} + +func TestParseSlotFunctionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotFunctionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/fUnCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName", + Expected: &SlotFunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + FunctionName: "functionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/functions/functionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/fUnCtIoNs/fUnCtIoNnAmE", + Expected: &SlotFunctionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + FunctionName: "fUnCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/fUnCtIoNs/fUnCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotFunctionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.FunctionName != v.Expected.FunctionName { + t.Fatalf("Expected %q but got %q for FunctionName", v.Expected.FunctionName, actual.FunctionName) + } + + } +} + +func TestSegmentsForSlotFunctionId(t *testing.T) { + segments := SlotFunctionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotFunctionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slothostnamebinding.go b/resource-manager/web/2024-11-01/webapps/id_slothostnamebinding.go new file mode 100644 index 00000000000..590d01a4bae --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slothostnamebinding.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotHostNameBindingId{}) +} + +var _ resourceids.ResourceId = &SlotHostNameBindingId{} + +// SlotHostNameBindingId is a struct representing the Resource ID for a Slot Host Name Binding +type SlotHostNameBindingId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + HostNameBindingName string +} + +// NewSlotHostNameBindingID returns a new SlotHostNameBindingId struct +func NewSlotHostNameBindingID(subscriptionId string, resourceGroupName string, siteName string, slotName string, hostNameBindingName string) SlotHostNameBindingId { + return SlotHostNameBindingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + HostNameBindingName: hostNameBindingName, + } +} + +// ParseSlotHostNameBindingID parses 'input' into a SlotHostNameBindingId +func ParseSlotHostNameBindingID(input string) (*SlotHostNameBindingId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHostNameBindingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHostNameBindingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotHostNameBindingIDInsensitively parses 'input' case-insensitively into a SlotHostNameBindingId +// note: this method should only be used for API response data and not user input +func ParseSlotHostNameBindingIDInsensitively(input string) (*SlotHostNameBindingId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHostNameBindingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHostNameBindingId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotHostNameBindingId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.HostNameBindingName, ok = input.Parsed["hostNameBindingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hostNameBindingName", input) + } + + return nil +} + +// ValidateSlotHostNameBindingID checks that 'input' can be parsed as a Slot Host Name Binding ID +func ValidateSlotHostNameBindingID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotHostNameBindingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Host Name Binding ID +func (id SlotHostNameBindingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/hostNameBindings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.HostNameBindingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Host Name Binding ID +func (id SlotHostNameBindingId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticHostNameBindings", "hostNameBindings", "hostNameBindings"), + resourceids.UserSpecifiedSegment("hostNameBindingName", "hostNameBindingName"), + } +} + +// String returns a human-readable description of this Slot Host Name Binding ID +func (id SlotHostNameBindingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Host Name Binding Name: %q", id.HostNameBindingName), + } + return fmt.Sprintf("Slot Host Name Binding (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slothostnamebinding_test.go b/resource-manager/web/2024-11-01/webapps/id_slothostnamebinding_test.go new file mode 100644 index 00000000000..d0e372c31e3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slothostnamebinding_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotHostNameBindingId{} + +func TestNewSlotHostNameBindingID(t *testing.T) { + id := NewSlotHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hostNameBindingName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.HostNameBindingName != "hostNameBindingName" { + t.Fatalf("Expected %q but got %q for Segment 'HostNameBindingName'", id.HostNameBindingName, "hostNameBindingName") + } +} + +func TestFormatSlotHostNameBindingID(t *testing.T) { + actual := NewSlotHostNameBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hostNameBindingName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hostNameBindings/hostNameBindingName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotHostNameBindingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHostNameBindingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hostNameBindings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hostNameBindings/hostNameBindingName", + Expected: &SlotHostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + HostNameBindingName: "hostNameBindingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hostNameBindings/hostNameBindingName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHostNameBindingID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HostNameBindingName != v.Expected.HostNameBindingName { + t.Fatalf("Expected %q but got %q for HostNameBindingName", v.Expected.HostNameBindingName, actual.HostNameBindingName) + } + + } +} + +func TestParseSlotHostNameBindingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHostNameBindingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hostNameBindings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hOsTnAmEbInDiNgS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hostNameBindings/hostNameBindingName", + Expected: &SlotHostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + HostNameBindingName: "hostNameBindingName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hostNameBindings/hostNameBindingName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hOsTnAmEbInDiNgS/hOsTnAmEbInDiNgNaMe", + Expected: &SlotHostNameBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + HostNameBindingName: "hOsTnAmEbInDiNgNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hOsTnAmEbInDiNgS/hOsTnAmEbInDiNgNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHostNameBindingIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HostNameBindingName != v.Expected.HostNameBindingName { + t.Fatalf("Expected %q but got %q for HostNameBindingName", v.Expected.HostNameBindingName, actual.HostNameBindingName) + } + + } +} + +func TestSegmentsForSlotHostNameBindingId(t *testing.T) { + segments := SlotHostNameBindingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotHostNameBindingId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slothybridconnection.go b/resource-manager/web/2024-11-01/webapps/id_slothybridconnection.go new file mode 100644 index 00000000000..c5a95c89142 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slothybridconnection.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotHybridConnectionId{}) +} + +var _ resourceids.ResourceId = &SlotHybridConnectionId{} + +// SlotHybridConnectionId is a struct representing the Resource ID for a Slot Hybrid Connection +type SlotHybridConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + HybridConnectionName string +} + +// NewSlotHybridConnectionID returns a new SlotHybridConnectionId struct +func NewSlotHybridConnectionID(subscriptionId string, resourceGroupName string, siteName string, slotName string, hybridConnectionName string) SlotHybridConnectionId { + return SlotHybridConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + HybridConnectionName: hybridConnectionName, + } +} + +// ParseSlotHybridConnectionID parses 'input' into a SlotHybridConnectionId +func ParseSlotHybridConnectionID(input string) (*SlotHybridConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHybridConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHybridConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotHybridConnectionIDInsensitively parses 'input' case-insensitively into a SlotHybridConnectionId +// note: this method should only be used for API response data and not user input +func ParseSlotHybridConnectionIDInsensitively(input string) (*SlotHybridConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHybridConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHybridConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotHybridConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.HybridConnectionName, ok = input.Parsed["hybridConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hybridConnectionName", input) + } + + return nil +} + +// ValidateSlotHybridConnectionID checks that 'input' can be parsed as a Slot Hybrid Connection ID +func ValidateSlotHybridConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotHybridConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Hybrid Connection ID +func (id SlotHybridConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/hybridConnection/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.HybridConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Hybrid Connection ID +func (id SlotHybridConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticHybridConnection", "hybridConnection", "hybridConnection"), + resourceids.UserSpecifiedSegment("hybridConnectionName", "hybridConnectionName"), + } +} + +// String returns a human-readable description of this Slot Hybrid Connection ID +func (id SlotHybridConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Hybrid Connection Name: %q", id.HybridConnectionName), + } + return fmt.Sprintf("Slot Hybrid Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slothybridconnection_test.go b/resource-manager/web/2024-11-01/webapps/id_slothybridconnection_test.go new file mode 100644 index 00000000000..30653e42594 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slothybridconnection_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotHybridConnectionId{} + +func TestNewSlotHybridConnectionID(t *testing.T) { + id := NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.HybridConnectionName != "hybridConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'HybridConnectionName'", id.HybridConnectionName, "hybridConnectionName") + } +} + +func TestFormatSlotHybridConnectionID(t *testing.T) { + actual := NewSlotHybridConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnection/hybridConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotHybridConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHybridConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnection", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnection/hybridConnectionName", + Expected: &SlotHybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + HybridConnectionName: "hybridConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnection/hybridConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHybridConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HybridConnectionName != v.Expected.HybridConnectionName { + t.Fatalf("Expected %q but got %q for HybridConnectionName", v.Expected.HybridConnectionName, actual.HybridConnectionName) + } + + } +} + +func TestParseSlotHybridConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHybridConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnection", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hYbRiDcOnNeCtIoN", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnection/hybridConnectionName", + Expected: &SlotHybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + HybridConnectionName: "hybridConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnection/hybridConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hYbRiDcOnNeCtIoN/hYbRiDcOnNeCtIoNnAmE", + Expected: &SlotHybridConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + HybridConnectionName: "hYbRiDcOnNeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hYbRiDcOnNeCtIoN/hYbRiDcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHybridConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HybridConnectionName != v.Expected.HybridConnectionName { + t.Fatalf("Expected %q but got %q for HybridConnectionName", v.Expected.HybridConnectionName, actual.HybridConnectionName) + } + + } +} + +func TestSegmentsForSlotHybridConnectionId(t *testing.T) { + segments := SlotHybridConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotHybridConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slothybridconnectionnamespacerelay.go b/resource-manager/web/2024-11-01/webapps/id_slothybridconnectionnamespacerelay.go new file mode 100644 index 00000000000..f2a53e559e0 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slothybridconnectionnamespacerelay.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotHybridConnectionNamespaceRelayId{}) +} + +var _ resourceids.ResourceId = &SlotHybridConnectionNamespaceRelayId{} + +// SlotHybridConnectionNamespaceRelayId is a struct representing the Resource ID for a Slot Hybrid Connection Namespace Relay +type SlotHybridConnectionNamespaceRelayId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + HybridConnectionNamespaceName string + RelayName string +} + +// NewSlotHybridConnectionNamespaceRelayID returns a new SlotHybridConnectionNamespaceRelayId struct +func NewSlotHybridConnectionNamespaceRelayID(subscriptionId string, resourceGroupName string, siteName string, slotName string, hybridConnectionNamespaceName string, relayName string) SlotHybridConnectionNamespaceRelayId { + return SlotHybridConnectionNamespaceRelayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + HybridConnectionNamespaceName: hybridConnectionNamespaceName, + RelayName: relayName, + } +} + +// ParseSlotHybridConnectionNamespaceRelayID parses 'input' into a SlotHybridConnectionNamespaceRelayId +func ParseSlotHybridConnectionNamespaceRelayID(input string) (*SlotHybridConnectionNamespaceRelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHybridConnectionNamespaceRelayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHybridConnectionNamespaceRelayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotHybridConnectionNamespaceRelayIDInsensitively parses 'input' case-insensitively into a SlotHybridConnectionNamespaceRelayId +// note: this method should only be used for API response data and not user input +func ParseSlotHybridConnectionNamespaceRelayIDInsensitively(input string) (*SlotHybridConnectionNamespaceRelayId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotHybridConnectionNamespaceRelayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotHybridConnectionNamespaceRelayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotHybridConnectionNamespaceRelayId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.HybridConnectionNamespaceName, ok = input.Parsed["hybridConnectionNamespaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "hybridConnectionNamespaceName", input) + } + + if id.RelayName, ok = input.Parsed["relayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "relayName", input) + } + + return nil +} + +// ValidateSlotHybridConnectionNamespaceRelayID checks that 'input' can be parsed as a Slot Hybrid Connection Namespace Relay ID +func ValidateSlotHybridConnectionNamespaceRelayID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotHybridConnectionNamespaceRelayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Hybrid Connection Namespace Relay ID +func (id SlotHybridConnectionNamespaceRelayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/hybridConnectionNamespaces/%s/relays/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.HybridConnectionNamespaceName, id.RelayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Hybrid Connection Namespace Relay ID +func (id SlotHybridConnectionNamespaceRelayId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticHybridConnectionNamespaces", "hybridConnectionNamespaces", "hybridConnectionNamespaces"), + resourceids.UserSpecifiedSegment("hybridConnectionNamespaceName", "hybridConnectionNamespaceName"), + resourceids.StaticSegment("staticRelays", "relays", "relays"), + resourceids.UserSpecifiedSegment("relayName", "relayName"), + } +} + +// String returns a human-readable description of this Slot Hybrid Connection Namespace Relay ID +func (id SlotHybridConnectionNamespaceRelayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Hybrid Connection Namespace Name: %q", id.HybridConnectionNamespaceName), + fmt.Sprintf("Relay Name: %q", id.RelayName), + } + return fmt.Sprintf("Slot Hybrid Connection Namespace Relay (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slothybridconnectionnamespacerelay_test.go b/resource-manager/web/2024-11-01/webapps/id_slothybridconnectionnamespacerelay_test.go new file mode 100644 index 00000000000..c668d1e93bc --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slothybridconnectionnamespacerelay_test.go @@ -0,0 +1,417 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotHybridConnectionNamespaceRelayId{} + +func TestNewSlotHybridConnectionNamespaceRelayID(t *testing.T) { + id := NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionNamespaceName", "relayName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.HybridConnectionNamespaceName != "hybridConnectionNamespaceName" { + t.Fatalf("Expected %q but got %q for Segment 'HybridConnectionNamespaceName'", id.HybridConnectionNamespaceName, "hybridConnectionNamespaceName") + } + + if id.RelayName != "relayName" { + t.Fatalf("Expected %q but got %q for Segment 'RelayName'", id.RelayName, "relayName") + } +} + +func TestFormatSlotHybridConnectionNamespaceRelayID(t *testing.T) { + actual := NewSlotHybridConnectionNamespaceRelayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "hybridConnectionNamespaceName", "relayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotHybridConnectionNamespaceRelayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHybridConnectionNamespaceRelayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName", + Expected: &SlotHybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + HybridConnectionNamespaceName: "hybridConnectionNamespaceName", + RelayName: "relayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHybridConnectionNamespaceRelayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestParseSlotHybridConnectionNamespaceRelayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotHybridConnectionNamespaceRelayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName", + Expected: &SlotHybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + HybridConnectionNamespaceName: "hybridConnectionNamespaceName", + RelayName: "relayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/hybridConnectionNamespaces/hybridConnectionNamespaceName/relays/relayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS/rElAyNaMe", + Expected: &SlotHybridConnectionNamespaceRelayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + HybridConnectionNamespaceName: "hYbRiDcOnNeCtIoNnAmEsPaCeNaMe", + RelayName: "rElAyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/hYbRiDcOnNeCtIoNnAmEsPaCeS/hYbRiDcOnNeCtIoNnAmEsPaCeNaMe/rElAyS/rElAyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotHybridConnectionNamespaceRelayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.HybridConnectionNamespaceName != v.Expected.HybridConnectionNamespaceName { + t.Fatalf("Expected %q but got %q for HybridConnectionNamespaceName", v.Expected.HybridConnectionNamespaceName, actual.HybridConnectionNamespaceName) + } + + if actual.RelayName != v.Expected.RelayName { + t.Fatalf("Expected %q but got %q for RelayName", v.Expected.RelayName, actual.RelayName) + } + + } +} + +func TestSegmentsForSlotHybridConnectionNamespaceRelayId(t *testing.T) { + segments := SlotHybridConnectionNamespaceRelayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotHybridConnectionNamespaceRelayId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotinstance.go b/resource-manager/web/2024-11-01/webapps/id_slotinstance.go new file mode 100644 index 00000000000..f6a4b514211 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotinstance.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotInstanceId{}) +} + +var _ resourceids.ResourceId = &SlotInstanceId{} + +// SlotInstanceId is a struct representing the Resource ID for a Slot Instance +type SlotInstanceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + InstanceId string +} + +// NewSlotInstanceID returns a new SlotInstanceId struct +func NewSlotInstanceID(subscriptionId string, resourceGroupName string, siteName string, slotName string, instanceId string) SlotInstanceId { + return SlotInstanceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + InstanceId: instanceId, + } +} + +// ParseSlotInstanceID parses 'input' into a SlotInstanceId +func ParseSlotInstanceID(input string) (*SlotInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotInstanceIDInsensitively parses 'input' case-insensitively into a SlotInstanceId +// note: this method should only be used for API response data and not user input +func ParseSlotInstanceIDInsensitively(input string) (*SlotInstanceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotInstanceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + return nil +} + +// ValidateSlotInstanceID checks that 'input' can be parsed as a Slot Instance ID +func ValidateSlotInstanceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotInstanceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Instance ID +func (id SlotInstanceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/instances/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.InstanceId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Instance ID +func (id SlotInstanceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceId"), + } +} + +// String returns a human-readable description of this Slot Instance ID +func (id SlotInstanceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Instance: %q", id.InstanceId), + } + return fmt.Sprintf("Slot Instance (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotinstance_test.go b/resource-manager/web/2024-11-01/webapps/id_slotinstance_test.go new file mode 100644 index 00000000000..2bd26deb6ee --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotinstance_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotInstanceId{} + +func TestNewSlotInstanceID(t *testing.T) { + id := NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.InstanceId != "instanceId" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceId") + } +} + +func TestFormatSlotInstanceID(t *testing.T) { + actual := NewSlotInstanceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotInstanceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId", + Expected: &SlotInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + InstanceId: "instanceId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + } +} + +func TestParseSlotInstanceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId", + Expected: &SlotInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + InstanceId: "instanceId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD", + Expected: &SlotInstanceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + InstanceId: "iNsTaNcEiD", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + } +} + +func TestSegmentsForSlotInstanceId(t *testing.T) { + segments := SlotInstanceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotInstanceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotinstanceprocess.go b/resource-manager/web/2024-11-01/webapps/id_slotinstanceprocess.go new file mode 100644 index 00000000000..7459e303aab --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotinstanceprocess.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotInstanceProcessId{}) +} + +var _ resourceids.ResourceId = &SlotInstanceProcessId{} + +// SlotInstanceProcessId is a struct representing the Resource ID for a Slot Instance Process +type SlotInstanceProcessId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + InstanceId string + ProcessId string +} + +// NewSlotInstanceProcessID returns a new SlotInstanceProcessId struct +func NewSlotInstanceProcessID(subscriptionId string, resourceGroupName string, siteName string, slotName string, instanceId string, processId string) SlotInstanceProcessId { + return SlotInstanceProcessId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + InstanceId: instanceId, + ProcessId: processId, + } +} + +// ParseSlotInstanceProcessID parses 'input' into a SlotInstanceProcessId +func ParseSlotInstanceProcessID(input string) (*SlotInstanceProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceProcessId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceProcessId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotInstanceProcessIDInsensitively parses 'input' case-insensitively into a SlotInstanceProcessId +// note: this method should only be used for API response data and not user input +func ParseSlotInstanceProcessIDInsensitively(input string) (*SlotInstanceProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceProcessId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceProcessId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotInstanceProcessId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + return nil +} + +// ValidateSlotInstanceProcessID checks that 'input' can be parsed as a Slot Instance Process ID +func ValidateSlotInstanceProcessID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotInstanceProcessID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Instance Process ID +func (id SlotInstanceProcessId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/instances/%s/processes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.InstanceId, id.ProcessId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Instance Process ID +func (id SlotInstanceProcessId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceId"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processId"), + } +} + +// String returns a human-readable description of this Slot Instance Process ID +func (id SlotInstanceProcessId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Instance: %q", id.InstanceId), + fmt.Sprintf("Process: %q", id.ProcessId), + } + return fmt.Sprintf("Slot Instance Process (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotinstanceprocess_test.go b/resource-manager/web/2024-11-01/webapps/id_slotinstanceprocess_test.go new file mode 100644 index 00000000000..c10bc2a0fc1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotinstanceprocess_test.go @@ -0,0 +1,417 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotInstanceProcessId{} + +func TestNewSlotInstanceProcessID(t *testing.T) { + id := NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.InstanceId != "instanceId" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceId") + } + + if id.ProcessId != "processId" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processId") + } +} + +func TestFormatSlotInstanceProcessID(t *testing.T) { + actual := NewSlotInstanceProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotInstanceProcessID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceProcessId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId", + Expected: &SlotInstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + InstanceId: "instanceId", + ProcessId: "processId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceProcessID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestParseSlotInstanceProcessIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceProcessId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId", + Expected: &SlotInstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + InstanceId: "instanceId", + ProcessId: "processId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId", + Expected: &SlotInstanceProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + InstanceId: "iNsTaNcEiD", + ProcessId: "pRoCeSsId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceProcessIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestSegmentsForSlotInstanceProcessId(t *testing.T) { + segments := SlotInstanceProcessId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotInstanceProcessId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotinstanceprocessmodule.go b/resource-manager/web/2024-11-01/webapps/id_slotinstanceprocessmodule.go new file mode 100644 index 00000000000..ec90a897094 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotinstanceprocessmodule.go @@ -0,0 +1,166 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotInstanceProcessModuleId{}) +} + +var _ resourceids.ResourceId = &SlotInstanceProcessModuleId{} + +// SlotInstanceProcessModuleId is a struct representing the Resource ID for a Slot Instance Process Module +type SlotInstanceProcessModuleId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + InstanceId string + ProcessId string + ModuleName string +} + +// NewSlotInstanceProcessModuleID returns a new SlotInstanceProcessModuleId struct +func NewSlotInstanceProcessModuleID(subscriptionId string, resourceGroupName string, siteName string, slotName string, instanceId string, processId string, moduleName string) SlotInstanceProcessModuleId { + return SlotInstanceProcessModuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + InstanceId: instanceId, + ProcessId: processId, + ModuleName: moduleName, + } +} + +// ParseSlotInstanceProcessModuleID parses 'input' into a SlotInstanceProcessModuleId +func ParseSlotInstanceProcessModuleID(input string) (*SlotInstanceProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceProcessModuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceProcessModuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotInstanceProcessModuleIDInsensitively parses 'input' case-insensitively into a SlotInstanceProcessModuleId +// note: this method should only be used for API response data and not user input +func ParseSlotInstanceProcessModuleIDInsensitively(input string) (*SlotInstanceProcessModuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotInstanceProcessModuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotInstanceProcessModuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotInstanceProcessModuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.InstanceId, ok = input.Parsed["instanceId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "instanceId", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + if id.ModuleName, ok = input.Parsed["moduleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "moduleName", input) + } + + return nil +} + +// ValidateSlotInstanceProcessModuleID checks that 'input' can be parsed as a Slot Instance Process Module ID +func ValidateSlotInstanceProcessModuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotInstanceProcessModuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Instance Process Module ID +func (id SlotInstanceProcessModuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/instances/%s/processes/%s/modules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.InstanceId, id.ProcessId, id.ModuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Instance Process Module ID +func (id SlotInstanceProcessModuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticInstances", "instances", "instances"), + resourceids.UserSpecifiedSegment("instanceId", "instanceId"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processId"), + resourceids.StaticSegment("staticModules", "modules", "modules"), + resourceids.UserSpecifiedSegment("moduleName", "moduleName"), + } +} + +// String returns a human-readable description of this Slot Instance Process Module ID +func (id SlotInstanceProcessModuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Instance: %q", id.InstanceId), + fmt.Sprintf("Process: %q", id.ProcessId), + fmt.Sprintf("Module Name: %q", id.ModuleName), + } + return fmt.Sprintf("Slot Instance Process Module (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotinstanceprocessmodule_test.go b/resource-manager/web/2024-11-01/webapps/id_slotinstanceprocessmodule_test.go new file mode 100644 index 00000000000..109eb72ff25 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotinstanceprocessmodule_test.go @@ -0,0 +1,462 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotInstanceProcessModuleId{} + +func TestNewSlotInstanceProcessModuleID(t *testing.T) { + id := NewSlotInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId", "moduleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.InstanceId != "instanceId" { + t.Fatalf("Expected %q but got %q for Segment 'InstanceId'", id.InstanceId, "instanceId") + } + + if id.ProcessId != "processId" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processId") + } + + if id.ModuleName != "moduleName" { + t.Fatalf("Expected %q but got %q for Segment 'ModuleName'", id.ModuleName, "moduleName") + } +} + +func TestFormatSlotInstanceProcessModuleID(t *testing.T) { + actual := NewSlotInstanceProcessModuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "instanceId", "processId", "moduleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/modules/moduleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotInstanceProcessModuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceProcessModuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/modules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/modules/moduleName", + Expected: &SlotInstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + InstanceId: "instanceId", + ProcessId: "processId", + ModuleName: "moduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/modules/moduleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceProcessModuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestParseSlotInstanceProcessModuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotInstanceProcessModuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/modules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId/mOdUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/modules/moduleName", + Expected: &SlotInstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + InstanceId: "instanceId", + ProcessId: "processId", + ModuleName: "moduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/instances/instanceId/processes/processId/modules/moduleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId/mOdUlEs/mOdUlEnAmE", + Expected: &SlotInstanceProcessModuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + InstanceId: "iNsTaNcEiD", + ProcessId: "pRoCeSsId", + ModuleName: "mOdUlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/iNsTaNcEs/iNsTaNcEiD/pRoCeSsEs/pRoCeSsId/mOdUlEs/mOdUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotInstanceProcessModuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.InstanceId != v.Expected.InstanceId { + t.Fatalf("Expected %q but got %q for InstanceId", v.Expected.InstanceId, actual.InstanceId) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + if actual.ModuleName != v.Expected.ModuleName { + t.Fatalf("Expected %q but got %q for ModuleName", v.Expected.ModuleName, actual.ModuleName) + } + + } +} + +func TestSegmentsForSlotInstanceProcessModuleId(t *testing.T) { + segments := SlotInstanceProcessModuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotInstanceProcessModuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotnetworkfeature.go b/resource-manager/web/2024-11-01/webapps/id_slotnetworkfeature.go new file mode 100644 index 00000000000..507114a0bf1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotnetworkfeature.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotNetworkFeatureId{}) +} + +var _ resourceids.ResourceId = &SlotNetworkFeatureId{} + +// SlotNetworkFeatureId is a struct representing the Resource ID for a Slot Network Feature +type SlotNetworkFeatureId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + NetworkFeatureName string +} + +// NewSlotNetworkFeatureID returns a new SlotNetworkFeatureId struct +func NewSlotNetworkFeatureID(subscriptionId string, resourceGroupName string, siteName string, slotName string, networkFeatureName string) SlotNetworkFeatureId { + return SlotNetworkFeatureId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + NetworkFeatureName: networkFeatureName, + } +} + +// ParseSlotNetworkFeatureID parses 'input' into a SlotNetworkFeatureId +func ParseSlotNetworkFeatureID(input string) (*SlotNetworkFeatureId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotNetworkFeatureId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotNetworkFeatureId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotNetworkFeatureIDInsensitively parses 'input' case-insensitively into a SlotNetworkFeatureId +// note: this method should only be used for API response data and not user input +func ParseSlotNetworkFeatureIDInsensitively(input string) (*SlotNetworkFeatureId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotNetworkFeatureId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotNetworkFeatureId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotNetworkFeatureId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.NetworkFeatureName, ok = input.Parsed["networkFeatureName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "networkFeatureName", input) + } + + return nil +} + +// ValidateSlotNetworkFeatureID checks that 'input' can be parsed as a Slot Network Feature ID +func ValidateSlotNetworkFeatureID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotNetworkFeatureID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Network Feature ID +func (id SlotNetworkFeatureId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/networkFeatures/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.NetworkFeatureName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Network Feature ID +func (id SlotNetworkFeatureId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticNetworkFeatures", "networkFeatures", "networkFeatures"), + resourceids.UserSpecifiedSegment("networkFeatureName", "networkFeatureName"), + } +} + +// String returns a human-readable description of this Slot Network Feature ID +func (id SlotNetworkFeatureId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Network Feature Name: %q", id.NetworkFeatureName), + } + return fmt.Sprintf("Slot Network Feature (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotnetworkfeature_test.go b/resource-manager/web/2024-11-01/webapps/id_slotnetworkfeature_test.go new file mode 100644 index 00000000000..3b0cebea96b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotnetworkfeature_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotNetworkFeatureId{} + +func TestNewSlotNetworkFeatureID(t *testing.T) { + id := NewSlotNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "networkFeatureName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.NetworkFeatureName != "networkFeatureName" { + t.Fatalf("Expected %q but got %q for Segment 'NetworkFeatureName'", id.NetworkFeatureName, "networkFeatureName") + } +} + +func TestFormatSlotNetworkFeatureID(t *testing.T) { + actual := NewSlotNetworkFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "networkFeatureName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkFeatures/networkFeatureName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotNetworkFeatureID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotNetworkFeatureId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkFeatures", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkFeatures/networkFeatureName", + Expected: &SlotNetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + NetworkFeatureName: "networkFeatureName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkFeatures/networkFeatureName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotNetworkFeatureID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.NetworkFeatureName != v.Expected.NetworkFeatureName { + t.Fatalf("Expected %q but got %q for NetworkFeatureName", v.Expected.NetworkFeatureName, actual.NetworkFeatureName) + } + + } +} + +func TestParseSlotNetworkFeatureIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotNetworkFeatureId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkFeatures", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkFeAtUrEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkFeatures/networkFeatureName", + Expected: &SlotNetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + NetworkFeatureName: "networkFeatureName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkFeatures/networkFeatureName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkFeAtUrEs/nEtWoRkFeAtUrEnAmE", + Expected: &SlotNetworkFeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + NetworkFeatureName: "nEtWoRkFeAtUrEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkFeAtUrEs/nEtWoRkFeAtUrEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotNetworkFeatureIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.NetworkFeatureName != v.Expected.NetworkFeatureName { + t.Fatalf("Expected %q but got %q for NetworkFeatureName", v.Expected.NetworkFeatureName, actual.NetworkFeatureName) + } + + } +} + +func TestSegmentsForSlotNetworkFeatureId(t *testing.T) { + segments := SlotNetworkFeatureId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotNetworkFeatureId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotnetworktrace.go b/resource-manager/web/2024-11-01/webapps/id_slotnetworktrace.go new file mode 100644 index 00000000000..4e4dd73328e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotnetworktrace.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotNetworkTraceId{}) +} + +var _ resourceids.ResourceId = &SlotNetworkTraceId{} + +// SlotNetworkTraceId is a struct representing the Resource ID for a Slot Network Trace +type SlotNetworkTraceId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + OperationId string +} + +// NewSlotNetworkTraceID returns a new SlotNetworkTraceId struct +func NewSlotNetworkTraceID(subscriptionId string, resourceGroupName string, siteName string, slotName string, operationId string) SlotNetworkTraceId { + return SlotNetworkTraceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + OperationId: operationId, + } +} + +// ParseSlotNetworkTraceID parses 'input' into a SlotNetworkTraceId +func ParseSlotNetworkTraceID(input string) (*SlotNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotNetworkTraceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotNetworkTraceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotNetworkTraceIDInsensitively parses 'input' case-insensitively into a SlotNetworkTraceId +// note: this method should only be used for API response data and not user input +func ParseSlotNetworkTraceIDInsensitively(input string) (*SlotNetworkTraceId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotNetworkTraceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotNetworkTraceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotNetworkTraceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.OperationId, ok = input.Parsed["operationId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "operationId", input) + } + + return nil +} + +// ValidateSlotNetworkTraceID checks that 'input' can be parsed as a Slot Network Trace ID +func ValidateSlotNetworkTraceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotNetworkTraceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Network Trace ID +func (id SlotNetworkTraceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/networkTrace/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.OperationId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Network Trace ID +func (id SlotNetworkTraceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticNetworkTrace", "networkTrace", "networkTrace"), + resourceids.UserSpecifiedSegment("operationId", "operationId"), + } +} + +// String returns a human-readable description of this Slot Network Trace ID +func (id SlotNetworkTraceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Operation: %q", id.OperationId), + } + return fmt.Sprintf("Slot Network Trace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotnetworktrace_test.go b/resource-manager/web/2024-11-01/webapps/id_slotnetworktrace_test.go new file mode 100644 index 00000000000..ef938f160c3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotnetworktrace_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotNetworkTraceId{} + +func TestNewSlotNetworkTraceID(t *testing.T) { + id := NewSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "operationId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.OperationId != "operationId" { + t.Fatalf("Expected %q but got %q for Segment 'OperationId'", id.OperationId, "operationId") + } +} + +func TestFormatSlotNetworkTraceID(t *testing.T) { + actual := NewSlotNetworkTraceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "operationId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTrace/operationId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotNetworkTraceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotNetworkTraceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTrace", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTrace/operationId", + Expected: &SlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + OperationId: "operationId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTrace/operationId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotNetworkTraceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestParseSlotNetworkTraceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotNetworkTraceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTrace", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkTrAcE", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTrace/operationId", + Expected: &SlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + OperationId: "operationId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/networkTrace/operationId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkTrAcE/oPeRaTiOnId", + Expected: &SlotNetworkTraceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + OperationId: "oPeRaTiOnId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/nEtWoRkTrAcE/oPeRaTiOnId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotNetworkTraceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.OperationId != v.Expected.OperationId { + t.Fatalf("Expected %q but got %q for OperationId", v.Expected.OperationId, actual.OperationId) + } + + } +} + +func TestSegmentsForSlotNetworkTraceId(t *testing.T) { + segments := SlotNetworkTraceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotNetworkTraceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotpremieraddon.go b/resource-manager/web/2024-11-01/webapps/id_slotpremieraddon.go new file mode 100644 index 00000000000..ca4498c2e93 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotpremieraddon.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotPremierAddonId{}) +} + +var _ resourceids.ResourceId = &SlotPremierAddonId{} + +// SlotPremierAddonId is a struct representing the Resource ID for a Slot Premier Addon +type SlotPremierAddonId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + PremierAddonName string +} + +// NewSlotPremierAddonID returns a new SlotPremierAddonId struct +func NewSlotPremierAddonID(subscriptionId string, resourceGroupName string, siteName string, slotName string, premierAddonName string) SlotPremierAddonId { + return SlotPremierAddonId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + PremierAddonName: premierAddonName, + } +} + +// ParseSlotPremierAddonID parses 'input' into a SlotPremierAddonId +func ParseSlotPremierAddonID(input string) (*SlotPremierAddonId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPremierAddonId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPremierAddonId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotPremierAddonIDInsensitively parses 'input' case-insensitively into a SlotPremierAddonId +// note: this method should only be used for API response data and not user input +func ParseSlotPremierAddonIDInsensitively(input string) (*SlotPremierAddonId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPremierAddonId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPremierAddonId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotPremierAddonId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.PremierAddonName, ok = input.Parsed["premierAddonName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "premierAddonName", input) + } + + return nil +} + +// ValidateSlotPremierAddonID checks that 'input' can be parsed as a Slot Premier Addon ID +func ValidateSlotPremierAddonID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotPremierAddonID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Premier Addon ID +func (id SlotPremierAddonId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/premierAddons/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.PremierAddonName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Premier Addon ID +func (id SlotPremierAddonId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticPremierAddons", "premierAddons", "premierAddons"), + resourceids.UserSpecifiedSegment("premierAddonName", "premierAddonName"), + } +} + +// String returns a human-readable description of this Slot Premier Addon ID +func (id SlotPremierAddonId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Premier Addon Name: %q", id.PremierAddonName), + } + return fmt.Sprintf("Slot Premier Addon (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotpremieraddon_test.go b/resource-manager/web/2024-11-01/webapps/id_slotpremieraddon_test.go new file mode 100644 index 00000000000..c6094e0240f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotpremieraddon_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotPremierAddonId{} + +func TestNewSlotPremierAddonID(t *testing.T) { + id := NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "premierAddonName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.PremierAddonName != "premierAddonName" { + t.Fatalf("Expected %q but got %q for Segment 'PremierAddonName'", id.PremierAddonName, "premierAddonName") + } +} + +func TestFormatSlotPremierAddonID(t *testing.T) { + actual := NewSlotPremierAddonID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "premierAddonName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/premierAddons/premierAddonName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotPremierAddonID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPremierAddonId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/premierAddons", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/premierAddons/premierAddonName", + Expected: &SlotPremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + PremierAddonName: "premierAddonName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/premierAddons/premierAddonName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPremierAddonID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PremierAddonName != v.Expected.PremierAddonName { + t.Fatalf("Expected %q but got %q for PremierAddonName", v.Expected.PremierAddonName, actual.PremierAddonName) + } + + } +} + +func TestParseSlotPremierAddonIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPremierAddonId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/premierAddons", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pReMiErAdDoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/premierAddons/premierAddonName", + Expected: &SlotPremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + PremierAddonName: "premierAddonName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/premierAddons/premierAddonName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pReMiErAdDoNs/pReMiErAdDoNnAmE", + Expected: &SlotPremierAddonId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + PremierAddonName: "pReMiErAdDoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pReMiErAdDoNs/pReMiErAdDoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPremierAddonIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PremierAddonName != v.Expected.PremierAddonName { + t.Fatalf("Expected %q but got %q for PremierAddonName", v.Expected.PremierAddonName, actual.PremierAddonName) + } + + } +} + +func TestSegmentsForSlotPremierAddonId(t *testing.T) { + segments := SlotPremierAddonId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotPremierAddonId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotprivateendpointconnection.go b/resource-manager/web/2024-11-01/webapps/id_slotprivateendpointconnection.go new file mode 100644 index 00000000000..7a29bd7cb8b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotprivateendpointconnection.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotPrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &SlotPrivateEndpointConnectionId{} + +// SlotPrivateEndpointConnectionId is a struct representing the Resource ID for a Slot Private Endpoint Connection +type SlotPrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + PrivateEndpointConnectionName string +} + +// NewSlotPrivateEndpointConnectionID returns a new SlotPrivateEndpointConnectionId struct +func NewSlotPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, siteName string, slotName string, privateEndpointConnectionName string) SlotPrivateEndpointConnectionId { + return SlotPrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParseSlotPrivateEndpointConnectionID parses 'input' into a SlotPrivateEndpointConnectionId +func ParseSlotPrivateEndpointConnectionID(input string) (*SlotPrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotPrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a SlotPrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParseSlotPrivateEndpointConnectionIDInsensitively(input string) (*SlotPrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPrivateEndpointConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotPrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidateSlotPrivateEndpointConnectionID checks that 'input' can be parsed as a Slot Private Endpoint Connection ID +func ValidateSlotPrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotPrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Private Endpoint Connection ID +func (id SlotPrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Private Endpoint Connection ID +func (id SlotPrivateEndpointConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionName"), + } +} + +// String returns a human-readable description of this Slot Private Endpoint Connection ID +func (id SlotPrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Slot Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotprivateendpointconnection_test.go b/resource-manager/web/2024-11-01/webapps/id_slotprivateendpointconnection_test.go new file mode 100644 index 00000000000..b7c1bd2958c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotprivateendpointconnection_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotPrivateEndpointConnectionId{} + +func TestNewSlotPrivateEndpointConnectionID(t *testing.T) { + id := NewSlotPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "privateEndpointConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionName") + } +} + +func TestFormatSlotPrivateEndpointConnectionID(t *testing.T) { + actual := NewSlotPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/privateEndpointConnections/privateEndpointConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotPrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &SlotPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParseSlotPrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &SlotPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/privateEndpointConnections/privateEndpointConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &SlotPrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForSlotPrivateEndpointConnectionId(t *testing.T) { + segments := SlotPrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotPrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotprocess.go b/resource-manager/web/2024-11-01/webapps/id_slotprocess.go new file mode 100644 index 00000000000..98487bec6fc --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotprocess.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotProcessId{}) +} + +var _ resourceids.ResourceId = &SlotProcessId{} + +// SlotProcessId is a struct representing the Resource ID for a Slot Process +type SlotProcessId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + ProcessId string +} + +// NewSlotProcessID returns a new SlotProcessId struct +func NewSlotProcessID(subscriptionId string, resourceGroupName string, siteName string, slotName string, processId string) SlotProcessId { + return SlotProcessId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + ProcessId: processId, + } +} + +// ParseSlotProcessID parses 'input' into a SlotProcessId +func ParseSlotProcessID(input string) (*SlotProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotProcessId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotProcessId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotProcessIDInsensitively parses 'input' case-insensitively into a SlotProcessId +// note: this method should only be used for API response data and not user input +func ParseSlotProcessIDInsensitively(input string) (*SlotProcessId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotProcessId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotProcessId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotProcessId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.ProcessId, ok = input.Parsed["processId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "processId", input) + } + + return nil +} + +// ValidateSlotProcessID checks that 'input' can be parsed as a Slot Process ID +func ValidateSlotProcessID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotProcessID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Process ID +func (id SlotProcessId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/processes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.ProcessId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Process ID +func (id SlotProcessId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticProcesses", "processes", "processes"), + resourceids.UserSpecifiedSegment("processId", "processId"), + } +} + +// String returns a human-readable description of this Slot Process ID +func (id SlotProcessId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Process: %q", id.ProcessId), + } + return fmt.Sprintf("Slot Process (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotprocess_test.go b/resource-manager/web/2024-11-01/webapps/id_slotprocess_test.go new file mode 100644 index 00000000000..79324e032ca --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotprocess_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotProcessId{} + +func TestNewSlotProcessID(t *testing.T) { + id := NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.ProcessId != "processId" { + t.Fatalf("Expected %q but got %q for Segment 'ProcessId'", id.ProcessId, "processId") + } +} + +func TestFormatSlotProcessID(t *testing.T) { + actual := NewSlotProcessID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "processId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotProcessID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotProcessId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId", + Expected: &SlotProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + ProcessId: "processId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotProcessID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestParseSlotProcessIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotProcessId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRoCeSsEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId", + Expected: &SlotProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + ProcessId: "processId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/processes/processId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRoCeSsEs/pRoCeSsId", + Expected: &SlotProcessId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + ProcessId: "pRoCeSsId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pRoCeSsEs/pRoCeSsId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotProcessIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.ProcessId != v.Expected.ProcessId { + t.Fatalf("Expected %q but got %q for ProcessId", v.Expected.ProcessId, actual.ProcessId) + } + + } +} + +func TestSegmentsForSlotProcessId(t *testing.T) { + segments := SlotProcessId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotProcessId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotpubliccertificate.go b/resource-manager/web/2024-11-01/webapps/id_slotpubliccertificate.go new file mode 100644 index 00000000000..45ded508c35 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotpubliccertificate.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotPublicCertificateId{}) +} + +var _ resourceids.ResourceId = &SlotPublicCertificateId{} + +// SlotPublicCertificateId is a struct representing the Resource ID for a Slot Public Certificate +type SlotPublicCertificateId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + PublicCertificateName string +} + +// NewSlotPublicCertificateID returns a new SlotPublicCertificateId struct +func NewSlotPublicCertificateID(subscriptionId string, resourceGroupName string, siteName string, slotName string, publicCertificateName string) SlotPublicCertificateId { + return SlotPublicCertificateId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + PublicCertificateName: publicCertificateName, + } +} + +// ParseSlotPublicCertificateID parses 'input' into a SlotPublicCertificateId +func ParseSlotPublicCertificateID(input string) (*SlotPublicCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPublicCertificateId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPublicCertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotPublicCertificateIDInsensitively parses 'input' case-insensitively into a SlotPublicCertificateId +// note: this method should only be used for API response data and not user input +func ParseSlotPublicCertificateIDInsensitively(input string) (*SlotPublicCertificateId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotPublicCertificateId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotPublicCertificateId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotPublicCertificateId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.PublicCertificateName, ok = input.Parsed["publicCertificateName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "publicCertificateName", input) + } + + return nil +} + +// ValidateSlotPublicCertificateID checks that 'input' can be parsed as a Slot Public Certificate ID +func ValidateSlotPublicCertificateID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotPublicCertificateID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Public Certificate ID +func (id SlotPublicCertificateId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/publicCertificates/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.PublicCertificateName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Public Certificate ID +func (id SlotPublicCertificateId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticPublicCertificates", "publicCertificates", "publicCertificates"), + resourceids.UserSpecifiedSegment("publicCertificateName", "publicCertificateName"), + } +} + +// String returns a human-readable description of this Slot Public Certificate ID +func (id SlotPublicCertificateId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Public Certificate Name: %q", id.PublicCertificateName), + } + return fmt.Sprintf("Slot Public Certificate (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotpubliccertificate_test.go b/resource-manager/web/2024-11-01/webapps/id_slotpubliccertificate_test.go new file mode 100644 index 00000000000..31f3e81c0fb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotpubliccertificate_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotPublicCertificateId{} + +func TestNewSlotPublicCertificateID(t *testing.T) { + id := NewSlotPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "publicCertificateName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.PublicCertificateName != "publicCertificateName" { + t.Fatalf("Expected %q but got %q for Segment 'PublicCertificateName'", id.PublicCertificateName, "publicCertificateName") + } +} + +func TestFormatSlotPublicCertificateID(t *testing.T) { + actual := NewSlotPublicCertificateID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "publicCertificateName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/publicCertificates/publicCertificateName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotPublicCertificateID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPublicCertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/publicCertificates", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/publicCertificates/publicCertificateName", + Expected: &SlotPublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + PublicCertificateName: "publicCertificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/publicCertificates/publicCertificateName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPublicCertificateID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PublicCertificateName != v.Expected.PublicCertificateName { + t.Fatalf("Expected %q but got %q for PublicCertificateName", v.Expected.PublicCertificateName, actual.PublicCertificateName) + } + + } +} + +func TestParseSlotPublicCertificateIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotPublicCertificateId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/publicCertificates", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pUbLiCcErTiFiCaTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/publicCertificates/publicCertificateName", + Expected: &SlotPublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + PublicCertificateName: "publicCertificateName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/publicCertificates/publicCertificateName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pUbLiCcErTiFiCaTeS/pUbLiCcErTiFiCaTeNaMe", + Expected: &SlotPublicCertificateId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + PublicCertificateName: "pUbLiCcErTiFiCaTeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/pUbLiCcErTiFiCaTeS/pUbLiCcErTiFiCaTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotPublicCertificateIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.PublicCertificateName != v.Expected.PublicCertificateName { + t.Fatalf("Expected %q but got %q for PublicCertificateName", v.Expected.PublicCertificateName, actual.PublicCertificateName) + } + + } +} + +func TestSegmentsForSlotPublicCertificateId(t *testing.T) { + segments := SlotPublicCertificateId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotPublicCertificateId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotsitecontainer.go b/resource-manager/web/2024-11-01/webapps/id_slotsitecontainer.go new file mode 100644 index 00000000000..b1b7bd75011 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotsitecontainer.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotSitecontainerId{}) +} + +var _ resourceids.ResourceId = &SlotSitecontainerId{} + +// SlotSitecontainerId is a struct representing the Resource ID for a Slot Sitecontainer +type SlotSitecontainerId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + SitecontainerName string +} + +// NewSlotSitecontainerID returns a new SlotSitecontainerId struct +func NewSlotSitecontainerID(subscriptionId string, resourceGroupName string, siteName string, slotName string, sitecontainerName string) SlotSitecontainerId { + return SlotSitecontainerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + SitecontainerName: sitecontainerName, + } +} + +// ParseSlotSitecontainerID parses 'input' into a SlotSitecontainerId +func ParseSlotSitecontainerID(input string) (*SlotSitecontainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotSitecontainerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotSitecontainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotSitecontainerIDInsensitively parses 'input' case-insensitively into a SlotSitecontainerId +// note: this method should only be used for API response data and not user input +func ParseSlotSitecontainerIDInsensitively(input string) (*SlotSitecontainerId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotSitecontainerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotSitecontainerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotSitecontainerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.SitecontainerName, ok = input.Parsed["sitecontainerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "sitecontainerName", input) + } + + return nil +} + +// ValidateSlotSitecontainerID checks that 'input' can be parsed as a Slot Sitecontainer ID +func ValidateSlotSitecontainerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotSitecontainerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Sitecontainer ID +func (id SlotSitecontainerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/sitecontainers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.SitecontainerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Sitecontainer ID +func (id SlotSitecontainerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticSitecontainers", "sitecontainers", "sitecontainers"), + resourceids.UserSpecifiedSegment("sitecontainerName", "sitecontainerName"), + } +} + +// String returns a human-readable description of this Slot Sitecontainer ID +func (id SlotSitecontainerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Sitecontainer Name: %q", id.SitecontainerName), + } + return fmt.Sprintf("Slot Sitecontainer (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotsitecontainer_test.go b/resource-manager/web/2024-11-01/webapps/id_slotsitecontainer_test.go new file mode 100644 index 00000000000..c09df8600ea --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotsitecontainer_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotSitecontainerId{} + +func TestNewSlotSitecontainerID(t *testing.T) { + id := NewSlotSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "sitecontainerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.SitecontainerName != "sitecontainerName" { + t.Fatalf("Expected %q but got %q for Segment 'SitecontainerName'", id.SitecontainerName, "sitecontainerName") + } +} + +func TestFormatSlotSitecontainerID(t *testing.T) { + actual := NewSlotSitecontainerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "sitecontainerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/sitecontainers/sitecontainerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotSitecontainerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotSitecontainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/sitecontainers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/sitecontainers/sitecontainerName", + Expected: &SlotSitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + SitecontainerName: "sitecontainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/sitecontainers/sitecontainerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotSitecontainerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SitecontainerName != v.Expected.SitecontainerName { + t.Fatalf("Expected %q but got %q for SitecontainerName", v.Expected.SitecontainerName, actual.SitecontainerName) + } + + } +} + +func TestParseSlotSitecontainerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotSitecontainerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/sitecontainers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/sItEcOnTaInErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/sitecontainers/sitecontainerName", + Expected: &SlotSitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + SitecontainerName: "sitecontainerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/sitecontainers/sitecontainerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/sItEcOnTaInErS/sItEcOnTaInErNaMe", + Expected: &SlotSitecontainerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + SitecontainerName: "sItEcOnTaInErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/sItEcOnTaInErS/sItEcOnTaInErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotSitecontainerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SitecontainerName != v.Expected.SitecontainerName { + t.Fatalf("Expected %q but got %q for SitecontainerName", v.Expected.SitecontainerName, actual.SitecontainerName) + } + + } +} + +func TestSegmentsForSlotSitecontainerId(t *testing.T) { + segments := SlotSitecontainerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotSitecontainerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotsiteextension.go b/resource-manager/web/2024-11-01/webapps/id_slotsiteextension.go new file mode 100644 index 00000000000..5df295c09ba --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotsiteextension.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotSiteExtensionId{}) +} + +var _ resourceids.ResourceId = &SlotSiteExtensionId{} + +// SlotSiteExtensionId is a struct representing the Resource ID for a Slot Site Extension +type SlotSiteExtensionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + SiteExtensionId string +} + +// NewSlotSiteExtensionID returns a new SlotSiteExtensionId struct +func NewSlotSiteExtensionID(subscriptionId string, resourceGroupName string, siteName string, slotName string, siteExtensionId string) SlotSiteExtensionId { + return SlotSiteExtensionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + SiteExtensionId: siteExtensionId, + } +} + +// ParseSlotSiteExtensionID parses 'input' into a SlotSiteExtensionId +func ParseSlotSiteExtensionID(input string) (*SlotSiteExtensionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotSiteExtensionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotSiteExtensionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotSiteExtensionIDInsensitively parses 'input' case-insensitively into a SlotSiteExtensionId +// note: this method should only be used for API response data and not user input +func ParseSlotSiteExtensionIDInsensitively(input string) (*SlotSiteExtensionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotSiteExtensionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotSiteExtensionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotSiteExtensionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.SiteExtensionId, ok = input.Parsed["siteExtensionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteExtensionId", input) + } + + return nil +} + +// ValidateSlotSiteExtensionID checks that 'input' can be parsed as a Slot Site Extension ID +func ValidateSlotSiteExtensionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotSiteExtensionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Site Extension ID +func (id SlotSiteExtensionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/siteExtensions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.SiteExtensionId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Site Extension ID +func (id SlotSiteExtensionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticSiteExtensions", "siteExtensions", "siteExtensions"), + resourceids.UserSpecifiedSegment("siteExtensionId", "siteExtensionId"), + } +} + +// String returns a human-readable description of this Slot Site Extension ID +func (id SlotSiteExtensionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Site Extension: %q", id.SiteExtensionId), + } + return fmt.Sprintf("Slot Site Extension (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotsiteextension_test.go b/resource-manager/web/2024-11-01/webapps/id_slotsiteextension_test.go new file mode 100644 index 00000000000..732d09fb195 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotsiteextension_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotSiteExtensionId{} + +func TestNewSlotSiteExtensionID(t *testing.T) { + id := NewSlotSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "siteExtensionId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.SiteExtensionId != "siteExtensionId" { + t.Fatalf("Expected %q but got %q for Segment 'SiteExtensionId'", id.SiteExtensionId, "siteExtensionId") + } +} + +func TestFormatSlotSiteExtensionID(t *testing.T) { + actual := NewSlotSiteExtensionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "siteExtensionId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/siteExtensions/siteExtensionId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotSiteExtensionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotSiteExtensionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/siteExtensions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/siteExtensions/siteExtensionId", + Expected: &SlotSiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + SiteExtensionId: "siteExtensionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/siteExtensions/siteExtensionId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotSiteExtensionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SiteExtensionId != v.Expected.SiteExtensionId { + t.Fatalf("Expected %q but got %q for SiteExtensionId", v.Expected.SiteExtensionId, actual.SiteExtensionId) + } + + } +} + +func TestParseSlotSiteExtensionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotSiteExtensionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/siteExtensions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/sItEeXtEnSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/siteExtensions/siteExtensionId", + Expected: &SlotSiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + SiteExtensionId: "siteExtensionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/siteExtensions/siteExtensionId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/sItEeXtEnSiOnS/sItEeXtEnSiOnId", + Expected: &SlotSiteExtensionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + SiteExtensionId: "sItEeXtEnSiOnId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/sItEeXtEnSiOnS/sItEeXtEnSiOnId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotSiteExtensionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SiteExtensionId != v.Expected.SiteExtensionId { + t.Fatalf("Expected %q but got %q for SiteExtensionId", v.Expected.SiteExtensionId, actual.SiteExtensionId) + } + + } +} + +func TestSegmentsForSlotSiteExtensionId(t *testing.T) { + segments := SlotSiteExtensionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotSiteExtensionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slottriggeredwebjob.go b/resource-manager/web/2024-11-01/webapps/id_slottriggeredwebjob.go new file mode 100644 index 00000000000..48ba81d16d3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slottriggeredwebjob.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotTriggeredWebJobId{}) +} + +var _ resourceids.ResourceId = &SlotTriggeredWebJobId{} + +// SlotTriggeredWebJobId is a struct representing the Resource ID for a Slot Triggered Web Job +type SlotTriggeredWebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + TriggeredWebJobName string +} + +// NewSlotTriggeredWebJobID returns a new SlotTriggeredWebJobId struct +func NewSlotTriggeredWebJobID(subscriptionId string, resourceGroupName string, siteName string, slotName string, triggeredWebJobName string) SlotTriggeredWebJobId { + return SlotTriggeredWebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + TriggeredWebJobName: triggeredWebJobName, + } +} + +// ParseSlotTriggeredWebJobID parses 'input' into a SlotTriggeredWebJobId +func ParseSlotTriggeredWebJobID(input string) (*SlotTriggeredWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotTriggeredWebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotTriggeredWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotTriggeredWebJobIDInsensitively parses 'input' case-insensitively into a SlotTriggeredWebJobId +// note: this method should only be used for API response data and not user input +func ParseSlotTriggeredWebJobIDInsensitively(input string) (*SlotTriggeredWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotTriggeredWebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotTriggeredWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotTriggeredWebJobId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.TriggeredWebJobName, ok = input.Parsed["triggeredWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggeredWebJobName", input) + } + + return nil +} + +// ValidateSlotTriggeredWebJobID checks that 'input' can be parsed as a Slot Triggered Web Job ID +func ValidateSlotTriggeredWebJobID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotTriggeredWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Triggered Web Job ID +func (id SlotTriggeredWebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/triggeredWebJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.TriggeredWebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Triggered Web Job ID +func (id SlotTriggeredWebJobId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticTriggeredWebJobs", "triggeredWebJobs", "triggeredWebJobs"), + resourceids.UserSpecifiedSegment("triggeredWebJobName", "triggeredWebJobName"), + } +} + +// String returns a human-readable description of this Slot Triggered Web Job ID +func (id SlotTriggeredWebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Triggered Web Job Name: %q", id.TriggeredWebJobName), + } + return fmt.Sprintf("Slot Triggered Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slottriggeredwebjob_test.go b/resource-manager/web/2024-11-01/webapps/id_slottriggeredwebjob_test.go new file mode 100644 index 00000000000..c7f66afaa1e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slottriggeredwebjob_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotTriggeredWebJobId{} + +func TestNewSlotTriggeredWebJobID(t *testing.T) { + id := NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.TriggeredWebJobName != "triggeredWebJobName" { + t.Fatalf("Expected %q but got %q for Segment 'TriggeredWebJobName'", id.TriggeredWebJobName, "triggeredWebJobName") + } +} + +func TestFormatSlotTriggeredWebJobID(t *testing.T) { + actual := NewSlotTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotTriggeredWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotTriggeredWebJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName", + Expected: &SlotTriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + TriggeredWebJobName: "triggeredWebJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotTriggeredWebJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + } +} + +func TestParseSlotTriggeredWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotTriggeredWebJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/tRiGgErEdWeBjObS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName", + Expected: &SlotTriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + TriggeredWebJobName: "triggeredWebJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe", + Expected: &SlotTriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + TriggeredWebJobName: "tRiGgErEdWeBjObNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotTriggeredWebJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + } +} + +func TestSegmentsForSlotTriggeredWebJobId(t *testing.T) { + segments := SlotTriggeredWebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotTriggeredWebJobId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotvirtualnetworkconnection.go b/resource-manager/web/2024-11-01/webapps/id_slotvirtualnetworkconnection.go new file mode 100644 index 00000000000..637d36cce57 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotvirtualnetworkconnection.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotVirtualNetworkConnectionId{}) +} + +var _ resourceids.ResourceId = &SlotVirtualNetworkConnectionId{} + +// SlotVirtualNetworkConnectionId is a struct representing the Resource ID for a Slot Virtual Network Connection +type SlotVirtualNetworkConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + VirtualNetworkConnectionName string +} + +// NewSlotVirtualNetworkConnectionID returns a new SlotVirtualNetworkConnectionId struct +func NewSlotVirtualNetworkConnectionID(subscriptionId string, resourceGroupName string, siteName string, slotName string, virtualNetworkConnectionName string) SlotVirtualNetworkConnectionId { + return SlotVirtualNetworkConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + } +} + +// ParseSlotVirtualNetworkConnectionID parses 'input' into a SlotVirtualNetworkConnectionId +func ParseSlotVirtualNetworkConnectionID(input string) (*SlotVirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotVirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotVirtualNetworkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotVirtualNetworkConnectionIDInsensitively parses 'input' case-insensitively into a SlotVirtualNetworkConnectionId +// note: this method should only be used for API response data and not user input +func ParseSlotVirtualNetworkConnectionIDInsensitively(input string) (*SlotVirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotVirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotVirtualNetworkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotVirtualNetworkConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + return nil +} + +// ValidateSlotVirtualNetworkConnectionID checks that 'input' can be parsed as a Slot Virtual Network Connection ID +func ValidateSlotVirtualNetworkConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotVirtualNetworkConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Virtual Network Connection ID +func (id SlotVirtualNetworkConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/virtualNetworkConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.VirtualNetworkConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Virtual Network Connection ID +func (id SlotVirtualNetworkConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionName"), + } +} + +// String returns a human-readable description of this Slot Virtual Network Connection ID +func (id SlotVirtualNetworkConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + } + return fmt.Sprintf("Slot Virtual Network Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotvirtualnetworkconnection_test.go b/resource-manager/web/2024-11-01/webapps/id_slotvirtualnetworkconnection_test.go new file mode 100644 index 00000000000..623d47d5691 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotvirtualnetworkconnection_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotVirtualNetworkConnectionId{} + +func TestNewSlotVirtualNetworkConnectionID(t *testing.T) { + id := NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionName") + } +} + +func TestFormatSlotVirtualNetworkConnectionID(t *testing.T) { + actual := NewSlotVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotVirtualNetworkConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotVirtualNetworkConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName", + Expected: &SlotVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotVirtualNetworkConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestParseSlotVirtualNetworkConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotVirtualNetworkConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName", + Expected: &SlotVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + Expected: &SlotVirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotVirtualNetworkConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestSegmentsForSlotVirtualNetworkConnectionId(t *testing.T) { + segments := SlotVirtualNetworkConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotVirtualNetworkConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotvirtualnetworkconnectiongateway.go b/resource-manager/web/2024-11-01/webapps/id_slotvirtualnetworkconnectiongateway.go new file mode 100644 index 00000000000..8f808a13188 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotvirtualnetworkconnectiongateway.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotVirtualNetworkConnectionGatewayId{}) +} + +var _ resourceids.ResourceId = &SlotVirtualNetworkConnectionGatewayId{} + +// SlotVirtualNetworkConnectionGatewayId is a struct representing the Resource ID for a Slot Virtual Network Connection Gateway +type SlotVirtualNetworkConnectionGatewayId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + VirtualNetworkConnectionName string + GatewayName string +} + +// NewSlotVirtualNetworkConnectionGatewayID returns a new SlotVirtualNetworkConnectionGatewayId struct +func NewSlotVirtualNetworkConnectionGatewayID(subscriptionId string, resourceGroupName string, siteName string, slotName string, virtualNetworkConnectionName string, gatewayName string) SlotVirtualNetworkConnectionGatewayId { + return SlotVirtualNetworkConnectionGatewayId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + GatewayName: gatewayName, + } +} + +// ParseSlotVirtualNetworkConnectionGatewayID parses 'input' into a SlotVirtualNetworkConnectionGatewayId +func ParseSlotVirtualNetworkConnectionGatewayID(input string) (*SlotVirtualNetworkConnectionGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotVirtualNetworkConnectionGatewayId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotVirtualNetworkConnectionGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotVirtualNetworkConnectionGatewayIDInsensitively parses 'input' case-insensitively into a SlotVirtualNetworkConnectionGatewayId +// note: this method should only be used for API response data and not user input +func ParseSlotVirtualNetworkConnectionGatewayIDInsensitively(input string) (*SlotVirtualNetworkConnectionGatewayId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotVirtualNetworkConnectionGatewayId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotVirtualNetworkConnectionGatewayId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotVirtualNetworkConnectionGatewayId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + if id.GatewayName, ok = input.Parsed["gatewayName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "gatewayName", input) + } + + return nil +} + +// ValidateSlotVirtualNetworkConnectionGatewayID checks that 'input' can be parsed as a Slot Virtual Network Connection Gateway ID +func ValidateSlotVirtualNetworkConnectionGatewayID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotVirtualNetworkConnectionGatewayID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Virtual Network Connection Gateway ID +func (id SlotVirtualNetworkConnectionGatewayId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/virtualNetworkConnections/%s/gateways/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.VirtualNetworkConnectionName, id.GatewayName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Virtual Network Connection Gateway ID +func (id SlotVirtualNetworkConnectionGatewayId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionName"), + resourceids.StaticSegment("staticGateways", "gateways", "gateways"), + resourceids.UserSpecifiedSegment("gatewayName", "gatewayName"), + } +} + +// String returns a human-readable description of this Slot Virtual Network Connection Gateway ID +func (id SlotVirtualNetworkConnectionGatewayId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + fmt.Sprintf("Gateway Name: %q", id.GatewayName), + } + return fmt.Sprintf("Slot Virtual Network Connection Gateway (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotvirtualnetworkconnectiongateway_test.go b/resource-manager/web/2024-11-01/webapps/id_slotvirtualnetworkconnectiongateway_test.go new file mode 100644 index 00000000000..34baec3c9ca --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotvirtualnetworkconnectiongateway_test.go @@ -0,0 +1,417 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotVirtualNetworkConnectionGatewayId{} + +func TestNewSlotVirtualNetworkConnectionGatewayID(t *testing.T) { + id := NewSlotVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName", "gatewayName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionName") + } + + if id.GatewayName != "gatewayName" { + t.Fatalf("Expected %q but got %q for Segment 'GatewayName'", id.GatewayName, "gatewayName") + } +} + +func TestFormatSlotVirtualNetworkConnectionGatewayID(t *testing.T) { + actual := NewSlotVirtualNetworkConnectionGatewayID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "virtualNetworkConnectionName", "gatewayName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotVirtualNetworkConnectionGatewayID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotVirtualNetworkConnectionGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/gateways", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName", + Expected: &SlotVirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + GatewayName: "gatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotVirtualNetworkConnectionGatewayID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestParseSlotVirtualNetworkConnectionGatewayIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotVirtualNetworkConnectionGatewayId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/gateways", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName", + Expected: &SlotVirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + GatewayName: "gatewayName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/virtualNetworkConnections/virtualNetworkConnectionName/gateways/gatewayName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS/gAtEwAyNaMe", + Expected: &SlotVirtualNetworkConnectionGatewayId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + GatewayName: "gAtEwAyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/gAtEwAyS/gAtEwAyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotVirtualNetworkConnectionGatewayIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + if actual.GatewayName != v.Expected.GatewayName { + t.Fatalf("Expected %q but got %q for GatewayName", v.Expected.GatewayName, actual.GatewayName) + } + + } +} + +func TestSegmentsForSlotVirtualNetworkConnectionGatewayId(t *testing.T) { + segments := SlotVirtualNetworkConnectionGatewayId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotVirtualNetworkConnectionGatewayId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotwebjob.go b/resource-manager/web/2024-11-01/webapps/id_slotwebjob.go new file mode 100644 index 00000000000..e9ea5bb00fb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotwebjob.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotWebJobId{}) +} + +var _ resourceids.ResourceId = &SlotWebJobId{} + +// SlotWebJobId is a struct representing the Resource ID for a Slot Web Job +type SlotWebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + WebJobName string +} + +// NewSlotWebJobID returns a new SlotWebJobId struct +func NewSlotWebJobID(subscriptionId string, resourceGroupName string, siteName string, slotName string, webJobName string) SlotWebJobId { + return SlotWebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + WebJobName: webJobName, + } +} + +// ParseSlotWebJobID parses 'input' into a SlotWebJobId +func ParseSlotWebJobID(input string) (*SlotWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotWebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotWebJobIDInsensitively parses 'input' case-insensitively into a SlotWebJobId +// note: this method should only be used for API response data and not user input +func ParseSlotWebJobIDInsensitively(input string) (*SlotWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotWebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotWebJobId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.WebJobName, ok = input.Parsed["webJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "webJobName", input) + } + + return nil +} + +// ValidateSlotWebJobID checks that 'input' can be parsed as a Slot Web Job ID +func ValidateSlotWebJobID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Web Job ID +func (id SlotWebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/webJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.WebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Web Job ID +func (id SlotWebJobId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticWebJobs", "webJobs", "webJobs"), + resourceids.UserSpecifiedSegment("webJobName", "webJobName"), + } +} + +// String returns a human-readable description of this Slot Web Job ID +func (id SlotWebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Web Job Name: %q", id.WebJobName), + } + return fmt.Sprintf("Slot Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotwebjob_test.go b/resource-manager/web/2024-11-01/webapps/id_slotwebjob_test.go new file mode 100644 index 00000000000..66396ef164e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotwebjob_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotWebJobId{} + +func TestNewSlotWebJobID(t *testing.T) { + id := NewSlotWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "webJobName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.WebJobName != "webJobName" { + t.Fatalf("Expected %q but got %q for Segment 'WebJobName'", id.WebJobName, "webJobName") + } +} + +func TestFormatSlotWebJobID(t *testing.T) { + actual := NewSlotWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "webJobName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/webJobs/webJobName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotWebJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/webJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/webJobs/webJobName", + Expected: &SlotWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + WebJobName: "webJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/webJobs/webJobName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotWebJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.WebJobName != v.Expected.WebJobName { + t.Fatalf("Expected %q but got %q for WebJobName", v.Expected.WebJobName, actual.WebJobName) + } + + } +} + +func TestParseSlotWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotWebJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/webJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/wEbJoBs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/webJobs/webJobName", + Expected: &SlotWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + WebJobName: "webJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/webJobs/webJobName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/wEbJoBs/wEbJoBnAmE", + Expected: &SlotWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + WebJobName: "wEbJoBnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/wEbJoBs/wEbJoBnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotWebJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.WebJobName != v.Expected.WebJobName { + t.Fatalf("Expected %q but got %q for WebJobName", v.Expected.WebJobName, actual.WebJobName) + } + + } +} + +func TestSegmentsForSlotWebJobId(t *testing.T) { + segments := SlotWebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotWebJobId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotworkflow.go b/resource-manager/web/2024-11-01/webapps/id_slotworkflow.go new file mode 100644 index 00000000000..a14291749c9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotworkflow.go @@ -0,0 +1,148 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SlotWorkflowId{}) +} + +var _ resourceids.ResourceId = &SlotWorkflowId{} + +// SlotWorkflowId is a struct representing the Resource ID for a Slot Workflow +type SlotWorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + WorkflowName string +} + +// NewSlotWorkflowID returns a new SlotWorkflowId struct +func NewSlotWorkflowID(subscriptionId string, resourceGroupName string, siteName string, slotName string, workflowName string) SlotWorkflowId { + return SlotWorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + WorkflowName: workflowName, + } +} + +// ParseSlotWorkflowID parses 'input' into a SlotWorkflowId +func ParseSlotWorkflowID(input string) (*SlotWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotWorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSlotWorkflowIDInsensitively parses 'input' case-insensitively into a SlotWorkflowId +// note: this method should only be used for API response data and not user input +func ParseSlotWorkflowIDInsensitively(input string) (*SlotWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&SlotWorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SlotWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SlotWorkflowId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateSlotWorkflowID checks that 'input' can be parsed as a Slot Workflow ID +func ValidateSlotWorkflowID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSlotWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Slot Workflow ID +func (id SlotWorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Slot Workflow ID +func (id SlotWorkflowId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + } +} + +// String returns a human-readable description of this Slot Workflow ID +func (id SlotWorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Slot Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_slotworkflow_test.go b/resource-manager/web/2024-11-01/webapps/id_slotworkflow_test.go new file mode 100644 index 00000000000..dea7721f260 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_slotworkflow_test.go @@ -0,0 +1,372 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SlotWorkflowId{} + +func TestNewSlotWorkflowID(t *testing.T) { + id := NewSlotWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "workflowName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } +} + +func TestFormatSlotWorkflowID(t *testing.T) { + actual := NewSlotWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "workflowName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/workflows/workflowName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSlotWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotWorkflowId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/workflows/workflowName", + Expected: &SlotWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/workflows/workflowName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotWorkflowID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseSlotWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SlotWorkflowId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/workflows/workflowName", + Expected: &SlotWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/workflows/workflowName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/wOrKfLoWs/wOrKfLoWnAmE", + Expected: &SlotWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + WorkflowName: "wOrKfLoWnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/wOrKfLoWs/wOrKfLoWnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSlotWorkflowIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForSlotWorkflowId(t *testing.T) { + segments := SlotWorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SlotWorkflowId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_snapshot.go b/resource-manager/web/2024-11-01/webapps/id_snapshot.go new file mode 100644 index 00000000000..4d03d32a391 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_snapshot.go @@ -0,0 +1,141 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SnapshotId{}) +} + +var _ resourceids.ResourceId = &SnapshotId{} + +// SnapshotId is a struct representing the Resource ID for a Snapshot +type SnapshotId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SnapshotId string +} + +// NewSnapshotID returns a new SnapshotId struct +func NewSnapshotID(subscriptionId string, resourceGroupName string, siteName string, snapshotId string) SnapshotId { + return SnapshotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SnapshotId: snapshotId, + } +} + +// ParseSnapshotID parses 'input' into a SnapshotId +func ParseSnapshotID(input string) (*SnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SnapshotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SnapshotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSnapshotIDInsensitively parses 'input' case-insensitively into a SnapshotId +// note: this method should only be used for API response data and not user input +func ParseSnapshotIDInsensitively(input string) (*SnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SnapshotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SnapshotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SnapshotId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SnapshotId, ok = input.Parsed["snapshotId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "snapshotId", input) + } + + return nil +} + +// ValidateSnapshotID checks that 'input' can be parsed as a Snapshot ID +func ValidateSnapshotID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSnapshotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Snapshot ID +func (id SnapshotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/config/web/snapshots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SnapshotId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Snapshot ID +func (id SnapshotId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticWeb", "web", "web"), + resourceids.StaticSegment("staticSnapshots", "snapshots", "snapshots"), + resourceids.UserSpecifiedSegment("snapshotId", "snapshotId"), + } +} + +// String returns a human-readable description of this Snapshot ID +func (id SnapshotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Snapshot: %q", id.SnapshotId), + } + return fmt.Sprintf("Snapshot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_snapshot_test.go b/resource-manager/web/2024-11-01/webapps/id_snapshot_test.go new file mode 100644 index 00000000000..266ebd16516 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_snapshot_test.go @@ -0,0 +1,357 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SnapshotId{} + +func TestNewSnapshotID(t *testing.T) { + id := NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "snapshotId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SnapshotId != "snapshotId" { + t.Fatalf("Expected %q but got %q for Segment 'SnapshotId'", id.SnapshotId, "snapshotId") + } +} + +func TestFormatSnapshotID(t *testing.T) { + actual := NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "snapshotId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web/snapshots/snapshotId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSnapshotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SnapshotId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web/snapshots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web/snapshots/snapshotId", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SnapshotId: "snapshotId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web/snapshots/snapshotId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSnapshotID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SnapshotId != v.Expected.SnapshotId { + t.Fatalf("Expected %q but got %q for SnapshotId", v.Expected.SnapshotId, actual.SnapshotId) + } + + } +} + +func TestParseSnapshotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SnapshotId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web/snapshots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/wEb/sNaPsHoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web/snapshots/snapshotId", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SnapshotId: "snapshotId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/config/web/snapshots/snapshotId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/wEb/sNaPsHoTs/sNaPsHoTiD", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SnapshotId: "sNaPsHoTiD", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/cOnFiG/wEb/sNaPsHoTs/sNaPsHoTiD/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSnapshotIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SnapshotId != v.Expected.SnapshotId { + t.Fatalf("Expected %q but got %q for SnapshotId", v.Expected.SnapshotId, actual.SnapshotId) + } + + } +} + +func TestSegmentsForSnapshotId(t *testing.T) { + segments := SnapshotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SnapshotId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_triggeredwebjob.go b/resource-manager/web/2024-11-01/webapps/id_triggeredwebjob.go new file mode 100644 index 00000000000..54e4277f8e3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_triggeredwebjob.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&TriggeredWebJobId{}) +} + +var _ resourceids.ResourceId = &TriggeredWebJobId{} + +// TriggeredWebJobId is a struct representing the Resource ID for a Triggered Web Job +type TriggeredWebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + TriggeredWebJobName string +} + +// NewTriggeredWebJobID returns a new TriggeredWebJobId struct +func NewTriggeredWebJobID(subscriptionId string, resourceGroupName string, siteName string, triggeredWebJobName string) TriggeredWebJobId { + return TriggeredWebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + TriggeredWebJobName: triggeredWebJobName, + } +} + +// ParseTriggeredWebJobID parses 'input' into a TriggeredWebJobId +func ParseTriggeredWebJobID(input string) (*TriggeredWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggeredWebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggeredWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTriggeredWebJobIDInsensitively parses 'input' case-insensitively into a TriggeredWebJobId +// note: this method should only be used for API response data and not user input +func ParseTriggeredWebJobIDInsensitively(input string) (*TriggeredWebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggeredWebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggeredWebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TriggeredWebJobId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.TriggeredWebJobName, ok = input.Parsed["triggeredWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggeredWebJobName", input) + } + + return nil +} + +// ValidateTriggeredWebJobID checks that 'input' can be parsed as a Triggered Web Job ID +func ValidateTriggeredWebJobID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseTriggeredWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Triggered Web Job ID +func (id TriggeredWebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/triggeredWebJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.TriggeredWebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Triggered Web Job ID +func (id TriggeredWebJobId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticTriggeredWebJobs", "triggeredWebJobs", "triggeredWebJobs"), + resourceids.UserSpecifiedSegment("triggeredWebJobName", "triggeredWebJobName"), + } +} + +// String returns a human-readable description of this Triggered Web Job ID +func (id TriggeredWebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Triggered Web Job Name: %q", id.TriggeredWebJobName), + } + return fmt.Sprintf("Triggered Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_triggeredwebjob_test.go b/resource-manager/web/2024-11-01/webapps/id_triggeredwebjob_test.go new file mode 100644 index 00000000000..f3a39e32c7e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_triggeredwebjob_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &TriggeredWebJobId{} + +func TestNewTriggeredWebJobID(t *testing.T) { + id := NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.TriggeredWebJobName != "triggeredWebJobName" { + t.Fatalf("Expected %q but got %q for Segment 'TriggeredWebJobName'", id.TriggeredWebJobName, "triggeredWebJobName") + } +} + +func TestFormatTriggeredWebJobID(t *testing.T) { + actual := NewTriggeredWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "triggeredWebJobName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTriggeredWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggeredWebJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName", + Expected: &TriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + TriggeredWebJobName: "triggeredWebJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggeredWebJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + } +} + +func TestParseTriggeredWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggeredWebJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/tRiGgErEdWeBjObS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName", + Expected: &TriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + TriggeredWebJobName: "triggeredWebJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/triggeredWebJobs/triggeredWebJobName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe", + Expected: &TriggeredWebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + TriggeredWebJobName: "tRiGgErEdWeBjObNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggeredWebJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + } +} + +func TestSegmentsForTriggeredWebJobId(t *testing.T) { + segments := TriggeredWebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TriggeredWebJobId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_triggeredwebjobhistory.go b/resource-manager/web/2024-11-01/webapps/id_triggeredwebjobhistory.go new file mode 100644 index 00000000000..d43eee154da --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_triggeredwebjobhistory.go @@ -0,0 +1,157 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&TriggeredWebJobHistoryId{}) +} + +var _ resourceids.ResourceId = &TriggeredWebJobHistoryId{} + +// TriggeredWebJobHistoryId is a struct representing the Resource ID for a Triggered Web Job History +type TriggeredWebJobHistoryId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + TriggeredWebJobName string + HistoryName string +} + +// NewTriggeredWebJobHistoryID returns a new TriggeredWebJobHistoryId struct +func NewTriggeredWebJobHistoryID(subscriptionId string, resourceGroupName string, siteName string, slotName string, triggeredWebJobName string, historyName string) TriggeredWebJobHistoryId { + return TriggeredWebJobHistoryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + TriggeredWebJobName: triggeredWebJobName, + HistoryName: historyName, + } +} + +// ParseTriggeredWebJobHistoryID parses 'input' into a TriggeredWebJobHistoryId +func ParseTriggeredWebJobHistoryID(input string) (*TriggeredWebJobHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggeredWebJobHistoryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggeredWebJobHistoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTriggeredWebJobHistoryIDInsensitively parses 'input' case-insensitively into a TriggeredWebJobHistoryId +// note: this method should only be used for API response data and not user input +func ParseTriggeredWebJobHistoryIDInsensitively(input string) (*TriggeredWebJobHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggeredWebJobHistoryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggeredWebJobHistoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TriggeredWebJobHistoryId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.TriggeredWebJobName, ok = input.Parsed["triggeredWebJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggeredWebJobName", input) + } + + if id.HistoryName, ok = input.Parsed["historyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "historyName", input) + } + + return nil +} + +// ValidateTriggeredWebJobHistoryID checks that 'input' can be parsed as a Triggered Web Job History ID +func ValidateTriggeredWebJobHistoryID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseTriggeredWebJobHistoryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Triggered Web Job History ID +func (id TriggeredWebJobHistoryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/triggeredWebJobs/%s/history/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.TriggeredWebJobName, id.HistoryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Triggered Web Job History ID +func (id TriggeredWebJobHistoryId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticTriggeredWebJobs", "triggeredWebJobs", "triggeredWebJobs"), + resourceids.UserSpecifiedSegment("triggeredWebJobName", "triggeredWebJobName"), + resourceids.StaticSegment("staticHistory", "history", "history"), + resourceids.UserSpecifiedSegment("historyName", "historyName"), + } +} + +// String returns a human-readable description of this Triggered Web Job History ID +func (id TriggeredWebJobHistoryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Triggered Web Job Name: %q", id.TriggeredWebJobName), + fmt.Sprintf("History Name: %q", id.HistoryName), + } + return fmt.Sprintf("Triggered Web Job History (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_triggeredwebjobhistory_test.go b/resource-manager/web/2024-11-01/webapps/id_triggeredwebjobhistory_test.go new file mode 100644 index 00000000000..cf92a965a0a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_triggeredwebjobhistory_test.go @@ -0,0 +1,417 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &TriggeredWebJobHistoryId{} + +func TestNewTriggeredWebJobHistoryID(t *testing.T) { + id := NewTriggeredWebJobHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName", "historyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.TriggeredWebJobName != "triggeredWebJobName" { + t.Fatalf("Expected %q but got %q for Segment 'TriggeredWebJobName'", id.TriggeredWebJobName, "triggeredWebJobName") + } + + if id.HistoryName != "historyName" { + t.Fatalf("Expected %q but got %q for Segment 'HistoryName'", id.HistoryName, "historyName") + } +} + +func TestFormatTriggeredWebJobHistoryID(t *testing.T) { + actual := NewTriggeredWebJobHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "triggeredWebJobName", "historyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/history/historyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTriggeredWebJobHistoryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggeredWebJobHistoryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/history", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/history/historyName", + Expected: &TriggeredWebJobHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + TriggeredWebJobName: "triggeredWebJobName", + HistoryName: "historyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/history/historyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggeredWebJobHistoryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestParseTriggeredWebJobHistoryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggeredWebJobHistoryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/tRiGgErEdWeBjObS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/history", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe/hIsToRy", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/history/historyName", + Expected: &TriggeredWebJobHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + TriggeredWebJobName: "triggeredWebJobName", + HistoryName: "historyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/triggeredWebJobs/triggeredWebJobName/history/historyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe/hIsToRy/hIsToRyNaMe", + Expected: &TriggeredWebJobHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + TriggeredWebJobName: "tRiGgErEdWeBjObNaMe", + HistoryName: "hIsToRyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/tRiGgErEdWeBjObS/tRiGgErEdWeBjObNaMe/hIsToRy/hIsToRyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggeredWebJobHistoryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.TriggeredWebJobName != v.Expected.TriggeredWebJobName { + t.Fatalf("Expected %q but got %q for TriggeredWebJobName", v.Expected.TriggeredWebJobName, actual.TriggeredWebJobName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestSegmentsForTriggeredWebJobHistoryId(t *testing.T) { + segments := TriggeredWebJobHistoryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TriggeredWebJobHistoryId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_virtualnetworkconnection.go b/resource-manager/web/2024-11-01/webapps/id_virtualnetworkconnection.go new file mode 100644 index 00000000000..0ddc9e9dbc9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_virtualnetworkconnection.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VirtualNetworkConnectionId{}) +} + +var _ resourceids.ResourceId = &VirtualNetworkConnectionId{} + +// VirtualNetworkConnectionId is a struct representing the Resource ID for a Virtual Network Connection +type VirtualNetworkConnectionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + VirtualNetworkConnectionName string +} + +// NewVirtualNetworkConnectionID returns a new VirtualNetworkConnectionId struct +func NewVirtualNetworkConnectionID(subscriptionId string, resourceGroupName string, siteName string, virtualNetworkConnectionName string) VirtualNetworkConnectionId { + return VirtualNetworkConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + VirtualNetworkConnectionName: virtualNetworkConnectionName, + } +} + +// ParseVirtualNetworkConnectionID parses 'input' into a VirtualNetworkConnectionId +func ParseVirtualNetworkConnectionID(input string) (*VirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVirtualNetworkConnectionIDInsensitively parses 'input' case-insensitively into a VirtualNetworkConnectionId +// note: this method should only be used for API response data and not user input +func ParseVirtualNetworkConnectionIDInsensitively(input string) (*VirtualNetworkConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VirtualNetworkConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VirtualNetworkConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VirtualNetworkConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.VirtualNetworkConnectionName, ok = input.Parsed["virtualNetworkConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "virtualNetworkConnectionName", input) + } + + return nil +} + +// ValidateVirtualNetworkConnectionID checks that 'input' can be parsed as a Virtual Network Connection ID +func ValidateVirtualNetworkConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVirtualNetworkConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Virtual Network Connection ID +func (id VirtualNetworkConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/virtualNetworkConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.VirtualNetworkConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Virtual Network Connection ID +func (id VirtualNetworkConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticVirtualNetworkConnections", "virtualNetworkConnections", "virtualNetworkConnections"), + resourceids.UserSpecifiedSegment("virtualNetworkConnectionName", "virtualNetworkConnectionName"), + } +} + +// String returns a human-readable description of this Virtual Network Connection ID +func (id VirtualNetworkConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Virtual Network Connection Name: %q", id.VirtualNetworkConnectionName), + } + return fmt.Sprintf("Virtual Network Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_virtualnetworkconnection_test.go b/resource-manager/web/2024-11-01/webapps/id_virtualnetworkconnection_test.go new file mode 100644 index 00000000000..0696a175e00 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_virtualnetworkconnection_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VirtualNetworkConnectionId{} + +func TestNewVirtualNetworkConnectionID(t *testing.T) { + id := NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.VirtualNetworkConnectionName != "virtualNetworkConnectionName" { + t.Fatalf("Expected %q but got %q for Segment 'VirtualNetworkConnectionName'", id.VirtualNetworkConnectionName, "virtualNetworkConnectionName") + } +} + +func TestFormatVirtualNetworkConnectionID(t *testing.T) { + actual := NewVirtualNetworkConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "virtualNetworkConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVirtualNetworkConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName", + Expected: &VirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestParseVirtualNetworkConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VirtualNetworkConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName", + Expected: &VirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + VirtualNetworkConnectionName: "virtualNetworkConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/virtualNetworkConnections/virtualNetworkConnectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + Expected: &VirtualNetworkConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + VirtualNetworkConnectionName: "vIrTuAlNeTwOrKcOnNeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/vIrTuAlNeTwOrKcOnNeCtIoNs/vIrTuAlNeTwOrKcOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVirtualNetworkConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.VirtualNetworkConnectionName != v.Expected.VirtualNetworkConnectionName { + t.Fatalf("Expected %q but got %q for VirtualNetworkConnectionName", v.Expected.VirtualNetworkConnectionName, actual.VirtualNetworkConnectionName) + } + + } +} + +func TestSegmentsForVirtualNetworkConnectionId(t *testing.T) { + segments := VirtualNetworkConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VirtualNetworkConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_webjob.go b/resource-manager/web/2024-11-01/webapps/id_webjob.go new file mode 100644 index 00000000000..b79bed51622 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_webjob.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WebJobId{}) +} + +var _ resourceids.ResourceId = &WebJobId{} + +// WebJobId is a struct representing the Resource ID for a Web Job +type WebJobId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WebJobName string +} + +// NewWebJobID returns a new WebJobId struct +func NewWebJobID(subscriptionId string, resourceGroupName string, siteName string, webJobName string) WebJobId { + return WebJobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WebJobName: webJobName, + } +} + +// ParseWebJobID parses 'input' into a WebJobId +func ParseWebJobID(input string) (*WebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&WebJobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWebJobIDInsensitively parses 'input' case-insensitively into a WebJobId +// note: this method should only be used for API response data and not user input +func ParseWebJobIDInsensitively(input string) (*WebJobId, error) { + parser := resourceids.NewParserFromResourceIdType(&WebJobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WebJobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WebJobId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WebJobName, ok = input.Parsed["webJobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "webJobName", input) + } + + return nil +} + +// ValidateWebJobID checks that 'input' can be parsed as a Web Job ID +func ValidateWebJobID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWebJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Web Job ID +func (id WebJobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/webJobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WebJobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Web Job ID +func (id WebJobId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticWebJobs", "webJobs", "webJobs"), + resourceids.UserSpecifiedSegment("webJobName", "webJobName"), + } +} + +// String returns a human-readable description of this Web Job ID +func (id WebJobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Web Job Name: %q", id.WebJobName), + } + return fmt.Sprintf("Web Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_webjob_test.go b/resource-manager/web/2024-11-01/webapps/id_webjob_test.go new file mode 100644 index 00000000000..092af0c8a38 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_webjob_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WebJobId{} + +func TestNewWebJobID(t *testing.T) { + id := NewWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "webJobName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WebJobName != "webJobName" { + t.Fatalf("Expected %q but got %q for Segment 'WebJobName'", id.WebJobName, "webJobName") + } +} + +func TestFormatWebJobID(t *testing.T) { + actual := NewWebJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "webJobName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/webJobs/webJobName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWebJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WebJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/webJobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/webJobs/webJobName", + Expected: &WebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WebJobName: "webJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/webJobs/webJobName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWebJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WebJobName != v.Expected.WebJobName { + t.Fatalf("Expected %q but got %q for WebJobName", v.Expected.WebJobName, actual.WebJobName) + } + + } +} + +func TestParseWebJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WebJobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/webJobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/wEbJoBs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/webJobs/webJobName", + Expected: &WebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WebJobName: "webJobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/webJobs/webJobName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/wEbJoBs/wEbJoBnAmE", + Expected: &WebJobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WebJobName: "wEbJoBnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/wEbJoBs/wEbJoBnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWebJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WebJobName != v.Expected.WebJobName { + t.Fatalf("Expected %q but got %q for WebJobName", v.Expected.WebJobName, actual.WebJobName) + } + + } +} + +func TestSegmentsForWebJobId(t *testing.T) { + segments := WebJobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WebJobId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_websnapshot.go b/resource-manager/web/2024-11-01/webapps/id_websnapshot.go new file mode 100644 index 00000000000..f878f0869f5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_websnapshot.go @@ -0,0 +1,150 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WebSnapshotId{}) +} + +var _ resourceids.ResourceId = &WebSnapshotId{} + +// WebSnapshotId is a struct representing the Resource ID for a Web Snapshot +type WebSnapshotId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + SlotName string + SnapshotId string +} + +// NewWebSnapshotID returns a new WebSnapshotId struct +func NewWebSnapshotID(subscriptionId string, resourceGroupName string, siteName string, slotName string, snapshotId string) WebSnapshotId { + return WebSnapshotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + SlotName: slotName, + SnapshotId: snapshotId, + } +} + +// ParseWebSnapshotID parses 'input' into a WebSnapshotId +func ParseWebSnapshotID(input string) (*WebSnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&WebSnapshotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WebSnapshotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWebSnapshotIDInsensitively parses 'input' case-insensitively into a WebSnapshotId +// note: this method should only be used for API response data and not user input +func ParseWebSnapshotIDInsensitively(input string) (*WebSnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&WebSnapshotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WebSnapshotId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WebSnapshotId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.SlotName, ok = input.Parsed["slotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "slotName", input) + } + + if id.SnapshotId, ok = input.Parsed["snapshotId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "snapshotId", input) + } + + return nil +} + +// ValidateWebSnapshotID checks that 'input' can be parsed as a Web Snapshot ID +func ValidateWebSnapshotID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWebSnapshotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Web Snapshot ID +func (id WebSnapshotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/slots/%s/config/web/snapshots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.SlotName, id.SnapshotId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Web Snapshot ID +func (id WebSnapshotId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticSlots", "slots", "slots"), + resourceids.UserSpecifiedSegment("slotName", "slotName"), + resourceids.StaticSegment("staticConfig", "config", "config"), + resourceids.StaticSegment("staticWeb", "web", "web"), + resourceids.StaticSegment("staticSnapshots", "snapshots", "snapshots"), + resourceids.UserSpecifiedSegment("snapshotId", "snapshotId"), + } +} + +// String returns a human-readable description of this Web Snapshot ID +func (id WebSnapshotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Slot Name: %q", id.SlotName), + fmt.Sprintf("Snapshot: %q", id.SnapshotId), + } + return fmt.Sprintf("Web Snapshot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_websnapshot_test.go b/resource-manager/web/2024-11-01/webapps/id_websnapshot_test.go new file mode 100644 index 00000000000..b63a5759cb5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_websnapshot_test.go @@ -0,0 +1,402 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WebSnapshotId{} + +func TestNewWebSnapshotID(t *testing.T) { + id := NewWebSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "snapshotId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.SlotName != "slotName" { + t.Fatalf("Expected %q but got %q for Segment 'SlotName'", id.SlotName, "slotName") + } + + if id.SnapshotId != "snapshotId" { + t.Fatalf("Expected %q but got %q for Segment 'SnapshotId'", id.SnapshotId, "snapshotId") + } +} + +func TestFormatWebSnapshotID(t *testing.T) { + actual := NewWebSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "slotName", "snapshotId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web/snapshots/snapshotId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWebSnapshotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WebSnapshotId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web/snapshots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web/snapshots/snapshotId", + Expected: &WebSnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + SnapshotId: "snapshotId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web/snapshots/snapshotId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWebSnapshotID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SnapshotId != v.Expected.SnapshotId { + t.Fatalf("Expected %q but got %q for SnapshotId", v.Expected.SnapshotId, actual.SnapshotId) + } + + } +} + +func TestParseWebSnapshotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WebSnapshotId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web/snapshots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/wEb/sNaPsHoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web/snapshots/snapshotId", + Expected: &WebSnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + SlotName: "slotName", + SnapshotId: "snapshotId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/slots/slotName/config/web/snapshots/snapshotId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/wEb/sNaPsHoTs/sNaPsHoTiD", + Expected: &WebSnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + SlotName: "sLoTnAmE", + SnapshotId: "sNaPsHoTiD", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/sLoTs/sLoTnAmE/cOnFiG/wEb/sNaPsHoTs/sNaPsHoTiD/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWebSnapshotIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.SlotName != v.Expected.SlotName { + t.Fatalf("Expected %q but got %q for SlotName", v.Expected.SlotName, actual.SlotName) + } + + if actual.SnapshotId != v.Expected.SnapshotId { + t.Fatalf("Expected %q but got %q for SnapshotId", v.Expected.SnapshotId, actual.SnapshotId) + } + + } +} + +func TestSegmentsForWebSnapshotId(t *testing.T) { + segments := WebSnapshotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WebSnapshotId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/id_workflow.go b/resource-manager/web/2024-11-01/webapps/id_workflow.go new file mode 100644 index 00000000000..b0bd85b2a72 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_workflow.go @@ -0,0 +1,139 @@ +package webapps + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkflowId{}) +} + +var _ resourceids.ResourceId = &WorkflowId{} + +// WorkflowId is a struct representing the Resource ID for a Workflow +type WorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string +} + +// NewWorkflowID returns a new WorkflowId struct +func NewWorkflowID(subscriptionId string, resourceGroupName string, siteName string, workflowName string) WorkflowId { + return WorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + } +} + +// ParseWorkflowID parses 'input' into a WorkflowId +func ParseWorkflowID(input string) (*WorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkflowIDInsensitively parses 'input' case-insensitively into a WorkflowId +// note: this method should only be used for API response data and not user input +func ParseWorkflowIDInsensitively(input string) (*WorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkflowId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateWorkflowID checks that 'input' can be parsed as a Workflow ID +func ValidateWorkflowID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workflow ID +func (id WorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workflow ID +func (id WorkflowId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + } +} + +// String returns a human-readable description of this Workflow ID +func (id WorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/webapps/id_workflow_test.go b/resource-manager/web/2024-11-01/webapps/id_workflow_test.go new file mode 100644 index 00000000000..c687bb8ce0f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/id_workflow_test.go @@ -0,0 +1,327 @@ +package webapps + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkflowId{} + +func TestNewWorkflowID(t *testing.T) { + id := NewWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } +} + +func TestFormatWorkflowID(t *testing.T) { + actual := NewWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/workflows/workflowName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkflowId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/workflows/workflowName", + Expected: &WorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/workflows/workflowName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkflowID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkflowId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/workflows/workflowName", + Expected: &WorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/workflows/workflowName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/wOrKfLoWs/wOrKfLoWnAmE", + Expected: &WorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/wOrKfLoWs/wOrKfLoWnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkflowIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForWorkflowId(t *testing.T) { + segments := WorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkflowId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/webapps/method_addpremieraddon.go b/resource-manager/web/2024-11-01/webapps/method_addpremieraddon.go new file mode 100644 index 00000000000..cfb57af1bf6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_addpremieraddon.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddPremierAddOnOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// AddPremierAddOn ... +func (c WebAppsClient) AddPremierAddOn(ctx context.Context, id PremierAddonId, input PremierAddOn) (result AddPremierAddOnOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PremierAddOn + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_addpremieraddonslot.go b/resource-manager/web/2024-11-01/webapps/method_addpremieraddonslot.go new file mode 100644 index 00000000000..aeafde304bb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_addpremieraddonslot.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddPremierAddOnSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// AddPremierAddOnSlot ... +func (c WebAppsClient) AddPremierAddOnSlot(ctx context.Context, id SlotPremierAddonId, input PremierAddOn) (result AddPremierAddOnSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PremierAddOn + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_analyzecustomhostname.go b/resource-manager/web/2024-11-01/webapps/method_analyzecustomhostname.go new file mode 100644 index 00000000000..11970d2903f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_analyzecustomhostname.go @@ -0,0 +1,84 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalyzeCustomHostnameOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomHostnameAnalysisResult +} + +type AnalyzeCustomHostnameOperationOptions struct { + HostName *string +} + +func DefaultAnalyzeCustomHostnameOperationOptions() AnalyzeCustomHostnameOperationOptions { + return AnalyzeCustomHostnameOperationOptions{} +} + +func (o AnalyzeCustomHostnameOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o AnalyzeCustomHostnameOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o AnalyzeCustomHostnameOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.HostName != nil { + out.Append("hostName", fmt.Sprintf("%v", *o.HostName)) + } + return &out +} + +// AnalyzeCustomHostname ... +func (c WebAppsClient) AnalyzeCustomHostname(ctx context.Context, id commonids.AppServiceId, options AnalyzeCustomHostnameOperationOptions) (result AnalyzeCustomHostnameOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/analyzeCustomHostname", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CustomHostnameAnalysisResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_analyzecustomhostnameslot.go b/resource-manager/web/2024-11-01/webapps/method_analyzecustomhostnameslot.go new file mode 100644 index 00000000000..b2430c9f9ba --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_analyzecustomhostnameslot.go @@ -0,0 +1,83 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AnalyzeCustomHostnameSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CustomHostnameAnalysisResult +} + +type AnalyzeCustomHostnameSlotOperationOptions struct { + HostName *string +} + +func DefaultAnalyzeCustomHostnameSlotOperationOptions() AnalyzeCustomHostnameSlotOperationOptions { + return AnalyzeCustomHostnameSlotOperationOptions{} +} + +func (o AnalyzeCustomHostnameSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o AnalyzeCustomHostnameSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o AnalyzeCustomHostnameSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.HostName != nil { + out.Append("hostName", fmt.Sprintf("%v", *o.HostName)) + } + return &out +} + +// AnalyzeCustomHostnameSlot ... +func (c WebAppsClient) AnalyzeCustomHostnameSlot(ctx context.Context, id SlotId, options AnalyzeCustomHostnameSlotOperationOptions) (result AnalyzeCustomHostnameSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Path: fmt.Sprintf("%s/analyzeCustomHostname", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CustomHostnameAnalysisResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_applyslotconfigtoproduction.go b/resource-manager/web/2024-11-01/webapps/method_applyslotconfigtoproduction.go new file mode 100644 index 00000000000..8a4030be7ce --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_applyslotconfigtoproduction.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplySlotConfigToProductionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ApplySlotConfigToProduction ... +func (c WebAppsClient) ApplySlotConfigToProduction(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity) (result ApplySlotConfigToProductionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/applySlotConfig", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_applyslotconfigurationslot.go b/resource-manager/web/2024-11-01/webapps/method_applyslotconfigurationslot.go new file mode 100644 index 00000000000..a17a32e4ddb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_applyslotconfigurationslot.go @@ -0,0 +1,51 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplySlotConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ApplySlotConfigurationSlot ... +func (c WebAppsClient) ApplySlotConfigurationSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (result ApplySlotConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/applySlotConfig", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_approveorrejectprivateendpointconnection.go b/resource-manager/web/2024-11-01/webapps/method_approveorrejectprivateendpointconnection.go new file mode 100644 index 00000000000..11c42e04fc1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_approveorrejectprivateendpointconnection.go @@ -0,0 +1,75 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApproveOrRejectPrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// ApproveOrRejectPrivateEndpointConnection ... +func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) (result ApproveOrRejectPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ApproveOrRejectPrivateEndpointConnectionThenPoll performs ApproveOrRejectPrivateEndpointConnection then polls until it's completed +func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) error { + result, err := c.ApproveOrRejectPrivateEndpointConnection(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_approveorrejectprivateendpointconnectionslot.go b/resource-manager/web/2024-11-01/webapps/method_approveorrejectprivateendpointconnectionslot.go new file mode 100644 index 00000000000..92ad203c214 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_approveorrejectprivateendpointconnectionslot.go @@ -0,0 +1,75 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApproveOrRejectPrivateEndpointConnectionSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// ApproveOrRejectPrivateEndpointConnectionSlot ... +func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) (result ApproveOrRejectPrivateEndpointConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ApproveOrRejectPrivateEndpointConnectionSlotThenPoll performs ApproveOrRejectPrivateEndpointConnectionSlot then polls until it's completed +func (c WebAppsClient) ApproveOrRejectPrivateEndpointConnectionSlotThenPoll(ctx context.Context, id SlotPrivateEndpointConnectionId, input RemotePrivateEndpointConnectionARMResource) error { + result, err := c.ApproveOrRejectPrivateEndpointConnectionSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ApproveOrRejectPrivateEndpointConnectionSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ApproveOrRejectPrivateEndpointConnectionSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_backup.go b/resource-manager/web/2024-11-01/webapps/method_backup.go new file mode 100644 index 00000000000..c1c49689e19 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_backup.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// Backup ... +func (c WebAppsClient) Backup(ctx context.Context, id commonids.AppServiceId, input BackupRequest) (result BackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/backup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_backupslot.go b/resource-manager/web/2024-11-01/webapps/method_backupslot.go new file mode 100644 index 00000000000..bb5f136eda5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_backupslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// BackupSlot ... +func (c WebAppsClient) BackupSlot(ctx context.Context, id SlotId, input BackupRequest) (result BackupSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/backup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createdeployment.go b/resource-manager/web/2024-11-01/webapps/method_createdeployment.go new file mode 100644 index 00000000000..942b704fb67 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createdeployment.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateDeploymentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// CreateDeployment ... +func (c WebAppsClient) CreateDeployment(ctx context.Context, id DeploymentId, input Deployment) (result CreateDeploymentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Deployment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createdeploymentslot.go b/resource-manager/web/2024-11-01/webapps/method_createdeploymentslot.go new file mode 100644 index 00000000000..69c846f798e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createdeploymentslot.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateDeploymentSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// CreateDeploymentSlot ... +func (c WebAppsClient) CreateDeploymentSlot(ctx context.Context, id SlotDeploymentId, input Deployment) (result CreateDeploymentSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Deployment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createfunction.go b/resource-manager/web/2024-11-01/webapps/method_createfunction.go new file mode 100644 index 00000000000..43f93d7412e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createfunction.go @@ -0,0 +1,74 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateFunctionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *FunctionEnvelope +} + +// CreateFunction ... +func (c WebAppsClient) CreateFunction(ctx context.Context, id FunctionId, input FunctionEnvelope) (result CreateFunctionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateFunctionThenPoll performs CreateFunction then polls until it's completed +func (c WebAppsClient) CreateFunctionThenPoll(ctx context.Context, id FunctionId, input FunctionEnvelope) error { + result, err := c.CreateFunction(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateFunction: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateFunction: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createinstancefunctionslot.go b/resource-manager/web/2024-11-01/webapps/method_createinstancefunctionslot.go new file mode 100644 index 00000000000..7a4fc6b316e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createinstancefunctionslot.go @@ -0,0 +1,74 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateInstanceFunctionSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *FunctionEnvelope +} + +// CreateInstanceFunctionSlot ... +func (c WebAppsClient) CreateInstanceFunctionSlot(ctx context.Context, id SlotFunctionId, input FunctionEnvelope) (result CreateInstanceFunctionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateInstanceFunctionSlotThenPoll performs CreateInstanceFunctionSlot then polls until it's completed +func (c WebAppsClient) CreateInstanceFunctionSlotThenPoll(ctx context.Context, id SlotFunctionId, input FunctionEnvelope) error { + result, err := c.CreateInstanceFunctionSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateInstanceFunctionSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateInstanceFunctionSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createinstancemsdeployoperation.go b/resource-manager/web/2024-11-01/webapps/method_createinstancemsdeployoperation.go new file mode 100644 index 00000000000..f2335f4f87d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createinstancemsdeployoperation.go @@ -0,0 +1,74 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateInstanceMSDeployOperationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// CreateInstanceMSDeployOperation ... +func (c WebAppsClient) CreateInstanceMSDeployOperation(ctx context.Context, id InstanceId, input MSDeploy) (result CreateInstanceMSDeployOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/mSDeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateInstanceMSDeployOperationThenPoll performs CreateInstanceMSDeployOperation then polls until it's completed +func (c WebAppsClient) CreateInstanceMSDeployOperationThenPoll(ctx context.Context, id InstanceId, input MSDeploy) error { + result, err := c.CreateInstanceMSDeployOperation(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateInstanceMSDeployOperation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateInstanceMSDeployOperation: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createinstancemsdeployoperationslot.go b/resource-manager/web/2024-11-01/webapps/method_createinstancemsdeployoperationslot.go new file mode 100644 index 00000000000..3688efbb8d8 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createinstancemsdeployoperationslot.go @@ -0,0 +1,74 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateInstanceMSDeployOperationSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// CreateInstanceMSDeployOperationSlot ... +func (c WebAppsClient) CreateInstanceMSDeployOperationSlot(ctx context.Context, id SlotInstanceId, input MSDeploy) (result CreateInstanceMSDeployOperationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/mSDeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateInstanceMSDeployOperationSlotThenPoll performs CreateInstanceMSDeployOperationSlot then polls until it's completed +func (c WebAppsClient) CreateInstanceMSDeployOperationSlotThenPoll(ctx context.Context, id SlotInstanceId, input MSDeploy) error { + result, err := c.CreateInstanceMSDeployOperationSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateInstanceMSDeployOperationSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateInstanceMSDeployOperationSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createmsdeployoperation.go b/resource-manager/web/2024-11-01/webapps/method_createmsdeployoperation.go new file mode 100644 index 00000000000..d6d6f41436d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createmsdeployoperation.go @@ -0,0 +1,75 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateMSDeployOperationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// CreateMSDeployOperation ... +func (c WebAppsClient) CreateMSDeployOperation(ctx context.Context, id commonids.AppServiceId, input MSDeploy) (result CreateMSDeployOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/mSDeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateMSDeployOperationThenPoll performs CreateMSDeployOperation then polls until it's completed +func (c WebAppsClient) CreateMSDeployOperationThenPoll(ctx context.Context, id commonids.AppServiceId, input MSDeploy) error { + result, err := c.CreateMSDeployOperation(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateMSDeployOperation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateMSDeployOperation: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createmsdeployoperationslot.go b/resource-manager/web/2024-11-01/webapps/method_createmsdeployoperationslot.go new file mode 100644 index 00000000000..429022fa814 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createmsdeployoperationslot.go @@ -0,0 +1,74 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateMSDeployOperationSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// CreateMSDeployOperationSlot ... +func (c WebAppsClient) CreateMSDeployOperationSlot(ctx context.Context, id SlotId, input MSDeploy) (result CreateMSDeployOperationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/mSDeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateMSDeployOperationSlotThenPoll performs CreateMSDeployOperationSlot then polls until it's completed +func (c WebAppsClient) CreateMSDeployOperationSlotThenPoll(ctx context.Context, id SlotId, input MSDeploy) error { + result, err := c.CreateMSDeployOperationSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateMSDeployOperationSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateMSDeployOperationSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createonedeployoperation.go b/resource-manager/web/2024-11-01/webapps/method_createonedeployoperation.go new file mode 100644 index 00000000000..d313d5b7340 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createonedeployoperation.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOneDeployOperationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// CreateOneDeployOperation ... +func (c WebAppsClient) CreateOneDeployOperation(ctx context.Context, id commonids.AppServiceId) (result CreateOneDeployOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/extensions/onedeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model interface{} + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdate.go b/resource-manager/web/2024-11-01/webapps/method_createorupdate.go new file mode 100644 index 00000000000..31581cafbd5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdate.go @@ -0,0 +1,76 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// CreateOrUpdate ... +func (c WebAppsClient) CreateOrUpdate(ctx context.Context, id commonids.AppServiceId, input Site) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c WebAppsClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.AppServiceId, input Site) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdateconfiguration.go b/resource-manager/web/2024-11-01/webapps/method_createorupdateconfiguration.go new file mode 100644 index 00000000000..85500fcf708 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdateconfiguration.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// CreateOrUpdateConfiguration ... +func (c WebAppsClient) CreateOrUpdateConfiguration(ctx context.Context, id commonids.AppServiceId, input SiteConfigResource) (result CreateOrUpdateConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteConfigResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdateconfigurationslot.go b/resource-manager/web/2024-11-01/webapps/method_createorupdateconfigurationslot.go new file mode 100644 index 00000000000..b41a356aa13 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdateconfigurationslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// CreateOrUpdateConfigurationSlot ... +func (c WebAppsClient) CreateOrUpdateConfigurationSlot(ctx context.Context, id SlotId, input SiteConfigResource) (result CreateOrUpdateConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteConfigResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatedomainownershipidentifier.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatedomainownershipidentifier.go new file mode 100644 index 00000000000..cf70725a9a9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatedomainownershipidentifier.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// CreateOrUpdateDomainOwnershipIdentifier ... +func (c WebAppsClient) CreateOrUpdateDomainOwnershipIdentifier(ctx context.Context, id SiteDomainOwnershipIdentifierId, input Identifier) (result CreateOrUpdateDomainOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Identifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatedomainownershipidentifierslot.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatedomainownershipidentifierslot.go new file mode 100644 index 00000000000..001554898ac --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatedomainownershipidentifierslot.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateDomainOwnershipIdentifierSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// CreateOrUpdateDomainOwnershipIdentifierSlot ... +func (c WebAppsClient) CreateOrUpdateDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId, input Identifier) (result CreateOrUpdateDomainOwnershipIdentifierSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Identifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatefunctionsecret.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatefunctionsecret.go new file mode 100644 index 00000000000..92497573560 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatefunctionsecret.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateFunctionSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KeyInfo +} + +// CreateOrUpdateFunctionSecret ... +func (c WebAppsClient) CreateOrUpdateFunctionSecret(ctx context.Context, id KeyId, input KeyInfo) (result CreateOrUpdateFunctionSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model KeyInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatefunctionsecretslot.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatefunctionsecretslot.go new file mode 100644 index 00000000000..0540fca8947 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatefunctionsecretslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateFunctionSecretSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KeyInfo +} + +// CreateOrUpdateFunctionSecretSlot ... +func (c WebAppsClient) CreateOrUpdateFunctionSecretSlot(ctx context.Context, id FunctionKeyId, input KeyInfo) (result CreateOrUpdateFunctionSecretSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model KeyInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatehostnamebinding.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatehostnamebinding.go new file mode 100644 index 00000000000..3a47a4207d0 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatehostnamebinding.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateHostNameBindingOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostNameBinding +} + +// CreateOrUpdateHostNameBinding ... +func (c WebAppsClient) CreateOrUpdateHostNameBinding(ctx context.Context, id HostNameBindingId, input HostNameBinding) (result CreateOrUpdateHostNameBindingOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HostNameBinding + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatehostnamebindingslot.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatehostnamebindingslot.go new file mode 100644 index 00000000000..f0746cde4e6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatehostnamebindingslot.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateHostNameBindingSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostNameBinding +} + +// CreateOrUpdateHostNameBindingSlot ... +func (c WebAppsClient) CreateOrUpdateHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId, input HostNameBinding) (result CreateOrUpdateHostNameBindingSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HostNameBinding + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatehostsecret.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatehostsecret.go new file mode 100644 index 00000000000..1b3b65509c9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatehostsecret.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateHostSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KeyInfo +} + +// CreateOrUpdateHostSecret ... +func (c WebAppsClient) CreateOrUpdateHostSecret(ctx context.Context, id DefaultId, input KeyInfo) (result CreateOrUpdateHostSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model KeyInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatehostsecretslot.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatehostsecretslot.go new file mode 100644 index 00000000000..f9bbc6bef55 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatehostsecretslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateHostSecretSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KeyInfo +} + +// CreateOrUpdateHostSecretSlot ... +func (c WebAppsClient) CreateOrUpdateHostSecretSlot(ctx context.Context, id HostDefaultId, input KeyInfo) (result CreateOrUpdateHostSecretSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model KeyInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatehybridconnection.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatehybridconnection.go new file mode 100644 index 00000000000..5c7b767edf5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatehybridconnection.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// CreateOrUpdateHybridConnection ... +func (c WebAppsClient) CreateOrUpdateHybridConnection(ctx context.Context, id RelayId, input HybridConnection) (result CreateOrUpdateHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatehybridconnectionslot.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatehybridconnectionslot.go new file mode 100644 index 00000000000..480ee3d1593 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatehybridconnectionslot.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateHybridConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// CreateOrUpdateHybridConnectionSlot ... +func (c WebAppsClient) CreateOrUpdateHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId, input HybridConnection) (result CreateOrUpdateHybridConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatepubliccertificate.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatepubliccertificate.go new file mode 100644 index 00000000000..b9aaaedb0d2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatepubliccertificate.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdatePublicCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicCertificate +} + +// CreateOrUpdatePublicCertificate ... +func (c WebAppsClient) CreateOrUpdatePublicCertificate(ctx context.Context, id PublicCertificateId, input PublicCertificate) (result CreateOrUpdatePublicCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PublicCertificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatepubliccertificateslot.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatepubliccertificateslot.go new file mode 100644 index 00000000000..b53ffdea524 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatepubliccertificateslot.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdatePublicCertificateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicCertificate +} + +// CreateOrUpdatePublicCertificateSlot ... +func (c WebAppsClient) CreateOrUpdatePublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId, input PublicCertificate) (result CreateOrUpdatePublicCertificateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PublicCertificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdaterelayserviceconnection.go b/resource-manager/web/2024-11-01/webapps/method_createorupdaterelayserviceconnection.go new file mode 100644 index 00000000000..8cd02d31bd7 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdaterelayserviceconnection.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateRelayServiceConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// CreateOrUpdateRelayServiceConnection ... +func (c WebAppsClient) CreateOrUpdateRelayServiceConnection(ctx context.Context, id HybridConnectionId, input RelayServiceConnectionEntity) (result CreateOrUpdateRelayServiceConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RelayServiceConnectionEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdaterelayserviceconnectionslot.go b/resource-manager/web/2024-11-01/webapps/method_createorupdaterelayserviceconnectionslot.go new file mode 100644 index 00000000000..ade59122646 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdaterelayserviceconnectionslot.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateRelayServiceConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// CreateOrUpdateRelayServiceConnectionSlot ... +func (c WebAppsClient) CreateOrUpdateRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId, input RelayServiceConnectionEntity) (result CreateOrUpdateRelayServiceConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RelayServiceConnectionEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatesitecontainer.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatesitecontainer.go new file mode 100644 index 00000000000..dfcf5fb0bf7 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatesitecontainer.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateSiteContainerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteContainer +} + +// CreateOrUpdateSiteContainer ... +func (c WebAppsClient) CreateOrUpdateSiteContainer(ctx context.Context, id SitecontainerId, input SiteContainer) (result CreateOrUpdateSiteContainerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteContainer + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatesitecontainerslot.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatesitecontainerslot.go new file mode 100644 index 00000000000..d122bbc52da --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatesitecontainerslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateSiteContainerSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteContainer +} + +// CreateOrUpdateSiteContainerSlot ... +func (c WebAppsClient) CreateOrUpdateSiteContainerSlot(ctx context.Context, id SlotSitecontainerId, input SiteContainer) (result CreateOrUpdateSiteContainerSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteContainer + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdateslot.go b/resource-manager/web/2024-11-01/webapps/method_createorupdateslot.go new file mode 100644 index 00000000000..3ab93dcea61 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdateslot.go @@ -0,0 +1,75 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// CreateOrUpdateSlot ... +func (c WebAppsClient) CreateOrUpdateSlot(ctx context.Context, id SlotId, input Site) (result CreateOrUpdateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateSlotThenPoll performs CreateOrUpdateSlot then polls until it's completed +func (c WebAppsClient) CreateOrUpdateSlotThenPoll(ctx context.Context, id SlotId, input Site) error { + result, err := c.CreateOrUpdateSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatesourcecontrol.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatesourcecontrol.go new file mode 100644 index 00000000000..6c883f15851 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatesourcecontrol.go @@ -0,0 +1,77 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateSourceControlOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// CreateOrUpdateSourceControl ... +func (c WebAppsClient) CreateOrUpdateSourceControl(ctx context.Context, id commonids.AppServiceId, input SiteSourceControl) (result CreateOrUpdateSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/sourceControls/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateSourceControlThenPoll performs CreateOrUpdateSourceControl then polls until it's completed +func (c WebAppsClient) CreateOrUpdateSourceControlThenPoll(ctx context.Context, id commonids.AppServiceId, input SiteSourceControl) error { + result, err := c.CreateOrUpdateSourceControl(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateSourceControl: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateSourceControl: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatesourcecontrolslot.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatesourcecontrolslot.go new file mode 100644 index 00000000000..aa82d5d4811 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatesourcecontrolslot.go @@ -0,0 +1,76 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateSourceControlSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// CreateOrUpdateSourceControlSlot ... +func (c WebAppsClient) CreateOrUpdateSourceControlSlot(ctx context.Context, id SlotId, input SiteSourceControl) (result CreateOrUpdateSourceControlSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/sourceControls/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateSourceControlSlotThenPoll performs CreateOrUpdateSourceControlSlot then polls until it's completed +func (c WebAppsClient) CreateOrUpdateSourceControlSlotThenPoll(ctx context.Context, id SlotId, input SiteSourceControl) error { + result, err := c.CreateOrUpdateSourceControlSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdateSourceControlSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdateSourceControlSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheck.go b/resource-manager/web/2024-11-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheck.go new file mode 100644 index 00000000000..fcc6949b431 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheck.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck ... +func (c WebAppsClient) CreateOrUpdateSwiftVirtualNetworkConnectionWithCheck(ctx context.Context, id commonids.AppServiceId, input SwiftVirtualNetwork) (result CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SwiftVirtualNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheckslot.go b/resource-manager/web/2024-11-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheckslot.go new file mode 100644 index 00000000000..d5f3050db94 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdateswiftvirtualnetworkconnectionwithcheckslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot ... +func (c WebAppsClient) CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx context.Context, id SlotId, input SwiftVirtualNetwork) (result CreateOrUpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SwiftVirtualNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatevnetconnection.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatevnetconnection.go new file mode 100644 index 00000000000..2b041462b62 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatevnetconnection.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateVnetConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// CreateOrUpdateVnetConnection ... +func (c WebAppsClient) CreateOrUpdateVnetConnection(ctx context.Context, id VirtualNetworkConnectionId, input VnetInfoResource) (result CreateOrUpdateVnetConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatevnetconnectiongateway.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatevnetconnectiongateway.go new file mode 100644 index 00000000000..0f1c95c3f39 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatevnetconnectiongateway.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateVnetConnectionGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// CreateOrUpdateVnetConnectionGateway ... +func (c WebAppsClient) CreateOrUpdateVnetConnectionGateway(ctx context.Context, id GatewayId, input VnetGateway) (result CreateOrUpdateVnetConnectionGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatevnetconnectiongatewayslot.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatevnetconnectiongatewayslot.go new file mode 100644 index 00000000000..d09166ca8e2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatevnetconnectiongatewayslot.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateVnetConnectionGatewaySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// CreateOrUpdateVnetConnectionGatewaySlot ... +func (c WebAppsClient) CreateOrUpdateVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId, input VnetGateway) (result CreateOrUpdateVnetConnectionGatewaySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_createorupdatevnetconnectionslot.go b/resource-manager/web/2024-11-01/webapps/method_createorupdatevnetconnectionslot.go new file mode 100644 index 00000000000..ca68e315257 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_createorupdatevnetconnectionslot.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateVnetConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// CreateOrUpdateVnetConnectionSlot ... +func (c WebAppsClient) CreateOrUpdateVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId, input VnetInfoResource) (result CreateOrUpdateVnetConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_delete.go b/resource-manager/web/2024-11-01/webapps/method_delete.go new file mode 100644 index 00000000000..9849348f6db --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_delete.go @@ -0,0 +1,82 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + DeleteEmptyServerFarm *bool + DeleteMetrics *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DeleteEmptyServerFarm != nil { + out.Append("deleteEmptyServerFarm", fmt.Sprintf("%v", *o.DeleteEmptyServerFarm)) + } + if o.DeleteMetrics != nil { + out.Append("deleteMetrics", fmt.Sprintf("%v", *o.DeleteMetrics)) + } + return &out +} + +// Delete ... +func (c WebAppsClient) Delete(ctx context.Context, id commonids.AppServiceId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletebackup.go b/resource-manager/web/2024-11-01/webapps/method_deletebackup.go new file mode 100644 index 00000000000..b2335e64953 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletebackup.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteBackupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBackup ... +func (c WebAppsClient) DeleteBackup(ctx context.Context, id BackupId) (result DeleteBackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletebackupconfiguration.go b/resource-manager/web/2024-11-01/webapps/method_deletebackupconfiguration.go new file mode 100644 index 00000000000..fe9d53c8236 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletebackupconfiguration.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteBackupConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBackupConfiguration ... +func (c WebAppsClient) DeleteBackupConfiguration(ctx context.Context, id commonids.AppServiceId) (result DeleteBackupConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/config/backup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletebackupconfigurationslot.go b/resource-manager/web/2024-11-01/webapps/method_deletebackupconfigurationslot.go new file mode 100644 index 00000000000..e417eec9042 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletebackupconfigurationslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteBackupConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBackupConfigurationSlot ... +func (c WebAppsClient) DeleteBackupConfigurationSlot(ctx context.Context, id SlotId) (result DeleteBackupConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/config/backup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletebackupslot.go b/resource-manager/web/2024-11-01/webapps/method_deletebackupslot.go new file mode 100644 index 00000000000..42f5d96f9bb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletebackupslot.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteBackupSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteBackupSlot ... +func (c WebAppsClient) DeleteBackupSlot(ctx context.Context, id SlotBackupId) (result DeleteBackupSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletecontinuouswebjob.go b/resource-manager/web/2024-11-01/webapps/method_deletecontinuouswebjob.go new file mode 100644 index 00000000000..291bdb8bdb2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletecontinuouswebjob.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteContinuousWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteContinuousWebJob ... +func (c WebAppsClient) DeleteContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result DeleteContinuousWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletecontinuouswebjobslot.go b/resource-manager/web/2024-11-01/webapps/method_deletecontinuouswebjobslot.go new file mode 100644 index 00000000000..08d6fbcf7ce --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletecontinuouswebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteContinuousWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteContinuousWebJobSlot ... +func (c WebAppsClient) DeleteContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result DeleteContinuousWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletedeployment.go b/resource-manager/web/2024-11-01/webapps/method_deletedeployment.go new file mode 100644 index 00000000000..602496fecbe --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletedeployment.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteDeploymentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDeployment ... +func (c WebAppsClient) DeleteDeployment(ctx context.Context, id DeploymentId) (result DeleteDeploymentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletedeploymentslot.go b/resource-manager/web/2024-11-01/webapps/method_deletedeploymentslot.go new file mode 100644 index 00000000000..dcc3d21bbd1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletedeploymentslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteDeploymentSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDeploymentSlot ... +func (c WebAppsClient) DeleteDeploymentSlot(ctx context.Context, id SlotDeploymentId) (result DeleteDeploymentSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletedomainownershipidentifier.go b/resource-manager/web/2024-11-01/webapps/method_deletedomainownershipidentifier.go new file mode 100644 index 00000000000..06a3c4983b6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletedomainownershipidentifier.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDomainOwnershipIdentifier ... +func (c WebAppsClient) DeleteDomainOwnershipIdentifier(ctx context.Context, id SiteDomainOwnershipIdentifierId) (result DeleteDomainOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletedomainownershipidentifierslot.go b/resource-manager/web/2024-11-01/webapps/method_deletedomainownershipidentifierslot.go new file mode 100644 index 00000000000..28567f8ab9e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletedomainownershipidentifierslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteDomainOwnershipIdentifierSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteDomainOwnershipIdentifierSlot ... +func (c WebAppsClient) DeleteDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId) (result DeleteDomainOwnershipIdentifierSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletefunction.go b/resource-manager/web/2024-11-01/webapps/method_deletefunction.go new file mode 100644 index 00000000000..63c737693dd --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletefunction.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteFunctionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteFunction ... +func (c WebAppsClient) DeleteFunction(ctx context.Context, id FunctionId) (result DeleteFunctionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletefunctionsecret.go b/resource-manager/web/2024-11-01/webapps/method_deletefunctionsecret.go new file mode 100644 index 00000000000..279dac44b09 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletefunctionsecret.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteFunctionSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteFunctionSecret ... +func (c WebAppsClient) DeleteFunctionSecret(ctx context.Context, id KeyId) (result DeleteFunctionSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletefunctionsecretslot.go b/resource-manager/web/2024-11-01/webapps/method_deletefunctionsecretslot.go new file mode 100644 index 00000000000..048a7322039 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletefunctionsecretslot.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteFunctionSecretSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteFunctionSecretSlot ... +func (c WebAppsClient) DeleteFunctionSecretSlot(ctx context.Context, id FunctionKeyId) (result DeleteFunctionSecretSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletehostnamebinding.go b/resource-manager/web/2024-11-01/webapps/method_deletehostnamebinding.go new file mode 100644 index 00000000000..f41070632fb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletehostnamebinding.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteHostNameBindingOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHostNameBinding ... +func (c WebAppsClient) DeleteHostNameBinding(ctx context.Context, id HostNameBindingId) (result DeleteHostNameBindingOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletehostnamebindingslot.go b/resource-manager/web/2024-11-01/webapps/method_deletehostnamebindingslot.go new file mode 100644 index 00000000000..f780f65c797 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletehostnamebindingslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteHostNameBindingSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHostNameBindingSlot ... +func (c WebAppsClient) DeleteHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId) (result DeleteHostNameBindingSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletehostsecret.go b/resource-manager/web/2024-11-01/webapps/method_deletehostsecret.go new file mode 100644 index 00000000000..f7140877326 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletehostsecret.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteHostSecretOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHostSecret ... +func (c WebAppsClient) DeleteHostSecret(ctx context.Context, id DefaultId) (result DeleteHostSecretOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletehostsecretslot.go b/resource-manager/web/2024-11-01/webapps/method_deletehostsecretslot.go new file mode 100644 index 00000000000..7b2feaf96f1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletehostsecretslot.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteHostSecretSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHostSecretSlot ... +func (c WebAppsClient) DeleteHostSecretSlot(ctx context.Context, id HostDefaultId) (result DeleteHostSecretSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletehybridconnection.go b/resource-manager/web/2024-11-01/webapps/method_deletehybridconnection.go new file mode 100644 index 00000000000..4c59c6746f2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletehybridconnection.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHybridConnection ... +func (c WebAppsClient) DeleteHybridConnection(ctx context.Context, id RelayId) (result DeleteHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletehybridconnectionslot.go b/resource-manager/web/2024-11-01/webapps/method_deletehybridconnectionslot.go new file mode 100644 index 00000000000..e5cd0c8f8ef --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletehybridconnectionslot.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteHybridConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteHybridConnectionSlot ... +func (c WebAppsClient) DeleteHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId) (result DeleteHybridConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deleteinstancefunctionslot.go b/resource-manager/web/2024-11-01/webapps/method_deleteinstancefunctionslot.go new file mode 100644 index 00000000000..b69048fa682 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deleteinstancefunctionslot.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteInstanceFunctionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteInstanceFunctionSlot ... +func (c WebAppsClient) DeleteInstanceFunctionSlot(ctx context.Context, id SlotFunctionId) (result DeleteInstanceFunctionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deleteinstanceprocess.go b/resource-manager/web/2024-11-01/webapps/method_deleteinstanceprocess.go new file mode 100644 index 00000000000..1f48c5d2ee7 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deleteinstanceprocess.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteInstanceProcessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteInstanceProcess ... +func (c WebAppsClient) DeleteInstanceProcess(ctx context.Context, id InstanceProcessId) (result DeleteInstanceProcessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deleteinstanceprocessslot.go b/resource-manager/web/2024-11-01/webapps/method_deleteinstanceprocessslot.go new file mode 100644 index 00000000000..4a86b938433 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deleteinstanceprocessslot.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteInstanceProcessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteInstanceProcessSlot ... +func (c WebAppsClient) DeleteInstanceProcessSlot(ctx context.Context, id SlotInstanceProcessId) (result DeleteInstanceProcessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletepremieraddon.go b/resource-manager/web/2024-11-01/webapps/method_deletepremieraddon.go new file mode 100644 index 00000000000..add6d111d1d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletepremieraddon.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletePremierAddOnOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePremierAddOn ... +func (c WebAppsClient) DeletePremierAddOn(ctx context.Context, id PremierAddonId) (result DeletePremierAddOnOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletepremieraddonslot.go b/resource-manager/web/2024-11-01/webapps/method_deletepremieraddonslot.go new file mode 100644 index 00000000000..e2e6333e3c4 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletepremieraddonslot.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletePremierAddOnSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePremierAddOnSlot ... +func (c WebAppsClient) DeletePremierAddOnSlot(ctx context.Context, id SlotPremierAddonId) (result DeletePremierAddOnSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deleteprivateendpointconnection.go b/resource-manager/web/2024-11-01/webapps/method_deleteprivateendpointconnection.go new file mode 100644 index 00000000000..f5b956958aa --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deleteprivateendpointconnection.go @@ -0,0 +1,72 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletePrivateEndpointConnectionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// DeletePrivateEndpointConnection ... +func (c WebAppsClient) DeletePrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeletePrivateEndpointConnectionThenPoll performs DeletePrivateEndpointConnection then polls until it's completed +func (c WebAppsClient) DeletePrivateEndpointConnectionThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnection(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnection: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnection: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deleteprivateendpointconnectionslot.go b/resource-manager/web/2024-11-01/webapps/method_deleteprivateendpointconnectionslot.go new file mode 100644 index 00000000000..61bbf74e21d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deleteprivateendpointconnectionslot.go @@ -0,0 +1,72 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletePrivateEndpointConnectionSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// DeletePrivateEndpointConnectionSlot ... +func (c WebAppsClient) DeletePrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId) (result DeletePrivateEndpointConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeletePrivateEndpointConnectionSlotThenPoll performs DeletePrivateEndpointConnectionSlot then polls until it's completed +func (c WebAppsClient) DeletePrivateEndpointConnectionSlotThenPoll(ctx context.Context, id SlotPrivateEndpointConnectionId) error { + result, err := c.DeletePrivateEndpointConnectionSlot(ctx, id) + if err != nil { + return fmt.Errorf("performing DeletePrivateEndpointConnectionSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeletePrivateEndpointConnectionSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deleteprocess.go b/resource-manager/web/2024-11-01/webapps/method_deleteprocess.go new file mode 100644 index 00000000000..e925942300c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deleteprocess.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteProcessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteProcess ... +func (c WebAppsClient) DeleteProcess(ctx context.Context, id ProcessId) (result DeleteProcessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deleteprocessslot.go b/resource-manager/web/2024-11-01/webapps/method_deleteprocessslot.go new file mode 100644 index 00000000000..da7cb778e03 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deleteprocessslot.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteProcessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteProcessSlot ... +func (c WebAppsClient) DeleteProcessSlot(ctx context.Context, id SlotProcessId) (result DeleteProcessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletepubliccertificate.go b/resource-manager/web/2024-11-01/webapps/method_deletepubliccertificate.go new file mode 100644 index 00000000000..8b04d322801 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletepubliccertificate.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletePublicCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePublicCertificate ... +func (c WebAppsClient) DeletePublicCertificate(ctx context.Context, id PublicCertificateId) (result DeletePublicCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletepubliccertificateslot.go b/resource-manager/web/2024-11-01/webapps/method_deletepubliccertificateslot.go new file mode 100644 index 00000000000..98fca6889bf --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletepubliccertificateslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletePublicCertificateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeletePublicCertificateSlot ... +func (c WebAppsClient) DeletePublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId) (result DeletePublicCertificateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deleterelayserviceconnection.go b/resource-manager/web/2024-11-01/webapps/method_deleterelayserviceconnection.go new file mode 100644 index 00000000000..be9ded1355d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deleterelayserviceconnection.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteRelayServiceConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteRelayServiceConnection ... +func (c WebAppsClient) DeleteRelayServiceConnection(ctx context.Context, id HybridConnectionId) (result DeleteRelayServiceConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deleterelayserviceconnectionslot.go b/resource-manager/web/2024-11-01/webapps/method_deleterelayserviceconnectionslot.go new file mode 100644 index 00000000000..42eccd7e9f5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deleterelayserviceconnectionslot.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteRelayServiceConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteRelayServiceConnectionSlot ... +func (c WebAppsClient) DeleteRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId) (result DeleteRelayServiceConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletesitecontainer.go b/resource-manager/web/2024-11-01/webapps/method_deletesitecontainer.go new file mode 100644 index 00000000000..ea860f567ef --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletesitecontainer.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteSiteContainerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSiteContainer ... +func (c WebAppsClient) DeleteSiteContainer(ctx context.Context, id SitecontainerId) (result DeleteSiteContainerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletesitecontainerslot.go b/resource-manager/web/2024-11-01/webapps/method_deletesitecontainerslot.go new file mode 100644 index 00000000000..f3ad5aa1a72 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletesitecontainerslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteSiteContainerSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSiteContainerSlot ... +func (c WebAppsClient) DeleteSiteContainerSlot(ctx context.Context, id SlotSitecontainerId) (result DeleteSiteContainerSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletesiteextension.go b/resource-manager/web/2024-11-01/webapps/method_deletesiteextension.go new file mode 100644 index 00000000000..525f7419d0d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletesiteextension.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteSiteExtensionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSiteExtension ... +func (c WebAppsClient) DeleteSiteExtension(ctx context.Context, id SiteExtensionId) (result DeleteSiteExtensionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletesiteextensionslot.go b/resource-manager/web/2024-11-01/webapps/method_deletesiteextensionslot.go new file mode 100644 index 00000000000..cad4ab2271e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletesiteextensionslot.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteSiteExtensionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSiteExtensionSlot ... +func (c WebAppsClient) DeleteSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (result DeleteSiteExtensionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deleteslot.go b/resource-manager/web/2024-11-01/webapps/method_deleteslot.go new file mode 100644 index 00000000000..67b4c2dcc06 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deleteslot.go @@ -0,0 +1,81 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteSlotOperationOptions struct { + DeleteEmptyServerFarm *bool + DeleteMetrics *bool +} + +func DefaultDeleteSlotOperationOptions() DeleteSlotOperationOptions { + return DeleteSlotOperationOptions{} +} + +func (o DeleteSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DeleteEmptyServerFarm != nil { + out.Append("deleteEmptyServerFarm", fmt.Sprintf("%v", *o.DeleteEmptyServerFarm)) + } + if o.DeleteMetrics != nil { + out.Append("deleteMetrics", fmt.Sprintf("%v", *o.DeleteMetrics)) + } + return &out +} + +// DeleteSlot ... +func (c WebAppsClient) DeleteSlot(ctx context.Context, id SlotId, options DeleteSlotOperationOptions) (result DeleteSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletesourcecontrol.go b/resource-manager/web/2024-11-01/webapps/method_deletesourcecontrol.go new file mode 100644 index 00000000000..dd5b73ad1b4 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletesourcecontrol.go @@ -0,0 +1,78 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteSourceControlOperationOptions struct { + AdditionalFlags *string +} + +func DefaultDeleteSourceControlOperationOptions() DeleteSourceControlOperationOptions { + return DeleteSourceControlOperationOptions{} +} + +func (o DeleteSourceControlOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteSourceControlOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteSourceControlOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AdditionalFlags != nil { + out.Append("additionalFlags", fmt.Sprintf("%v", *o.AdditionalFlags)) + } + return &out +} + +// DeleteSourceControl ... +func (c WebAppsClient) DeleteSourceControl(ctx context.Context, id commonids.AppServiceId, options DeleteSourceControlOperationOptions) (result DeleteSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: fmt.Sprintf("%s/sourceControls/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletesourcecontrolslot.go b/resource-manager/web/2024-11-01/webapps/method_deletesourcecontrolslot.go new file mode 100644 index 00000000000..45220bcdbd1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletesourcecontrolslot.go @@ -0,0 +1,77 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteSourceControlSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteSourceControlSlotOperationOptions struct { + AdditionalFlags *string +} + +func DefaultDeleteSourceControlSlotOperationOptions() DeleteSourceControlSlotOperationOptions { + return DeleteSourceControlSlotOperationOptions{} +} + +func (o DeleteSourceControlSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteSourceControlSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteSourceControlSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.AdditionalFlags != nil { + out.Append("additionalFlags", fmt.Sprintf("%v", *o.AdditionalFlags)) + } + return &out +} + +// DeleteSourceControlSlot ... +func (c WebAppsClient) DeleteSourceControlSlot(ctx context.Context, id SlotId, options DeleteSourceControlSlotOperationOptions) (result DeleteSourceControlSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: fmt.Sprintf("%s/sourceControls/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deleteswiftvirtualnetwork.go b/resource-manager/web/2024-11-01/webapps/method_deleteswiftvirtualnetwork.go new file mode 100644 index 00000000000..5f7c911990a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deleteswiftvirtualnetwork.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteSwiftVirtualNetworkOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSwiftVirtualNetwork ... +func (c WebAppsClient) DeleteSwiftVirtualNetwork(ctx context.Context, id commonids.AppServiceId) (result DeleteSwiftVirtualNetworkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deleteswiftvirtualnetworkslot.go b/resource-manager/web/2024-11-01/webapps/method_deleteswiftvirtualnetworkslot.go new file mode 100644 index 00000000000..a63702c17c3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deleteswiftvirtualnetworkslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteSwiftVirtualNetworkSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteSwiftVirtualNetworkSlot ... +func (c WebAppsClient) DeleteSwiftVirtualNetworkSlot(ctx context.Context, id SlotId) (result DeleteSwiftVirtualNetworkSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletetriggeredwebjob.go b/resource-manager/web/2024-11-01/webapps/method_deletetriggeredwebjob.go new file mode 100644 index 00000000000..c09a8a7cdcf --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletetriggeredwebjob.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteTriggeredWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteTriggeredWebJob ... +func (c WebAppsClient) DeleteTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (result DeleteTriggeredWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletetriggeredwebjobslot.go b/resource-manager/web/2024-11-01/webapps/method_deletetriggeredwebjobslot.go new file mode 100644 index 00000000000..c9aa75af711 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletetriggeredwebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteTriggeredWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteTriggeredWebJobSlot ... +func (c WebAppsClient) DeleteTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (result DeleteTriggeredWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletevnetconnection.go b/resource-manager/web/2024-11-01/webapps/method_deletevnetconnection.go new file mode 100644 index 00000000000..09e001b1b8a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletevnetconnection.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteVnetConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteVnetConnection ... +func (c WebAppsClient) DeleteVnetConnection(ctx context.Context, id VirtualNetworkConnectionId) (result DeleteVnetConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deletevnetconnectionslot.go b/resource-manager/web/2024-11-01/webapps/method_deletevnetconnectionslot.go new file mode 100644 index 00000000000..eb208686b5d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deletevnetconnectionslot.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteVnetConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteVnetConnectionSlot ... +func (c WebAppsClient) DeleteVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId) (result DeleteVnetConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deployworkflowartifacts.go b/resource-manager/web/2024-11-01/webapps/method_deployworkflowartifacts.go new file mode 100644 index 00000000000..8b6316e6292 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deployworkflowartifacts.go @@ -0,0 +1,52 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeployWorkflowArtifactsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeployWorkflowArtifacts ... +func (c WebAppsClient) DeployWorkflowArtifacts(ctx context.Context, id commonids.AppServiceId, input WorkflowArtifacts) (result DeployWorkflowArtifactsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deployWorkflowArtifacts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_deployworkflowartifactsslot.go b/resource-manager/web/2024-11-01/webapps/method_deployworkflowartifactsslot.go new file mode 100644 index 00000000000..86a6bd816b5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_deployworkflowartifactsslot.go @@ -0,0 +1,51 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeployWorkflowArtifactsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// DeployWorkflowArtifactsSlot ... +func (c WebAppsClient) DeployWorkflowArtifactsSlot(ctx context.Context, id SlotId, input WorkflowArtifacts) (result DeployWorkflowArtifactsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deployWorkflowArtifacts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_discoverbackup.go b/resource-manager/web/2024-11-01/webapps/method_discoverbackup.go new file mode 100644 index 00000000000..85b417c4364 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_discoverbackup.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoverBackupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestoreRequest +} + +// DiscoverBackup ... +func (c WebAppsClient) DiscoverBackup(ctx context.Context, id commonids.AppServiceId, input RestoreRequest) (result DiscoverBackupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/discoverbackup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RestoreRequest + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_discoverbackupslot.go b/resource-manager/web/2024-11-01/webapps/method_discoverbackupslot.go new file mode 100644 index 00000000000..bc2c9a593cb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_discoverbackupslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiscoverBackupSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RestoreRequest +} + +// DiscoverBackupSlot ... +func (c WebAppsClient) DiscoverBackupSlot(ctx context.Context, id SlotId, input RestoreRequest) (result DiscoverBackupSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/discoverbackup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RestoreRequest + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_generatenewsitepublishingpassword.go b/resource-manager/web/2024-11-01/webapps/method_generatenewsitepublishingpassword.go new file mode 100644 index 00000000000..6e02a601437 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_generatenewsitepublishingpassword.go @@ -0,0 +1,49 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GenerateNewSitePublishingPasswordOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GenerateNewSitePublishingPassword ... +func (c WebAppsClient) GenerateNewSitePublishingPassword(ctx context.Context, id commonids.AppServiceId) (result GenerateNewSitePublishingPasswordOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/newpassword", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_generatenewsitepublishingpasswordslot.go b/resource-manager/web/2024-11-01/webapps/method_generatenewsitepublishingpasswordslot.go new file mode 100644 index 00000000000..71e052a00e2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_generatenewsitepublishingpasswordslot.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GenerateNewSitePublishingPasswordSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// GenerateNewSitePublishingPasswordSlot ... +func (c WebAppsClient) GenerateNewSitePublishingPasswordSlot(ctx context.Context, id SlotId) (result GenerateNewSitePublishingPasswordSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/newpassword", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_get.go b/resource-manager/web/2024-11-01/webapps/method_get.go new file mode 100644 index 00000000000..31066458715 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_get.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// Get ... +func (c WebAppsClient) Get(ctx context.Context, id commonids.AppServiceId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Site + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getappsettingkeyvaultreference.go b/resource-manager/web/2024-11-01/webapps/method_getappsettingkeyvaultreference.go new file mode 100644 index 00000000000..f27fab51318 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getappsettingkeyvaultreference.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAppSettingKeyVaultReferenceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiKVReference +} + +// GetAppSettingKeyVaultReference ... +func (c WebAppsClient) GetAppSettingKeyVaultReference(ctx context.Context, id AppSettingId) (result GetAppSettingKeyVaultReferenceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApiKVReference + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getappsettingkeyvaultreferenceslot.go b/resource-manager/web/2024-11-01/webapps/method_getappsettingkeyvaultreferenceslot.go new file mode 100644 index 00000000000..99870c87c7b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getappsettingkeyvaultreferenceslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAppSettingKeyVaultReferenceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiKVReference +} + +// GetAppSettingKeyVaultReferenceSlot ... +func (c WebAppsClient) GetAppSettingKeyVaultReferenceSlot(ctx context.Context, id ConfigReferenceAppSettingId) (result GetAppSettingKeyVaultReferenceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApiKVReference + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getappsettingskeyvaultreferences.go b/resource-manager/web/2024-11-01/webapps/method_getappsettingskeyvaultreferences.go new file mode 100644 index 00000000000..043c62e221d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getappsettingskeyvaultreferences.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAppSettingsKeyVaultReferencesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiKVReference +} + +type GetAppSettingsKeyVaultReferencesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApiKVReference +} + +type GetAppSettingsKeyVaultReferencesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetAppSettingsKeyVaultReferencesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetAppSettingsKeyVaultReferences ... +func (c WebAppsClient) GetAppSettingsKeyVaultReferences(ctx context.Context, id commonids.AppServiceId) (result GetAppSettingsKeyVaultReferencesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetAppSettingsKeyVaultReferencesCustomPager{}, + Path: fmt.Sprintf("%s/config/configReferences/appSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiKVReference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetAppSettingsKeyVaultReferencesComplete retrieves all the results into a single object +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesComplete(ctx context.Context, id commonids.AppServiceId) (GetAppSettingsKeyVaultReferencesCompleteResult, error) { + return c.GetAppSettingsKeyVaultReferencesCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) +} + +// GetAppSettingsKeyVaultReferencesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate ApiKVReferenceOperationPredicate) (result GetAppSettingsKeyVaultReferencesCompleteResult, err error) { + items := make([]ApiKVReference, 0) + + resp, err := c.GetAppSettingsKeyVaultReferences(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetAppSettingsKeyVaultReferencesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getappsettingskeyvaultreferencesslot.go b/resource-manager/web/2024-11-01/webapps/method_getappsettingskeyvaultreferencesslot.go new file mode 100644 index 00000000000..ee5c3cbf23a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getappsettingskeyvaultreferencesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAppSettingsKeyVaultReferencesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiKVReference +} + +type GetAppSettingsKeyVaultReferencesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApiKVReference +} + +type GetAppSettingsKeyVaultReferencesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetAppSettingsKeyVaultReferencesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetAppSettingsKeyVaultReferencesSlot ... +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesSlot(ctx context.Context, id SlotId) (result GetAppSettingsKeyVaultReferencesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetAppSettingsKeyVaultReferencesSlotCustomPager{}, + Path: fmt.Sprintf("%s/config/configReferences/appSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiKVReference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetAppSettingsKeyVaultReferencesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesSlotComplete(ctx context.Context, id SlotId) (GetAppSettingsKeyVaultReferencesSlotCompleteResult, error) { + return c.GetAppSettingsKeyVaultReferencesSlotCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) +} + +// GetAppSettingsKeyVaultReferencesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetAppSettingsKeyVaultReferencesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ApiKVReferenceOperationPredicate) (result GetAppSettingsKeyVaultReferencesSlotCompleteResult, err error) { + items := make([]ApiKVReference, 0) + + resp, err := c.GetAppSettingsKeyVaultReferencesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetAppSettingsKeyVaultReferencesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getauthsettings.go b/resource-manager/web/2024-11-01/webapps/method_getauthsettings.go new file mode 100644 index 00000000000..5deb735be93 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getauthsettings.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAuthSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettings +} + +// GetAuthSettings ... +func (c WebAppsClient) GetAuthSettings(ctx context.Context, id commonids.AppServiceId) (result GetAuthSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/authsettings/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettings + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getauthsettingsslot.go b/resource-manager/web/2024-11-01/webapps/method_getauthsettingsslot.go new file mode 100644 index 00000000000..8e803724937 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getauthsettingsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAuthSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettings +} + +// GetAuthSettingsSlot ... +func (c WebAppsClient) GetAuthSettingsSlot(ctx context.Context, id SlotId) (result GetAuthSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/authsettings/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettings + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getauthsettingsv2.go b/resource-manager/web/2024-11-01/webapps/method_getauthsettingsv2.go new file mode 100644 index 00000000000..a0504e9fd96 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getauthsettingsv2.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAuthSettingsV2OperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// GetAuthSettingsV2 ... +func (c WebAppsClient) GetAuthSettingsV2(ctx context.Context, id commonids.AppServiceId) (result GetAuthSettingsV2OperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/authsettingsV2/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettingsV2 + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getauthsettingsv2slot.go b/resource-manager/web/2024-11-01/webapps/method_getauthsettingsv2slot.go new file mode 100644 index 00000000000..1709a5010c1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getauthsettingsv2slot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAuthSettingsV2SlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// GetAuthSettingsV2Slot ... +func (c WebAppsClient) GetAuthSettingsV2Slot(ctx context.Context, id SlotId) (result GetAuthSettingsV2SlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/authsettingsV2/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettingsV2 + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getauthsettingsv2withoutsecrets.go b/resource-manager/web/2024-11-01/webapps/method_getauthsettingsv2withoutsecrets.go new file mode 100644 index 00000000000..124903a090d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getauthsettingsv2withoutsecrets.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAuthSettingsV2WithoutSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// GetAuthSettingsV2WithoutSecrets ... +func (c WebAppsClient) GetAuthSettingsV2WithoutSecrets(ctx context.Context, id commonids.AppServiceId) (result GetAuthSettingsV2WithoutSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/authsettingsV2", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettingsV2 + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getauthsettingsv2withoutsecretsslot.go b/resource-manager/web/2024-11-01/webapps/method_getauthsettingsv2withoutsecretsslot.go new file mode 100644 index 00000000000..a969211442f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getauthsettingsv2withoutsecretsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAuthSettingsV2WithoutSecretsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// GetAuthSettingsV2WithoutSecretsSlot ... +func (c WebAppsClient) GetAuthSettingsV2WithoutSecretsSlot(ctx context.Context, id SlotId) (result GetAuthSettingsV2WithoutSecretsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/authsettingsV2", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettingsV2 + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getbackupconfiguration.go b/resource-manager/web/2024-11-01/webapps/method_getbackupconfiguration.go new file mode 100644 index 00000000000..89906332ea3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getbackupconfiguration.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBackupConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupRequest +} + +// GetBackupConfiguration ... +func (c WebAppsClient) GetBackupConfiguration(ctx context.Context, id commonids.AppServiceId) (result GetBackupConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/backup/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupRequest + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getbackupconfigurationslot.go b/resource-manager/web/2024-11-01/webapps/method_getbackupconfigurationslot.go new file mode 100644 index 00000000000..7be87a5817a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getbackupconfigurationslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBackupConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupRequest +} + +// GetBackupConfigurationSlot ... +func (c WebAppsClient) GetBackupConfigurationSlot(ctx context.Context, id SlotId) (result GetBackupConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/backup/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupRequest + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getbackupstatus.go b/resource-manager/web/2024-11-01/webapps/method_getbackupstatus.go new file mode 100644 index 00000000000..ab296926328 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getbackupstatus.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBackupStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// GetBackupStatus ... +func (c WebAppsClient) GetBackupStatus(ctx context.Context, id BackupId) (result GetBackupStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getbackupstatusslot.go b/resource-manager/web/2024-11-01/webapps/method_getbackupstatusslot.go new file mode 100644 index 00000000000..0e862af25fb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getbackupstatusslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBackupStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// GetBackupStatusSlot ... +func (c WebAppsClient) GetBackupStatusSlot(ctx context.Context, id SlotBackupId) (result GetBackupStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getconfiguration.go b/resource-manager/web/2024-11-01/webapps/method_getconfiguration.go new file mode 100644 index 00000000000..1d73ea645f6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getconfiguration.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// GetConfiguration ... +func (c WebAppsClient) GetConfiguration(ctx context.Context, id commonids.AppServiceId) (result GetConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteConfigResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getconfigurationslot.go b/resource-manager/web/2024-11-01/webapps/method_getconfigurationslot.go new file mode 100644 index 00000000000..89546b08eb1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getconfigurationslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// GetConfigurationSlot ... +func (c WebAppsClient) GetConfigurationSlot(ctx context.Context, id SlotId) (result GetConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteConfigResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getconfigurationsnapshot.go b/resource-manager/web/2024-11-01/webapps/method_getconfigurationsnapshot.go new file mode 100644 index 00000000000..016b9fcd3bf --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getconfigurationsnapshot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetConfigurationSnapshotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// GetConfigurationSnapshot ... +func (c WebAppsClient) GetConfigurationSnapshot(ctx context.Context, id SnapshotId) (result GetConfigurationSnapshotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteConfigResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getconfigurationsnapshotslot.go b/resource-manager/web/2024-11-01/webapps/method_getconfigurationsnapshotslot.go new file mode 100644 index 00000000000..80d0457f72f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getconfigurationsnapshotslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetConfigurationSnapshotSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// GetConfigurationSnapshotSlot ... +func (c WebAppsClient) GetConfigurationSnapshotSlot(ctx context.Context, id WebSnapshotId) (result GetConfigurationSnapshotSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteConfigResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getcontainerlogszip.go b/resource-manager/web/2024-11-01/webapps/method_getcontainerlogszip.go new file mode 100644 index 00000000000..b0790356147 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getcontainerlogszip.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetContainerLogsZipOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetContainerLogsZip ... +func (c WebAppsClient) GetContainerLogsZip(ctx context.Context, id commonids.AppServiceId) (result GetContainerLogsZipOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/containerlogs/zip/download", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getcontainerlogszipslot.go b/resource-manager/web/2024-11-01/webapps/method_getcontainerlogszipslot.go new file mode 100644 index 00000000000..080f4f9691c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getcontainerlogszipslot.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetContainerLogsZipSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetContainerLogsZipSlot ... +func (c WebAppsClient) GetContainerLogsZipSlot(ctx context.Context, id SlotId) (result GetContainerLogsZipSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/containerlogs/zip/download", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getcontinuouswebjob.go b/resource-manager/web/2024-11-01/webapps/method_getcontinuouswebjob.go new file mode 100644 index 00000000000..9f5a071f437 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getcontinuouswebjob.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetContinuousWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContinuousWebJob +} + +// GetContinuousWebJob ... +func (c WebAppsClient) GetContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result GetContinuousWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ContinuousWebJob + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getcontinuouswebjobslot.go b/resource-manager/web/2024-11-01/webapps/method_getcontinuouswebjobslot.go new file mode 100644 index 00000000000..8d4e01c6c04 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getcontinuouswebjobslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetContinuousWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContinuousWebJob +} + +// GetContinuousWebJobSlot ... +func (c WebAppsClient) GetContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result GetContinuousWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ContinuousWebJob + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getdeployment.go b/resource-manager/web/2024-11-01/webapps/method_getdeployment.go new file mode 100644 index 00000000000..0355511e44e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getdeployment.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetDeploymentOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// GetDeployment ... +func (c WebAppsClient) GetDeployment(ctx context.Context, id DeploymentId) (result GetDeploymentOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Deployment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getdeploymentslot.go b/resource-manager/web/2024-11-01/webapps/method_getdeploymentslot.go new file mode 100644 index 00000000000..4ab616abcec --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getdeploymentslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetDeploymentSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// GetDeploymentSlot ... +func (c WebAppsClient) GetDeploymentSlot(ctx context.Context, id SlotDeploymentId) (result GetDeploymentSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Deployment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getdiagnosticlogsconfiguration.go b/resource-manager/web/2024-11-01/webapps/method_getdiagnosticlogsconfiguration.go new file mode 100644 index 00000000000..0612d0c160c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getdiagnosticlogsconfiguration.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetDiagnosticLogsConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteLogsConfig +} + +// GetDiagnosticLogsConfiguration ... +func (c WebAppsClient) GetDiagnosticLogsConfiguration(ctx context.Context, id commonids.AppServiceId) (result GetDiagnosticLogsConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/logs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteLogsConfig + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getdiagnosticlogsconfigurationslot.go b/resource-manager/web/2024-11-01/webapps/method_getdiagnosticlogsconfigurationslot.go new file mode 100644 index 00000000000..aef303209ac --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getdiagnosticlogsconfigurationslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetDiagnosticLogsConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteLogsConfig +} + +// GetDiagnosticLogsConfigurationSlot ... +func (c WebAppsClient) GetDiagnosticLogsConfigurationSlot(ctx context.Context, id SlotId) (result GetDiagnosticLogsConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/logs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteLogsConfig + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getdomainownershipidentifier.go b/resource-manager/web/2024-11-01/webapps/method_getdomainownershipidentifier.go new file mode 100644 index 00000000000..bc014922e27 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getdomainownershipidentifier.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// GetDomainOwnershipIdentifier ... +func (c WebAppsClient) GetDomainOwnershipIdentifier(ctx context.Context, id SiteDomainOwnershipIdentifierId) (result GetDomainOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Identifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getdomainownershipidentifierslot.go b/resource-manager/web/2024-11-01/webapps/method_getdomainownershipidentifierslot.go new file mode 100644 index 00000000000..a2e91d0b828 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getdomainownershipidentifierslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetDomainOwnershipIdentifierSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// GetDomainOwnershipIdentifierSlot ... +func (c WebAppsClient) GetDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId) (result GetDomainOwnershipIdentifierSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Identifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getftpallowed.go b/resource-manager/web/2024-11-01/webapps/method_getftpallowed.go new file mode 100644 index 00000000000..3fb4b79a51b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getftpallowed.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetFtpAllowedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// GetFtpAllowed ... +func (c WebAppsClient) GetFtpAllowed(ctx context.Context, id commonids.AppServiceId) (result GetFtpAllowedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getftpallowedslot.go b/resource-manager/web/2024-11-01/webapps/method_getftpallowedslot.go new file mode 100644 index 00000000000..2b3a8004dfc --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getftpallowedslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetFtpAllowedSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// GetFtpAllowedSlot ... +func (c WebAppsClient) GetFtpAllowedSlot(ctx context.Context, id SlotId) (result GetFtpAllowedSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getfunction.go b/resource-manager/web/2024-11-01/webapps/method_getfunction.go new file mode 100644 index 00000000000..c119bf71fa2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getfunction.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetFunctionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionEnvelope +} + +// GetFunction ... +func (c WebAppsClient) GetFunction(ctx context.Context, id FunctionId) (result GetFunctionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FunctionEnvelope + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getfunctionsadmintoken.go b/resource-manager/web/2024-11-01/webapps/method_getfunctionsadmintoken.go new file mode 100644 index 00000000000..cef965d4ee4 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getfunctionsadmintoken.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetFunctionsAdminTokenOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// GetFunctionsAdminToken ... +func (c WebAppsClient) GetFunctionsAdminToken(ctx context.Context, id commonids.AppServiceId) (result GetFunctionsAdminTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functions/admin/token", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model string + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getfunctionsadmintokenslot.go b/resource-manager/web/2024-11-01/webapps/method_getfunctionsadmintokenslot.go new file mode 100644 index 00000000000..cf37de92f47 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getfunctionsadmintokenslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetFunctionsAdminTokenSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +// GetFunctionsAdminTokenSlot ... +func (c WebAppsClient) GetFunctionsAdminTokenSlot(ctx context.Context, id SlotId) (result GetFunctionsAdminTokenSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/functions/admin/token", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model string + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_gethostnamebinding.go b/resource-manager/web/2024-11-01/webapps/method_gethostnamebinding.go new file mode 100644 index 00000000000..023c7f1797c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_gethostnamebinding.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetHostNameBindingOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostNameBinding +} + +// GetHostNameBinding ... +func (c WebAppsClient) GetHostNameBinding(ctx context.Context, id HostNameBindingId) (result GetHostNameBindingOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HostNameBinding + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_gethostnamebindingslot.go b/resource-manager/web/2024-11-01/webapps/method_gethostnamebindingslot.go new file mode 100644 index 00000000000..d96ab86f748 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_gethostnamebindingslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetHostNameBindingSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostNameBinding +} + +// GetHostNameBindingSlot ... +func (c WebAppsClient) GetHostNameBindingSlot(ctx context.Context, id SlotHostNameBindingId) (result GetHostNameBindingSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HostNameBinding + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_gethybridconnection.go b/resource-manager/web/2024-11-01/webapps/method_gethybridconnection.go new file mode 100644 index 00000000000..f018d1b6ec8 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_gethybridconnection.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// GetHybridConnection ... +func (c WebAppsClient) GetHybridConnection(ctx context.Context, id RelayId) (result GetHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_gethybridconnectionslot.go b/resource-manager/web/2024-11-01/webapps/method_gethybridconnectionslot.go new file mode 100644 index 00000000000..e36e2d5b984 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_gethybridconnectionslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetHybridConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// GetHybridConnectionSlot ... +func (c WebAppsClient) GetHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId) (result GetHybridConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getinstancefunctionslot.go b/resource-manager/web/2024-11-01/webapps/method_getinstancefunctionslot.go new file mode 100644 index 00000000000..6e95d906f08 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getinstancefunctionslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetInstanceFunctionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionEnvelope +} + +// GetInstanceFunctionSlot ... +func (c WebAppsClient) GetInstanceFunctionSlot(ctx context.Context, id SlotFunctionId) (result GetInstanceFunctionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FunctionEnvelope + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getinstanceinfo.go b/resource-manager/web/2024-11-01/webapps/method_getinstanceinfo.go new file mode 100644 index 00000000000..0d535788c59 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getinstanceinfo.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetInstanceInfoOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebSiteInstanceStatus +} + +// GetInstanceInfo ... +func (c WebAppsClient) GetInstanceInfo(ctx context.Context, id InstanceId) (result GetInstanceInfoOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WebSiteInstanceStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getinstanceinfoslot.go b/resource-manager/web/2024-11-01/webapps/method_getinstanceinfoslot.go new file mode 100644 index 00000000000..7ac3ffaf1c8 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getinstanceinfoslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetInstanceInfoSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebSiteInstanceStatus +} + +// GetInstanceInfoSlot ... +func (c WebAppsClient) GetInstanceInfoSlot(ctx context.Context, id SlotInstanceId) (result GetInstanceInfoSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WebSiteInstanceStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getinstancemsdeploylog.go b/resource-manager/web/2024-11-01/webapps/method_getinstancemsdeploylog.go new file mode 100644 index 00000000000..5f0ecd4b9d3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getinstancemsdeploylog.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetInstanceMSDeployLogOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployLog +} + +// GetInstanceMSDeployLog ... +func (c WebAppsClient) GetInstanceMSDeployLog(ctx context.Context, id InstanceId) (result GetInstanceMSDeployLogOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy/log", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSDeployLog + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getinstancemsdeploylogslot.go b/resource-manager/web/2024-11-01/webapps/method_getinstancemsdeploylogslot.go new file mode 100644 index 00000000000..4aa95f5cdc1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getinstancemsdeploylogslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetInstanceMSDeployLogSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployLog +} + +// GetInstanceMSDeployLogSlot ... +func (c WebAppsClient) GetInstanceMSDeployLogSlot(ctx context.Context, id SlotInstanceId) (result GetInstanceMSDeployLogSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy/log", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSDeployLog + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getinstancemsdeploystatus.go b/resource-manager/web/2024-11-01/webapps/method_getinstancemsdeploystatus.go new file mode 100644 index 00000000000..9b0781e0511 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getinstancemsdeploystatus.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetInstanceMsDeployStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// GetInstanceMsDeployStatus ... +func (c WebAppsClient) GetInstanceMsDeployStatus(ctx context.Context, id InstanceId) (result GetInstanceMsDeployStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSDeployStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getinstancemsdeploystatusslot.go b/resource-manager/web/2024-11-01/webapps/method_getinstancemsdeploystatusslot.go new file mode 100644 index 00000000000..08c034a5c4b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getinstancemsdeploystatusslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetInstanceMsDeployStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// GetInstanceMsDeployStatusSlot ... +func (c WebAppsClient) GetInstanceMsDeployStatusSlot(ctx context.Context, id SlotInstanceId) (result GetInstanceMsDeployStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSDeployStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getinstanceprocess.go b/resource-manager/web/2024-11-01/webapps/method_getinstanceprocess.go new file mode 100644 index 00000000000..32dd68b49cb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getinstanceprocess.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetInstanceProcessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessInfo +} + +// GetInstanceProcess ... +func (c WebAppsClient) GetInstanceProcess(ctx context.Context, id InstanceProcessId) (result GetInstanceProcessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ProcessInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getinstanceprocessdump.go b/resource-manager/web/2024-11-01/webapps/method_getinstanceprocessdump.go new file mode 100644 index 00000000000..b3c0570e944 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getinstanceprocessdump.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetInstanceProcessDumpOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetInstanceProcessDump ... +func (c WebAppsClient) GetInstanceProcessDump(ctx context.Context, id InstanceProcessId) (result GetInstanceProcessDumpOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dump", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getinstanceprocessdumpslot.go b/resource-manager/web/2024-11-01/webapps/method_getinstanceprocessdumpslot.go new file mode 100644 index 00000000000..f8e66cc080a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getinstanceprocessdumpslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetInstanceProcessDumpSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetInstanceProcessDumpSlot ... +func (c WebAppsClient) GetInstanceProcessDumpSlot(ctx context.Context, id SlotInstanceProcessId) (result GetInstanceProcessDumpSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dump", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getinstanceprocessmodule.go b/resource-manager/web/2024-11-01/webapps/method_getinstanceprocessmodule.go new file mode 100644 index 00000000000..f936b7fea0e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getinstanceprocessmodule.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetInstanceProcessModuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessModuleInfo +} + +// GetInstanceProcessModule ... +func (c WebAppsClient) GetInstanceProcessModule(ctx context.Context, id InstanceProcessModuleId) (result GetInstanceProcessModuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ProcessModuleInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getinstanceprocessmoduleslot.go b/resource-manager/web/2024-11-01/webapps/method_getinstanceprocessmoduleslot.go new file mode 100644 index 00000000000..f68ff944498 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getinstanceprocessmoduleslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetInstanceProcessModuleSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessModuleInfo +} + +// GetInstanceProcessModuleSlot ... +func (c WebAppsClient) GetInstanceProcessModuleSlot(ctx context.Context, id SlotInstanceProcessModuleId) (result GetInstanceProcessModuleSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ProcessModuleInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getinstanceprocessslot.go b/resource-manager/web/2024-11-01/webapps/method_getinstanceprocessslot.go new file mode 100644 index 00000000000..a799b1317f0 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getinstanceprocessslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetInstanceProcessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessInfo +} + +// GetInstanceProcessSlot ... +func (c WebAppsClient) GetInstanceProcessSlot(ctx context.Context, id SlotInstanceProcessId) (result GetInstanceProcessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ProcessInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getinstanceworkflowslot.go b/resource-manager/web/2024-11-01/webapps/method_getinstanceworkflowslot.go new file mode 100644 index 00000000000..8ef0c8f31c8 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getinstanceworkflowslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetInstanceWorkflowSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowEnvelope +} + +// GetInstanceWorkflowSlot ... +func (c WebAppsClient) GetInstanceWorkflowSlot(ctx context.Context, id SlotWorkflowId) (result GetInstanceWorkflowSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowEnvelope + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getmigratemysqlstatus.go b/resource-manager/web/2024-11-01/webapps/method_getmigratemysqlstatus.go new file mode 100644 index 00000000000..f05e2dd6aea --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getmigratemysqlstatus.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetMigrateMySqlStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MigrateMySqlStatus +} + +// GetMigrateMySqlStatus ... +func (c WebAppsClient) GetMigrateMySqlStatus(ctx context.Context, id commonids.AppServiceId) (result GetMigrateMySqlStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/migrateMySql/status", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MigrateMySqlStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getmigratemysqlstatusslot.go b/resource-manager/web/2024-11-01/webapps/method_getmigratemysqlstatusslot.go new file mode 100644 index 00000000000..973c158cbbf --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getmigratemysqlstatusslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetMigrateMySqlStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MigrateMySqlStatus +} + +// GetMigrateMySqlStatusSlot ... +func (c WebAppsClient) GetMigrateMySqlStatusSlot(ctx context.Context, id SlotId) (result GetMigrateMySqlStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/migrateMySql/status", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MigrateMySqlStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getmsdeploylog.go b/resource-manager/web/2024-11-01/webapps/method_getmsdeploylog.go new file mode 100644 index 00000000000..e284c016eea --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getmsdeploylog.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetMSDeployLogOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployLog +} + +// GetMSDeployLog ... +func (c WebAppsClient) GetMSDeployLog(ctx context.Context, id commonids.AppServiceId) (result GetMSDeployLogOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy/log", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSDeployLog + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getmsdeploylogslot.go b/resource-manager/web/2024-11-01/webapps/method_getmsdeploylogslot.go new file mode 100644 index 00000000000..2f843d00946 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getmsdeploylogslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetMSDeployLogSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployLog +} + +// GetMSDeployLogSlot ... +func (c WebAppsClient) GetMSDeployLogSlot(ctx context.Context, id SlotId) (result GetMSDeployLogSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy/log", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSDeployLog + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getmsdeploystatus.go b/resource-manager/web/2024-11-01/webapps/method_getmsdeploystatus.go new file mode 100644 index 00000000000..2b61aa427cd --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getmsdeploystatus.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetMSDeployStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// GetMSDeployStatus ... +func (c WebAppsClient) GetMSDeployStatus(ctx context.Context, id commonids.AppServiceId) (result GetMSDeployStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSDeployStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getmsdeploystatusslot.go b/resource-manager/web/2024-11-01/webapps/method_getmsdeploystatusslot.go new file mode 100644 index 00000000000..d644965e7fa --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getmsdeploystatusslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetMSDeployStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MSDeployStatus +} + +// GetMSDeployStatusSlot ... +func (c WebAppsClient) GetMSDeployStatusSlot(ctx context.Context, id SlotId) (result GetMSDeployStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/mSDeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MSDeployStatus + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getnetworktraces.go b/resource-manager/web/2024-11-01/webapps/method_getnetworktraces.go new file mode 100644 index 00000000000..c7baf1f6f32 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getnetworktraces.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetNetworkTracesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +// GetNetworkTraces ... +func (c WebAppsClient) GetNetworkTraces(ctx context.Context, id NetworkTraceId) (result GetNetworkTracesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []NetworkTrace + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getnetworktracesslot.go b/resource-manager/web/2024-11-01/webapps/method_getnetworktracesslot.go new file mode 100644 index 00000000000..be577fd2382 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getnetworktracesslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetNetworkTracesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +// GetNetworkTracesSlot ... +func (c WebAppsClient) GetNetworkTracesSlot(ctx context.Context, id SlotNetworkTraceId) (result GetNetworkTracesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []NetworkTrace + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getnetworktracesslotv2.go b/resource-manager/web/2024-11-01/webapps/method_getnetworktracesslotv2.go new file mode 100644 index 00000000000..6adf1088332 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getnetworktracesslotv2.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetNetworkTracesSlotV2OperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +// GetNetworkTracesSlotV2 ... +func (c WebAppsClient) GetNetworkTracesSlotV2(ctx context.Context, id SiteSlotNetworkTraceId) (result GetNetworkTracesSlotV2OperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []NetworkTrace + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getnetworktracesv2.go b/resource-manager/web/2024-11-01/webapps/method_getnetworktracesv2.go new file mode 100644 index 00000000000..a647b7df7d6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getnetworktracesv2.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetNetworkTracesV2OperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +// GetNetworkTracesV2 ... +func (c WebAppsClient) GetNetworkTracesV2(ctx context.Context, id SiteNetworkTraceId) (result GetNetworkTracesV2OperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []NetworkTrace + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getonedeploystatus.go b/resource-manager/web/2024-11-01/webapps/method_getonedeploystatus.go new file mode 100644 index 00000000000..861f9c0d26d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getonedeploystatus.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOneDeployStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// GetOneDeployStatus ... +func (c WebAppsClient) GetOneDeployStatus(ctx context.Context, id commonids.AppServiceId) (result GetOneDeployStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/extensions/onedeploy", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model interface{} + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getpremieraddon.go b/resource-manager/web/2024-11-01/webapps/method_getpremieraddon.go new file mode 100644 index 00000000000..cab1e802f61 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getpremieraddon.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPremierAddOnOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// GetPremierAddOn ... +func (c WebAppsClient) GetPremierAddOn(ctx context.Context, id PremierAddonId) (result GetPremierAddOnOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PremierAddOn + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getpremieraddonslot.go b/resource-manager/web/2024-11-01/webapps/method_getpremieraddonslot.go new file mode 100644 index 00000000000..b18d56f259b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getpremieraddonslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPremierAddOnSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// GetPremierAddOnSlot ... +func (c WebAppsClient) GetPremierAddOnSlot(ctx context.Context, id SlotPremierAddonId) (result GetPremierAddOnSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PremierAddOn + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getprivateaccess.go b/resource-manager/web/2024-11-01/webapps/method_getprivateaccess.go new file mode 100644 index 00000000000..a475aa2c107 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getprivateaccess.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPrivateAccessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateAccess +} + +// GetPrivateAccess ... +func (c WebAppsClient) GetPrivateAccess(ctx context.Context, id commonids.AppServiceId) (result GetPrivateAccessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateAccess/virtualNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateAccess + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getprivateaccessslot.go b/resource-manager/web/2024-11-01/webapps/method_getprivateaccessslot.go new file mode 100644 index 00000000000..5ca04dcfd35 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getprivateaccessslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPrivateAccessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateAccess +} + +// GetPrivateAccessSlot ... +func (c WebAppsClient) GetPrivateAccessSlot(ctx context.Context, id SlotId) (result GetPrivateAccessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateAccess/virtualNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateAccess + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getprivateendpointconnection.go b/resource-manager/web/2024-11-01/webapps/method_getprivateendpointconnection.go new file mode 100644 index 00000000000..078deb2c24a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getprivateendpointconnection.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPrivateEndpointConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnection ... +func (c WebAppsClient) GetPrivateEndpointConnection(ctx context.Context, id PrivateEndpointConnectionId) (result GetPrivateEndpointConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RemotePrivateEndpointConnectionARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getprivateendpointconnectionlist.go b/resource-manager/web/2024-11-01/webapps/method_getprivateendpointconnectionlist.go new file mode 100644 index 00000000000..7eab86729c0 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getprivateendpointconnectionlist.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPrivateEndpointConnectionListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetPrivateEndpointConnectionListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetPrivateEndpointConnectionList ... +func (c WebAppsClient) GetPrivateEndpointConnectionList(ctx context.Context, id commonids.AppServiceId) (result GetPrivateEndpointConnectionListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetPrivateEndpointConnectionListCustomPager{}, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RemotePrivateEndpointConnectionARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetPrivateEndpointConnectionListComplete retrieves all the results into a single object +func (c WebAppsClient) GetPrivateEndpointConnectionListComplete(ctx context.Context, id commonids.AppServiceId) (GetPrivateEndpointConnectionListCompleteResult, error) { + return c.GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) +} + +// GetPrivateEndpointConnectionListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetPrivateEndpointConnectionListCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (result GetPrivateEndpointConnectionListCompleteResult, err error) { + items := make([]RemotePrivateEndpointConnectionARMResource, 0) + + resp, err := c.GetPrivateEndpointConnectionList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetPrivateEndpointConnectionListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getprivateendpointconnectionlistslot.go b/resource-manager/web/2024-11-01/webapps/method_getprivateendpointconnectionlistslot.go new file mode 100644 index 00000000000..46bf684dad2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getprivateendpointconnectionlistslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPrivateEndpointConnectionListSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []RemotePrivateEndpointConnectionARMResource +} + +type GetPrivateEndpointConnectionListSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetPrivateEndpointConnectionListSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetPrivateEndpointConnectionListSlot ... +func (c WebAppsClient) GetPrivateEndpointConnectionListSlot(ctx context.Context, id SlotId) (result GetPrivateEndpointConnectionListSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetPrivateEndpointConnectionListSlotCustomPager{}, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RemotePrivateEndpointConnectionARMResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetPrivateEndpointConnectionListSlotComplete retrieves all the results into a single object +func (c WebAppsClient) GetPrivateEndpointConnectionListSlotComplete(ctx context.Context, id SlotId) (GetPrivateEndpointConnectionListSlotCompleteResult, error) { + return c.GetPrivateEndpointConnectionListSlotCompleteMatchingPredicate(ctx, id, RemotePrivateEndpointConnectionARMResourceOperationPredicate{}) +} + +// GetPrivateEndpointConnectionListSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetPrivateEndpointConnectionListSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate RemotePrivateEndpointConnectionARMResourceOperationPredicate) (result GetPrivateEndpointConnectionListSlotCompleteResult, err error) { + items := make([]RemotePrivateEndpointConnectionARMResource, 0) + + resp, err := c.GetPrivateEndpointConnectionListSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetPrivateEndpointConnectionListSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getprivateendpointconnectionslot.go b/resource-manager/web/2024-11-01/webapps/method_getprivateendpointconnectionslot.go new file mode 100644 index 00000000000..dc1da065c8f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getprivateendpointconnectionslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPrivateEndpointConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RemotePrivateEndpointConnectionARMResource +} + +// GetPrivateEndpointConnectionSlot ... +func (c WebAppsClient) GetPrivateEndpointConnectionSlot(ctx context.Context, id SlotPrivateEndpointConnectionId) (result GetPrivateEndpointConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RemotePrivateEndpointConnectionARMResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getprivatelinkresources.go b/resource-manager/web/2024-11-01/webapps/method_getprivatelinkresources.go new file mode 100644 index 00000000000..7a0922f7157 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getprivatelinkresources.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPrivateLinkResourcesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesWrapper +} + +// GetPrivateLinkResources ... +func (c WebAppsClient) GetPrivateLinkResources(ctx context.Context, id commonids.AppServiceId) (result GetPrivateLinkResourcesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateLinkResourcesWrapper + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getprivatelinkresourcesslot.go b/resource-manager/web/2024-11-01/webapps/method_getprivatelinkresourcesslot.go new file mode 100644 index 00000000000..3dc2ee16463 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getprivatelinkresourcesslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPrivateLinkResourcesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesWrapper +} + +// GetPrivateLinkResourcesSlot ... +func (c WebAppsClient) GetPrivateLinkResourcesSlot(ctx context.Context, id SlotId) (result GetPrivateLinkResourcesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateLinkResourcesWrapper + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getprocess.go b/resource-manager/web/2024-11-01/webapps/method_getprocess.go new file mode 100644 index 00000000000..f53ec86fa97 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getprocess.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetProcessOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessInfo +} + +// GetProcess ... +func (c WebAppsClient) GetProcess(ctx context.Context, id ProcessId) (result GetProcessOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ProcessInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getprocessdump.go b/resource-manager/web/2024-11-01/webapps/method_getprocessdump.go new file mode 100644 index 00000000000..4aa575213d9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getprocessdump.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetProcessDumpOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetProcessDump ... +func (c WebAppsClient) GetProcessDump(ctx context.Context, id ProcessId) (result GetProcessDumpOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dump", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getprocessdumpslot.go b/resource-manager/web/2024-11-01/webapps/method_getprocessdumpslot.go new file mode 100644 index 00000000000..b904b54a53d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getprocessdumpslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetProcessDumpSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetProcessDumpSlot ... +func (c WebAppsClient) GetProcessDumpSlot(ctx context.Context, id SlotProcessId) (result GetProcessDumpSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dump", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getprocessmodule.go b/resource-manager/web/2024-11-01/webapps/method_getprocessmodule.go new file mode 100644 index 00000000000..84621827e5b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getprocessmodule.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetProcessModuleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessModuleInfo +} + +// GetProcessModule ... +func (c WebAppsClient) GetProcessModule(ctx context.Context, id ModuleId) (result GetProcessModuleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ProcessModuleInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getprocessmoduleslot.go b/resource-manager/web/2024-11-01/webapps/method_getprocessmoduleslot.go new file mode 100644 index 00000000000..eb70f4f6077 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getprocessmoduleslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetProcessModuleSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessModuleInfo +} + +// GetProcessModuleSlot ... +func (c WebAppsClient) GetProcessModuleSlot(ctx context.Context, id ProcessModuleId) (result GetProcessModuleSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ProcessModuleInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getprocessslot.go b/resource-manager/web/2024-11-01/webapps/method_getprocessslot.go new file mode 100644 index 00000000000..125ebe5550c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getprocessslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetProcessSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ProcessInfo +} + +// GetProcessSlot ... +func (c WebAppsClient) GetProcessSlot(ctx context.Context, id SlotProcessId) (result GetProcessSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ProcessInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getpubliccertificate.go b/resource-manager/web/2024-11-01/webapps/method_getpubliccertificate.go new file mode 100644 index 00000000000..d2b18926090 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getpubliccertificate.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPublicCertificateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicCertificate +} + +// GetPublicCertificate ... +func (c WebAppsClient) GetPublicCertificate(ctx context.Context, id PublicCertificateId) (result GetPublicCertificateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PublicCertificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getpubliccertificateslot.go b/resource-manager/web/2024-11-01/webapps/method_getpubliccertificateslot.go new file mode 100644 index 00000000000..81a159edd9f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getpubliccertificateslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetPublicCertificateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PublicCertificate +} + +// GetPublicCertificateSlot ... +func (c WebAppsClient) GetPublicCertificateSlot(ctx context.Context, id SlotPublicCertificateId) (result GetPublicCertificateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PublicCertificate + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getrelayserviceconnection.go b/resource-manager/web/2024-11-01/webapps/method_getrelayserviceconnection.go new file mode 100644 index 00000000000..279bcaac0fc --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getrelayserviceconnection.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetRelayServiceConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// GetRelayServiceConnection ... +func (c WebAppsClient) GetRelayServiceConnection(ctx context.Context, id HybridConnectionId) (result GetRelayServiceConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RelayServiceConnectionEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getrelayserviceconnectionslot.go b/resource-manager/web/2024-11-01/webapps/method_getrelayserviceconnectionslot.go new file mode 100644 index 00000000000..8260c31d4d5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getrelayserviceconnectionslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetRelayServiceConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// GetRelayServiceConnectionSlot ... +func (c WebAppsClient) GetRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId) (result GetRelayServiceConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RelayServiceConnectionEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getscmallowed.go b/resource-manager/web/2024-11-01/webapps/method_getscmallowed.go new file mode 100644 index 00000000000..9b0418a2f0f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getscmallowed.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetScmAllowedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// GetScmAllowed ... +func (c WebAppsClient) GetScmAllowed(ctx context.Context, id commonids.AppServiceId) (result GetScmAllowedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getscmallowedslot.go b/resource-manager/web/2024-11-01/webapps/method_getscmallowedslot.go new file mode 100644 index 00000000000..53a7a3a2331 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getscmallowedslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetScmAllowedSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// GetScmAllowedSlot ... +func (c WebAppsClient) GetScmAllowedSlot(ctx context.Context, id SlotId) (result GetScmAllowedSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getsiteconnectionstringkeyvaultreference.go b/resource-manager/web/2024-11-01/webapps/method_getsiteconnectionstringkeyvaultreference.go new file mode 100644 index 00000000000..aff9e649a27 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getsiteconnectionstringkeyvaultreference.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSiteConnectionStringKeyVaultReferenceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiKVReference +} + +// GetSiteConnectionStringKeyVaultReference ... +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReference(ctx context.Context, id ConnectionStringId) (result GetSiteConnectionStringKeyVaultReferenceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApiKVReference + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getsiteconnectionstringkeyvaultreferences.go b/resource-manager/web/2024-11-01/webapps/method_getsiteconnectionstringkeyvaultreferences.go new file mode 100644 index 00000000000..6544219dc39 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getsiteconnectionstringkeyvaultreferences.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSiteConnectionStringKeyVaultReferencesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiKVReference +} + +type GetSiteConnectionStringKeyVaultReferencesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApiKVReference +} + +type GetSiteConnectionStringKeyVaultReferencesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetSiteConnectionStringKeyVaultReferencesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetSiteConnectionStringKeyVaultReferences ... +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferences(ctx context.Context, id commonids.AppServiceId) (result GetSiteConnectionStringKeyVaultReferencesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetSiteConnectionStringKeyVaultReferencesCustomPager{}, + Path: fmt.Sprintf("%s/config/configReferences/connectionStrings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiKVReference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetSiteConnectionStringKeyVaultReferencesComplete retrieves all the results into a single object +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesComplete(ctx context.Context, id commonids.AppServiceId) (GetSiteConnectionStringKeyVaultReferencesCompleteResult, error) { + return c.GetSiteConnectionStringKeyVaultReferencesCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) +} + +// GetSiteConnectionStringKeyVaultReferencesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate ApiKVReferenceOperationPredicate) (result GetSiteConnectionStringKeyVaultReferencesCompleteResult, err error) { + items := make([]ApiKVReference, 0) + + resp, err := c.GetSiteConnectionStringKeyVaultReferences(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetSiteConnectionStringKeyVaultReferencesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getsiteconnectionstringkeyvaultreferenceslot.go b/resource-manager/web/2024-11-01/webapps/method_getsiteconnectionstringkeyvaultreferenceslot.go new file mode 100644 index 00000000000..9cd169fbf00 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getsiteconnectionstringkeyvaultreferenceslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSiteConnectionStringKeyVaultReferenceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ApiKVReference +} + +// GetSiteConnectionStringKeyVaultReferenceSlot ... +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferenceSlot(ctx context.Context, id ConfigReferenceConnectionStringId) (result GetSiteConnectionStringKeyVaultReferenceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ApiKVReference + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getsiteconnectionstringkeyvaultreferencesslot.go b/resource-manager/web/2024-11-01/webapps/method_getsiteconnectionstringkeyvaultreferencesslot.go new file mode 100644 index 00000000000..94803ca2384 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getsiteconnectionstringkeyvaultreferencesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSiteConnectionStringKeyVaultReferencesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ApiKVReference +} + +type GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ApiKVReference +} + +type GetSiteConnectionStringKeyVaultReferencesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *GetSiteConnectionStringKeyVaultReferencesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// GetSiteConnectionStringKeyVaultReferencesSlot ... +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesSlot(ctx context.Context, id SlotId) (result GetSiteConnectionStringKeyVaultReferencesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &GetSiteConnectionStringKeyVaultReferencesSlotCustomPager{}, + Path: fmt.Sprintf("%s/config/configReferences/connectionStrings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ApiKVReference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// GetSiteConnectionStringKeyVaultReferencesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesSlotComplete(ctx context.Context, id SlotId) (GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult, error) { + return c.GetSiteConnectionStringKeyVaultReferencesSlotCompleteMatchingPredicate(ctx, id, ApiKVReferenceOperationPredicate{}) +} + +// GetSiteConnectionStringKeyVaultReferencesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) GetSiteConnectionStringKeyVaultReferencesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ApiKVReferenceOperationPredicate) (result GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult, err error) { + items := make([]ApiKVReference, 0) + + resp, err := c.GetSiteConnectionStringKeyVaultReferencesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = GetSiteConnectionStringKeyVaultReferencesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getsitecontainer.go b/resource-manager/web/2024-11-01/webapps/method_getsitecontainer.go new file mode 100644 index 00000000000..bd1302d106f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getsitecontainer.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSiteContainerOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteContainer +} + +// GetSiteContainer ... +func (c WebAppsClient) GetSiteContainer(ctx context.Context, id SitecontainerId) (result GetSiteContainerOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteContainer + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getsitecontainerslot.go b/resource-manager/web/2024-11-01/webapps/method_getsitecontainerslot.go new file mode 100644 index 00000000000..0f130308780 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getsitecontainerslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSiteContainerSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteContainer +} + +// GetSiteContainerSlot ... +func (c WebAppsClient) GetSiteContainerSlot(ctx context.Context, id SlotSitecontainerId) (result GetSiteContainerSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteContainer + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getsiteextension.go b/resource-manager/web/2024-11-01/webapps/method_getsiteextension.go new file mode 100644 index 00000000000..0a6945f3b7d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getsiteextension.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSiteExtensionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteExtensionInfo +} + +// GetSiteExtension ... +func (c WebAppsClient) GetSiteExtension(ctx context.Context, id SiteExtensionId) (result GetSiteExtensionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteExtensionInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getsiteextensionslot.go b/resource-manager/web/2024-11-01/webapps/method_getsiteextensionslot.go new file mode 100644 index 00000000000..e54acbb50ef --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getsiteextensionslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSiteExtensionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteExtensionInfo +} + +// GetSiteExtensionSlot ... +func (c WebAppsClient) GetSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (result GetSiteExtensionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteExtensionInfo + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getsitephperrorlogflag.go b/resource-manager/web/2024-11-01/webapps/method_getsitephperrorlogflag.go new file mode 100644 index 00000000000..63dbaae3ef5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getsitephperrorlogflag.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSitePhpErrorLogFlagOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SitePhpErrorLogFlag +} + +// GetSitePhpErrorLogFlag ... +func (c WebAppsClient) GetSitePhpErrorLogFlag(ctx context.Context, id commonids.AppServiceId) (result GetSitePhpErrorLogFlagOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/phplogging", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SitePhpErrorLogFlag + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getsitephperrorlogflagslot.go b/resource-manager/web/2024-11-01/webapps/method_getsitephperrorlogflagslot.go new file mode 100644 index 00000000000..4476bb15496 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getsitephperrorlogflagslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSitePhpErrorLogFlagSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SitePhpErrorLogFlag +} + +// GetSitePhpErrorLogFlagSlot ... +func (c WebAppsClient) GetSitePhpErrorLogFlagSlot(ctx context.Context, id SlotId) (result GetSitePhpErrorLogFlagSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/phplogging", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SitePhpErrorLogFlag + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getslot.go b/resource-manager/web/2024-11-01/webapps/method_getslot.go new file mode 100644 index 00000000000..96f47332251 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// GetSlot ... +func (c WebAppsClient) GetSlot(ctx context.Context, id SlotId) (result GetSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Site + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getsourcecontrol.go b/resource-manager/web/2024-11-01/webapps/method_getsourcecontrol.go new file mode 100644 index 00000000000..8f1380fc15a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getsourcecontrol.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// GetSourceControl ... +func (c WebAppsClient) GetSourceControl(ctx context.Context, id commonids.AppServiceId) (result GetSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sourceControls/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteSourceControl + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getsourcecontrolslot.go b/resource-manager/web/2024-11-01/webapps/method_getsourcecontrolslot.go new file mode 100644 index 00000000000..59f28a81eeb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getsourcecontrolslot.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSourceControlSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// GetSourceControlSlot ... +func (c WebAppsClient) GetSourceControlSlot(ctx context.Context, id SlotId) (result GetSourceControlSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/sourceControls/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteSourceControl + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getswiftvirtualnetworkconnection.go b/resource-manager/web/2024-11-01/webapps/method_getswiftvirtualnetworkconnection.go new file mode 100644 index 00000000000..8d24a59f9ff --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getswiftvirtualnetworkconnection.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSwiftVirtualNetworkConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// GetSwiftVirtualNetworkConnection ... +func (c WebAppsClient) GetSwiftVirtualNetworkConnection(ctx context.Context, id commonids.AppServiceId) (result GetSwiftVirtualNetworkConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SwiftVirtualNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getswiftvirtualnetworkconnectionslot.go b/resource-manager/web/2024-11-01/webapps/method_getswiftvirtualnetworkconnectionslot.go new file mode 100644 index 00000000000..c94d3312298 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getswiftvirtualnetworkconnectionslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSwiftVirtualNetworkConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// GetSwiftVirtualNetworkConnectionSlot ... +func (c WebAppsClient) GetSwiftVirtualNetworkConnectionSlot(ctx context.Context, id SlotId) (result GetSwiftVirtualNetworkConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SwiftVirtualNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_gettriggeredwebjob.go b/resource-manager/web/2024-11-01/webapps/method_gettriggeredwebjob.go new file mode 100644 index 00000000000..f408fb21bb1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_gettriggeredwebjob.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetTriggeredWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TriggeredWebJob +} + +// GetTriggeredWebJob ... +func (c WebAppsClient) GetTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (result GetTriggeredWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model TriggeredWebJob + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_gettriggeredwebjobhistory.go b/resource-manager/web/2024-11-01/webapps/method_gettriggeredwebjobhistory.go new file mode 100644 index 00000000000..d8dac67561f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_gettriggeredwebjobhistory.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetTriggeredWebJobHistoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TriggeredJobHistory +} + +// GetTriggeredWebJobHistory ... +func (c WebAppsClient) GetTriggeredWebJobHistory(ctx context.Context, id HistoryId) (result GetTriggeredWebJobHistoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model TriggeredJobHistory + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_gettriggeredwebjobhistoryslot.go b/resource-manager/web/2024-11-01/webapps/method_gettriggeredwebjobhistoryslot.go new file mode 100644 index 00000000000..db0ae2aa46c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_gettriggeredwebjobhistoryslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetTriggeredWebJobHistorySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TriggeredJobHistory +} + +// GetTriggeredWebJobHistorySlot ... +func (c WebAppsClient) GetTriggeredWebJobHistorySlot(ctx context.Context, id TriggeredWebJobHistoryId) (result GetTriggeredWebJobHistorySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model TriggeredJobHistory + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_gettriggeredwebjobslot.go b/resource-manager/web/2024-11-01/webapps/method_gettriggeredwebjobslot.go new file mode 100644 index 00000000000..9d5fdbad976 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_gettriggeredwebjobslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetTriggeredWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TriggeredWebJob +} + +// GetTriggeredWebJobSlot ... +func (c WebAppsClient) GetTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (result GetTriggeredWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model TriggeredWebJob + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getvnetconnection.go b/resource-manager/web/2024-11-01/webapps/method_getvnetconnection.go new file mode 100644 index 00000000000..4568fe01196 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getvnetconnection.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetVnetConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// GetVnetConnection ... +func (c WebAppsClient) GetVnetConnection(ctx context.Context, id VirtualNetworkConnectionId) (result GetVnetConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getvnetconnectiongateway.go b/resource-manager/web/2024-11-01/webapps/method_getvnetconnectiongateway.go new file mode 100644 index 00000000000..71c79ea8c65 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getvnetconnectiongateway.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetVnetConnectionGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// GetVnetConnectionGateway ... +func (c WebAppsClient) GetVnetConnectionGateway(ctx context.Context, id GatewayId) (result GetVnetConnectionGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getvnetconnectiongatewayslot.go b/resource-manager/web/2024-11-01/webapps/method_getvnetconnectiongatewayslot.go new file mode 100644 index 00000000000..7abcca7f5ab --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getvnetconnectiongatewayslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetVnetConnectionGatewaySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// GetVnetConnectionGatewaySlot ... +func (c WebAppsClient) GetVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId) (result GetVnetConnectionGatewaySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getvnetconnectionslot.go b/resource-manager/web/2024-11-01/webapps/method_getvnetconnectionslot.go new file mode 100644 index 00000000000..d212cb00170 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getvnetconnectionslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetVnetConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// GetVnetConnectionSlot ... +func (c WebAppsClient) GetVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId) (result GetVnetConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getwebjob.go b/resource-manager/web/2024-11-01/webapps/method_getwebjob.go new file mode 100644 index 00000000000..283a114229d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getwebjob.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebJob +} + +// GetWebJob ... +func (c WebAppsClient) GetWebJob(ctx context.Context, id WebJobId) (result GetWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WebJob + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getwebjobslot.go b/resource-manager/web/2024-11-01/webapps/method_getwebjobslot.go new file mode 100644 index 00000000000..e1b57da034c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getwebjobslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WebJob +} + +// GetWebJobSlot ... +func (c WebAppsClient) GetWebJobSlot(ctx context.Context, id SlotWebJobId) (result GetWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WebJob + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getwebsitecontainerlogs.go b/resource-manager/web/2024-11-01/webapps/method_getwebsitecontainerlogs.go new file mode 100644 index 00000000000..b663861a930 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getwebsitecontainerlogs.go @@ -0,0 +1,56 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetWebSiteContainerLogsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetWebSiteContainerLogs ... +func (c WebAppsClient) GetWebSiteContainerLogs(ctx context.Context, id commonids.AppServiceId) (result GetWebSiteContainerLogsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/containerlogs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getwebsitecontainerlogsslot.go b/resource-manager/web/2024-11-01/webapps/method_getwebsitecontainerlogsslot.go new file mode 100644 index 00000000000..6446530d54e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getwebsitecontainerlogsslot.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetWebSiteContainerLogsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// GetWebSiteContainerLogsSlot ... +func (c WebAppsClient) GetWebSiteContainerLogsSlot(ctx context.Context, id SlotId) (result GetWebSiteContainerLogsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/containerlogs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_getworkflow.go b/resource-manager/web/2024-11-01/webapps/method_getworkflow.go new file mode 100644 index 00000000000..5588ed7e61d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_getworkflow.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetWorkflowOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowEnvelope +} + +// GetWorkflow ... +func (c WebAppsClient) GetWorkflow(ctx context.Context, id WorkflowId) (result GetWorkflowOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowEnvelope + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_installsiteextension.go b/resource-manager/web/2024-11-01/webapps/method_installsiteextension.go new file mode 100644 index 00000000000..7e485b9878f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_installsiteextension.go @@ -0,0 +1,71 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InstallSiteExtensionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SiteExtensionInfo +} + +// InstallSiteExtension ... +func (c WebAppsClient) InstallSiteExtension(ctx context.Context, id SiteExtensionId) (result InstallSiteExtensionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// InstallSiteExtensionThenPoll performs InstallSiteExtension then polls until it's completed +func (c WebAppsClient) InstallSiteExtensionThenPoll(ctx context.Context, id SiteExtensionId) error { + result, err := c.InstallSiteExtension(ctx, id) + if err != nil { + return fmt.Errorf("performing InstallSiteExtension: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after InstallSiteExtension: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_installsiteextensionslot.go b/resource-manager/web/2024-11-01/webapps/method_installsiteextensionslot.go new file mode 100644 index 00000000000..4bea72555e7 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_installsiteextensionslot.go @@ -0,0 +1,71 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InstallSiteExtensionSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *SiteExtensionInfo +} + +// InstallSiteExtensionSlot ... +func (c WebAppsClient) InstallSiteExtensionSlot(ctx context.Context, id SlotSiteExtensionId) (result InstallSiteExtensionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// InstallSiteExtensionSlotThenPoll performs InstallSiteExtensionSlot then polls until it's completed +func (c WebAppsClient) InstallSiteExtensionSlotThenPoll(ctx context.Context, id SlotSiteExtensionId) error { + result, err := c.InstallSiteExtensionSlot(ctx, id) + if err != nil { + return fmt.Errorf("performing InstallSiteExtensionSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after InstallSiteExtensionSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_iscloneable.go b/resource-manager/web/2024-11-01/webapps/method_iscloneable.go new file mode 100644 index 00000000000..0603d8f018e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_iscloneable.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IsCloneableOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteCloneability +} + +// IsCloneable ... +func (c WebAppsClient) IsCloneable(ctx context.Context, id commonids.AppServiceId) (result IsCloneableOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/iscloneable", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteCloneability + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_iscloneableslot.go b/resource-manager/web/2024-11-01/webapps/method_iscloneableslot.go new file mode 100644 index 00000000000..e971d3c63e4 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_iscloneableslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IsCloneableSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteCloneability +} + +// IsCloneableSlot ... +func (c WebAppsClient) IsCloneableSlot(ctx context.Context, id SlotId) (result IsCloneableSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/iscloneable", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteCloneability + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_list.go b/resource-manager/web/2024-11-01/webapps/method_list.go new file mode 100644 index 00000000000..460b637e374 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_list.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c WebAppsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/sites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c WebAppsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SiteOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SiteOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listapplicationsettings.go b/resource-manager/web/2024-11-01/webapps/method_listapplicationsettings.go new file mode 100644 index 00000000000..ce70c9042fa --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listapplicationsettings.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListApplicationSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListApplicationSettings ... +func (c WebAppsClient) ListApplicationSettings(ctx context.Context, id commonids.AppServiceId) (result ListApplicationSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/appSettings/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listapplicationsettingsslot.go b/resource-manager/web/2024-11-01/webapps/method_listapplicationsettingsslot.go new file mode 100644 index 00000000000..7eefeaa0feb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listapplicationsettingsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListApplicationSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListApplicationSettingsSlot ... +func (c WebAppsClient) ListApplicationSettingsSlot(ctx context.Context, id SlotId) (result ListApplicationSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/appSettings/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listazurestorageaccounts.go b/resource-manager/web/2024-11-01/webapps/method_listazurestorageaccounts.go new file mode 100644 index 00000000000..bc513083273 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listazurestorageaccounts.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAzureStorageAccountsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureStoragePropertyDictionaryResource +} + +// ListAzureStorageAccounts ... +func (c WebAppsClient) ListAzureStorageAccounts(ctx context.Context, id commonids.AppServiceId) (result ListAzureStorageAccountsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/azurestorageaccounts/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AzureStoragePropertyDictionaryResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listazurestorageaccountsslot.go b/resource-manager/web/2024-11-01/webapps/method_listazurestorageaccountsslot.go new file mode 100644 index 00000000000..c5a1cd2c3ab --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listazurestorageaccountsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListAzureStorageAccountsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureStoragePropertyDictionaryResource +} + +// ListAzureStorageAccountsSlot ... +func (c WebAppsClient) ListAzureStorageAccountsSlot(ctx context.Context, id SlotId) (result ListAzureStorageAccountsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/azurestorageaccounts/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AzureStoragePropertyDictionaryResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listbackups.go b/resource-manager/web/2024-11-01/webapps/method_listbackups.go new file mode 100644 index 00000000000..a8b70b26ecf --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listbackups.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBackupsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupItem +} + +type ListBackupsCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackupItem +} + +type ListBackupsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBackupsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBackups ... +func (c WebAppsClient) ListBackups(ctx context.Context, id commonids.AppServiceId) (result ListBackupsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBackupsCustomPager{}, + Path: fmt.Sprintf("%s/backups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BackupItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBackupsComplete retrieves all the results into a single object +func (c WebAppsClient) ListBackupsComplete(ctx context.Context, id commonids.AppServiceId) (ListBackupsCompleteResult, error) { + return c.ListBackupsCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) +} + +// ListBackupsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListBackupsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate BackupItemOperationPredicate) (result ListBackupsCompleteResult, err error) { + items := make([]BackupItem, 0) + + resp, err := c.ListBackups(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBackupsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listbackupsslot.go b/resource-manager/web/2024-11-01/webapps/method_listbackupsslot.go new file mode 100644 index 00000000000..c76afbae931 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listbackupsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBackupsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupItem +} + +type ListBackupsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackupItem +} + +type ListBackupsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBackupsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBackupsSlot ... +func (c WebAppsClient) ListBackupsSlot(ctx context.Context, id SlotId) (result ListBackupsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBackupsSlotCustomPager{}, + Path: fmt.Sprintf("%s/backups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BackupItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBackupsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListBackupsSlotComplete(ctx context.Context, id SlotId) (ListBackupsSlotCompleteResult, error) { + return c.ListBackupsSlotCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) +} + +// ListBackupsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListBackupsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate BackupItemOperationPredicate) (result ListBackupsSlotCompleteResult, err error) { + items := make([]BackupItem, 0) + + resp, err := c.ListBackupsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBackupsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listbackupstatussecrets.go b/resource-manager/web/2024-11-01/webapps/method_listbackupstatussecrets.go new file mode 100644 index 00000000000..31d9021a61b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listbackupstatussecrets.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBackupStatusSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// ListBackupStatusSecrets ... +func (c WebAppsClient) ListBackupStatusSecrets(ctx context.Context, id BackupId, input BackupRequest) (result ListBackupStatusSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listbackupstatussecretsslot.go b/resource-manager/web/2024-11-01/webapps/method_listbackupstatussecretsslot.go new file mode 100644 index 00000000000..ddc128b594c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listbackupstatussecretsslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBackupStatusSecretsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupItem +} + +// ListBackupStatusSecretsSlot ... +func (c WebAppsClient) ListBackupStatusSecretsSlot(ctx context.Context, id SlotBackupId, input BackupRequest) (result ListBackupStatusSecretsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listbasicpublishingcredentialspolicies.go b/resource-manager/web/2024-11-01/webapps/method_listbasicpublishingcredentialspolicies.go new file mode 100644 index 00000000000..48de93b0880 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listbasicpublishingcredentialspolicies.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBasicPublishingCredentialsPoliciesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmPublishingCredentialsPoliciesEntity +} + +type ListBasicPublishingCredentialsPoliciesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmPublishingCredentialsPoliciesEntity +} + +type ListBasicPublishingCredentialsPoliciesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBasicPublishingCredentialsPoliciesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBasicPublishingCredentialsPolicies ... +func (c WebAppsClient) ListBasicPublishingCredentialsPolicies(ctx context.Context, id commonids.AppServiceId) (result ListBasicPublishingCredentialsPoliciesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBasicPublishingCredentialsPoliciesCustomPager{}, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmPublishingCredentialsPoliciesEntity `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBasicPublishingCredentialsPoliciesComplete retrieves all the results into a single object +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesComplete(ctx context.Context, id commonids.AppServiceId) (ListBasicPublishingCredentialsPoliciesCompleteResult, error) { + return c.ListBasicPublishingCredentialsPoliciesCompleteMatchingPredicate(ctx, id, CsmPublishingCredentialsPoliciesEntityOperationPredicate{}) +} + +// ListBasicPublishingCredentialsPoliciesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate CsmPublishingCredentialsPoliciesEntityOperationPredicate) (result ListBasicPublishingCredentialsPoliciesCompleteResult, err error) { + items := make([]CsmPublishingCredentialsPoliciesEntity, 0) + + resp, err := c.ListBasicPublishingCredentialsPolicies(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBasicPublishingCredentialsPoliciesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listbasicpublishingcredentialspoliciesslot.go b/resource-manager/web/2024-11-01/webapps/method_listbasicpublishingcredentialspoliciesslot.go new file mode 100644 index 00000000000..6bfb2b86ffe --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listbasicpublishingcredentialspoliciesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBasicPublishingCredentialsPoliciesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmPublishingCredentialsPoliciesEntity +} + +type ListBasicPublishingCredentialsPoliciesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmPublishingCredentialsPoliciesEntity +} + +type ListBasicPublishingCredentialsPoliciesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBasicPublishingCredentialsPoliciesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBasicPublishingCredentialsPoliciesSlot ... +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesSlot(ctx context.Context, id SlotId) (result ListBasicPublishingCredentialsPoliciesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListBasicPublishingCredentialsPoliciesSlotCustomPager{}, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmPublishingCredentialsPoliciesEntity `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBasicPublishingCredentialsPoliciesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesSlotComplete(ctx context.Context, id SlotId) (ListBasicPublishingCredentialsPoliciesSlotCompleteResult, error) { + return c.ListBasicPublishingCredentialsPoliciesSlotCompleteMatchingPredicate(ctx, id, CsmPublishingCredentialsPoliciesEntityOperationPredicate{}) +} + +// ListBasicPublishingCredentialsPoliciesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListBasicPublishingCredentialsPoliciesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate CsmPublishingCredentialsPoliciesEntityOperationPredicate) (result ListBasicPublishingCredentialsPoliciesSlotCompleteResult, err error) { + items := make([]CsmPublishingCredentialsPoliciesEntity, 0) + + resp, err := c.ListBasicPublishingCredentialsPoliciesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBasicPublishingCredentialsPoliciesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listbyresourcegroup.go b/resource-manager/web/2024-11-01/webapps/method_listbyresourcegroup.go new file mode 100644 index 00000000000..0453dace48d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listbyresourcegroup.go @@ -0,0 +1,135 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type ListByResourceGroupOperationOptions struct { + IncludeSlots *bool +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IncludeSlots != nil { + out.Append("includeSlots", fmt.Sprintf("%v", *o.IncludeSlots)) + } + return &out +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c WebAppsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.Web/sites", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c WebAppsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, SiteOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate SiteOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.ListByResourceGroup(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listconfigurations.go b/resource-manager/web/2024-11-01/webapps/method_listconfigurations.go new file mode 100644 index 00000000000..8e804a2f12c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listconfigurations.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListConfigurationsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteConfigResource +} + +type ListConfigurationsCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteConfigResource +} + +type ListConfigurationsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListConfigurationsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListConfigurations ... +func (c WebAppsClient) ListConfigurations(ctx context.Context, id commonids.AppServiceId) (result ListConfigurationsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListConfigurationsCustomPager{}, + Path: fmt.Sprintf("%s/config", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SiteConfigResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListConfigurationsComplete retrieves all the results into a single object +func (c WebAppsClient) ListConfigurationsComplete(ctx context.Context, id commonids.AppServiceId) (ListConfigurationsCompleteResult, error) { + return c.ListConfigurationsCompleteMatchingPredicate(ctx, id, SiteConfigResourceOperationPredicate{}) +} + +// ListConfigurationsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListConfigurationsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SiteConfigResourceOperationPredicate) (result ListConfigurationsCompleteResult, err error) { + items := make([]SiteConfigResource, 0) + + resp, err := c.ListConfigurations(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListConfigurationsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listconfigurationsnapshotinfo.go b/resource-manager/web/2024-11-01/webapps/method_listconfigurationsnapshotinfo.go new file mode 100644 index 00000000000..c3b12636fbb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listconfigurationsnapshotinfo.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListConfigurationSnapshotInfoOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteConfigurationSnapshotInfo +} + +type ListConfigurationSnapshotInfoCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteConfigurationSnapshotInfo +} + +type ListConfigurationSnapshotInfoCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListConfigurationSnapshotInfoCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListConfigurationSnapshotInfo ... +func (c WebAppsClient) ListConfigurationSnapshotInfo(ctx context.Context, id commonids.AppServiceId) (result ListConfigurationSnapshotInfoOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListConfigurationSnapshotInfoCustomPager{}, + Path: fmt.Sprintf("%s/config/web/snapshots", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SiteConfigurationSnapshotInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListConfigurationSnapshotInfoComplete retrieves all the results into a single object +func (c WebAppsClient) ListConfigurationSnapshotInfoComplete(ctx context.Context, id commonids.AppServiceId) (ListConfigurationSnapshotInfoCompleteResult, error) { + return c.ListConfigurationSnapshotInfoCompleteMatchingPredicate(ctx, id, SiteConfigurationSnapshotInfoOperationPredicate{}) +} + +// ListConfigurationSnapshotInfoCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListConfigurationSnapshotInfoCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SiteConfigurationSnapshotInfoOperationPredicate) (result ListConfigurationSnapshotInfoCompleteResult, err error) { + items := make([]SiteConfigurationSnapshotInfo, 0) + + resp, err := c.ListConfigurationSnapshotInfo(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListConfigurationSnapshotInfoCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listconfigurationsnapshotinfoslot.go b/resource-manager/web/2024-11-01/webapps/method_listconfigurationsnapshotinfoslot.go new file mode 100644 index 00000000000..cef77008f85 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listconfigurationsnapshotinfoslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListConfigurationSnapshotInfoSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteConfigurationSnapshotInfo +} + +type ListConfigurationSnapshotInfoSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteConfigurationSnapshotInfo +} + +type ListConfigurationSnapshotInfoSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListConfigurationSnapshotInfoSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListConfigurationSnapshotInfoSlot ... +func (c WebAppsClient) ListConfigurationSnapshotInfoSlot(ctx context.Context, id SlotId) (result ListConfigurationSnapshotInfoSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListConfigurationSnapshotInfoSlotCustomPager{}, + Path: fmt.Sprintf("%s/config/web/snapshots", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SiteConfigurationSnapshotInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListConfigurationSnapshotInfoSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListConfigurationSnapshotInfoSlotComplete(ctx context.Context, id SlotId) (ListConfigurationSnapshotInfoSlotCompleteResult, error) { + return c.ListConfigurationSnapshotInfoSlotCompleteMatchingPredicate(ctx, id, SiteConfigurationSnapshotInfoOperationPredicate{}) +} + +// ListConfigurationSnapshotInfoSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListConfigurationSnapshotInfoSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteConfigurationSnapshotInfoOperationPredicate) (result ListConfigurationSnapshotInfoSlotCompleteResult, err error) { + items := make([]SiteConfigurationSnapshotInfo, 0) + + resp, err := c.ListConfigurationSnapshotInfoSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListConfigurationSnapshotInfoSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listconfigurationsslot.go b/resource-manager/web/2024-11-01/webapps/method_listconfigurationsslot.go new file mode 100644 index 00000000000..4e3d0acefe3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listconfigurationsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListConfigurationsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteConfigResource +} + +type ListConfigurationsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteConfigResource +} + +type ListConfigurationsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListConfigurationsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListConfigurationsSlot ... +func (c WebAppsClient) ListConfigurationsSlot(ctx context.Context, id SlotId) (result ListConfigurationsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListConfigurationsSlotCustomPager{}, + Path: fmt.Sprintf("%s/config", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SiteConfigResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListConfigurationsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListConfigurationsSlotComplete(ctx context.Context, id SlotId) (ListConfigurationsSlotCompleteResult, error) { + return c.ListConfigurationsSlotCompleteMatchingPredicate(ctx, id, SiteConfigResourceOperationPredicate{}) +} + +// ListConfigurationsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListConfigurationsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteConfigResourceOperationPredicate) (result ListConfigurationsSlotCompleteResult, err error) { + items := make([]SiteConfigResource, 0) + + resp, err := c.ListConfigurationsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListConfigurationsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listconnectionstrings.go b/resource-manager/web/2024-11-01/webapps/method_listconnectionstrings.go new file mode 100644 index 00000000000..64554b4fd90 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listconnectionstrings.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListConnectionStringsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionStringDictionary +} + +// ListConnectionStrings ... +func (c WebAppsClient) ListConnectionStrings(ctx context.Context, id commonids.AppServiceId) (result ListConnectionStringsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/connectionStrings/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectionStringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listconnectionstringsslot.go b/resource-manager/web/2024-11-01/webapps/method_listconnectionstringsslot.go new file mode 100644 index 00000000000..4f5c82268e8 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listconnectionstringsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListConnectionStringsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionStringDictionary +} + +// ListConnectionStringsSlot ... +func (c WebAppsClient) ListConnectionStringsSlot(ctx context.Context, id SlotId) (result ListConnectionStringsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/connectionStrings/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectionStringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listcontinuouswebjobs.go b/resource-manager/web/2024-11-01/webapps/method_listcontinuouswebjobs.go new file mode 100644 index 00000000000..63d3df76b91 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listcontinuouswebjobs.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListContinuousWebJobsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContinuousWebJob +} + +type ListContinuousWebJobsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ContinuousWebJob +} + +type ListContinuousWebJobsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListContinuousWebJobsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListContinuousWebJobs ... +func (c WebAppsClient) ListContinuousWebJobs(ctx context.Context, id commonids.AppServiceId) (result ListContinuousWebJobsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListContinuousWebJobsCustomPager{}, + Path: fmt.Sprintf("%s/continuousWebJobs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ContinuousWebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListContinuousWebJobsComplete retrieves all the results into a single object +func (c WebAppsClient) ListContinuousWebJobsComplete(ctx context.Context, id commonids.AppServiceId) (ListContinuousWebJobsCompleteResult, error) { + return c.ListContinuousWebJobsCompleteMatchingPredicate(ctx, id, ContinuousWebJobOperationPredicate{}) +} + +// ListContinuousWebJobsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListContinuousWebJobsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate ContinuousWebJobOperationPredicate) (result ListContinuousWebJobsCompleteResult, err error) { + items := make([]ContinuousWebJob, 0) + + resp, err := c.ListContinuousWebJobs(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListContinuousWebJobsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listcontinuouswebjobsslot.go b/resource-manager/web/2024-11-01/webapps/method_listcontinuouswebjobsslot.go new file mode 100644 index 00000000000..f187ed28ce3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listcontinuouswebjobsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListContinuousWebJobsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ContinuousWebJob +} + +type ListContinuousWebJobsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ContinuousWebJob +} + +type ListContinuousWebJobsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListContinuousWebJobsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListContinuousWebJobsSlot ... +func (c WebAppsClient) ListContinuousWebJobsSlot(ctx context.Context, id SlotId) (result ListContinuousWebJobsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListContinuousWebJobsSlotCustomPager{}, + Path: fmt.Sprintf("%s/continuousWebJobs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ContinuousWebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListContinuousWebJobsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListContinuousWebJobsSlotComplete(ctx context.Context, id SlotId) (ListContinuousWebJobsSlotCompleteResult, error) { + return c.ListContinuousWebJobsSlotCompleteMatchingPredicate(ctx, id, ContinuousWebJobOperationPredicate{}) +} + +// ListContinuousWebJobsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListContinuousWebJobsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ContinuousWebJobOperationPredicate) (result ListContinuousWebJobsSlotCompleteResult, err error) { + items := make([]ContinuousWebJob, 0) + + resp, err := c.ListContinuousWebJobsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListContinuousWebJobsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listdeploymentlog.go b/resource-manager/web/2024-11-01/webapps/method_listdeploymentlog.go new file mode 100644 index 00000000000..c08913fb632 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listdeploymentlog.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListDeploymentLogOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// ListDeploymentLog ... +func (c WebAppsClient) ListDeploymentLog(ctx context.Context, id DeploymentId) (result ListDeploymentLogOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/log", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Deployment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listdeploymentlogslot.go b/resource-manager/web/2024-11-01/webapps/method_listdeploymentlogslot.go new file mode 100644 index 00000000000..ac50302c638 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listdeploymentlogslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListDeploymentLogSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Deployment +} + +// ListDeploymentLogSlot ... +func (c WebAppsClient) ListDeploymentLogSlot(ctx context.Context, id SlotDeploymentId) (result ListDeploymentLogSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/log", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Deployment + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listdeployments.go b/resource-manager/web/2024-11-01/webapps/method_listdeployments.go new file mode 100644 index 00000000000..62fe0173758 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listdeployments.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListDeploymentsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Deployment +} + +type ListDeploymentsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Deployment +} + +type ListDeploymentsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListDeploymentsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListDeployments ... +func (c WebAppsClient) ListDeployments(ctx context.Context, id commonids.AppServiceId) (result ListDeploymentsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListDeploymentsCustomPager{}, + Path: fmt.Sprintf("%s/deployments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Deployment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDeploymentsComplete retrieves all the results into a single object +func (c WebAppsClient) ListDeploymentsComplete(ctx context.Context, id commonids.AppServiceId) (ListDeploymentsCompleteResult, error) { + return c.ListDeploymentsCompleteMatchingPredicate(ctx, id, DeploymentOperationPredicate{}) +} + +// ListDeploymentsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListDeploymentsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate DeploymentOperationPredicate) (result ListDeploymentsCompleteResult, err error) { + items := make([]Deployment, 0) + + resp, err := c.ListDeployments(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListDeploymentsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listdeploymentsslot.go b/resource-manager/web/2024-11-01/webapps/method_listdeploymentsslot.go new file mode 100644 index 00000000000..d42866c7b88 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listdeploymentsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListDeploymentsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Deployment +} + +type ListDeploymentsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []Deployment +} + +type ListDeploymentsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListDeploymentsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListDeploymentsSlot ... +func (c WebAppsClient) ListDeploymentsSlot(ctx context.Context, id SlotId) (result ListDeploymentsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListDeploymentsSlotCustomPager{}, + Path: fmt.Sprintf("%s/deployments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Deployment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDeploymentsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListDeploymentsSlotComplete(ctx context.Context, id SlotId) (ListDeploymentsSlotCompleteResult, error) { + return c.ListDeploymentsSlotCompleteMatchingPredicate(ctx, id, DeploymentOperationPredicate{}) +} + +// ListDeploymentsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListDeploymentsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate DeploymentOperationPredicate) (result ListDeploymentsSlotCompleteResult, err error) { + items := make([]Deployment, 0) + + resp, err := c.ListDeploymentsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListDeploymentsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listdomainownershipidentifiers.go b/resource-manager/web/2024-11-01/webapps/method_listdomainownershipidentifiers.go new file mode 100644 index 00000000000..113e62c90b8 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listdomainownershipidentifiers.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListDomainOwnershipIdentifiersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Identifier +} + +type ListDomainOwnershipIdentifiersCompleteResult struct { + LatestHttpResponse *http.Response + Items []Identifier +} + +type ListDomainOwnershipIdentifiersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListDomainOwnershipIdentifiersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListDomainOwnershipIdentifiers ... +func (c WebAppsClient) ListDomainOwnershipIdentifiers(ctx context.Context, id commonids.AppServiceId) (result ListDomainOwnershipIdentifiersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListDomainOwnershipIdentifiersCustomPager{}, + Path: fmt.Sprintf("%s/domainOwnershipIdentifiers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Identifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDomainOwnershipIdentifiersComplete retrieves all the results into a single object +func (c WebAppsClient) ListDomainOwnershipIdentifiersComplete(ctx context.Context, id commonids.AppServiceId) (ListDomainOwnershipIdentifiersCompleteResult, error) { + return c.ListDomainOwnershipIdentifiersCompleteMatchingPredicate(ctx, id, IdentifierOperationPredicate{}) +} + +// ListDomainOwnershipIdentifiersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListDomainOwnershipIdentifiersCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate IdentifierOperationPredicate) (result ListDomainOwnershipIdentifiersCompleteResult, err error) { + items := make([]Identifier, 0) + + resp, err := c.ListDomainOwnershipIdentifiers(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListDomainOwnershipIdentifiersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listdomainownershipidentifiersslot.go b/resource-manager/web/2024-11-01/webapps/method_listdomainownershipidentifiersslot.go new file mode 100644 index 00000000000..8bf54d7bc37 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listdomainownershipidentifiersslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListDomainOwnershipIdentifiersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Identifier +} + +type ListDomainOwnershipIdentifiersSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []Identifier +} + +type ListDomainOwnershipIdentifiersSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListDomainOwnershipIdentifiersSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListDomainOwnershipIdentifiersSlot ... +func (c WebAppsClient) ListDomainOwnershipIdentifiersSlot(ctx context.Context, id SlotId) (result ListDomainOwnershipIdentifiersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListDomainOwnershipIdentifiersSlotCustomPager{}, + Path: fmt.Sprintf("%s/domainOwnershipIdentifiers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Identifier `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListDomainOwnershipIdentifiersSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListDomainOwnershipIdentifiersSlotComplete(ctx context.Context, id SlotId) (ListDomainOwnershipIdentifiersSlotCompleteResult, error) { + return c.ListDomainOwnershipIdentifiersSlotCompleteMatchingPredicate(ctx, id, IdentifierOperationPredicate{}) +} + +// ListDomainOwnershipIdentifiersSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListDomainOwnershipIdentifiersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate IdentifierOperationPredicate) (result ListDomainOwnershipIdentifiersSlotCompleteResult, err error) { + items := make([]Identifier, 0) + + resp, err := c.ListDomainOwnershipIdentifiersSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListDomainOwnershipIdentifiersSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listfunctionkeys.go b/resource-manager/web/2024-11-01/webapps/method_listfunctionkeys.go new file mode 100644 index 00000000000..8408b4dae45 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listfunctionkeys.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListFunctionKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListFunctionKeys ... +func (c WebAppsClient) ListFunctionKeys(ctx context.Context, id FunctionId) (result ListFunctionKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listfunctionkeysslot.go b/resource-manager/web/2024-11-01/webapps/method_listfunctionkeysslot.go new file mode 100644 index 00000000000..08a6e0172a6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listfunctionkeysslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListFunctionKeysSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListFunctionKeysSlot ... +func (c WebAppsClient) ListFunctionKeysSlot(ctx context.Context, id SlotFunctionId) (result ListFunctionKeysSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listfunctions.go b/resource-manager/web/2024-11-01/webapps/method_listfunctions.go new file mode 100644 index 00000000000..bec63cb0d75 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listfunctions.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListFunctionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FunctionEnvelope +} + +type ListFunctionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []FunctionEnvelope +} + +type ListFunctionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListFunctionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListFunctions ... +func (c WebAppsClient) ListFunctions(ctx context.Context, id commonids.AppServiceId) (result ListFunctionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListFunctionsCustomPager{}, + Path: fmt.Sprintf("%s/functions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FunctionEnvelope `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListFunctionsComplete retrieves all the results into a single object +func (c WebAppsClient) ListFunctionsComplete(ctx context.Context, id commonids.AppServiceId) (ListFunctionsCompleteResult, error) { + return c.ListFunctionsCompleteMatchingPredicate(ctx, id, FunctionEnvelopeOperationPredicate{}) +} + +// ListFunctionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListFunctionsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate FunctionEnvelopeOperationPredicate) (result ListFunctionsCompleteResult, err error) { + items := make([]FunctionEnvelope, 0) + + resp, err := c.ListFunctions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListFunctionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listfunctionsecrets.go b/resource-manager/web/2024-11-01/webapps/method_listfunctionsecrets.go new file mode 100644 index 00000000000..45eb50cf982 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listfunctionsecrets.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListFunctionSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionSecrets +} + +// ListFunctionSecrets ... +func (c WebAppsClient) ListFunctionSecrets(ctx context.Context, id FunctionId) (result ListFunctionSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listsecrets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FunctionSecrets + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listfunctionsecretsslot.go b/resource-manager/web/2024-11-01/webapps/method_listfunctionsecretsslot.go new file mode 100644 index 00000000000..15de188c3d5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listfunctionsecretsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListFunctionSecretsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionSecrets +} + +// ListFunctionSecretsSlot ... +func (c WebAppsClient) ListFunctionSecretsSlot(ctx context.Context, id SlotFunctionId) (result ListFunctionSecretsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listsecrets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FunctionSecrets + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listhostkeys.go b/resource-manager/web/2024-11-01/webapps/method_listhostkeys.go new file mode 100644 index 00000000000..fabdace3a5d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listhostkeys.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListHostKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostKeys +} + +// ListHostKeys ... +func (c WebAppsClient) ListHostKeys(ctx context.Context, id commonids.AppServiceId) (result ListHostKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HostKeys + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listhostkeysslot.go b/resource-manager/web/2024-11-01/webapps/method_listhostkeysslot.go new file mode 100644 index 00000000000..750e7a12832 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listhostkeysslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListHostKeysSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HostKeys +} + +// ListHostKeysSlot ... +func (c WebAppsClient) ListHostKeysSlot(ctx context.Context, id SlotId) (result ListHostKeysSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HostKeys + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listhostnamebindings.go b/resource-manager/web/2024-11-01/webapps/method_listhostnamebindings.go new file mode 100644 index 00000000000..3dc80a9cfb7 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listhostnamebindings.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListHostNameBindingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HostNameBinding +} + +type ListHostNameBindingsCompleteResult struct { + LatestHttpResponse *http.Response + Items []HostNameBinding +} + +type ListHostNameBindingsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListHostNameBindingsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListHostNameBindings ... +func (c WebAppsClient) ListHostNameBindings(ctx context.Context, id commonids.AppServiceId) (result ListHostNameBindingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListHostNameBindingsCustomPager{}, + Path: fmt.Sprintf("%s/hostNameBindings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]HostNameBinding `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHostNameBindingsComplete retrieves all the results into a single object +func (c WebAppsClient) ListHostNameBindingsComplete(ctx context.Context, id commonids.AppServiceId) (ListHostNameBindingsCompleteResult, error) { + return c.ListHostNameBindingsCompleteMatchingPredicate(ctx, id, HostNameBindingOperationPredicate{}) +} + +// ListHostNameBindingsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListHostNameBindingsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate HostNameBindingOperationPredicate) (result ListHostNameBindingsCompleteResult, err error) { + items := make([]HostNameBinding, 0) + + resp, err := c.ListHostNameBindings(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListHostNameBindingsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listhostnamebindingsslot.go b/resource-manager/web/2024-11-01/webapps/method_listhostnamebindingsslot.go new file mode 100644 index 00000000000..e2425090bce --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listhostnamebindingsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListHostNameBindingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]HostNameBinding +} + +type ListHostNameBindingsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []HostNameBinding +} + +type ListHostNameBindingsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListHostNameBindingsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListHostNameBindingsSlot ... +func (c WebAppsClient) ListHostNameBindingsSlot(ctx context.Context, id SlotId) (result ListHostNameBindingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListHostNameBindingsSlotCustomPager{}, + Path: fmt.Sprintf("%s/hostNameBindings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]HostNameBinding `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListHostNameBindingsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListHostNameBindingsSlotComplete(ctx context.Context, id SlotId) (ListHostNameBindingsSlotCompleteResult, error) { + return c.ListHostNameBindingsSlotCompleteMatchingPredicate(ctx, id, HostNameBindingOperationPredicate{}) +} + +// ListHostNameBindingsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListHostNameBindingsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate HostNameBindingOperationPredicate) (result ListHostNameBindingsSlotCompleteResult, err error) { + items := make([]HostNameBinding, 0) + + resp, err := c.ListHostNameBindingsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListHostNameBindingsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listhybridconnections.go b/resource-manager/web/2024-11-01/webapps/method_listhybridconnections.go new file mode 100644 index 00000000000..0aea9bb9d04 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listhybridconnections.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListHybridConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// ListHybridConnections ... +func (c WebAppsClient) ListHybridConnections(ctx context.Context, id commonids.AppServiceId) (result ListHybridConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnectionRelays", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listhybridconnectionsslot.go b/resource-manager/web/2024-11-01/webapps/method_listhybridconnectionsslot.go new file mode 100644 index 00000000000..d6ec6a8ec2b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listhybridconnectionsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListHybridConnectionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// ListHybridConnectionsSlot ... +func (c WebAppsClient) ListHybridConnectionsSlot(ctx context.Context, id SlotId) (result ListHybridConnectionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnectionRelays", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listinstancefunctionsslot.go b/resource-manager/web/2024-11-01/webapps/method_listinstancefunctionsslot.go new file mode 100644 index 00000000000..6c10eace684 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listinstancefunctionsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListInstanceFunctionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]FunctionEnvelope +} + +type ListInstanceFunctionsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []FunctionEnvelope +} + +type ListInstanceFunctionsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceFunctionsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceFunctionsSlot ... +func (c WebAppsClient) ListInstanceFunctionsSlot(ctx context.Context, id SlotId) (result ListInstanceFunctionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceFunctionsSlotCustomPager{}, + Path: fmt.Sprintf("%s/functions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FunctionEnvelope `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceFunctionsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceFunctionsSlotComplete(ctx context.Context, id SlotId) (ListInstanceFunctionsSlotCompleteResult, error) { + return c.ListInstanceFunctionsSlotCompleteMatchingPredicate(ctx, id, FunctionEnvelopeOperationPredicate{}) +} + +// ListInstanceFunctionsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceFunctionsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate FunctionEnvelopeOperationPredicate) (result ListInstanceFunctionsSlotCompleteResult, err error) { + items := make([]FunctionEnvelope, 0) + + resp, err := c.ListInstanceFunctionsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceFunctionsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listinstanceidentifiers.go b/resource-manager/web/2024-11-01/webapps/method_listinstanceidentifiers.go new file mode 100644 index 00000000000..62730a6aff2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listinstanceidentifiers.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListInstanceIdentifiersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebSiteInstanceStatus +} + +type ListInstanceIdentifiersCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebSiteInstanceStatus +} + +type ListInstanceIdentifiersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceIdentifiersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceIdentifiers ... +func (c WebAppsClient) ListInstanceIdentifiers(ctx context.Context, id commonids.AppServiceId) (result ListInstanceIdentifiersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceIdentifiersCustomPager{}, + Path: fmt.Sprintf("%s/instances", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WebSiteInstanceStatus `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceIdentifiersComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceIdentifiersComplete(ctx context.Context, id commonids.AppServiceId) (ListInstanceIdentifiersCompleteResult, error) { + return c.ListInstanceIdentifiersCompleteMatchingPredicate(ctx, id, WebSiteInstanceStatusOperationPredicate{}) +} + +// ListInstanceIdentifiersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceIdentifiersCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate WebSiteInstanceStatusOperationPredicate) (result ListInstanceIdentifiersCompleteResult, err error) { + items := make([]WebSiteInstanceStatus, 0) + + resp, err := c.ListInstanceIdentifiers(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceIdentifiersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listinstanceidentifiersslot.go b/resource-manager/web/2024-11-01/webapps/method_listinstanceidentifiersslot.go new file mode 100644 index 00000000000..65ad91633e2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listinstanceidentifiersslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListInstanceIdentifiersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebSiteInstanceStatus +} + +type ListInstanceIdentifiersSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebSiteInstanceStatus +} + +type ListInstanceIdentifiersSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceIdentifiersSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceIdentifiersSlot ... +func (c WebAppsClient) ListInstanceIdentifiersSlot(ctx context.Context, id SlotId) (result ListInstanceIdentifiersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceIdentifiersSlotCustomPager{}, + Path: fmt.Sprintf("%s/instances", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WebSiteInstanceStatus `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceIdentifiersSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceIdentifiersSlotComplete(ctx context.Context, id SlotId) (ListInstanceIdentifiersSlotCompleteResult, error) { + return c.ListInstanceIdentifiersSlotCompleteMatchingPredicate(ctx, id, WebSiteInstanceStatusOperationPredicate{}) +} + +// ListInstanceIdentifiersSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceIdentifiersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate WebSiteInstanceStatusOperationPredicate) (result ListInstanceIdentifiersSlotCompleteResult, err error) { + items := make([]WebSiteInstanceStatus, 0) + + resp, err := c.ListInstanceIdentifiersSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceIdentifiersSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listinstanceprocesses.go b/resource-manager/web/2024-11-01/webapps/method_listinstanceprocesses.go new file mode 100644 index 00000000000..7b596445609 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listinstanceprocesses.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListInstanceProcessesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessInfo +} + +type ListInstanceProcessesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessInfo +} + +type ListInstanceProcessesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceProcessesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceProcesses ... +func (c WebAppsClient) ListInstanceProcesses(ctx context.Context, id InstanceId) (result ListInstanceProcessesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceProcessesCustomPager{}, + Path: fmt.Sprintf("%s/processes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessesComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessesComplete(ctx context.Context, id InstanceId) (ListInstanceProcessesCompleteResult, error) { + return c.ListInstanceProcessesCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) +} + +// ListInstanceProcessesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessesCompleteMatchingPredicate(ctx context.Context, id InstanceId, predicate ProcessInfoOperationPredicate) (result ListInstanceProcessesCompleteResult, err error) { + items := make([]ProcessInfo, 0) + + resp, err := c.ListInstanceProcesses(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceProcessesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listinstanceprocessesslot.go b/resource-manager/web/2024-11-01/webapps/method_listinstanceprocessesslot.go new file mode 100644 index 00000000000..725411fb8b1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listinstanceprocessesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListInstanceProcessesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessInfo +} + +type ListInstanceProcessesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessInfo +} + +type ListInstanceProcessesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceProcessesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceProcessesSlot ... +func (c WebAppsClient) ListInstanceProcessesSlot(ctx context.Context, id SlotInstanceId) (result ListInstanceProcessesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceProcessesSlotCustomPager{}, + Path: fmt.Sprintf("%s/processes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessesSlotComplete(ctx context.Context, id SlotInstanceId) (ListInstanceProcessesSlotCompleteResult, error) { + return c.ListInstanceProcessesSlotCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) +} + +// ListInstanceProcessesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessesSlotCompleteMatchingPredicate(ctx context.Context, id SlotInstanceId, predicate ProcessInfoOperationPredicate) (result ListInstanceProcessesSlotCompleteResult, err error) { + items := make([]ProcessInfo, 0) + + resp, err := c.ListInstanceProcessesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceProcessesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listinstanceprocessmodules.go b/resource-manager/web/2024-11-01/webapps/method_listinstanceprocessmodules.go new file mode 100644 index 00000000000..113a7dd68a6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listinstanceprocessmodules.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListInstanceProcessModulesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessModuleInfo +} + +type ListInstanceProcessModulesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessModuleInfo +} + +type ListInstanceProcessModulesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceProcessModulesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceProcessModules ... +func (c WebAppsClient) ListInstanceProcessModules(ctx context.Context, id InstanceProcessId) (result ListInstanceProcessModulesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceProcessModulesCustomPager{}, + Path: fmt.Sprintf("%s/modules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessModuleInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessModulesComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessModulesComplete(ctx context.Context, id InstanceProcessId) (ListInstanceProcessModulesCompleteResult, error) { + return c.ListInstanceProcessModulesCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) +} + +// ListInstanceProcessModulesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessModulesCompleteMatchingPredicate(ctx context.Context, id InstanceProcessId, predicate ProcessModuleInfoOperationPredicate) (result ListInstanceProcessModulesCompleteResult, err error) { + items := make([]ProcessModuleInfo, 0) + + resp, err := c.ListInstanceProcessModules(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceProcessModulesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listinstanceprocessmodulesslot.go b/resource-manager/web/2024-11-01/webapps/method_listinstanceprocessmodulesslot.go new file mode 100644 index 00000000000..23d09675fe8 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listinstanceprocessmodulesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListInstanceProcessModulesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessModuleInfo +} + +type ListInstanceProcessModulesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessModuleInfo +} + +type ListInstanceProcessModulesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceProcessModulesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceProcessModulesSlot ... +func (c WebAppsClient) ListInstanceProcessModulesSlot(ctx context.Context, id SlotInstanceProcessId) (result ListInstanceProcessModulesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceProcessModulesSlotCustomPager{}, + Path: fmt.Sprintf("%s/modules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessModuleInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessModulesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessModulesSlotComplete(ctx context.Context, id SlotInstanceProcessId) (ListInstanceProcessModulesSlotCompleteResult, error) { + return c.ListInstanceProcessModulesSlotCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) +} + +// ListInstanceProcessModulesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessModulesSlotCompleteMatchingPredicate(ctx context.Context, id SlotInstanceProcessId, predicate ProcessModuleInfoOperationPredicate) (result ListInstanceProcessModulesSlotCompleteResult, err error) { + items := make([]ProcessModuleInfo, 0) + + resp, err := c.ListInstanceProcessModulesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceProcessModulesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listinstanceprocessthreads.go b/resource-manager/web/2024-11-01/webapps/method_listinstanceprocessthreads.go new file mode 100644 index 00000000000..82d9b44dc60 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listinstanceprocessthreads.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListInstanceProcessThreadsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessThreadInfo +} + +type ListInstanceProcessThreadsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessThreadInfo +} + +type ListInstanceProcessThreadsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceProcessThreadsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceProcessThreads ... +func (c WebAppsClient) ListInstanceProcessThreads(ctx context.Context, id InstanceProcessId) (result ListInstanceProcessThreadsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceProcessThreadsCustomPager{}, + Path: fmt.Sprintf("%s/threads", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessThreadInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessThreadsComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessThreadsComplete(ctx context.Context, id InstanceProcessId) (ListInstanceProcessThreadsCompleteResult, error) { + return c.ListInstanceProcessThreadsCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) +} + +// ListInstanceProcessThreadsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessThreadsCompleteMatchingPredicate(ctx context.Context, id InstanceProcessId, predicate ProcessThreadInfoOperationPredicate) (result ListInstanceProcessThreadsCompleteResult, err error) { + items := make([]ProcessThreadInfo, 0) + + resp, err := c.ListInstanceProcessThreads(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceProcessThreadsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listinstanceprocessthreadsslot.go b/resource-manager/web/2024-11-01/webapps/method_listinstanceprocessthreadsslot.go new file mode 100644 index 00000000000..513fe67c6a7 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listinstanceprocessthreadsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListInstanceProcessThreadsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessThreadInfo +} + +type ListInstanceProcessThreadsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessThreadInfo +} + +type ListInstanceProcessThreadsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceProcessThreadsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceProcessThreadsSlot ... +func (c WebAppsClient) ListInstanceProcessThreadsSlot(ctx context.Context, id SlotInstanceProcessId) (result ListInstanceProcessThreadsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceProcessThreadsSlotCustomPager{}, + Path: fmt.Sprintf("%s/threads", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessThreadInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceProcessThreadsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceProcessThreadsSlotComplete(ctx context.Context, id SlotInstanceProcessId) (ListInstanceProcessThreadsSlotCompleteResult, error) { + return c.ListInstanceProcessThreadsSlotCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) +} + +// ListInstanceProcessThreadsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceProcessThreadsSlotCompleteMatchingPredicate(ctx context.Context, id SlotInstanceProcessId, predicate ProcessThreadInfoOperationPredicate) (result ListInstanceProcessThreadsSlotCompleteResult, err error) { + items := make([]ProcessThreadInfo, 0) + + resp, err := c.ListInstanceProcessThreadsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceProcessThreadsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listinstanceworkflowsslot.go b/resource-manager/web/2024-11-01/webapps/method_listinstanceworkflowsslot.go new file mode 100644 index 00000000000..472996214b1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listinstanceworkflowsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListInstanceWorkflowsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowEnvelope +} + +type ListInstanceWorkflowsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowEnvelope +} + +type ListInstanceWorkflowsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListInstanceWorkflowsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListInstanceWorkflowsSlot ... +func (c WebAppsClient) ListInstanceWorkflowsSlot(ctx context.Context, id SlotId) (result ListInstanceWorkflowsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListInstanceWorkflowsSlotCustomPager{}, + Path: fmt.Sprintf("%s/workflows", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowEnvelope `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListInstanceWorkflowsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListInstanceWorkflowsSlotComplete(ctx context.Context, id SlotId) (ListInstanceWorkflowsSlotCompleteResult, error) { + return c.ListInstanceWorkflowsSlotCompleteMatchingPredicate(ctx, id, WorkflowEnvelopeOperationPredicate{}) +} + +// ListInstanceWorkflowsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListInstanceWorkflowsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate WorkflowEnvelopeOperationPredicate) (result ListInstanceWorkflowsSlotCompleteResult, err error) { + items := make([]WorkflowEnvelope, 0) + + resp, err := c.ListInstanceWorkflowsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListInstanceWorkflowsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listmetadata.go b/resource-manager/web/2024-11-01/webapps/method_listmetadata.go new file mode 100644 index 00000000000..8998ba62c0d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listmetadata.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListMetadataOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListMetadata ... +func (c WebAppsClient) ListMetadata(ctx context.Context, id commonids.AppServiceId) (result ListMetadataOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/metadata/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listmetadataslot.go b/resource-manager/web/2024-11-01/webapps/method_listmetadataslot.go new file mode 100644 index 00000000000..b2dcfca269d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listmetadataslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListMetadataSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// ListMetadataSlot ... +func (c WebAppsClient) ListMetadataSlot(ctx context.Context, id SlotId) (result ListMetadataSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/metadata/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listnetworkfeatures.go b/resource-manager/web/2024-11-01/webapps/method_listnetworkfeatures.go new file mode 100644 index 00000000000..fde1a7c3d73 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listnetworkfeatures.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListNetworkFeaturesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkFeatures +} + +// ListNetworkFeatures ... +func (c WebAppsClient) ListNetworkFeatures(ctx context.Context, id NetworkFeatureId) (result ListNetworkFeaturesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkFeatures + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listnetworkfeaturesslot.go b/resource-manager/web/2024-11-01/webapps/method_listnetworkfeaturesslot.go new file mode 100644 index 00000000000..c91b5baede0 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listnetworkfeaturesslot.go @@ -0,0 +1,53 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListNetworkFeaturesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NetworkFeatures +} + +// ListNetworkFeaturesSlot ... +func (c WebAppsClient) ListNetworkFeaturesSlot(ctx context.Context, id SlotNetworkFeatureId) (result ListNetworkFeaturesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NetworkFeatures + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listperfmoncounters.go b/resource-manager/web/2024-11-01/webapps/method_listperfmoncounters.go new file mode 100644 index 00000000000..ab98305afda --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listperfmoncounters.go @@ -0,0 +1,135 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListPerfMonCountersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PerfMonResponse +} + +type ListPerfMonCountersCompleteResult struct { + LatestHttpResponse *http.Response + Items []PerfMonResponse +} + +type ListPerfMonCountersOperationOptions struct { + Filter *string +} + +func DefaultListPerfMonCountersOperationOptions() ListPerfMonCountersOperationOptions { + return ListPerfMonCountersOperationOptions{} +} + +func (o ListPerfMonCountersOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListPerfMonCountersOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListPerfMonCountersOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListPerfMonCountersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListPerfMonCountersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListPerfMonCounters ... +func (c WebAppsClient) ListPerfMonCounters(ctx context.Context, id commonids.AppServiceId, options ListPerfMonCountersOperationOptions) (result ListPerfMonCountersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListPerfMonCountersCustomPager{}, + Path: fmt.Sprintf("%s/perfcounters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PerfMonResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPerfMonCountersComplete retrieves all the results into a single object +func (c WebAppsClient) ListPerfMonCountersComplete(ctx context.Context, id commonids.AppServiceId, options ListPerfMonCountersOperationOptions) (ListPerfMonCountersCompleteResult, error) { + return c.ListPerfMonCountersCompleteMatchingPredicate(ctx, id, options, PerfMonResponseOperationPredicate{}) +} + +// ListPerfMonCountersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListPerfMonCountersCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, options ListPerfMonCountersOperationOptions, predicate PerfMonResponseOperationPredicate) (result ListPerfMonCountersCompleteResult, err error) { + items := make([]PerfMonResponse, 0) + + resp, err := c.ListPerfMonCounters(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListPerfMonCountersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listperfmoncountersslot.go b/resource-manager/web/2024-11-01/webapps/method_listperfmoncountersslot.go new file mode 100644 index 00000000000..b82ebb85e22 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listperfmoncountersslot.go @@ -0,0 +1,134 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListPerfMonCountersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PerfMonResponse +} + +type ListPerfMonCountersSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []PerfMonResponse +} + +type ListPerfMonCountersSlotOperationOptions struct { + Filter *string +} + +func DefaultListPerfMonCountersSlotOperationOptions() ListPerfMonCountersSlotOperationOptions { + return ListPerfMonCountersSlotOperationOptions{} +} + +func (o ListPerfMonCountersSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListPerfMonCountersSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListPerfMonCountersSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListPerfMonCountersSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListPerfMonCountersSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListPerfMonCountersSlot ... +func (c WebAppsClient) ListPerfMonCountersSlot(ctx context.Context, id SlotId, options ListPerfMonCountersSlotOperationOptions) (result ListPerfMonCountersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListPerfMonCountersSlotCustomPager{}, + Path: fmt.Sprintf("%s/perfcounters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PerfMonResponse `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPerfMonCountersSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListPerfMonCountersSlotComplete(ctx context.Context, id SlotId, options ListPerfMonCountersSlotOperationOptions) (ListPerfMonCountersSlotCompleteResult, error) { + return c.ListPerfMonCountersSlotCompleteMatchingPredicate(ctx, id, options, PerfMonResponseOperationPredicate{}) +} + +// ListPerfMonCountersSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListPerfMonCountersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, options ListPerfMonCountersSlotOperationOptions, predicate PerfMonResponseOperationPredicate) (result ListPerfMonCountersSlotCompleteResult, err error) { + items := make([]PerfMonResponse, 0) + + resp, err := c.ListPerfMonCountersSlot(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListPerfMonCountersSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listpremieraddons.go b/resource-manager/web/2024-11-01/webapps/method_listpremieraddons.go new file mode 100644 index 00000000000..b11bf4233c3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listpremieraddons.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListPremierAddOnsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// ListPremierAddOns ... +func (c WebAppsClient) ListPremierAddOns(ctx context.Context, id commonids.AppServiceId) (result ListPremierAddOnsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/premierAddons", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PremierAddOn + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listpremieraddonsslot.go b/resource-manager/web/2024-11-01/webapps/method_listpremieraddonsslot.go new file mode 100644 index 00000000000..73dbf683ae9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listpremieraddonsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListPremierAddOnsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// ListPremierAddOnsSlot ... +func (c WebAppsClient) ListPremierAddOnsSlot(ctx context.Context, id SlotId) (result ListPremierAddOnsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/premierAddons", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PremierAddOn + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listprocesses.go b/resource-manager/web/2024-11-01/webapps/method_listprocesses.go new file mode 100644 index 00000000000..ebf1da0bcf9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listprocesses.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListProcessesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessInfo +} + +type ListProcessesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessInfo +} + +type ListProcessesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListProcessesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListProcesses ... +func (c WebAppsClient) ListProcesses(ctx context.Context, id commonids.AppServiceId) (result ListProcessesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListProcessesCustomPager{}, + Path: fmt.Sprintf("%s/processes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessesComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessesComplete(ctx context.Context, id commonids.AppServiceId) (ListProcessesCompleteResult, error) { + return c.ListProcessesCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) +} + +// ListProcessesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate ProcessInfoOperationPredicate) (result ListProcessesCompleteResult, err error) { + items := make([]ProcessInfo, 0) + + resp, err := c.ListProcesses(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListProcessesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listprocessesslot.go b/resource-manager/web/2024-11-01/webapps/method_listprocessesslot.go new file mode 100644 index 00000000000..d737e095497 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listprocessesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListProcessesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessInfo +} + +type ListProcessesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessInfo +} + +type ListProcessesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListProcessesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListProcessesSlot ... +func (c WebAppsClient) ListProcessesSlot(ctx context.Context, id SlotId) (result ListProcessesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListProcessesSlotCustomPager{}, + Path: fmt.Sprintf("%s/processes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessesSlotComplete(ctx context.Context, id SlotId) (ListProcessesSlotCompleteResult, error) { + return c.ListProcessesSlotCompleteMatchingPredicate(ctx, id, ProcessInfoOperationPredicate{}) +} + +// ListProcessesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate ProcessInfoOperationPredicate) (result ListProcessesSlotCompleteResult, err error) { + items := make([]ProcessInfo, 0) + + resp, err := c.ListProcessesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListProcessesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listprocessmodules.go b/resource-manager/web/2024-11-01/webapps/method_listprocessmodules.go new file mode 100644 index 00000000000..e1a3a6af39e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listprocessmodules.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListProcessModulesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessModuleInfo +} + +type ListProcessModulesCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessModuleInfo +} + +type ListProcessModulesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListProcessModulesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListProcessModules ... +func (c WebAppsClient) ListProcessModules(ctx context.Context, id ProcessId) (result ListProcessModulesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListProcessModulesCustomPager{}, + Path: fmt.Sprintf("%s/modules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessModuleInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessModulesComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessModulesComplete(ctx context.Context, id ProcessId) (ListProcessModulesCompleteResult, error) { + return c.ListProcessModulesCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) +} + +// ListProcessModulesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessModulesCompleteMatchingPredicate(ctx context.Context, id ProcessId, predicate ProcessModuleInfoOperationPredicate) (result ListProcessModulesCompleteResult, err error) { + items := make([]ProcessModuleInfo, 0) + + resp, err := c.ListProcessModules(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListProcessModulesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listprocessmodulesslot.go b/resource-manager/web/2024-11-01/webapps/method_listprocessmodulesslot.go new file mode 100644 index 00000000000..0ddc8a915f9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listprocessmodulesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListProcessModulesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessModuleInfo +} + +type ListProcessModulesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessModuleInfo +} + +type ListProcessModulesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListProcessModulesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListProcessModulesSlot ... +func (c WebAppsClient) ListProcessModulesSlot(ctx context.Context, id SlotProcessId) (result ListProcessModulesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListProcessModulesSlotCustomPager{}, + Path: fmt.Sprintf("%s/modules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessModuleInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessModulesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessModulesSlotComplete(ctx context.Context, id SlotProcessId) (ListProcessModulesSlotCompleteResult, error) { + return c.ListProcessModulesSlotCompleteMatchingPredicate(ctx, id, ProcessModuleInfoOperationPredicate{}) +} + +// ListProcessModulesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessModulesSlotCompleteMatchingPredicate(ctx context.Context, id SlotProcessId, predicate ProcessModuleInfoOperationPredicate) (result ListProcessModulesSlotCompleteResult, err error) { + items := make([]ProcessModuleInfo, 0) + + resp, err := c.ListProcessModulesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListProcessModulesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listprocessthreads.go b/resource-manager/web/2024-11-01/webapps/method_listprocessthreads.go new file mode 100644 index 00000000000..32356aa2170 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listprocessthreads.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListProcessThreadsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessThreadInfo +} + +type ListProcessThreadsCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessThreadInfo +} + +type ListProcessThreadsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListProcessThreadsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListProcessThreads ... +func (c WebAppsClient) ListProcessThreads(ctx context.Context, id ProcessId) (result ListProcessThreadsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListProcessThreadsCustomPager{}, + Path: fmt.Sprintf("%s/threads", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessThreadInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessThreadsComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessThreadsComplete(ctx context.Context, id ProcessId) (ListProcessThreadsCompleteResult, error) { + return c.ListProcessThreadsCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) +} + +// ListProcessThreadsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessThreadsCompleteMatchingPredicate(ctx context.Context, id ProcessId, predicate ProcessThreadInfoOperationPredicate) (result ListProcessThreadsCompleteResult, err error) { + items := make([]ProcessThreadInfo, 0) + + resp, err := c.ListProcessThreads(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListProcessThreadsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listprocessthreadsslot.go b/resource-manager/web/2024-11-01/webapps/method_listprocessthreadsslot.go new file mode 100644 index 00000000000..d3335f9f125 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listprocessthreadsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListProcessThreadsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ProcessThreadInfo +} + +type ListProcessThreadsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []ProcessThreadInfo +} + +type ListProcessThreadsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListProcessThreadsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListProcessThreadsSlot ... +func (c WebAppsClient) ListProcessThreadsSlot(ctx context.Context, id SlotProcessId) (result ListProcessThreadsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListProcessThreadsSlotCustomPager{}, + Path: fmt.Sprintf("%s/threads", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ProcessThreadInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProcessThreadsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListProcessThreadsSlotComplete(ctx context.Context, id SlotProcessId) (ListProcessThreadsSlotCompleteResult, error) { + return c.ListProcessThreadsSlotCompleteMatchingPredicate(ctx, id, ProcessThreadInfoOperationPredicate{}) +} + +// ListProcessThreadsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProcessThreadsSlotCompleteMatchingPredicate(ctx context.Context, id SlotProcessId, predicate ProcessThreadInfoOperationPredicate) (result ListProcessThreadsSlotCompleteResult, err error) { + items := make([]ProcessThreadInfo, 0) + + resp, err := c.ListProcessThreadsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListProcessThreadsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listproductionsitedeploymentstatuses.go b/resource-manager/web/2024-11-01/webapps/method_listproductionsitedeploymentstatuses.go new file mode 100644 index 00000000000..dbca4c9c5cf --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listproductionsitedeploymentstatuses.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListProductionSiteDeploymentStatusesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmDeploymentStatus +} + +type ListProductionSiteDeploymentStatusesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmDeploymentStatus +} + +type ListProductionSiteDeploymentStatusesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListProductionSiteDeploymentStatusesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListProductionSiteDeploymentStatuses ... +func (c WebAppsClient) ListProductionSiteDeploymentStatuses(ctx context.Context, id commonids.AppServiceId) (result ListProductionSiteDeploymentStatusesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListProductionSiteDeploymentStatusesCustomPager{}, + Path: fmt.Sprintf("%s/deploymentStatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmDeploymentStatus `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListProductionSiteDeploymentStatusesComplete retrieves all the results into a single object +func (c WebAppsClient) ListProductionSiteDeploymentStatusesComplete(ctx context.Context, id commonids.AppServiceId) (ListProductionSiteDeploymentStatusesCompleteResult, error) { + return c.ListProductionSiteDeploymentStatusesCompleteMatchingPredicate(ctx, id, CsmDeploymentStatusOperationPredicate{}) +} + +// ListProductionSiteDeploymentStatusesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListProductionSiteDeploymentStatusesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate CsmDeploymentStatusOperationPredicate) (result ListProductionSiteDeploymentStatusesCompleteResult, err error) { + items := make([]CsmDeploymentStatus, 0) + + resp, err := c.ListProductionSiteDeploymentStatuses(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListProductionSiteDeploymentStatusesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listpubliccertificates.go b/resource-manager/web/2024-11-01/webapps/method_listpubliccertificates.go new file mode 100644 index 00000000000..1566dc4e69f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listpubliccertificates.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListPublicCertificatesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PublicCertificate +} + +type ListPublicCertificatesCompleteResult struct { + LatestHttpResponse *http.Response + Items []PublicCertificate +} + +type ListPublicCertificatesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListPublicCertificatesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListPublicCertificates ... +func (c WebAppsClient) ListPublicCertificates(ctx context.Context, id commonids.AppServiceId) (result ListPublicCertificatesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListPublicCertificatesCustomPager{}, + Path: fmt.Sprintf("%s/publicCertificates", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PublicCertificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPublicCertificatesComplete retrieves all the results into a single object +func (c WebAppsClient) ListPublicCertificatesComplete(ctx context.Context, id commonids.AppServiceId) (ListPublicCertificatesCompleteResult, error) { + return c.ListPublicCertificatesCompleteMatchingPredicate(ctx, id, PublicCertificateOperationPredicate{}) +} + +// ListPublicCertificatesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListPublicCertificatesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate PublicCertificateOperationPredicate) (result ListPublicCertificatesCompleteResult, err error) { + items := make([]PublicCertificate, 0) + + resp, err := c.ListPublicCertificates(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListPublicCertificatesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listpubliccertificatesslot.go b/resource-manager/web/2024-11-01/webapps/method_listpubliccertificatesslot.go new file mode 100644 index 00000000000..fb63cdc093c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listpubliccertificatesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListPublicCertificatesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PublicCertificate +} + +type ListPublicCertificatesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []PublicCertificate +} + +type ListPublicCertificatesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListPublicCertificatesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListPublicCertificatesSlot ... +func (c WebAppsClient) ListPublicCertificatesSlot(ctx context.Context, id SlotId) (result ListPublicCertificatesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListPublicCertificatesSlotCustomPager{}, + Path: fmt.Sprintf("%s/publicCertificates", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]PublicCertificate `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListPublicCertificatesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListPublicCertificatesSlotComplete(ctx context.Context, id SlotId) (ListPublicCertificatesSlotCompleteResult, error) { + return c.ListPublicCertificatesSlotCompleteMatchingPredicate(ctx, id, PublicCertificateOperationPredicate{}) +} + +// ListPublicCertificatesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListPublicCertificatesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate PublicCertificateOperationPredicate) (result ListPublicCertificatesSlotCompleteResult, err error) { + items := make([]PublicCertificate, 0) + + resp, err := c.ListPublicCertificatesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListPublicCertificatesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listpublishingcredentials.go b/resource-manager/web/2024-11-01/webapps/method_listpublishingcredentials.go new file mode 100644 index 00000000000..3c3e5a7d373 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listpublishingcredentials.go @@ -0,0 +1,71 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListPublishingCredentialsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *User +} + +// ListPublishingCredentials ... +func (c WebAppsClient) ListPublishingCredentials(ctx context.Context, id commonids.AppServiceId) (result ListPublishingCredentialsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/publishingcredentials/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ListPublishingCredentialsThenPoll performs ListPublishingCredentials then polls until it's completed +func (c WebAppsClient) ListPublishingCredentialsThenPoll(ctx context.Context, id commonids.AppServiceId) error { + result, err := c.ListPublishingCredentials(ctx, id) + if err != nil { + return fmt.Errorf("performing ListPublishingCredentials: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ListPublishingCredentials: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listpublishingcredentialsslot.go b/resource-manager/web/2024-11-01/webapps/method_listpublishingcredentialsslot.go new file mode 100644 index 00000000000..6c38961b04a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listpublishingcredentialsslot.go @@ -0,0 +1,70 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListPublishingCredentialsSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *User +} + +// ListPublishingCredentialsSlot ... +func (c WebAppsClient) ListPublishingCredentialsSlot(ctx context.Context, id SlotId) (result ListPublishingCredentialsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/publishingcredentials/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ListPublishingCredentialsSlotThenPoll performs ListPublishingCredentialsSlot then polls until it's completed +func (c WebAppsClient) ListPublishingCredentialsSlotThenPoll(ctx context.Context, id SlotId) error { + result, err := c.ListPublishingCredentialsSlot(ctx, id) + if err != nil { + return fmt.Errorf("performing ListPublishingCredentialsSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ListPublishingCredentialsSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listpublishingprofilexmlwithsecrets.go b/resource-manager/web/2024-11-01/webapps/method_listpublishingprofilexmlwithsecrets.go new file mode 100644 index 00000000000..07b6308ca62 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listpublishingprofilexmlwithsecrets.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListPublishingProfileXmlWithSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// ListPublishingProfileXmlWithSecrets ... +func (c WebAppsClient) ListPublishingProfileXmlWithSecrets(ctx context.Context, id commonids.AppServiceId, input CsmPublishingProfileOptions) (result ListPublishingProfileXmlWithSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/publishxml", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listpublishingprofilexmlwithsecretsslot.go b/resource-manager/web/2024-11-01/webapps/method_listpublishingprofilexmlwithsecretsslot.go new file mode 100644 index 00000000000..7f32d269123 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listpublishingprofilexmlwithsecretsslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListPublishingProfileXmlWithSecretsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]byte +} + +// ListPublishingProfileXmlWithSecretsSlot ... +func (c WebAppsClient) ListPublishingProfileXmlWithSecretsSlot(ctx context.Context, id SlotId, input CsmPublishingProfileOptions) (result ListPublishingProfileXmlWithSecretsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/publishxml", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []byte + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listrelayserviceconnections.go b/resource-manager/web/2024-11-01/webapps/method_listrelayserviceconnections.go new file mode 100644 index 00000000000..de929a519e3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listrelayserviceconnections.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListRelayServiceConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// ListRelayServiceConnections ... +func (c WebAppsClient) ListRelayServiceConnections(ctx context.Context, id commonids.AppServiceId) (result ListRelayServiceConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnection", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RelayServiceConnectionEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listrelayserviceconnectionsslot.go b/resource-manager/web/2024-11-01/webapps/method_listrelayserviceconnectionsslot.go new file mode 100644 index 00000000000..56b6752c72f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listrelayserviceconnectionsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListRelayServiceConnectionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// ListRelayServiceConnectionsSlot ... +func (c WebAppsClient) ListRelayServiceConnectionsSlot(ctx context.Context, id SlotId) (result ListRelayServiceConnectionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/hybridConnection", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RelayServiceConnectionEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listsitebackups.go b/resource-manager/web/2024-11-01/webapps/method_listsitebackups.go new file mode 100644 index 00000000000..453b979ef15 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listsitebackups.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSiteBackupsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupItem +} + +type ListSiteBackupsCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackupItem +} + +type ListSiteBackupsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteBackupsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteBackups ... +func (c WebAppsClient) ListSiteBackups(ctx context.Context, id commonids.AppServiceId) (result ListSiteBackupsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListSiteBackupsCustomPager{}, + Path: fmt.Sprintf("%s/listbackups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BackupItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteBackupsComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteBackupsComplete(ctx context.Context, id commonids.AppServiceId) (ListSiteBackupsCompleteResult, error) { + return c.ListSiteBackupsCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) +} + +// ListSiteBackupsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteBackupsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate BackupItemOperationPredicate) (result ListSiteBackupsCompleteResult, err error) { + items := make([]BackupItem, 0) + + resp, err := c.ListSiteBackups(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteBackupsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listsitebackupsslot.go b/resource-manager/web/2024-11-01/webapps/method_listsitebackupsslot.go new file mode 100644 index 00000000000..4b1fa4a16f5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listsitebackupsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSiteBackupsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]BackupItem +} + +type ListSiteBackupsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []BackupItem +} + +type ListSiteBackupsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteBackupsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteBackupsSlot ... +func (c WebAppsClient) ListSiteBackupsSlot(ctx context.Context, id SlotId) (result ListSiteBackupsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListSiteBackupsSlotCustomPager{}, + Path: fmt.Sprintf("%s/listbackups", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BackupItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteBackupsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteBackupsSlotComplete(ctx context.Context, id SlotId) (ListSiteBackupsSlotCompleteResult, error) { + return c.ListSiteBackupsSlotCompleteMatchingPredicate(ctx, id, BackupItemOperationPredicate{}) +} + +// ListSiteBackupsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteBackupsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate BackupItemOperationPredicate) (result ListSiteBackupsSlotCompleteResult, err error) { + items := make([]BackupItem, 0) + + resp, err := c.ListSiteBackupsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteBackupsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listsitecontainers.go b/resource-manager/web/2024-11-01/webapps/method_listsitecontainers.go new file mode 100644 index 00000000000..b5451f754a5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listsitecontainers.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSiteContainersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteContainer +} + +type ListSiteContainersCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteContainer +} + +type ListSiteContainersCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteContainersCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteContainers ... +func (c WebAppsClient) ListSiteContainers(ctx context.Context, id commonids.AppServiceId) (result ListSiteContainersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteContainersCustomPager{}, + Path: fmt.Sprintf("%s/sitecontainers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SiteContainer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteContainersComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteContainersComplete(ctx context.Context, id commonids.AppServiceId) (ListSiteContainersCompleteResult, error) { + return c.ListSiteContainersCompleteMatchingPredicate(ctx, id, SiteContainerOperationPredicate{}) +} + +// ListSiteContainersCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteContainersCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SiteContainerOperationPredicate) (result ListSiteContainersCompleteResult, err error) { + items := make([]SiteContainer, 0) + + resp, err := c.ListSiteContainers(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteContainersCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listsitecontainersslot.go b/resource-manager/web/2024-11-01/webapps/method_listsitecontainersslot.go new file mode 100644 index 00000000000..ad7e84da3ef --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listsitecontainersslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSiteContainersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteContainer +} + +type ListSiteContainersSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteContainer +} + +type ListSiteContainersSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteContainersSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteContainersSlot ... +func (c WebAppsClient) ListSiteContainersSlot(ctx context.Context, id SlotId) (result ListSiteContainersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteContainersSlotCustomPager{}, + Path: fmt.Sprintf("%s/sitecontainers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SiteContainer `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteContainersSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteContainersSlotComplete(ctx context.Context, id SlotId) (ListSiteContainersSlotCompleteResult, error) { + return c.ListSiteContainersSlotCompleteMatchingPredicate(ctx, id, SiteContainerOperationPredicate{}) +} + +// ListSiteContainersSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteContainersSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteContainerOperationPredicate) (result ListSiteContainersSlotCompleteResult, err error) { + items := make([]SiteContainer, 0) + + resp, err := c.ListSiteContainersSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteContainersSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listsiteextensions.go b/resource-manager/web/2024-11-01/webapps/method_listsiteextensions.go new file mode 100644 index 00000000000..8541bc980ce --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listsiteextensions.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSiteExtensionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteExtensionInfo +} + +type ListSiteExtensionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteExtensionInfo +} + +type ListSiteExtensionsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteExtensionsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteExtensions ... +func (c WebAppsClient) ListSiteExtensions(ctx context.Context, id commonids.AppServiceId) (result ListSiteExtensionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteExtensionsCustomPager{}, + Path: fmt.Sprintf("%s/siteExtensions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SiteExtensionInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteExtensionsComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteExtensionsComplete(ctx context.Context, id commonids.AppServiceId) (ListSiteExtensionsCompleteResult, error) { + return c.ListSiteExtensionsCompleteMatchingPredicate(ctx, id, SiteExtensionInfoOperationPredicate{}) +} + +// ListSiteExtensionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteExtensionsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SiteExtensionInfoOperationPredicate) (result ListSiteExtensionsCompleteResult, err error) { + items := make([]SiteExtensionInfo, 0) + + resp, err := c.ListSiteExtensions(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteExtensionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listsiteextensionsslot.go b/resource-manager/web/2024-11-01/webapps/method_listsiteextensionsslot.go new file mode 100644 index 00000000000..b71b603d02f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listsiteextensionsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSiteExtensionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SiteExtensionInfo +} + +type ListSiteExtensionsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []SiteExtensionInfo +} + +type ListSiteExtensionsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSiteExtensionsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSiteExtensionsSlot ... +func (c WebAppsClient) ListSiteExtensionsSlot(ctx context.Context, id SlotId) (result ListSiteExtensionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSiteExtensionsSlotCustomPager{}, + Path: fmt.Sprintf("%s/siteExtensions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SiteExtensionInfo `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSiteExtensionsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSiteExtensionsSlotComplete(ctx context.Context, id SlotId) (ListSiteExtensionsSlotCompleteResult, error) { + return c.ListSiteExtensionsSlotCompleteMatchingPredicate(ctx, id, SiteExtensionInfoOperationPredicate{}) +} + +// ListSiteExtensionsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSiteExtensionsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SiteExtensionInfoOperationPredicate) (result ListSiteExtensionsSlotCompleteResult, err error) { + items := make([]SiteExtensionInfo, 0) + + resp, err := c.ListSiteExtensionsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSiteExtensionsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listsitepushsettings.go b/resource-manager/web/2024-11-01/webapps/method_listsitepushsettings.go new file mode 100644 index 00000000000..99b7cd099b7 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listsitepushsettings.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSitePushSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PushSettings +} + +// ListSitePushSettings ... +func (c WebAppsClient) ListSitePushSettings(ctx context.Context, id commonids.AppServiceId) (result ListSitePushSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/pushsettings/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PushSettings + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listsitepushsettingsslot.go b/resource-manager/web/2024-11-01/webapps/method_listsitepushsettingsslot.go new file mode 100644 index 00000000000..38b18425808 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listsitepushsettingsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSitePushSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PushSettings +} + +// ListSitePushSettingsSlot ... +func (c WebAppsClient) ListSitePushSettingsSlot(ctx context.Context, id SlotId) (result ListSitePushSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/config/pushsettings/list", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PushSettings + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listslotconfigurationnames.go b/resource-manager/web/2024-11-01/webapps/method_listslotconfigurationnames.go new file mode 100644 index 00000000000..ccfa9dc0e21 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listslotconfigurationnames.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSlotConfigurationNamesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SlotConfigNamesResource +} + +// ListSlotConfigurationNames ... +func (c WebAppsClient) ListSlotConfigurationNames(ctx context.Context, id commonids.AppServiceId) (result ListSlotConfigurationNamesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/config/slotConfigNames", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SlotConfigNamesResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listslotdifferencesfromproduction.go b/resource-manager/web/2024-11-01/webapps/method_listslotdifferencesfromproduction.go new file mode 100644 index 00000000000..8452739cf2b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listslotdifferencesfromproduction.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSlotDifferencesFromProductionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SlotDifference +} + +type ListSlotDifferencesFromProductionCompleteResult struct { + LatestHttpResponse *http.Response + Items []SlotDifference +} + +type ListSlotDifferencesFromProductionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSlotDifferencesFromProductionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSlotDifferencesFromProduction ... +func (c WebAppsClient) ListSlotDifferencesFromProduction(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity) (result ListSlotDifferencesFromProductionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListSlotDifferencesFromProductionCustomPager{}, + Path: fmt.Sprintf("%s/slotsdiffs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SlotDifference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSlotDifferencesFromProductionComplete retrieves all the results into a single object +func (c WebAppsClient) ListSlotDifferencesFromProductionComplete(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity) (ListSlotDifferencesFromProductionCompleteResult, error) { + return c.ListSlotDifferencesFromProductionCompleteMatchingPredicate(ctx, id, input, SlotDifferenceOperationPredicate{}) +} + +// ListSlotDifferencesFromProductionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSlotDifferencesFromProductionCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity, predicate SlotDifferenceOperationPredicate) (result ListSlotDifferencesFromProductionCompleteResult, err error) { + items := make([]SlotDifference, 0) + + resp, err := c.ListSlotDifferencesFromProduction(ctx, id, input) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSlotDifferencesFromProductionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listslotdifferencesslot.go b/resource-manager/web/2024-11-01/webapps/method_listslotdifferencesslot.go new file mode 100644 index 00000000000..7dad87c2b7a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listslotdifferencesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSlotDifferencesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SlotDifference +} + +type ListSlotDifferencesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []SlotDifference +} + +type ListSlotDifferencesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSlotDifferencesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSlotDifferencesSlot ... +func (c WebAppsClient) ListSlotDifferencesSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (result ListSlotDifferencesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListSlotDifferencesSlotCustomPager{}, + Path: fmt.Sprintf("%s/slotsdiffs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SlotDifference `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSlotDifferencesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSlotDifferencesSlotComplete(ctx context.Context, id SlotId, input CsmSlotEntity) (ListSlotDifferencesSlotCompleteResult, error) { + return c.ListSlotDifferencesSlotCompleteMatchingPredicate(ctx, id, input, SlotDifferenceOperationPredicate{}) +} + +// ListSlotDifferencesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSlotDifferencesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, input CsmSlotEntity, predicate SlotDifferenceOperationPredicate) (result ListSlotDifferencesSlotCompleteResult, err error) { + items := make([]SlotDifference, 0) + + resp, err := c.ListSlotDifferencesSlot(ctx, id, input) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSlotDifferencesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listslots.go b/resource-manager/web/2024-11-01/webapps/method_listslots.go new file mode 100644 index 00000000000..c76f15d5d03 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listslots.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSlotsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Site +} + +type ListSlotsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Site +} + +type ListSlotsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSlotsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSlots ... +func (c WebAppsClient) ListSlots(ctx context.Context, id commonids.AppServiceId) (result ListSlotsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSlotsCustomPager{}, + Path: fmt.Sprintf("%s/slots", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Site `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSlotsComplete retrieves all the results into a single object +func (c WebAppsClient) ListSlotsComplete(ctx context.Context, id commonids.AppServiceId) (ListSlotsCompleteResult, error) { + return c.ListSlotsCompleteMatchingPredicate(ctx, id, SiteOperationPredicate{}) +} + +// ListSlotsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSlotsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SiteOperationPredicate) (result ListSlotsCompleteResult, err error) { + items := make([]Site, 0) + + resp, err := c.ListSlots(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSlotsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listslotsitedeploymentstatusesslot.go b/resource-manager/web/2024-11-01/webapps/method_listslotsitedeploymentstatusesslot.go new file mode 100644 index 00000000000..8ceee87cc66 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listslotsitedeploymentstatusesslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSlotSiteDeploymentStatusesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmDeploymentStatus +} + +type ListSlotSiteDeploymentStatusesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmDeploymentStatus +} + +type ListSlotSiteDeploymentStatusesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSlotSiteDeploymentStatusesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSlotSiteDeploymentStatusesSlot ... +func (c WebAppsClient) ListSlotSiteDeploymentStatusesSlot(ctx context.Context, id SlotId) (result ListSlotSiteDeploymentStatusesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSlotSiteDeploymentStatusesSlotCustomPager{}, + Path: fmt.Sprintf("%s/deploymentStatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmDeploymentStatus `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSlotSiteDeploymentStatusesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSlotSiteDeploymentStatusesSlotComplete(ctx context.Context, id SlotId) (ListSlotSiteDeploymentStatusesSlotCompleteResult, error) { + return c.ListSlotSiteDeploymentStatusesSlotCompleteMatchingPredicate(ctx, id, CsmDeploymentStatusOperationPredicate{}) +} + +// ListSlotSiteDeploymentStatusesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSlotSiteDeploymentStatusesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate CsmDeploymentStatusOperationPredicate) (result ListSlotSiteDeploymentStatusesSlotCompleteResult, err error) { + items := make([]CsmDeploymentStatus, 0) + + resp, err := c.ListSlotSiteDeploymentStatusesSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSlotSiteDeploymentStatusesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listsnapshots.go b/resource-manager/web/2024-11-01/webapps/method_listsnapshots.go new file mode 100644 index 00000000000..ae445c7d99c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listsnapshots.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSnapshotsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListSnapshotsCompleteResult struct { + LatestHttpResponse *http.Response + Items []Snapshot +} + +type ListSnapshotsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSnapshotsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSnapshots ... +func (c WebAppsClient) ListSnapshots(ctx context.Context, id commonids.AppServiceId) (result ListSnapshotsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSnapshotsCustomPager{}, + Path: fmt.Sprintf("%s/snapshots", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSnapshotsComplete retrieves all the results into a single object +func (c WebAppsClient) ListSnapshotsComplete(ctx context.Context, id commonids.AppServiceId) (ListSnapshotsCompleteResult, error) { + return c.ListSnapshotsCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListSnapshotsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSnapshotsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SnapshotOperationPredicate) (result ListSnapshotsCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.ListSnapshots(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSnapshotsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listsnapshotsfromdrsecondary.go b/resource-manager/web/2024-11-01/webapps/method_listsnapshotsfromdrsecondary.go new file mode 100644 index 00000000000..878e74fccd0 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listsnapshotsfromdrsecondary.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSnapshotsFromDRSecondaryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListSnapshotsFromDRSecondaryCompleteResult struct { + LatestHttpResponse *http.Response + Items []Snapshot +} + +type ListSnapshotsFromDRSecondaryCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSnapshotsFromDRSecondaryCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSnapshotsFromDRSecondary ... +func (c WebAppsClient) ListSnapshotsFromDRSecondary(ctx context.Context, id commonids.AppServiceId) (result ListSnapshotsFromDRSecondaryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSnapshotsFromDRSecondaryCustomPager{}, + Path: fmt.Sprintf("%s/snapshotsdr", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSnapshotsFromDRSecondaryComplete retrieves all the results into a single object +func (c WebAppsClient) ListSnapshotsFromDRSecondaryComplete(ctx context.Context, id commonids.AppServiceId) (ListSnapshotsFromDRSecondaryCompleteResult, error) { + return c.ListSnapshotsFromDRSecondaryCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListSnapshotsFromDRSecondaryCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSnapshotsFromDRSecondaryCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate SnapshotOperationPredicate) (result ListSnapshotsFromDRSecondaryCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.ListSnapshotsFromDRSecondary(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSnapshotsFromDRSecondaryCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listsnapshotsfromdrsecondaryslot.go b/resource-manager/web/2024-11-01/webapps/method_listsnapshotsfromdrsecondaryslot.go new file mode 100644 index 00000000000..6e438ec2ff9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listsnapshotsfromdrsecondaryslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSnapshotsFromDRSecondarySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListSnapshotsFromDRSecondarySlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []Snapshot +} + +type ListSnapshotsFromDRSecondarySlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSnapshotsFromDRSecondarySlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSnapshotsFromDRSecondarySlot ... +func (c WebAppsClient) ListSnapshotsFromDRSecondarySlot(ctx context.Context, id SlotId) (result ListSnapshotsFromDRSecondarySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSnapshotsFromDRSecondarySlotCustomPager{}, + Path: fmt.Sprintf("%s/snapshotsdr", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSnapshotsFromDRSecondarySlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSnapshotsFromDRSecondarySlotComplete(ctx context.Context, id SlotId) (ListSnapshotsFromDRSecondarySlotCompleteResult, error) { + return c.ListSnapshotsFromDRSecondarySlotCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListSnapshotsFromDRSecondarySlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSnapshotsFromDRSecondarySlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SnapshotOperationPredicate) (result ListSnapshotsFromDRSecondarySlotCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.ListSnapshotsFromDRSecondarySlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSnapshotsFromDRSecondarySlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listsnapshotsslot.go b/resource-manager/web/2024-11-01/webapps/method_listsnapshotsslot.go new file mode 100644 index 00000000000..840f0882265 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listsnapshotsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSnapshotsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListSnapshotsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []Snapshot +} + +type ListSnapshotsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSnapshotsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSnapshotsSlot ... +func (c WebAppsClient) ListSnapshotsSlot(ctx context.Context, id SlotId) (result ListSnapshotsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListSnapshotsSlotCustomPager{}, + Path: fmt.Sprintf("%s/snapshots", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSnapshotsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListSnapshotsSlotComplete(ctx context.Context, id SlotId) (ListSnapshotsSlotCompleteResult, error) { + return c.ListSnapshotsSlotCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListSnapshotsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListSnapshotsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate SnapshotOperationPredicate) (result ListSnapshotsSlotCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.ListSnapshotsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListSnapshotsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listsyncfunctiontriggers.go b/resource-manager/web/2024-11-01/webapps/method_listsyncfunctiontriggers.go new file mode 100644 index 00000000000..3ba753d99a5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listsyncfunctiontriggers.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSyncFunctionTriggersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionSecrets +} + +// ListSyncFunctionTriggers ... +func (c WebAppsClient) ListSyncFunctionTriggers(ctx context.Context, id commonids.AppServiceId) (result ListSyncFunctionTriggersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listsyncfunctiontriggerstatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FunctionSecrets + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listsyncfunctiontriggersslot.go b/resource-manager/web/2024-11-01/webapps/method_listsyncfunctiontriggersslot.go new file mode 100644 index 00000000000..87112ea8e9a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listsyncfunctiontriggersslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSyncFunctionTriggersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FunctionSecrets +} + +// ListSyncFunctionTriggersSlot ... +func (c WebAppsClient) ListSyncFunctionTriggersSlot(ctx context.Context, id SlotId) (result ListSyncFunctionTriggersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listsyncfunctiontriggerstatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model FunctionSecrets + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listsyncstatus.go b/resource-manager/web/2024-11-01/webapps/method_listsyncstatus.go new file mode 100644 index 00000000000..bc0ee3e79f0 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listsyncstatus.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSyncStatusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ListSyncStatus ... +func (c WebAppsClient) ListSyncStatus(ctx context.Context, id commonids.AppServiceId) (result ListSyncStatusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/listsyncstatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listsyncstatusslot.go b/resource-manager/web/2024-11-01/webapps/method_listsyncstatusslot.go new file mode 100644 index 00000000000..bf199ced94d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listsyncstatusslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSyncStatusSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ListSyncStatusSlot ... +func (c WebAppsClient) ListSyncStatusSlot(ctx context.Context, id SlotId) (result ListSyncStatusSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/listsyncstatus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listtriggeredwebjobhistory.go b/resource-manager/web/2024-11-01/webapps/method_listtriggeredwebjobhistory.go new file mode 100644 index 00000000000..881719e8edf --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listtriggeredwebjobhistory.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListTriggeredWebJobHistoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TriggeredJobHistory +} + +type ListTriggeredWebJobHistoryCompleteResult struct { + LatestHttpResponse *http.Response + Items []TriggeredJobHistory +} + +type ListTriggeredWebJobHistoryCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListTriggeredWebJobHistoryCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListTriggeredWebJobHistory ... +func (c WebAppsClient) ListTriggeredWebJobHistory(ctx context.Context, id TriggeredWebJobId) (result ListTriggeredWebJobHistoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListTriggeredWebJobHistoryCustomPager{}, + Path: fmt.Sprintf("%s/history", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TriggeredJobHistory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListTriggeredWebJobHistoryComplete retrieves all the results into a single object +func (c WebAppsClient) ListTriggeredWebJobHistoryComplete(ctx context.Context, id TriggeredWebJobId) (ListTriggeredWebJobHistoryCompleteResult, error) { + return c.ListTriggeredWebJobHistoryCompleteMatchingPredicate(ctx, id, TriggeredJobHistoryOperationPredicate{}) +} + +// ListTriggeredWebJobHistoryCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListTriggeredWebJobHistoryCompleteMatchingPredicate(ctx context.Context, id TriggeredWebJobId, predicate TriggeredJobHistoryOperationPredicate) (result ListTriggeredWebJobHistoryCompleteResult, err error) { + items := make([]TriggeredJobHistory, 0) + + resp, err := c.ListTriggeredWebJobHistory(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListTriggeredWebJobHistoryCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listtriggeredwebjobhistoryslot.go b/resource-manager/web/2024-11-01/webapps/method_listtriggeredwebjobhistoryslot.go new file mode 100644 index 00000000000..727607c47c6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listtriggeredwebjobhistoryslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListTriggeredWebJobHistorySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TriggeredJobHistory +} + +type ListTriggeredWebJobHistorySlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []TriggeredJobHistory +} + +type ListTriggeredWebJobHistorySlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListTriggeredWebJobHistorySlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListTriggeredWebJobHistorySlot ... +func (c WebAppsClient) ListTriggeredWebJobHistorySlot(ctx context.Context, id SlotTriggeredWebJobId) (result ListTriggeredWebJobHistorySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListTriggeredWebJobHistorySlotCustomPager{}, + Path: fmt.Sprintf("%s/history", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TriggeredJobHistory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListTriggeredWebJobHistorySlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListTriggeredWebJobHistorySlotComplete(ctx context.Context, id SlotTriggeredWebJobId) (ListTriggeredWebJobHistorySlotCompleteResult, error) { + return c.ListTriggeredWebJobHistorySlotCompleteMatchingPredicate(ctx, id, TriggeredJobHistoryOperationPredicate{}) +} + +// ListTriggeredWebJobHistorySlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListTriggeredWebJobHistorySlotCompleteMatchingPredicate(ctx context.Context, id SlotTriggeredWebJobId, predicate TriggeredJobHistoryOperationPredicate) (result ListTriggeredWebJobHistorySlotCompleteResult, err error) { + items := make([]TriggeredJobHistory, 0) + + resp, err := c.ListTriggeredWebJobHistorySlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListTriggeredWebJobHistorySlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listtriggeredwebjobs.go b/resource-manager/web/2024-11-01/webapps/method_listtriggeredwebjobs.go new file mode 100644 index 00000000000..a732150b7fb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listtriggeredwebjobs.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListTriggeredWebJobsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TriggeredWebJob +} + +type ListTriggeredWebJobsCompleteResult struct { + LatestHttpResponse *http.Response + Items []TriggeredWebJob +} + +type ListTriggeredWebJobsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListTriggeredWebJobsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListTriggeredWebJobs ... +func (c WebAppsClient) ListTriggeredWebJobs(ctx context.Context, id commonids.AppServiceId) (result ListTriggeredWebJobsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListTriggeredWebJobsCustomPager{}, + Path: fmt.Sprintf("%s/triggeredWebJobs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TriggeredWebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListTriggeredWebJobsComplete retrieves all the results into a single object +func (c WebAppsClient) ListTriggeredWebJobsComplete(ctx context.Context, id commonids.AppServiceId) (ListTriggeredWebJobsCompleteResult, error) { + return c.ListTriggeredWebJobsCompleteMatchingPredicate(ctx, id, TriggeredWebJobOperationPredicate{}) +} + +// ListTriggeredWebJobsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListTriggeredWebJobsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate TriggeredWebJobOperationPredicate) (result ListTriggeredWebJobsCompleteResult, err error) { + items := make([]TriggeredWebJob, 0) + + resp, err := c.ListTriggeredWebJobs(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListTriggeredWebJobsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listtriggeredwebjobsslot.go b/resource-manager/web/2024-11-01/webapps/method_listtriggeredwebjobsslot.go new file mode 100644 index 00000000000..6dbb5cb9064 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listtriggeredwebjobsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListTriggeredWebJobsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TriggeredWebJob +} + +type ListTriggeredWebJobsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []TriggeredWebJob +} + +type ListTriggeredWebJobsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListTriggeredWebJobsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListTriggeredWebJobsSlot ... +func (c WebAppsClient) ListTriggeredWebJobsSlot(ctx context.Context, id SlotId) (result ListTriggeredWebJobsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListTriggeredWebJobsSlotCustomPager{}, + Path: fmt.Sprintf("%s/triggeredWebJobs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TriggeredWebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListTriggeredWebJobsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListTriggeredWebJobsSlotComplete(ctx context.Context, id SlotId) (ListTriggeredWebJobsSlotCompleteResult, error) { + return c.ListTriggeredWebJobsSlotCompleteMatchingPredicate(ctx, id, TriggeredWebJobOperationPredicate{}) +} + +// ListTriggeredWebJobsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListTriggeredWebJobsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate TriggeredWebJobOperationPredicate) (result ListTriggeredWebJobsSlotCompleteResult, err error) { + items := make([]TriggeredWebJob, 0) + + resp, err := c.ListTriggeredWebJobsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListTriggeredWebJobsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listusages.go b/resource-manager/web/2024-11-01/webapps/method_listusages.go new file mode 100644 index 00000000000..09825b54c80 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listusages.go @@ -0,0 +1,135 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListUsagesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type ListUsagesCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmUsageQuota +} + +type ListUsagesOperationOptions struct { + Filter *string +} + +func DefaultListUsagesOperationOptions() ListUsagesOperationOptions { + return ListUsagesOperationOptions{} +} + +func (o ListUsagesOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListUsagesOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListUsagesOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListUsagesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListUsagesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListUsages ... +func (c WebAppsClient) ListUsages(ctx context.Context, id commonids.AppServiceId, options ListUsagesOperationOptions) (result ListUsagesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListUsagesCustomPager{}, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListUsagesComplete retrieves all the results into a single object +func (c WebAppsClient) ListUsagesComplete(ctx context.Context, id commonids.AppServiceId, options ListUsagesOperationOptions) (ListUsagesCompleteResult, error) { + return c.ListUsagesCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) +} + +// ListUsagesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListUsagesCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, options ListUsagesOperationOptions, predicate CsmUsageQuotaOperationPredicate) (result ListUsagesCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.ListUsages(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListUsagesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listusagesslot.go b/resource-manager/web/2024-11-01/webapps/method_listusagesslot.go new file mode 100644 index 00000000000..0f5459ebad6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listusagesslot.go @@ -0,0 +1,134 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListUsagesSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CsmUsageQuota +} + +type ListUsagesSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []CsmUsageQuota +} + +type ListUsagesSlotOperationOptions struct { + Filter *string +} + +func DefaultListUsagesSlotOperationOptions() ListUsagesSlotOperationOptions { + return ListUsagesSlotOperationOptions{} +} + +func (o ListUsagesSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListUsagesSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListUsagesSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + return &out +} + +type ListUsagesSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListUsagesSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListUsagesSlot ... +func (c WebAppsClient) ListUsagesSlot(ctx context.Context, id SlotId, options ListUsagesSlotOperationOptions) (result ListUsagesSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListUsagesSlotCustomPager{}, + Path: fmt.Sprintf("%s/usages", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CsmUsageQuota `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListUsagesSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListUsagesSlotComplete(ctx context.Context, id SlotId, options ListUsagesSlotOperationOptions) (ListUsagesSlotCompleteResult, error) { + return c.ListUsagesSlotCompleteMatchingPredicate(ctx, id, options, CsmUsageQuotaOperationPredicate{}) +} + +// ListUsagesSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListUsagesSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, options ListUsagesSlotOperationOptions, predicate CsmUsageQuotaOperationPredicate) (result ListUsagesSlotCompleteResult, err error) { + items := make([]CsmUsageQuota, 0) + + resp, err := c.ListUsagesSlot(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListUsagesSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listvnetconnections.go b/resource-manager/web/2024-11-01/webapps/method_listvnetconnections.go new file mode 100644 index 00000000000..9257086d2e2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listvnetconnections.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListVnetConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetInfoResource +} + +// ListVnetConnections ... +func (c WebAppsClient) ListVnetConnections(ctx context.Context, id commonids.AppServiceId) (result ListVnetConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/virtualNetworkConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listvnetconnectionsslot.go b/resource-manager/web/2024-11-01/webapps/method_listvnetconnectionsslot.go new file mode 100644 index 00000000000..942cd6b0476 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listvnetconnectionsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListVnetConnectionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]VnetInfoResource +} + +// ListVnetConnectionsSlot ... +func (c WebAppsClient) ListVnetConnectionsSlot(ctx context.Context, id SlotId) (result ListVnetConnectionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/virtualNetworkConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model []VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listwebjobs.go b/resource-manager/web/2024-11-01/webapps/method_listwebjobs.go new file mode 100644 index 00000000000..46c96736e0d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listwebjobs.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListWebJobsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebJob +} + +type ListWebJobsCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebJob +} + +type ListWebJobsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWebJobsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWebJobs ... +func (c WebAppsClient) ListWebJobs(ctx context.Context, id commonids.AppServiceId) (result ListWebJobsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWebJobsCustomPager{}, + Path: fmt.Sprintf("%s/webJobs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebJobsComplete retrieves all the results into a single object +func (c WebAppsClient) ListWebJobsComplete(ctx context.Context, id commonids.AppServiceId) (ListWebJobsCompleteResult, error) { + return c.ListWebJobsCompleteMatchingPredicate(ctx, id, WebJobOperationPredicate{}) +} + +// ListWebJobsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListWebJobsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate WebJobOperationPredicate) (result ListWebJobsCompleteResult, err error) { + items := make([]WebJob, 0) + + resp, err := c.ListWebJobs(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWebJobsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listwebjobsslot.go b/resource-manager/web/2024-11-01/webapps/method_listwebjobsslot.go new file mode 100644 index 00000000000..421ab88f0e1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listwebjobsslot.go @@ -0,0 +1,105 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListWebJobsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WebJob +} + +type ListWebJobsSlotCompleteResult struct { + LatestHttpResponse *http.Response + Items []WebJob +} + +type ListWebJobsSlotCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWebJobsSlotCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWebJobsSlot ... +func (c WebAppsClient) ListWebJobsSlot(ctx context.Context, id SlotId) (result ListWebJobsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWebJobsSlotCustomPager{}, + Path: fmt.Sprintf("%s/webJobs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WebJob `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWebJobsSlotComplete retrieves all the results into a single object +func (c WebAppsClient) ListWebJobsSlotComplete(ctx context.Context, id SlotId) (ListWebJobsSlotCompleteResult, error) { + return c.ListWebJobsSlotCompleteMatchingPredicate(ctx, id, WebJobOperationPredicate{}) +} + +// ListWebJobsSlotCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListWebJobsSlotCompleteMatchingPredicate(ctx context.Context, id SlotId, predicate WebJobOperationPredicate) (result ListWebJobsSlotCompleteResult, err error) { + items := make([]WebJob, 0) + + resp, err := c.ListWebJobsSlot(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWebJobsSlotCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listworkflows.go b/resource-manager/web/2024-11-01/webapps/method_listworkflows.go new file mode 100644 index 00000000000..a098ec74cd5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listworkflows.go @@ -0,0 +1,106 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListWorkflowsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowEnvelope +} + +type ListWorkflowsCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowEnvelope +} + +type ListWorkflowsCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListWorkflowsCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListWorkflows ... +func (c WebAppsClient) ListWorkflows(ctx context.Context, id commonids.AppServiceId) (result ListWorkflowsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListWorkflowsCustomPager{}, + Path: fmt.Sprintf("%s/workflows", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowEnvelope `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListWorkflowsComplete retrieves all the results into a single object +func (c WebAppsClient) ListWorkflowsComplete(ctx context.Context, id commonids.AppServiceId) (ListWorkflowsCompleteResult, error) { + return c.ListWorkflowsCompleteMatchingPredicate(ctx, id, WorkflowEnvelopeOperationPredicate{}) +} + +// ListWorkflowsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WebAppsClient) ListWorkflowsCompleteMatchingPredicate(ctx context.Context, id commonids.AppServiceId, predicate WorkflowEnvelopeOperationPredicate) (result ListWorkflowsCompleteResult, err error) { + items := make([]WorkflowEnvelope, 0) + + resp, err := c.ListWorkflows(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListWorkflowsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listworkflowsconnections.go b/resource-manager/web/2024-11-01/webapps/method_listworkflowsconnections.go new file mode 100644 index 00000000000..4c7d04686ac --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listworkflowsconnections.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListWorkflowsConnectionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowEnvelope +} + +// ListWorkflowsConnections ... +func (c WebAppsClient) ListWorkflowsConnections(ctx context.Context, id commonids.AppServiceId) (result ListWorkflowsConnectionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listWorkflowsConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowEnvelope + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_listworkflowsconnectionsslot.go b/resource-manager/web/2024-11-01/webapps/method_listworkflowsconnectionsslot.go new file mode 100644 index 00000000000..b85e7a72003 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_listworkflowsconnectionsslot.go @@ -0,0 +1,54 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListWorkflowsConnectionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowEnvelope +} + +// ListWorkflowsConnectionsSlot ... +func (c WebAppsClient) ListWorkflowsConnectionsSlot(ctx context.Context, id SlotId) (result ListWorkflowsConnectionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listWorkflowsConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowEnvelope + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_migratemysql.go b/resource-manager/web/2024-11-01/webapps/method_migratemysql.go new file mode 100644 index 00000000000..ce8f8a7c00c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_migratemysql.go @@ -0,0 +1,75 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateMySqlOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *Operation +} + +// MigrateMySql ... +func (c WebAppsClient) MigrateMySql(ctx context.Context, id commonids.AppServiceId, input MigrateMySqlRequest) (result MigrateMySqlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/migrateMySql", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// MigrateMySqlThenPoll performs MigrateMySql then polls until it's completed +func (c WebAppsClient) MigrateMySqlThenPoll(ctx context.Context, id commonids.AppServiceId, input MigrateMySqlRequest) error { + result, err := c.MigrateMySql(ctx, id, input) + if err != nil { + return fmt.Errorf("performing MigrateMySql: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MigrateMySql: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_migratestorage.go b/resource-manager/web/2024-11-01/webapps/method_migratestorage.go new file mode 100644 index 00000000000..1fb58c4f795 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_migratestorage.go @@ -0,0 +1,104 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateStorageOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *StorageMigrationResponse +} + +type MigrateStorageOperationOptions struct { + SubscriptionName *string +} + +func DefaultMigrateStorageOperationOptions() MigrateStorageOperationOptions { + return MigrateStorageOperationOptions{} +} + +func (o MigrateStorageOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o MigrateStorageOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o MigrateStorageOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SubscriptionName != nil { + out.Append("subscriptionName", fmt.Sprintf("%v", *o.SubscriptionName)) + } + return &out +} + +// MigrateStorage ... +func (c WebAppsClient) MigrateStorage(ctx context.Context, id commonids.AppServiceId, input StorageMigrationOptions, options MigrateStorageOperationOptions) (result MigrateStorageOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: options, + Path: fmt.Sprintf("%s/migrate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// MigrateStorageThenPoll performs MigrateStorage then polls until it's completed +func (c WebAppsClient) MigrateStorageThenPoll(ctx context.Context, id commonids.AppServiceId, input StorageMigrationOptions, options MigrateStorageOperationOptions) error { + result, err := c.MigrateStorage(ctx, id, input, options) + if err != nil { + return fmt.Errorf("performing MigrateStorage: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after MigrateStorage: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_putprivateaccessvnet.go b/resource-manager/web/2024-11-01/webapps/method_putprivateaccessvnet.go new file mode 100644 index 00000000000..419ea335744 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_putprivateaccessvnet.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PutPrivateAccessVnetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateAccess +} + +// PutPrivateAccessVnet ... +func (c WebAppsClient) PutPrivateAccessVnet(ctx context.Context, id commonids.AppServiceId, input PrivateAccess) (result PutPrivateAccessVnetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/privateAccess/virtualNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateAccess + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_putprivateaccessvnetslot.go b/resource-manager/web/2024-11-01/webapps/method_putprivateaccessvnetslot.go new file mode 100644 index 00000000000..a2031d0024b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_putprivateaccessvnetslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PutPrivateAccessVnetSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateAccess +} + +// PutPrivateAccessVnetSlot ... +func (c WebAppsClient) PutPrivateAccessVnetSlot(ctx context.Context, id SlotId, input PrivateAccess) (result PutPrivateAccessVnetSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/privateAccess/virtualNetworks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateAccess + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_recoversiteconfigurationsnapshot.go b/resource-manager/web/2024-11-01/webapps/method_recoversiteconfigurationsnapshot.go new file mode 100644 index 00000000000..9bd00ef6a3f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_recoversiteconfigurationsnapshot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoverSiteConfigurationSnapshotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RecoverSiteConfigurationSnapshot ... +func (c WebAppsClient) RecoverSiteConfigurationSnapshot(ctx context.Context, id SnapshotId) (result RecoverSiteConfigurationSnapshotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_recoversiteconfigurationsnapshotslot.go b/resource-manager/web/2024-11-01/webapps/method_recoversiteconfigurationsnapshotslot.go new file mode 100644 index 00000000000..c2218167e74 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_recoversiteconfigurationsnapshotslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecoverSiteConfigurationSnapshotSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RecoverSiteConfigurationSnapshotSlot ... +func (c WebAppsClient) RecoverSiteConfigurationSnapshotSlot(ctx context.Context, id WebSnapshotId) (result RecoverSiteConfigurationSnapshotSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/recover", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_resetproductionslotconfig.go b/resource-manager/web/2024-11-01/webapps/method_resetproductionslotconfig.go new file mode 100644 index 00000000000..d3e1980493a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_resetproductionslotconfig.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResetProductionSlotConfigOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetProductionSlotConfig ... +func (c WebAppsClient) ResetProductionSlotConfig(ctx context.Context, id commonids.AppServiceId) (result ResetProductionSlotConfigOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetSlotConfig", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_resetslotconfigurationslot.go b/resource-manager/web/2024-11-01/webapps/method_resetslotconfigurationslot.go new file mode 100644 index 00000000000..15aae400653 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_resetslotconfigurationslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResetSlotConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// ResetSlotConfigurationSlot ... +func (c WebAppsClient) ResetSlotConfigurationSlot(ctx context.Context, id SlotId) (result ResetSlotConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetSlotConfig", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_restart.go b/resource-manager/web/2024-11-01/webapps/method_restart.go new file mode 100644 index 00000000000..47d9224417a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_restart.go @@ -0,0 +1,81 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestartOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type RestartOperationOptions struct { + SoftRestart *bool + Synchronous *bool +} + +func DefaultRestartOperationOptions() RestartOperationOptions { + return RestartOperationOptions{} +} + +func (o RestartOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestartOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RestartOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SoftRestart != nil { + out.Append("softRestart", fmt.Sprintf("%v", *o.SoftRestart)) + } + if o.Synchronous != nil { + out.Append("synchronous", fmt.Sprintf("%v", *o.Synchronous)) + } + return &out +} + +// Restart ... +func (c WebAppsClient) Restart(ctx context.Context, id commonids.AppServiceId, options RestartOperationOptions) (result RestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/restart", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_restartslot.go b/resource-manager/web/2024-11-01/webapps/method_restartslot.go new file mode 100644 index 00000000000..ca81876358d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_restartslot.go @@ -0,0 +1,80 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestartSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +type RestartSlotOperationOptions struct { + SoftRestart *bool + Synchronous *bool +} + +func DefaultRestartSlotOperationOptions() RestartSlotOperationOptions { + return RestartSlotOperationOptions{} +} + +func (o RestartSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RestartSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RestartSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SoftRestart != nil { + out.Append("softRestart", fmt.Sprintf("%v", *o.SoftRestart)) + } + if o.Synchronous != nil { + out.Append("synchronous", fmt.Sprintf("%v", *o.Synchronous)) + } + return &out +} + +// RestartSlot ... +func (c WebAppsClient) RestartSlot(ctx context.Context, id SlotId, options RestartSlotOperationOptions) (result RestartSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/restart", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_restore.go b/resource-manager/web/2024-11-01/webapps/method_restore.go new file mode 100644 index 00000000000..021d7f79a35 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_restore.go @@ -0,0 +1,74 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Restore ... +func (c WebAppsClient) Restore(ctx context.Context, id BackupId, input RestoreRequest) (result RestoreOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restore", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestoreThenPoll performs Restore then polls until it's completed +func (c WebAppsClient) RestoreThenPoll(ctx context.Context, id BackupId, input RestoreRequest) error { + result, err := c.Restore(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Restore: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Restore: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_restorefrombackupblob.go b/resource-manager/web/2024-11-01/webapps/method_restorefrombackupblob.go new file mode 100644 index 00000000000..0483caf9f9c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_restorefrombackupblob.go @@ -0,0 +1,75 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreFromBackupBlobOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreFromBackupBlob ... +func (c WebAppsClient) RestoreFromBackupBlob(ctx context.Context, id commonids.AppServiceId, input RestoreRequest) (result RestoreFromBackupBlobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFromBackupBlob", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestoreFromBackupBlobThenPoll performs RestoreFromBackupBlob then polls until it's completed +func (c WebAppsClient) RestoreFromBackupBlobThenPoll(ctx context.Context, id commonids.AppServiceId, input RestoreRequest) error { + result, err := c.RestoreFromBackupBlob(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreFromBackupBlob: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreFromBackupBlob: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_restorefrombackupblobslot.go b/resource-manager/web/2024-11-01/webapps/method_restorefrombackupblobslot.go new file mode 100644 index 00000000000..27fd565b8af --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_restorefrombackupblobslot.go @@ -0,0 +1,74 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreFromBackupBlobSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreFromBackupBlobSlot ... +func (c WebAppsClient) RestoreFromBackupBlobSlot(ctx context.Context, id SlotId, input RestoreRequest) (result RestoreFromBackupBlobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFromBackupBlob", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestoreFromBackupBlobSlotThenPoll performs RestoreFromBackupBlobSlot then polls until it's completed +func (c WebAppsClient) RestoreFromBackupBlobSlotThenPoll(ctx context.Context, id SlotId, input RestoreRequest) error { + result, err := c.RestoreFromBackupBlobSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreFromBackupBlobSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreFromBackupBlobSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_restorefromdeletedapp.go b/resource-manager/web/2024-11-01/webapps/method_restorefromdeletedapp.go new file mode 100644 index 00000000000..1b8a16b10b5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_restorefromdeletedapp.go @@ -0,0 +1,75 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreFromDeletedAppOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreFromDeletedApp ... +func (c WebAppsClient) RestoreFromDeletedApp(ctx context.Context, id commonids.AppServiceId, input DeletedAppRestoreRequest) (result RestoreFromDeletedAppOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFromDeletedApp", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestoreFromDeletedAppThenPoll performs RestoreFromDeletedApp then polls until it's completed +func (c WebAppsClient) RestoreFromDeletedAppThenPoll(ctx context.Context, id commonids.AppServiceId, input DeletedAppRestoreRequest) error { + result, err := c.RestoreFromDeletedApp(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreFromDeletedApp: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreFromDeletedApp: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_restorefromdeletedappslot.go b/resource-manager/web/2024-11-01/webapps/method_restorefromdeletedappslot.go new file mode 100644 index 00000000000..6fd61e73c37 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_restorefromdeletedappslot.go @@ -0,0 +1,74 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreFromDeletedAppSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreFromDeletedAppSlot ... +func (c WebAppsClient) RestoreFromDeletedAppSlot(ctx context.Context, id SlotId, input DeletedAppRestoreRequest) (result RestoreFromDeletedAppSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreFromDeletedApp", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestoreFromDeletedAppSlotThenPoll performs RestoreFromDeletedAppSlot then polls until it's completed +func (c WebAppsClient) RestoreFromDeletedAppSlotThenPoll(ctx context.Context, id SlotId, input DeletedAppRestoreRequest) error { + result, err := c.RestoreFromDeletedAppSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreFromDeletedAppSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreFromDeletedAppSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_restoreslot.go b/resource-manager/web/2024-11-01/webapps/method_restoreslot.go new file mode 100644 index 00000000000..0e401f516af --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_restoreslot.go @@ -0,0 +1,74 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreSlot ... +func (c WebAppsClient) RestoreSlot(ctx context.Context, id SlotBackupId, input RestoreRequest) (result RestoreSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restore", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestoreSlotThenPoll performs RestoreSlot then polls until it's completed +func (c WebAppsClient) RestoreSlotThenPoll(ctx context.Context, id SlotBackupId, input RestoreRequest) error { + result, err := c.RestoreSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_restoresnapshot.go b/resource-manager/web/2024-11-01/webapps/method_restoresnapshot.go new file mode 100644 index 00000000000..191a16d685d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_restoresnapshot.go @@ -0,0 +1,75 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreSnapshotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreSnapshot ... +func (c WebAppsClient) RestoreSnapshot(ctx context.Context, id commonids.AppServiceId, input SnapshotRestoreRequest) (result RestoreSnapshotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreSnapshot", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestoreSnapshotThenPoll performs RestoreSnapshot then polls until it's completed +func (c WebAppsClient) RestoreSnapshotThenPoll(ctx context.Context, id commonids.AppServiceId, input SnapshotRestoreRequest) error { + result, err := c.RestoreSnapshot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreSnapshot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreSnapshot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_restoresnapshotslot.go b/resource-manager/web/2024-11-01/webapps/method_restoresnapshotslot.go new file mode 100644 index 00000000000..95c72292ac1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_restoresnapshotslot.go @@ -0,0 +1,74 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreSnapshotSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RestoreSnapshotSlot ... +func (c WebAppsClient) RestoreSnapshotSlot(ctx context.Context, id SlotId, input SnapshotRestoreRequest) (result RestoreSnapshotSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restoreSnapshot", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RestoreSnapshotSlotThenPoll performs RestoreSnapshotSlot then polls until it's completed +func (c WebAppsClient) RestoreSnapshotSlotThenPoll(ctx context.Context, id SlotId, input SnapshotRestoreRequest) error { + result, err := c.RestoreSnapshotSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RestoreSnapshotSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RestoreSnapshotSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_runtriggeredwebjob.go b/resource-manager/web/2024-11-01/webapps/method_runtriggeredwebjob.go new file mode 100644 index 00000000000..368004f11bb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_runtriggeredwebjob.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunTriggeredWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RunTriggeredWebJob ... +func (c WebAppsClient) RunTriggeredWebJob(ctx context.Context, id TriggeredWebJobId) (result RunTriggeredWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/run", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_runtriggeredwebjobslot.go b/resource-manager/web/2024-11-01/webapps/method_runtriggeredwebjobslot.go new file mode 100644 index 00000000000..20589d753fc --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_runtriggeredwebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunTriggeredWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RunTriggeredWebJobSlot ... +func (c WebAppsClient) RunTriggeredWebJobSlot(ctx context.Context, id SlotTriggeredWebJobId) (result RunTriggeredWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/run", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_start.go b/resource-manager/web/2024-11-01/webapps/method_start.go new file mode 100644 index 00000000000..6eeb4574e82 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_start.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Start ... +func (c WebAppsClient) Start(ctx context.Context, id commonids.AppServiceId) (result StartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_startcontinuouswebjob.go b/resource-manager/web/2024-11-01/webapps/method_startcontinuouswebjob.go new file mode 100644 index 00000000000..e3a68b92d35 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_startcontinuouswebjob.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartContinuousWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StartContinuousWebJob ... +func (c WebAppsClient) StartContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result StartContinuousWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_startcontinuouswebjobslot.go b/resource-manager/web/2024-11-01/webapps/method_startcontinuouswebjobslot.go new file mode 100644 index 00000000000..25b7624a51e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_startcontinuouswebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartContinuousWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StartContinuousWebJobSlot ... +func (c WebAppsClient) StartContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result StartContinuousWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_startnetworktrace.go b/resource-manager/web/2024-11-01/webapps/method_startnetworktrace.go new file mode 100644 index 00000000000..3b1246a0d11 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_startnetworktrace.go @@ -0,0 +1,109 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartNetworkTraceOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +type StartNetworkTraceOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasURL *string +} + +func DefaultStartNetworkTraceOperationOptions() StartNetworkTraceOperationOptions { + return StartNetworkTraceOperationOptions{} +} + +func (o StartNetworkTraceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartNetworkTraceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o StartNetworkTraceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasURL != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasURL)) + } + return &out +} + +// StartNetworkTrace ... +func (c WebAppsClient) StartNetworkTrace(ctx context.Context, id commonids.AppServiceId, options StartNetworkTraceOperationOptions) (result StartNetworkTraceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/startNetworkTrace", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StartNetworkTraceThenPoll performs StartNetworkTrace then polls until it's completed +func (c WebAppsClient) StartNetworkTraceThenPoll(ctx context.Context, id commonids.AppServiceId, options StartNetworkTraceOperationOptions) error { + result, err := c.StartNetworkTrace(ctx, id, options) + if err != nil { + return fmt.Errorf("performing StartNetworkTrace: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartNetworkTrace: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_startnetworktraceslot.go b/resource-manager/web/2024-11-01/webapps/method_startnetworktraceslot.go new file mode 100644 index 00000000000..72c280deeef --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_startnetworktraceslot.go @@ -0,0 +1,108 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartNetworkTraceSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +type StartNetworkTraceSlotOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasURL *string +} + +func DefaultStartNetworkTraceSlotOperationOptions() StartNetworkTraceSlotOperationOptions { + return StartNetworkTraceSlotOperationOptions{} +} + +func (o StartNetworkTraceSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartNetworkTraceSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o StartNetworkTraceSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasURL != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasURL)) + } + return &out +} + +// StartNetworkTraceSlot ... +func (c WebAppsClient) StartNetworkTraceSlot(ctx context.Context, id SlotId, options StartNetworkTraceSlotOperationOptions) (result StartNetworkTraceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/startNetworkTrace", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StartNetworkTraceSlotThenPoll performs StartNetworkTraceSlot then polls until it's completed +func (c WebAppsClient) StartNetworkTraceSlotThenPoll(ctx context.Context, id SlotId, options StartNetworkTraceSlotOperationOptions) error { + result, err := c.StartNetworkTraceSlot(ctx, id, options) + if err != nil { + return fmt.Errorf("performing StartNetworkTraceSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartNetworkTraceSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_startslot.go b/resource-manager/web/2024-11-01/webapps/method_startslot.go new file mode 100644 index 00000000000..e1ef6c58413 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_startslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StartSlot ... +func (c WebAppsClient) StartSlot(ctx context.Context, id SlotId) (result StartSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_startwebsitenetworktrace.go b/resource-manager/web/2024-11-01/webapps/method_startwebsitenetworktrace.go new file mode 100644 index 00000000000..0feb53df65b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_startwebsitenetworktrace.go @@ -0,0 +1,92 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartWebSiteNetworkTraceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +type StartWebSiteNetworkTraceOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasURL *string +} + +func DefaultStartWebSiteNetworkTraceOperationOptions() StartWebSiteNetworkTraceOperationOptions { + return StartWebSiteNetworkTraceOperationOptions{} +} + +func (o StartWebSiteNetworkTraceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasURL != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasURL)) + } + return &out +} + +// StartWebSiteNetworkTrace ... +func (c WebAppsClient) StartWebSiteNetworkTrace(ctx context.Context, id commonids.AppServiceId, options StartWebSiteNetworkTraceOperationOptions) (result StartWebSiteNetworkTraceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/networkTrace/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model string + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_startwebsitenetworktraceoperation.go b/resource-manager/web/2024-11-01/webapps/method_startwebsitenetworktraceoperation.go new file mode 100644 index 00000000000..1a67be6cba1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_startwebsitenetworktraceoperation.go @@ -0,0 +1,109 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartWebSiteNetworkTraceOperationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +type StartWebSiteNetworkTraceOperationOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasURL *string +} + +func DefaultStartWebSiteNetworkTraceOperationOperationOptions() StartWebSiteNetworkTraceOperationOperationOptions { + return StartWebSiteNetworkTraceOperationOperationOptions{} +} + +func (o StartWebSiteNetworkTraceOperationOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasURL != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasURL)) + } + return &out +} + +// StartWebSiteNetworkTraceOperation ... +func (c WebAppsClient) StartWebSiteNetworkTraceOperation(ctx context.Context, id commonids.AppServiceId, options StartWebSiteNetworkTraceOperationOperationOptions) (result StartWebSiteNetworkTraceOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/networkTrace/startOperation", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StartWebSiteNetworkTraceOperationThenPoll performs StartWebSiteNetworkTraceOperation then polls until it's completed +func (c WebAppsClient) StartWebSiteNetworkTraceOperationThenPoll(ctx context.Context, id commonids.AppServiceId, options StartWebSiteNetworkTraceOperationOperationOptions) error { + result, err := c.StartWebSiteNetworkTraceOperation(ctx, id, options) + if err != nil { + return fmt.Errorf("performing StartWebSiteNetworkTraceOperation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartWebSiteNetworkTraceOperation: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_startwebsitenetworktraceoperationslot.go b/resource-manager/web/2024-11-01/webapps/method_startwebsitenetworktraceoperationslot.go new file mode 100644 index 00000000000..90f4cda8f0d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_startwebsitenetworktraceoperationslot.go @@ -0,0 +1,108 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartWebSiteNetworkTraceOperationSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *[]NetworkTrace +} + +type StartWebSiteNetworkTraceOperationSlotOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasURL *string +} + +func DefaultStartWebSiteNetworkTraceOperationSlotOperationOptions() StartWebSiteNetworkTraceOperationSlotOperationOptions { + return StartWebSiteNetworkTraceOperationSlotOperationOptions{} +} + +func (o StartWebSiteNetworkTraceOperationSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o StartWebSiteNetworkTraceOperationSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasURL != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasURL)) + } + return &out +} + +// StartWebSiteNetworkTraceOperationSlot ... +func (c WebAppsClient) StartWebSiteNetworkTraceOperationSlot(ctx context.Context, id SlotId, options StartWebSiteNetworkTraceOperationSlotOperationOptions) (result StartWebSiteNetworkTraceOperationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/networkTrace/startOperation", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StartWebSiteNetworkTraceOperationSlotThenPoll performs StartWebSiteNetworkTraceOperationSlot then polls until it's completed +func (c WebAppsClient) StartWebSiteNetworkTraceOperationSlotThenPoll(ctx context.Context, id SlotId, options StartWebSiteNetworkTraceOperationSlotOperationOptions) error { + result, err := c.StartWebSiteNetworkTraceOperationSlot(ctx, id, options) + if err != nil { + return fmt.Errorf("performing StartWebSiteNetworkTraceOperationSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after StartWebSiteNetworkTraceOperationSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_startwebsitenetworktraceslot.go b/resource-manager/web/2024-11-01/webapps/method_startwebsitenetworktraceslot.go new file mode 100644 index 00000000000..10467c0eda1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_startwebsitenetworktraceslot.go @@ -0,0 +1,91 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartWebSiteNetworkTraceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *string +} + +type StartWebSiteNetworkTraceSlotOperationOptions struct { + DurationInSeconds *int64 + MaxFrameLength *int64 + SasURL *string +} + +func DefaultStartWebSiteNetworkTraceSlotOperationOptions() StartWebSiteNetworkTraceSlotOperationOptions { + return StartWebSiteNetworkTraceSlotOperationOptions{} +} + +func (o StartWebSiteNetworkTraceSlotOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o StartWebSiteNetworkTraceSlotOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o StartWebSiteNetworkTraceSlotOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.DurationInSeconds != nil { + out.Append("durationInSeconds", fmt.Sprintf("%v", *o.DurationInSeconds)) + } + if o.MaxFrameLength != nil { + out.Append("maxFrameLength", fmt.Sprintf("%v", *o.MaxFrameLength)) + } + if o.SasURL != nil { + out.Append("sasUrl", fmt.Sprintf("%v", *o.SasURL)) + } + return &out +} + +// StartWebSiteNetworkTraceSlot ... +func (c WebAppsClient) StartWebSiteNetworkTraceSlot(ctx context.Context, id SlotId, options StartWebSiteNetworkTraceSlotOperationOptions) (result StartWebSiteNetworkTraceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + OptionsObject: options, + Path: fmt.Sprintf("%s/networkTrace/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model string + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_stop.go b/resource-manager/web/2024-11-01/webapps/method_stop.go new file mode 100644 index 00000000000..7f3caf53d9d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_stop.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Stop ... +func (c WebAppsClient) Stop(ctx context.Context, id commonids.AppServiceId) (result StopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_stopcontinuouswebjob.go b/resource-manager/web/2024-11-01/webapps/method_stopcontinuouswebjob.go new file mode 100644 index 00000000000..66fcde1e73b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_stopcontinuouswebjob.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopContinuousWebJobOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopContinuousWebJob ... +func (c WebAppsClient) StopContinuousWebJob(ctx context.Context, id ContinuousWebJobId) (result StopContinuousWebJobOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_stopcontinuouswebjobslot.go b/resource-manager/web/2024-11-01/webapps/method_stopcontinuouswebjobslot.go new file mode 100644 index 00000000000..6195a3125e2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_stopcontinuouswebjobslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopContinuousWebJobSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopContinuousWebJobSlot ... +func (c WebAppsClient) StopContinuousWebJobSlot(ctx context.Context, id SlotContinuousWebJobId) (result StopContinuousWebJobSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_stopnetworktrace.go b/resource-manager/web/2024-11-01/webapps/method_stopnetworktrace.go new file mode 100644 index 00000000000..098cdf97671 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_stopnetworktrace.go @@ -0,0 +1,49 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopNetworkTraceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopNetworkTrace ... +func (c WebAppsClient) StopNetworkTrace(ctx context.Context, id commonids.AppServiceId) (result StopNetworkTraceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stopNetworkTrace", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_stopnetworktraceslot.go b/resource-manager/web/2024-11-01/webapps/method_stopnetworktraceslot.go new file mode 100644 index 00000000000..08644e40fc9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_stopnetworktraceslot.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopNetworkTraceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopNetworkTraceSlot ... +func (c WebAppsClient) StopNetworkTraceSlot(ctx context.Context, id SlotId) (result StopNetworkTraceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stopNetworkTrace", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_stopslot.go b/resource-manager/web/2024-11-01/webapps/method_stopslot.go new file mode 100644 index 00000000000..cd89d662a26 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_stopslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopSlot ... +func (c WebAppsClient) StopSlot(ctx context.Context, id SlotId) (result StopSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_stopwebsitenetworktrace.go b/resource-manager/web/2024-11-01/webapps/method_stopwebsitenetworktrace.go new file mode 100644 index 00000000000..7c3fcd820e8 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_stopwebsitenetworktrace.go @@ -0,0 +1,49 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopWebSiteNetworkTraceOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopWebSiteNetworkTrace ... +func (c WebAppsClient) StopWebSiteNetworkTrace(ctx context.Context, id commonids.AppServiceId) (result StopWebSiteNetworkTraceOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/networkTrace/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_stopwebsitenetworktraceslot.go b/resource-manager/web/2024-11-01/webapps/method_stopwebsitenetworktraceslot.go new file mode 100644 index 00000000000..4ac3a77814a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_stopwebsitenetworktraceslot.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopWebSiteNetworkTraceSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// StopWebSiteNetworkTraceSlot ... +func (c WebAppsClient) StopWebSiteNetworkTraceSlot(ctx context.Context, id SlotId) (result StopWebSiteNetworkTraceSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/networkTrace/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_swapslotslot.go b/resource-manager/web/2024-11-01/webapps/method_swapslotslot.go new file mode 100644 index 00000000000..4adb4148b94 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_swapslotslot.go @@ -0,0 +1,74 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwapSlotSlotOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SwapSlotSlot ... +func (c WebAppsClient) SwapSlotSlot(ctx context.Context, id SlotId, input CsmSlotEntity) (result SwapSlotSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/slotsswap", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SwapSlotSlotThenPoll performs SwapSlotSlot then polls until it's completed +func (c WebAppsClient) SwapSlotSlotThenPoll(ctx context.Context, id SlotId, input CsmSlotEntity) error { + result, err := c.SwapSlotSlot(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SwapSlotSlot: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SwapSlotSlot: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_swapslotwithproduction.go b/resource-manager/web/2024-11-01/webapps/method_swapslotwithproduction.go new file mode 100644 index 00000000000..924b47593e5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_swapslotwithproduction.go @@ -0,0 +1,75 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwapSlotWithProductionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SwapSlotWithProduction ... +func (c WebAppsClient) SwapSlotWithProduction(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity) (result SwapSlotWithProductionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/slotsswap", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SwapSlotWithProductionThenPoll performs SwapSlotWithProduction then polls until it's completed +func (c WebAppsClient) SwapSlotWithProductionThenPoll(ctx context.Context, id commonids.AppServiceId, input CsmSlotEntity) error { + result, err := c.SwapSlotWithProduction(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SwapSlotWithProduction: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SwapSlotWithProduction: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/webapps/method_syncfunctions.go b/resource-manager/web/2024-11-01/webapps/method_syncfunctions.go new file mode 100644 index 00000000000..f9e53a89d27 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_syncfunctions.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SyncFunctionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncFunctions ... +func (c WebAppsClient) SyncFunctions(ctx context.Context, id commonids.AppServiceId) (result SyncFunctionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/sync", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_syncfunctionsslot.go b/resource-manager/web/2024-11-01/webapps/method_syncfunctionsslot.go new file mode 100644 index 00000000000..37773597814 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_syncfunctionsslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SyncFunctionsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncFunctionsSlot ... +func (c WebAppsClient) SyncFunctionsSlot(ctx context.Context, id SlotId) (result SyncFunctionsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/host/default/sync", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_syncfunctiontriggers.go b/resource-manager/web/2024-11-01/webapps/method_syncfunctiontriggers.go new file mode 100644 index 00000000000..1370fe7c5d3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_syncfunctiontriggers.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SyncFunctionTriggersOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncFunctionTriggers ... +func (c WebAppsClient) SyncFunctionTriggers(ctx context.Context, id commonids.AppServiceId) (result SyncFunctionTriggersOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/syncfunctiontriggers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_syncfunctiontriggersslot.go b/resource-manager/web/2024-11-01/webapps/method_syncfunctiontriggersslot.go new file mode 100644 index 00000000000..f3cef3f11df --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_syncfunctiontriggersslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SyncFunctionTriggersSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncFunctionTriggersSlot ... +func (c WebAppsClient) SyncFunctionTriggersSlot(ctx context.Context, id SlotId) (result SyncFunctionTriggersSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/syncfunctiontriggers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_syncrepository.go b/resource-manager/web/2024-11-01/webapps/method_syncrepository.go new file mode 100644 index 00000000000..d798d4f5793 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_syncrepository.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SyncRepositoryOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncRepository ... +func (c WebAppsClient) SyncRepository(ctx context.Context, id commonids.AppServiceId) (result SyncRepositoryOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sync", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_syncrepositoryslot.go b/resource-manager/web/2024-11-01/webapps/method_syncrepositoryslot.go new file mode 100644 index 00000000000..81b7009d872 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_syncrepositoryslot.go @@ -0,0 +1,47 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SyncRepositorySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// SyncRepositorySlot ... +func (c WebAppsClient) SyncRepositorySlot(ctx context.Context, id SlotId) (result SyncRepositorySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/sync", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_update.go b/resource-manager/web/2024-11-01/webapps/method_update.go new file mode 100644 index 00000000000..ce51465dd90 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_update.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// Update ... +func (c WebAppsClient) Update(ctx context.Context, id commonids.AppServiceId, input SitePatchResource) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Site + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateapplicationsettings.go b/resource-manager/web/2024-11-01/webapps/method_updateapplicationsettings.go new file mode 100644 index 00000000000..a6abe2e7f9f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateapplicationsettings.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateApplicationSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// UpdateApplicationSettings ... +func (c WebAppsClient) UpdateApplicationSettings(ctx context.Context, id commonids.AppServiceId, input StringDictionary) (result UpdateApplicationSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/appSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateapplicationsettingsslot.go b/resource-manager/web/2024-11-01/webapps/method_updateapplicationsettingsslot.go new file mode 100644 index 00000000000..dabaad9a1bb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateapplicationsettingsslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateApplicationSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// UpdateApplicationSettingsSlot ... +func (c WebAppsClient) UpdateApplicationSettingsSlot(ctx context.Context, id SlotId, input StringDictionary) (result UpdateApplicationSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/appSettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateauthsettings.go b/resource-manager/web/2024-11-01/webapps/method_updateauthsettings.go new file mode 100644 index 00000000000..c4721b446e6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateauthsettings.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateAuthSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettings +} + +// UpdateAuthSettings ... +func (c WebAppsClient) UpdateAuthSettings(ctx context.Context, id commonids.AppServiceId, input SiteAuthSettings) (result UpdateAuthSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/authsettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettings + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateauthsettingsslot.go b/resource-manager/web/2024-11-01/webapps/method_updateauthsettingsslot.go new file mode 100644 index 00000000000..efd12302a3c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateauthsettingsslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateAuthSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettings +} + +// UpdateAuthSettingsSlot ... +func (c WebAppsClient) UpdateAuthSettingsSlot(ctx context.Context, id SlotId, input SiteAuthSettings) (result UpdateAuthSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/authsettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettings + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateauthsettingsv2.go b/resource-manager/web/2024-11-01/webapps/method_updateauthsettingsv2.go new file mode 100644 index 00000000000..630b45422db --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateauthsettingsv2.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateAuthSettingsV2OperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// UpdateAuthSettingsV2 ... +func (c WebAppsClient) UpdateAuthSettingsV2(ctx context.Context, id commonids.AppServiceId, input SiteAuthSettingsV2) (result UpdateAuthSettingsV2OperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/authsettingsV2", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettingsV2 + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateauthsettingsv2slot.go b/resource-manager/web/2024-11-01/webapps/method_updateauthsettingsv2slot.go new file mode 100644 index 00000000000..6e054358fe5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateauthsettingsv2slot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateAuthSettingsV2SlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteAuthSettingsV2 +} + +// UpdateAuthSettingsV2Slot ... +func (c WebAppsClient) UpdateAuthSettingsV2Slot(ctx context.Context, id SlotId, input SiteAuthSettingsV2) (result UpdateAuthSettingsV2SlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/authsettingsV2", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteAuthSettingsV2 + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateazurestorageaccounts.go b/resource-manager/web/2024-11-01/webapps/method_updateazurestorageaccounts.go new file mode 100644 index 00000000000..bbda87f586c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateazurestorageaccounts.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateAzureStorageAccountsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureStoragePropertyDictionaryResource +} + +// UpdateAzureStorageAccounts ... +func (c WebAppsClient) UpdateAzureStorageAccounts(ctx context.Context, id commonids.AppServiceId, input AzureStoragePropertyDictionaryResource) (result UpdateAzureStorageAccountsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/azurestorageaccounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AzureStoragePropertyDictionaryResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateazurestorageaccountsslot.go b/resource-manager/web/2024-11-01/webapps/method_updateazurestorageaccountsslot.go new file mode 100644 index 00000000000..de67b3d4cff --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateazurestorageaccountsslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateAzureStorageAccountsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AzureStoragePropertyDictionaryResource +} + +// UpdateAzureStorageAccountsSlot ... +func (c WebAppsClient) UpdateAzureStorageAccountsSlot(ctx context.Context, id SlotId, input AzureStoragePropertyDictionaryResource) (result UpdateAzureStorageAccountsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/azurestorageaccounts", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AzureStoragePropertyDictionaryResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatebackupconfiguration.go b/resource-manager/web/2024-11-01/webapps/method_updatebackupconfiguration.go new file mode 100644 index 00000000000..eadd42c46b4 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatebackupconfiguration.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateBackupConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupRequest +} + +// UpdateBackupConfiguration ... +func (c WebAppsClient) UpdateBackupConfiguration(ctx context.Context, id commonids.AppServiceId, input BackupRequest) (result UpdateBackupConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/backup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupRequest + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatebackupconfigurationslot.go b/resource-manager/web/2024-11-01/webapps/method_updatebackupconfigurationslot.go new file mode 100644 index 00000000000..6cc6c0db6dd --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatebackupconfigurationslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateBackupConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *BackupRequest +} + +// UpdateBackupConfigurationSlot ... +func (c WebAppsClient) UpdateBackupConfigurationSlot(ctx context.Context, id SlotId, input BackupRequest) (result UpdateBackupConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/backup", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model BackupRequest + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateconfiguration.go b/resource-manager/web/2024-11-01/webapps/method_updateconfiguration.go new file mode 100644 index 00000000000..540effb8493 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateconfiguration.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateConfigurationOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// UpdateConfiguration ... +func (c WebAppsClient) UpdateConfiguration(ctx context.Context, id commonids.AppServiceId, input SiteConfigResource) (result UpdateConfigurationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/config/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteConfigResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateconfigurationslot.go b/resource-manager/web/2024-11-01/webapps/method_updateconfigurationslot.go new file mode 100644 index 00000000000..2b8a3c837d6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateconfigurationslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateConfigurationSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteConfigResource +} + +// UpdateConfigurationSlot ... +func (c WebAppsClient) UpdateConfigurationSlot(ctx context.Context, id SlotId, input SiteConfigResource) (result UpdateConfigurationSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/config/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteConfigResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateconnectionstrings.go b/resource-manager/web/2024-11-01/webapps/method_updateconnectionstrings.go new file mode 100644 index 00000000000..e2583e323f7 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateconnectionstrings.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateConnectionStringsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionStringDictionary +} + +// UpdateConnectionStrings ... +func (c WebAppsClient) UpdateConnectionStrings(ctx context.Context, id commonids.AppServiceId, input ConnectionStringDictionary) (result UpdateConnectionStringsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/connectionStrings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectionStringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateconnectionstringsslot.go b/resource-manager/web/2024-11-01/webapps/method_updateconnectionstringsslot.go new file mode 100644 index 00000000000..02c8aab1742 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateconnectionstringsslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateConnectionStringsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectionStringDictionary +} + +// UpdateConnectionStringsSlot ... +func (c WebAppsClient) UpdateConnectionStringsSlot(ctx context.Context, id SlotId, input ConnectionStringDictionary) (result UpdateConnectionStringsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/connectionStrings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ConnectionStringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatediagnosticlogsconfig.go b/resource-manager/web/2024-11-01/webapps/method_updatediagnosticlogsconfig.go new file mode 100644 index 00000000000..3fd9dd8089b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatediagnosticlogsconfig.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateDiagnosticLogsConfigOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteLogsConfig +} + +// UpdateDiagnosticLogsConfig ... +func (c WebAppsClient) UpdateDiagnosticLogsConfig(ctx context.Context, id commonids.AppServiceId, input SiteLogsConfig) (result UpdateDiagnosticLogsConfigOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/logs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteLogsConfig + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatediagnosticlogsconfigslot.go b/resource-manager/web/2024-11-01/webapps/method_updatediagnosticlogsconfigslot.go new file mode 100644 index 00000000000..76e26082497 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatediagnosticlogsconfigslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateDiagnosticLogsConfigSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteLogsConfig +} + +// UpdateDiagnosticLogsConfigSlot ... +func (c WebAppsClient) UpdateDiagnosticLogsConfigSlot(ctx context.Context, id SlotId, input SiteLogsConfig) (result UpdateDiagnosticLogsConfigSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/logs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteLogsConfig + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatedomainownershipidentifier.go b/resource-manager/web/2024-11-01/webapps/method_updatedomainownershipidentifier.go new file mode 100644 index 00000000000..8bb087cd8f8 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatedomainownershipidentifier.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateDomainOwnershipIdentifierOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// UpdateDomainOwnershipIdentifier ... +func (c WebAppsClient) UpdateDomainOwnershipIdentifier(ctx context.Context, id SiteDomainOwnershipIdentifierId, input Identifier) (result UpdateDomainOwnershipIdentifierOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Identifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatedomainownershipidentifierslot.go b/resource-manager/web/2024-11-01/webapps/method_updatedomainownershipidentifierslot.go new file mode 100644 index 00000000000..8bfd226892c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatedomainownershipidentifierslot.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateDomainOwnershipIdentifierSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Identifier +} + +// UpdateDomainOwnershipIdentifierSlot ... +func (c WebAppsClient) UpdateDomainOwnershipIdentifierSlot(ctx context.Context, id SlotDomainOwnershipIdentifierId, input Identifier) (result UpdateDomainOwnershipIdentifierSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Identifier + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateftpallowed.go b/resource-manager/web/2024-11-01/webapps/method_updateftpallowed.go new file mode 100644 index 00000000000..fb80df44e08 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateftpallowed.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateFtpAllowedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// UpdateFtpAllowed ... +func (c WebAppsClient) UpdateFtpAllowed(ctx context.Context, id commonids.AppServiceId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateFtpAllowedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateftpallowedslot.go b/resource-manager/web/2024-11-01/webapps/method_updateftpallowedslot.go new file mode 100644 index 00000000000..8600093e952 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateftpallowedslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateFtpAllowedSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// UpdateFtpAllowedSlot ... +func (c WebAppsClient) UpdateFtpAllowedSlot(ctx context.Context, id SlotId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateFtpAllowedSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/ftp", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatehybridconnection.go b/resource-manager/web/2024-11-01/webapps/method_updatehybridconnection.go new file mode 100644 index 00000000000..14d186263b3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatehybridconnection.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateHybridConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// UpdateHybridConnection ... +func (c WebAppsClient) UpdateHybridConnection(ctx context.Context, id RelayId, input HybridConnection) (result UpdateHybridConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatehybridconnectionslot.go b/resource-manager/web/2024-11-01/webapps/method_updatehybridconnectionslot.go new file mode 100644 index 00000000000..8136fefe9af --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatehybridconnectionslot.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateHybridConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *HybridConnection +} + +// UpdateHybridConnectionSlot ... +func (c WebAppsClient) UpdateHybridConnectionSlot(ctx context.Context, id SlotHybridConnectionNamespaceRelayId, input HybridConnection) (result UpdateHybridConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model HybridConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatemachinekey.go b/resource-manager/web/2024-11-01/webapps/method_updatemachinekey.go new file mode 100644 index 00000000000..795eaf05e0d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatemachinekey.go @@ -0,0 +1,55 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateMachineKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *interface{} +} + +// UpdateMachineKey ... +func (c WebAppsClient) UpdateMachineKey(ctx context.Context, id commonids.AppServiceId) (result UpdateMachineKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/updatemachinekey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model interface{} + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatemetadata.go b/resource-manager/web/2024-11-01/webapps/method_updatemetadata.go new file mode 100644 index 00000000000..55294309b86 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatemetadata.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateMetadataOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// UpdateMetadata ... +func (c WebAppsClient) UpdateMetadata(ctx context.Context, id commonids.AppServiceId, input StringDictionary) (result UpdateMetadataOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/metadata", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatemetadataslot.go b/resource-manager/web/2024-11-01/webapps/method_updatemetadataslot.go new file mode 100644 index 00000000000..99995876e7c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatemetadataslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateMetadataSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *StringDictionary +} + +// UpdateMetadataSlot ... +func (c WebAppsClient) UpdateMetadataSlot(ctx context.Context, id SlotId, input StringDictionary) (result UpdateMetadataSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/metadata", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model StringDictionary + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatepremieraddon.go b/resource-manager/web/2024-11-01/webapps/method_updatepremieraddon.go new file mode 100644 index 00000000000..dcd3c9b2a8b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatepremieraddon.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdatePremierAddOnOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// UpdatePremierAddOn ... +func (c WebAppsClient) UpdatePremierAddOn(ctx context.Context, id PremierAddonId, input PremierAddOnPatchResource) (result UpdatePremierAddOnOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PremierAddOn + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatepremieraddonslot.go b/resource-manager/web/2024-11-01/webapps/method_updatepremieraddonslot.go new file mode 100644 index 00000000000..e1c27a4d55e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatepremieraddonslot.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdatePremierAddOnSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PremierAddOn +} + +// UpdatePremierAddOnSlot ... +func (c WebAppsClient) UpdatePremierAddOnSlot(ctx context.Context, id SlotPremierAddonId, input PremierAddOnPatchResource) (result UpdatePremierAddOnSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PremierAddOn + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updaterelayserviceconnection.go b/resource-manager/web/2024-11-01/webapps/method_updaterelayserviceconnection.go new file mode 100644 index 00000000000..cd611e9ec20 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updaterelayserviceconnection.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateRelayServiceConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// UpdateRelayServiceConnection ... +func (c WebAppsClient) UpdateRelayServiceConnection(ctx context.Context, id HybridConnectionId, input RelayServiceConnectionEntity) (result UpdateRelayServiceConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RelayServiceConnectionEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updaterelayserviceconnectionslot.go b/resource-manager/web/2024-11-01/webapps/method_updaterelayserviceconnectionslot.go new file mode 100644 index 00000000000..c24d82100f8 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updaterelayserviceconnectionslot.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateRelayServiceConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RelayServiceConnectionEntity +} + +// UpdateRelayServiceConnectionSlot ... +func (c WebAppsClient) UpdateRelayServiceConnectionSlot(ctx context.Context, id SlotHybridConnectionId, input RelayServiceConnectionEntity) (result UpdateRelayServiceConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RelayServiceConnectionEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatescmallowed.go b/resource-manager/web/2024-11-01/webapps/method_updatescmallowed.go new file mode 100644 index 00000000000..120d3629001 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatescmallowed.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateScmAllowedOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// UpdateScmAllowed ... +func (c WebAppsClient) UpdateScmAllowed(ctx context.Context, id commonids.AppServiceId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateScmAllowedOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatescmallowedslot.go b/resource-manager/web/2024-11-01/webapps/method_updatescmallowedslot.go new file mode 100644 index 00000000000..a3243abfa63 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatescmallowedslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateScmAllowedSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CsmPublishingCredentialsPoliciesEntity +} + +// UpdateScmAllowedSlot ... +func (c WebAppsClient) UpdateScmAllowedSlot(ctx context.Context, id SlotId, input CsmPublishingCredentialsPoliciesEntity) (result UpdateScmAllowedSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/basicPublishingCredentialsPolicies/scm", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CsmPublishingCredentialsPoliciesEntity + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatesitepushsettings.go b/resource-manager/web/2024-11-01/webapps/method_updatesitepushsettings.go new file mode 100644 index 00000000000..668665c05d4 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatesitepushsettings.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSitePushSettingsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PushSettings +} + +// UpdateSitePushSettings ... +func (c WebAppsClient) UpdateSitePushSettings(ctx context.Context, id commonids.AppServiceId, input PushSettings) (result UpdateSitePushSettingsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/pushsettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PushSettings + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatesitepushsettingsslot.go b/resource-manager/web/2024-11-01/webapps/method_updatesitepushsettingsslot.go new file mode 100644 index 00000000000..09988246b8c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatesitepushsettingsslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSitePushSettingsSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PushSettings +} + +// UpdateSitePushSettingsSlot ... +func (c WebAppsClient) UpdateSitePushSettingsSlot(ctx context.Context, id SlotId, input PushSettings) (result UpdateSitePushSettingsSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/pushsettings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PushSettings + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateslot.go b/resource-manager/web/2024-11-01/webapps/method_updateslot.go new file mode 100644 index 00000000000..82afe00eea3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Site +} + +// UpdateSlot ... +func (c WebAppsClient) UpdateSlot(ctx context.Context, id SlotId, input SitePatchResource) (result UpdateSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Site + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateslotconfigurationnames.go b/resource-manager/web/2024-11-01/webapps/method_updateslotconfigurationnames.go new file mode 100644 index 00000000000..8eb1665dd4d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateslotconfigurationnames.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSlotConfigurationNamesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SlotConfigNamesResource +} + +// UpdateSlotConfigurationNames ... +func (c WebAppsClient) UpdateSlotConfigurationNames(ctx context.Context, id commonids.AppServiceId, input SlotConfigNamesResource) (result UpdateSlotConfigurationNamesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: fmt.Sprintf("%s/config/slotConfigNames", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SlotConfigNamesResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatesourcecontrol.go b/resource-manager/web/2024-11-01/webapps/method_updatesourcecontrol.go new file mode 100644 index 00000000000..a9b4d29999b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatesourcecontrol.go @@ -0,0 +1,61 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSourceControlOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// UpdateSourceControl ... +func (c WebAppsClient) UpdateSourceControl(ctx context.Context, id commonids.AppServiceId, input SiteSourceControl) (result UpdateSourceControlOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/sourceControls/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteSourceControl + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatesourcecontrolslot.go b/resource-manager/web/2024-11-01/webapps/method_updatesourcecontrolslot.go new file mode 100644 index 00000000000..27063f72815 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatesourcecontrolslot.go @@ -0,0 +1,60 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSourceControlSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SiteSourceControl +} + +// UpdateSourceControlSlot ... +func (c WebAppsClient) UpdateSourceControlSlot(ctx context.Context, id SlotId, input SiteSourceControl) (result UpdateSourceControlSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/sourceControls/web", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SiteSourceControl + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheck.go b/resource-manager/web/2024-11-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheck.go new file mode 100644 index 00000000000..1ed44d1b945 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheck.go @@ -0,0 +1,59 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// UpdateSwiftVirtualNetworkConnectionWithCheck ... +func (c WebAppsClient) UpdateSwiftVirtualNetworkConnectionWithCheck(ctx context.Context, id commonids.AppServiceId, input SwiftVirtualNetwork) (result UpdateSwiftVirtualNetworkConnectionWithCheckOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SwiftVirtualNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheckslot.go b/resource-manager/web/2024-11-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheckslot.go new file mode 100644 index 00000000000..86d0e38f499 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updateswiftvirtualnetworkconnectionwithcheckslot.go @@ -0,0 +1,58 @@ +package webapps + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *SwiftVirtualNetwork +} + +// UpdateSwiftVirtualNetworkConnectionWithCheckSlot ... +func (c WebAppsClient) UpdateSwiftVirtualNetworkConnectionWithCheckSlot(ctx context.Context, id SlotId, input SwiftVirtualNetwork) (result UpdateSwiftVirtualNetworkConnectionWithCheckSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: fmt.Sprintf("%s/networkConfig/virtualNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model SwiftVirtualNetwork + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatevnetconnection.go b/resource-manager/web/2024-11-01/webapps/method_updatevnetconnection.go new file mode 100644 index 00000000000..d24ddba2035 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatevnetconnection.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateVnetConnectionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// UpdateVnetConnection ... +func (c WebAppsClient) UpdateVnetConnection(ctx context.Context, id VirtualNetworkConnectionId, input VnetInfoResource) (result UpdateVnetConnectionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatevnetconnectiongateway.go b/resource-manager/web/2024-11-01/webapps/method_updatevnetconnectiongateway.go new file mode 100644 index 00000000000..710e26ab2d6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatevnetconnectiongateway.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateVnetConnectionGatewayOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// UpdateVnetConnectionGateway ... +func (c WebAppsClient) UpdateVnetConnectionGateway(ctx context.Context, id GatewayId, input VnetGateway) (result UpdateVnetConnectionGatewayOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatevnetconnectiongatewayslot.go b/resource-manager/web/2024-11-01/webapps/method_updatevnetconnectiongatewayslot.go new file mode 100644 index 00000000000..e292d9dd430 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatevnetconnectiongatewayslot.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateVnetConnectionGatewaySlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetGateway +} + +// UpdateVnetConnectionGatewaySlot ... +func (c WebAppsClient) UpdateVnetConnectionGatewaySlot(ctx context.Context, id SlotVirtualNetworkConnectionGatewayId, input VnetGateway) (result UpdateVnetConnectionGatewaySlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetGateway + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/method_updatevnetconnectionslot.go b/resource-manager/web/2024-11-01/webapps/method_updatevnetconnectionslot.go new file mode 100644 index 00000000000..1ce4e92a640 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/method_updatevnetconnectionslot.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateVnetConnectionSlotOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *VnetInfoResource +} + +// UpdateVnetConnectionSlot ... +func (c WebAppsClient) UpdateVnetConnectionSlot(ctx context.Context, id SlotVirtualNetworkConnectionId, input VnetInfoResource) (result UpdateVnetConnectionSlotOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VnetInfoResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/webapps/model_allowedaudiencesvalidation.go b/resource-manager/web/2024-11-01/webapps/model_allowedaudiencesvalidation.go new file mode 100644 index 00000000000..da259d9fd38 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_allowedaudiencesvalidation.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AllowedAudiencesValidation struct { + AllowedAudiences *[]string `json:"allowedAudiences,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_allowedprincipals.go b/resource-manager/web/2024-11-01/webapps/model_allowedprincipals.go new file mode 100644 index 00000000000..b17b5652dd2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_allowedprincipals.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AllowedPrincipals struct { + Groups *[]string `json:"groups,omitempty"` + Identities *[]string `json:"identities,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_apidefinitioninfo.go b/resource-manager/web/2024-11-01/webapps/model_apidefinitioninfo.go new file mode 100644 index 00000000000..152027e15e2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_apidefinitioninfo.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiDefinitionInfo struct { + Url *string `json:"url,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_apikvreference.go b/resource-manager/web/2024-11-01/webapps/model_apikvreference.go new file mode 100644 index 00000000000..62f12266d3b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_apikvreference.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiKVReference struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ApiKVReferenceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_apikvreferenceproperties.go b/resource-manager/web/2024-11-01/webapps/model_apikvreferenceproperties.go new file mode 100644 index 00000000000..58a0f5398cc --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_apikvreferenceproperties.go @@ -0,0 +1,20 @@ +package webapps + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiKVReferenceProperties struct { + ActiveVersion *string `json:"activeVersion,omitempty"` + Details *string `json:"details,omitempty"` + IdentityType *identity.SystemAndUserAssignedMap `json:"identityType,omitempty"` + Reference *string `json:"reference,omitempty"` + SecretName *string `json:"secretName,omitempty"` + SecretVersion *string `json:"secretVersion,omitempty"` + Source *ConfigReferenceSource `json:"source,omitempty"` + Status *ResolveStatus `json:"status,omitempty"` + VaultName *string `json:"vaultName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_apimanagementconfig.go b/resource-manager/web/2024-11-01/webapps/model_apimanagementconfig.go new file mode 100644 index 00000000000..9acd3c84278 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_apimanagementconfig.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiManagementConfig struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_apple.go b/resource-manager/web/2024-11-01/webapps/model_apple.go new file mode 100644 index 00000000000..69e9769061b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_apple.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Apple struct { + Enabled *bool `json:"enabled,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *AppleRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_appleregistration.go b/resource-manager/web/2024-11-01/webapps/model_appleregistration.go new file mode 100644 index 00000000000..304a6b2b50f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_appleregistration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppleRegistration struct { + ClientId *string `json:"clientId,omitempty"` + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_applicationlogsconfig.go b/resource-manager/web/2024-11-01/webapps/model_applicationlogsconfig.go new file mode 100644 index 00000000000..9734bceb194 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_applicationlogsconfig.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApplicationLogsConfig struct { + AzureBlobStorage *AzureBlobStorageApplicationLogsConfig `json:"azureBlobStorage,omitempty"` + AzureTableStorage *AzureTableStorageApplicationLogsConfig `json:"azureTableStorage,omitempty"` + FileSystem *FileSystemApplicationLogsConfig `json:"fileSystem,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_appregistration.go b/resource-manager/web/2024-11-01/webapps/model_appregistration.go new file mode 100644 index 00000000000..658b68d4c6e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_appregistration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AppRegistration struct { + AppId *string `json:"appId,omitempty"` + AppSecretSettingName *string `json:"appSecretSettingName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_armidwrapper.go b/resource-manager/web/2024-11-01/webapps/model_armidwrapper.go new file mode 100644 index 00000000000..f73fbd64bb2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_armidwrapper.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArmIdWrapper struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_authplatform.go b/resource-manager/web/2024-11-01/webapps/model_authplatform.go new file mode 100644 index 00000000000..c1222a45d4e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_authplatform.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AuthPlatform struct { + ConfigFilePath *string `json:"configFilePath,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_autohealactions.go b/resource-manager/web/2024-11-01/webapps/model_autohealactions.go new file mode 100644 index 00000000000..c33d955c76e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_autohealactions.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealActions struct { + ActionType *AutoHealActionType `json:"actionType,omitempty"` + CustomAction *AutoHealCustomAction `json:"customAction,omitempty"` + MinProcessExecutionTime *string `json:"minProcessExecutionTime,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_autohealcustomaction.go b/resource-manager/web/2024-11-01/webapps/model_autohealcustomaction.go new file mode 100644 index 00000000000..49bfb9eb35b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_autohealcustomaction.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealCustomAction struct { + Exe *string `json:"exe,omitempty"` + Parameters *string `json:"parameters,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_autohealrules.go b/resource-manager/web/2024-11-01/webapps/model_autohealrules.go new file mode 100644 index 00000000000..b96bc1ad965 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_autohealrules.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealRules struct { + Actions *AutoHealActions `json:"actions,omitempty"` + Triggers *AutoHealTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_autohealtriggers.go b/resource-manager/web/2024-11-01/webapps/model_autohealtriggers.go new file mode 100644 index 00000000000..932862aab96 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_autohealtriggers.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoHealTriggers struct { + PrivateBytesInKB *int64 `json:"privateBytesInKB,omitempty"` + Requests *RequestsBasedTrigger `json:"requests,omitempty"` + SlowRequests *SlowRequestsBasedTrigger `json:"slowRequests,omitempty"` + SlowRequestsWithPath *[]SlowRequestsBasedTrigger `json:"slowRequestsWithPath,omitempty"` + StatusCodes *[]StatusCodesBasedTrigger `json:"statusCodes,omitempty"` + StatusCodesRange *[]StatusCodesRangeBasedTrigger `json:"statusCodesRange,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_azureactivedirectory.go b/resource-manager/web/2024-11-01/webapps/model_azureactivedirectory.go new file mode 100644 index 00000000000..cda4c5114d2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_azureactivedirectory.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectory struct { + Enabled *bool `json:"enabled,omitempty"` + IsAutoProvisioned *bool `json:"isAutoProvisioned,omitempty"` + Login *AzureActiveDirectoryLogin `json:"login,omitempty"` + Registration *AzureActiveDirectoryRegistration `json:"registration,omitempty"` + Validation *AzureActiveDirectoryValidation `json:"validation,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_azureactivedirectorylogin.go b/resource-manager/web/2024-11-01/webapps/model_azureactivedirectorylogin.go new file mode 100644 index 00000000000..590062cd0e1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_azureactivedirectorylogin.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectoryLogin struct { + DisableWWWAuthenticate *bool `json:"disableWWWAuthenticate,omitempty"` + LoginParameters *[]string `json:"loginParameters,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_azureactivedirectoryregistration.go b/resource-manager/web/2024-11-01/webapps/model_azureactivedirectoryregistration.go new file mode 100644 index 00000000000..8cb7ab16efb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_azureactivedirectoryregistration.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectoryRegistration struct { + ClientId *string `json:"clientId,omitempty"` + ClientSecretCertificateIssuer *string `json:"clientSecretCertificateIssuer,omitempty"` + ClientSecretCertificateSubjectAlternativeName *string `json:"clientSecretCertificateSubjectAlternativeName,omitempty"` + ClientSecretCertificateThumbprint *string `json:"clientSecretCertificateThumbprint,omitempty"` + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` + OpenIdIssuer *string `json:"openIdIssuer,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_azureactivedirectoryvalidation.go b/resource-manager/web/2024-11-01/webapps/model_azureactivedirectoryvalidation.go new file mode 100644 index 00000000000..bd699d34a12 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_azureactivedirectoryvalidation.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureActiveDirectoryValidation struct { + AllowedAudiences *[]string `json:"allowedAudiences,omitempty"` + DefaultAuthorizationPolicy *DefaultAuthorizationPolicy `json:"defaultAuthorizationPolicy,omitempty"` + JwtClaimChecks *JwtClaimChecks `json:"jwtClaimChecks,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_azureblobstorageapplicationlogsconfig.go b/resource-manager/web/2024-11-01/webapps/model_azureblobstorageapplicationlogsconfig.go new file mode 100644 index 00000000000..37a7b27b3e9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_azureblobstorageapplicationlogsconfig.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBlobStorageApplicationLogsConfig struct { + Level *LogLevel `json:"level,omitempty"` + RetentionInDays *int64 `json:"retentionInDays,omitempty"` + SasURL *string `json:"sasUrl,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_azureblobstoragehttplogsconfig.go b/resource-manager/web/2024-11-01/webapps/model_azureblobstoragehttplogsconfig.go new file mode 100644 index 00000000000..74820c0d5ac --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_azureblobstoragehttplogsconfig.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureBlobStorageHTTPLogsConfig struct { + Enabled *bool `json:"enabled,omitempty"` + RetentionInDays *int64 `json:"retentionInDays,omitempty"` + SasURL *string `json:"sasUrl,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_azurestaticwebapps.go b/resource-manager/web/2024-11-01/webapps/model_azurestaticwebapps.go new file mode 100644 index 00000000000..16d67230d5f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_azurestaticwebapps.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStaticWebApps struct { + Enabled *bool `json:"enabled,omitempty"` + Registration *AzureStaticWebAppsRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_azurestaticwebappsregistration.go b/resource-manager/web/2024-11-01/webapps/model_azurestaticwebappsregistration.go new file mode 100644 index 00000000000..bd78e405cfe --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_azurestaticwebappsregistration.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStaticWebAppsRegistration struct { + ClientId *string `json:"clientId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_azurestorageinfovalue.go b/resource-manager/web/2024-11-01/webapps/model_azurestorageinfovalue.go new file mode 100644 index 00000000000..e92f9c01952 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_azurestorageinfovalue.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStorageInfoValue struct { + AccessKey *string `json:"accessKey,omitempty"` + AccountName *string `json:"accountName,omitempty"` + MountPath *string `json:"mountPath,omitempty"` + Protocol *AzureStorageProtocol `json:"protocol,omitempty"` + ShareName *string `json:"shareName,omitempty"` + State *AzureStorageState `json:"state,omitempty"` + Type *AzureStorageType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_azurestoragepropertydictionaryresource.go b/resource-manager/web/2024-11-01/webapps/model_azurestoragepropertydictionaryresource.go new file mode 100644 index 00000000000..6c7675fec3f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_azurestoragepropertydictionaryresource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureStoragePropertyDictionaryResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *map[string]AzureStorageInfoValue `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_azuretablestorageapplicationlogsconfig.go b/resource-manager/web/2024-11-01/webapps/model_azuretablestorageapplicationlogsconfig.go new file mode 100644 index 00000000000..8d8ca355fe4 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_azuretablestorageapplicationlogsconfig.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureTableStorageApplicationLogsConfig struct { + Level *LogLevel `json:"level,omitempty"` + SasURL string `json:"sasUrl"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_backupitem.go b/resource-manager/web/2024-11-01/webapps/model_backupitem.go new file mode 100644 index 00000000000..7bf578be3a9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_backupitem.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupItem struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackupItemProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_backupitemproperties.go b/resource-manager/web/2024-11-01/webapps/model_backupitemproperties.go new file mode 100644 index 00000000000..b74153eec80 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_backupitemproperties.go @@ -0,0 +1,63 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupItemProperties struct { + BlobName *string `json:"blobName,omitempty"` + CorrelationId *string `json:"correlationId,omitempty"` + Created *string `json:"created,omitempty"` + Databases *[]DatabaseBackupSetting `json:"databases,omitempty"` + FinishedTimeStamp *string `json:"finishedTimeStamp,omitempty"` + Id *int64 `json:"id,omitempty"` + LastRestoreTimeStamp *string `json:"lastRestoreTimeStamp,omitempty"` + Log *string `json:"log,omitempty"` + Name *string `json:"name,omitempty"` + Scheduled *bool `json:"scheduled,omitempty"` + SizeInBytes *int64 `json:"sizeInBytes,omitempty"` + Status *BackupItemStatus `json:"status,omitempty"` + StorageAccountURL *string `json:"storageAccountUrl,omitempty"` + WebsiteSizeInBytes *int64 `json:"websiteSizeInBytes,omitempty"` +} + +func (o *BackupItemProperties) GetCreatedAsTime() (*time.Time, error) { + if o.Created == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Created, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupItemProperties) SetCreatedAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Created = &formatted +} + +func (o *BackupItemProperties) GetFinishedTimeStampAsTime() (*time.Time, error) { + if o.FinishedTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.FinishedTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupItemProperties) SetFinishedTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.FinishedTimeStamp = &formatted +} + +func (o *BackupItemProperties) GetLastRestoreTimeStampAsTime() (*time.Time, error) { + if o.LastRestoreTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastRestoreTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupItemProperties) SetLastRestoreTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastRestoreTimeStamp = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_backuprequest.go b/resource-manager/web/2024-11-01/webapps/model_backuprequest.go new file mode 100644 index 00000000000..5247f8695cc --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_backuprequest.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *BackupRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_backuprequestproperties.go b/resource-manager/web/2024-11-01/webapps/model_backuprequestproperties.go new file mode 100644 index 00000000000..0d0229d8c83 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_backuprequestproperties.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupRequestProperties struct { + BackupName *string `json:"backupName,omitempty"` + BackupSchedule *BackupSchedule `json:"backupSchedule,omitempty"` + Databases *[]DatabaseBackupSetting `json:"databases,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + StorageAccountURL string `json:"storageAccountUrl"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_backupschedule.go b/resource-manager/web/2024-11-01/webapps/model_backupschedule.go new file mode 100644 index 00000000000..8fb777f2e01 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_backupschedule.go @@ -0,0 +1,43 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackupSchedule struct { + FrequencyInterval int64 `json:"frequencyInterval"` + FrequencyUnit FrequencyUnit `json:"frequencyUnit"` + KeepAtLeastOneBackup bool `json:"keepAtLeastOneBackup"` + LastExecutionTime *string `json:"lastExecutionTime,omitempty"` + RetentionPeriodInDays int64 `json:"retentionPeriodInDays"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *BackupSchedule) GetLastExecutionTimeAsTime() (*time.Time, error) { + if o.LastExecutionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastExecutionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupSchedule) SetLastExecutionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastExecutionTime = &formatted +} + +func (o *BackupSchedule) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *BackupSchedule) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_blobstoragetokenstore.go b/resource-manager/web/2024-11-01/webapps/model_blobstoragetokenstore.go new file mode 100644 index 00000000000..2cbf67fbeae --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_blobstoragetokenstore.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BlobStorageTokenStore struct { + SasURLSettingName *string `json:"sasUrlSettingName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_clientregistration.go b/resource-manager/web/2024-11-01/webapps/model_clientregistration.go new file mode 100644 index 00000000000..a0983671ae0 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_clientregistration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClientRegistration struct { + ClientId *string `json:"clientId,omitempty"` + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_cloninginfo.go b/resource-manager/web/2024-11-01/webapps/model_cloninginfo.go new file mode 100644 index 00000000000..0934bb9fecc --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_cloninginfo.go @@ -0,0 +1,18 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CloningInfo struct { + AppSettingsOverrides *map[string]string `json:"appSettingsOverrides,omitempty"` + CloneCustomHostNames *bool `json:"cloneCustomHostNames,omitempty"` + CloneSourceControl *bool `json:"cloneSourceControl,omitempty"` + ConfigureLoadBalancing *bool `json:"configureLoadBalancing,omitempty"` + CorrelationId *string `json:"correlationId,omitempty"` + HostingEnvironment *string `json:"hostingEnvironment,omitempty"` + Overwrite *bool `json:"overwrite,omitempty"` + SourceWebAppId string `json:"sourceWebAppId"` + SourceWebAppLocation *string `json:"sourceWebAppLocation,omitempty"` + TrafficManagerProfileId *string `json:"trafficManagerProfileId,omitempty"` + TrafficManagerProfileName *string `json:"trafficManagerProfileName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_connectionstringdictionary.go b/resource-manager/web/2024-11-01/webapps/model_connectionstringdictionary.go new file mode 100644 index 00000000000..ce8d8b95927 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_connectionstringdictionary.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionStringDictionary struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *map[string]ConnStringValueTypePair `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_connstringinfo.go b/resource-manager/web/2024-11-01/webapps/model_connstringinfo.go new file mode 100644 index 00000000000..a41ade2e9db --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_connstringinfo.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnStringInfo struct { + ConnectionString *string `json:"connectionString,omitempty"` + Name *string `json:"name,omitempty"` + Type *ConnectionStringType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_connstringvaluetypepair.go b/resource-manager/web/2024-11-01/webapps/model_connstringvaluetypepair.go new file mode 100644 index 00000000000..a80c0c6b95e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_connstringvaluetypepair.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnStringValueTypePair struct { + Type ConnectionStringType `json:"type"` + Value string `json:"value"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_containercpustatistics.go b/resource-manager/web/2024-11-01/webapps/model_containercpustatistics.go new file mode 100644 index 00000000000..dd2b3964567 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_containercpustatistics.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerCPUStatistics struct { + CpuUsage *ContainerCPUUsage `json:"cpuUsage,omitempty"` + OnlineCPUCount *int64 `json:"onlineCpuCount,omitempty"` + SystemCPUUsage *int64 `json:"systemCpuUsage,omitempty"` + ThrottlingData *ContainerThrottlingData `json:"throttlingData,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_containercpuusage.go b/resource-manager/web/2024-11-01/webapps/model_containercpuusage.go new file mode 100644 index 00000000000..c7c0de7ff15 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_containercpuusage.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerCPUUsage struct { + KernelModeUsage *int64 `json:"kernelModeUsage,omitempty"` + PerCPUUsage *[]int64 `json:"perCpuUsage,omitempty"` + TotalUsage *int64 `json:"totalUsage,omitempty"` + UserModeUsage *int64 `json:"userModeUsage,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_containerinfo.go b/resource-manager/web/2024-11-01/webapps/model_containerinfo.go new file mode 100644 index 00000000000..e69d7c9d60a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_containerinfo.go @@ -0,0 +1,45 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerInfo struct { + CurrentCPUStats *ContainerCPUStatistics `json:"currentCpuStats,omitempty"` + CurrentTimeStamp *string `json:"currentTimeStamp,omitempty"` + Eth0 *ContainerNetworkInterfaceStatistics `json:"eth0,omitempty"` + Id *string `json:"id,omitempty"` + MemoryStats *ContainerMemoryStatistics `json:"memoryStats,omitempty"` + Name *string `json:"name,omitempty"` + PreviousCPUStats *ContainerCPUStatistics `json:"previousCpuStats,omitempty"` + PreviousTimeStamp *string `json:"previousTimeStamp,omitempty"` +} + +func (o *ContainerInfo) GetCurrentTimeStampAsTime() (*time.Time, error) { + if o.CurrentTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CurrentTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *ContainerInfo) SetCurrentTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CurrentTimeStamp = &formatted +} + +func (o *ContainerInfo) GetPreviousTimeStampAsTime() (*time.Time, error) { + if o.PreviousTimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.PreviousTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *ContainerInfo) SetPreviousTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.PreviousTimeStamp = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_containermemorystatistics.go b/resource-manager/web/2024-11-01/webapps/model_containermemorystatistics.go new file mode 100644 index 00000000000..766817d234f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_containermemorystatistics.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerMemoryStatistics struct { + Limit *int64 `json:"limit,omitempty"` + MaxUsage *int64 `json:"maxUsage,omitempty"` + Usage *int64 `json:"usage,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_containernetworkinterfacestatistics.go b/resource-manager/web/2024-11-01/webapps/model_containernetworkinterfacestatistics.go new file mode 100644 index 00000000000..70eed77205c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_containernetworkinterfacestatistics.go @@ -0,0 +1,15 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerNetworkInterfaceStatistics struct { + RxBytes *int64 `json:"rxBytes,omitempty"` + RxDropped *int64 `json:"rxDropped,omitempty"` + RxErrors *int64 `json:"rxErrors,omitempty"` + RxPackets *int64 `json:"rxPackets,omitempty"` + TxBytes *int64 `json:"txBytes,omitempty"` + TxDropped *int64 `json:"txDropped,omitempty"` + TxErrors *int64 `json:"txErrors,omitempty"` + TxPackets *int64 `json:"txPackets,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_containerthrottlingdata.go b/resource-manager/web/2024-11-01/webapps/model_containerthrottlingdata.go new file mode 100644 index 00000000000..9a8399671cb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_containerthrottlingdata.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerThrottlingData struct { + Periods *int64 `json:"periods,omitempty"` + ThrottledPeriods *int64 `json:"throttledPeriods,omitempty"` + ThrottledTime *int64 `json:"throttledTime,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_continuouswebjob.go b/resource-manager/web/2024-11-01/webapps/model_continuouswebjob.go new file mode 100644 index 00000000000..960c0b21c35 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_continuouswebjob.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContinuousWebJob struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ContinuousWebJobProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_continuouswebjobproperties.go b/resource-manager/web/2024-11-01/webapps/model_continuouswebjobproperties.go new file mode 100644 index 00000000000..ae1f697a892 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_continuouswebjobproperties.go @@ -0,0 +1,17 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContinuousWebJobProperties struct { + DetailedStatus *string `json:"detailed_status,omitempty"` + Error *string `json:"error,omitempty"` + ExtraInfoUrl *string `json:"extra_info_url,omitempty"` + LogUrl *string `json:"log_url,omitempty"` + RunCommand *string `json:"run_command,omitempty"` + Settings *map[string]interface{} `json:"settings,omitempty"` + Status *ContinuousWebJobStatus `json:"status,omitempty"` + Url *string `json:"url,omitempty"` + UsingSdk *bool `json:"using_sdk,omitempty"` + WebJobType *WebJobType `json:"web_job_type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_cookieexpiration.go b/resource-manager/web/2024-11-01/webapps/model_cookieexpiration.go new file mode 100644 index 00000000000..1acd40bff42 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_cookieexpiration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CookieExpiration struct { + Convention *CookieExpirationConvention `json:"convention,omitempty"` + TimeToExpiration *string `json:"timeToExpiration,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_corssettings.go b/resource-manager/web/2024-11-01/webapps/model_corssettings.go new file mode 100644 index 00000000000..58894d63e23 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_corssettings.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CorsSettings struct { + AllowedOrigins *[]string `json:"allowedOrigins,omitempty"` + SupportCredentials *bool `json:"supportCredentials,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_csmdeploymentstatus.go b/resource-manager/web/2024-11-01/webapps/model_csmdeploymentstatus.go new file mode 100644 index 00000000000..011d7f38b97 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_csmdeploymentstatus.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmDeploymentStatus struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CsmDeploymentStatusProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_csmdeploymentstatusproperties.go b/resource-manager/web/2024-11-01/webapps/model_csmdeploymentstatusproperties.go new file mode 100644 index 00000000000..08a6ae20c11 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_csmdeploymentstatusproperties.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmDeploymentStatusProperties struct { + DeploymentId *string `json:"deploymentId,omitempty"` + Errors *[]ErrorEntity `json:"errors,omitempty"` + FailedInstancesLogs *[]string `json:"failedInstancesLogs,omitempty"` + NumberOfInstancesFailed *int64 `json:"numberOfInstancesFailed,omitempty"` + NumberOfInstancesInProgress *int64 `json:"numberOfInstancesInProgress,omitempty"` + NumberOfInstancesSuccessful *int64 `json:"numberOfInstancesSuccessful,omitempty"` + Status *DeploymentBuildStatus `json:"status,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_csmpublishingcredentialspoliciesentity.go b/resource-manager/web/2024-11-01/webapps/model_csmpublishingcredentialspoliciesentity.go new file mode 100644 index 00000000000..dcdf32e913e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_csmpublishingcredentialspoliciesentity.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmPublishingCredentialsPoliciesEntity struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CsmPublishingCredentialsPoliciesEntityProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_csmpublishingcredentialspoliciesentityproperties.go b/resource-manager/web/2024-11-01/webapps/model_csmpublishingcredentialspoliciesentityproperties.go new file mode 100644 index 00000000000..bc91e5c0882 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_csmpublishingcredentialspoliciesentityproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmPublishingCredentialsPoliciesEntityProperties struct { + Allow bool `json:"allow"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_csmpublishingprofileoptions.go b/resource-manager/web/2024-11-01/webapps/model_csmpublishingprofileoptions.go new file mode 100644 index 00000000000..acf65055371 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_csmpublishingprofileoptions.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmPublishingProfileOptions struct { + Format *PublishingProfileFormat `json:"format,omitempty"` + IncludeDisasterRecoveryEndpoints *bool `json:"includeDisasterRecoveryEndpoints,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_csmslotentity.go b/resource-manager/web/2024-11-01/webapps/model_csmslotentity.go new file mode 100644 index 00000000000..086fe3ab931 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_csmslotentity.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmSlotEntity struct { + PreserveVnet bool `json:"preserveVnet"` + TargetSlot string `json:"targetSlot"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_csmusagequota.go b/resource-manager/web/2024-11-01/webapps/model_csmusagequota.go new file mode 100644 index 00000000000..7fad4d7865d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_csmusagequota.go @@ -0,0 +1,30 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CsmUsageQuota struct { + CurrentValue *int64 `json:"currentValue,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *LocalizableString `json:"name,omitempty"` + NextResetTime *string `json:"nextResetTime,omitempty"` + Unit *string `json:"unit,omitempty"` +} + +func (o *CsmUsageQuota) GetNextResetTimeAsTime() (*time.Time, error) { + if o.NextResetTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextResetTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CsmUsageQuota) SetNextResetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextResetTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_customhostnameanalysisresult.go b/resource-manager/web/2024-11-01/webapps/model_customhostnameanalysisresult.go new file mode 100644 index 00000000000..965958b5906 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_customhostnameanalysisresult.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomHostnameAnalysisResult struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *CustomHostnameAnalysisResultProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_customhostnameanalysisresultproperties.go b/resource-manager/web/2024-11-01/webapps/model_customhostnameanalysisresultproperties.go new file mode 100644 index 00000000000..e8641765248 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_customhostnameanalysisresultproperties.go @@ -0,0 +1,18 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomHostnameAnalysisResultProperties struct { + ARecords *[]string `json:"aRecords,omitempty"` + AlternateCNameRecords *[]string `json:"alternateCNameRecords,omitempty"` + AlternateTxtRecords *[]string `json:"alternateTxtRecords,omitempty"` + CNameRecords *[]string `json:"cNameRecords,omitempty"` + ConflictingAppResourceId *string `json:"conflictingAppResourceId,omitempty"` + CustomDomainVerificationFailureInfo *ErrorEntity `json:"customDomainVerificationFailureInfo,omitempty"` + CustomDomainVerificationTest *DnsVerificationTestResult `json:"customDomainVerificationTest,omitempty"` + HasConflictAcrossSubscription *bool `json:"hasConflictAcrossSubscription,omitempty"` + HasConflictOnScaleUnit *bool `json:"hasConflictOnScaleUnit,omitempty"` + IsHostnameAlreadyVerified *bool `json:"isHostnameAlreadyVerified,omitempty"` + TxtRecords *[]string `json:"txtRecords,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_customopenidconnectprovider.go b/resource-manager/web/2024-11-01/webapps/model_customopenidconnectprovider.go new file mode 100644 index 00000000000..6131cc54b0f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_customopenidconnectprovider.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomOpenIdConnectProvider struct { + Enabled *bool `json:"enabled,omitempty"` + Login *OpenIdConnectLogin `json:"login,omitempty"` + Registration *OpenIdConnectRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_daprconfig.go b/resource-manager/web/2024-11-01/webapps/model_daprconfig.go new file mode 100644 index 00000000000..4405627b643 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_daprconfig.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DaprConfig struct { + AppId *string `json:"appId,omitempty"` + AppPort *int64 `json:"appPort,omitempty"` + EnableApiLogging *bool `json:"enableApiLogging,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + HTTPMaxRequestSize *int64 `json:"httpMaxRequestSize,omitempty"` + HTTPReadBufferSize *int64 `json:"httpReadBufferSize,omitempty"` + LogLevel *DaprLogLevel `json:"logLevel,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_databasebackupsetting.go b/resource-manager/web/2024-11-01/webapps/model_databasebackupsetting.go new file mode 100644 index 00000000000..57baff31aa0 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_databasebackupsetting.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabaseBackupSetting struct { + ConnectionString *string `json:"connectionString,omitempty"` + ConnectionStringName *string `json:"connectionStringName,omitempty"` + DatabaseType DatabaseType `json:"databaseType"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_defaultauthorizationpolicy.go b/resource-manager/web/2024-11-01/webapps/model_defaultauthorizationpolicy.go new file mode 100644 index 00000000000..7cc4f0cf723 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_defaultauthorizationpolicy.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DefaultAuthorizationPolicy struct { + AllowedApplications *[]string `json:"allowedApplications,omitempty"` + AllowedPrincipals *AllowedPrincipals `json:"allowedPrincipals,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_deletedapprestorerequest.go b/resource-manager/web/2024-11-01/webapps/model_deletedapprestorerequest.go new file mode 100644 index 00000000000..9ef81650415 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_deletedapprestorerequest.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedAppRestoreRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DeletedAppRestoreRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_deletedapprestorerequestproperties.go b/resource-manager/web/2024-11-01/webapps/model_deletedapprestorerequestproperties.go new file mode 100644 index 00000000000..48010e62a87 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_deletedapprestorerequestproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeletedAppRestoreRequestProperties struct { + DeletedSiteId *string `json:"deletedSiteId,omitempty"` + RecoverConfiguration *bool `json:"recoverConfiguration,omitempty"` + SnapshotTime *string `json:"snapshotTime,omitempty"` + UseDRSecondary *bool `json:"useDRSecondary,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_deployment.go b/resource-manager/web/2024-11-01/webapps/model_deployment.go new file mode 100644 index 00000000000..764e2891dd4 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_deployment.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Deployment struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DeploymentProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_deploymentproperties.go b/resource-manager/web/2024-11-01/webapps/model_deploymentproperties.go new file mode 100644 index 00000000000..62df75e6494 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_deploymentproperties.go @@ -0,0 +1,46 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeploymentProperties struct { + Active *bool `json:"active,omitempty"` + Author *string `json:"author,omitempty"` + AuthorEmail *string `json:"author_email,omitempty"` + Deployer *string `json:"deployer,omitempty"` + Details *string `json:"details,omitempty"` + EndTime *string `json:"end_time,omitempty"` + Message *string `json:"message,omitempty"` + StartTime *string `json:"start_time,omitempty"` + Status *int64 `json:"status,omitempty"` +} + +func (o *DeploymentProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DeploymentProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *DeploymentProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *DeploymentProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_enabledconfig.go b/resource-manager/web/2024-11-01/webapps/model_enabledconfig.go new file mode 100644 index 00000000000..740c6a6f750 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_enabledconfig.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnabledConfig struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_environmentvariable.go b/resource-manager/web/2024-11-01/webapps/model_environmentvariable.go new file mode 100644 index 00000000000..44c25f7e4c1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_environmentvariable.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentVariable struct { + Name string `json:"name"` + Value string `json:"value"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_errorentity.go b/resource-manager/web/2024-11-01/webapps/model_errorentity.go new file mode 100644 index 00000000000..3d84f5ece58 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_errorentity.go @@ -0,0 +1,15 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorEntity struct { + Code *string `json:"code,omitempty"` + Details *[]ErrorEntity `json:"details,omitempty"` + ExtendedCode *string `json:"extendedCode,omitempty"` + InnerErrors *[]ErrorEntity `json:"innerErrors,omitempty"` + Message *string `json:"message,omitempty"` + MessageTemplate *string `json:"messageTemplate,omitempty"` + Parameters *[]string `json:"parameters,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_experiments.go b/resource-manager/web/2024-11-01/webapps/model_experiments.go new file mode 100644 index 00000000000..9e8a3418c84 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_experiments.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Experiments struct { + RampUpRules *[]RampUpRule `json:"rampUpRules,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_extendedlocation.go b/resource-manager/web/2024-11-01/webapps/model_extendedlocation.go new file mode 100644 index 00000000000..3f619b04f38 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_extendedlocation.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExtendedLocation struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_facebook.go b/resource-manager/web/2024-11-01/webapps/model_facebook.go new file mode 100644 index 00000000000..834ae971243 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_facebook.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Facebook struct { + Enabled *bool `json:"enabled,omitempty"` + GraphApiVersion *string `json:"graphApiVersion,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *AppRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_filesystemapplicationlogsconfig.go b/resource-manager/web/2024-11-01/webapps/model_filesystemapplicationlogsconfig.go new file mode 100644 index 00000000000..89cb89d942b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_filesystemapplicationlogsconfig.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FileSystemApplicationLogsConfig struct { + Level *LogLevel `json:"level,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_filesystemhttplogsconfig.go b/resource-manager/web/2024-11-01/webapps/model_filesystemhttplogsconfig.go new file mode 100644 index 00000000000..f69fa8fecca --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_filesystemhttplogsconfig.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FileSystemHTTPLogsConfig struct { + Enabled *bool `json:"enabled,omitempty"` + RetentionInDays *int64 `json:"retentionInDays,omitempty"` + RetentionInMb *int64 `json:"retentionInMb,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_filesystemtokenstore.go b/resource-manager/web/2024-11-01/webapps/model_filesystemtokenstore.go new file mode 100644 index 00000000000..123a111d50b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_filesystemtokenstore.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FileSystemTokenStore struct { + Directory *string `json:"directory,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_forwardproxy.go b/resource-manager/web/2024-11-01/webapps/model_forwardproxy.go new file mode 100644 index 00000000000..897a226b706 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_forwardproxy.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ForwardProxy struct { + Convention *ForwardProxyConvention `json:"convention,omitempty"` + CustomHostHeaderName *string `json:"customHostHeaderName,omitempty"` + CustomProtoHeaderName *string `json:"customProtoHeaderName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_functionappconfig.go b/resource-manager/web/2024-11-01/webapps/model_functionappconfig.go new file mode 100644 index 00000000000..598987c0273 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_functionappconfig.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionAppConfig struct { + Deployment *FunctionsDeployment `json:"deployment,omitempty"` + Runtime *FunctionsRuntime `json:"runtime,omitempty"` + ScaleAndConcurrency *FunctionsScaleAndConcurrency `json:"scaleAndConcurrency,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_functionenvelope.go b/resource-manager/web/2024-11-01/webapps/model_functionenvelope.go new file mode 100644 index 00000000000..d690c668b8a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_functionenvelope.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionEnvelope struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *FunctionEnvelopeProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_functionenvelopeproperties.go b/resource-manager/web/2024-11-01/webapps/model_functionenvelopeproperties.go new file mode 100644 index 00000000000..b32434f7616 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_functionenvelopeproperties.go @@ -0,0 +1,20 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionEnvelopeProperties struct { + Config *interface{} `json:"config,omitempty"` + ConfigHref *string `json:"config_href,omitempty"` + Files *map[string]string `json:"files,omitempty"` + FunctionAppId *string `json:"function_app_id,omitempty"` + Href *string `json:"href,omitempty"` + InvokeUrlTemplate *string `json:"invoke_url_template,omitempty"` + IsDisabled *bool `json:"isDisabled,omitempty"` + Language *string `json:"language,omitempty"` + ScriptHref *string `json:"script_href,omitempty"` + ScriptRootPathHref *string `json:"script_root_path_href,omitempty"` + SecretsFileHref *string `json:"secrets_file_href,omitempty"` + TestData *string `json:"test_data,omitempty"` + TestDataHref *string `json:"test_data_href,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_functionsalwaysreadyconfig.go b/resource-manager/web/2024-11-01/webapps/model_functionsalwaysreadyconfig.go new file mode 100644 index 00000000000..b8121838cd6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_functionsalwaysreadyconfig.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsAlwaysReadyConfig struct { + InstanceCount *int64 `json:"instanceCount,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_functionsdeployment.go b/resource-manager/web/2024-11-01/webapps/model_functionsdeployment.go new file mode 100644 index 00000000000..fa7c6e12a33 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_functionsdeployment.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeployment struct { + Storage *FunctionsDeploymentStorage `json:"storage,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_functionsdeploymentstorage.go b/resource-manager/web/2024-11-01/webapps/model_functionsdeploymentstorage.go new file mode 100644 index 00000000000..b8752386166 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_functionsdeploymentstorage.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorage struct { + Authentication *FunctionsDeploymentStorageAuthentication `json:"authentication,omitempty"` + Type *FunctionsDeploymentStorageType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_functionsdeploymentstorageauthentication.go b/resource-manager/web/2024-11-01/webapps/model_functionsdeploymentstorageauthentication.go new file mode 100644 index 00000000000..087a9f1559f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_functionsdeploymentstorageauthentication.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsDeploymentStorageAuthentication struct { + StorageAccountConnectionStringName *string `json:"storageAccountConnectionStringName,omitempty"` + Type *AuthenticationType `json:"type,omitempty"` + UserAssignedIdentityResourceId *string `json:"userAssignedIdentityResourceId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_functionsecrets.go b/resource-manager/web/2024-11-01/webapps/model_functionsecrets.go new file mode 100644 index 00000000000..daa46718fb3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_functionsecrets.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionSecrets struct { + Key *string `json:"key,omitempty"` + TriggerUrl *string `json:"trigger_url,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_functionsruntime.go b/resource-manager/web/2024-11-01/webapps/model_functionsruntime.go new file mode 100644 index 00000000000..025981cf91c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_functionsruntime.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsRuntime struct { + Name *RuntimeName `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_functionsscaleandconcurrency.go b/resource-manager/web/2024-11-01/webapps/model_functionsscaleandconcurrency.go new file mode 100644 index 00000000000..2d29b194fcc --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_functionsscaleandconcurrency.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrency struct { + AlwaysReady *[]FunctionsAlwaysReadyConfig `json:"alwaysReady,omitempty"` + InstanceMemoryMB *int64 `json:"instanceMemoryMB,omitempty"` + MaximumInstanceCount *int64 `json:"maximumInstanceCount,omitempty"` + Triggers *FunctionsScaleAndConcurrencyTriggers `json:"triggers,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_functionsscaleandconcurrencytriggers.go b/resource-manager/web/2024-11-01/webapps/model_functionsscaleandconcurrencytriggers.go new file mode 100644 index 00000000000..070def9b6d2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_functionsscaleandconcurrencytriggers.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggers struct { + HTTP *FunctionsScaleAndConcurrencyTriggersHTTP `json:"http,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_functionsscaleandconcurrencytriggershttp.go b/resource-manager/web/2024-11-01/webapps/model_functionsscaleandconcurrencytriggershttp.go new file mode 100644 index 00000000000..e5d499bf429 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_functionsscaleandconcurrencytriggershttp.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FunctionsScaleAndConcurrencyTriggersHTTP struct { + PerInstanceConcurrency *int64 `json:"perInstanceConcurrency,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_github.go b/resource-manager/web/2024-11-01/webapps/model_github.go new file mode 100644 index 00000000000..0baa912b7f4 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_github.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GitHub struct { + Enabled *bool `json:"enabled,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *ClientRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_githubactioncodeconfiguration.go b/resource-manager/web/2024-11-01/webapps/model_githubactioncodeconfiguration.go new file mode 100644 index 00000000000..96e13fda517 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_githubactioncodeconfiguration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GitHubActionCodeConfiguration struct { + RuntimeStack *string `json:"runtimeStack,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_githubactionconfiguration.go b/resource-manager/web/2024-11-01/webapps/model_githubactionconfiguration.go new file mode 100644 index 00000000000..3e0089953d8 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_githubactionconfiguration.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GitHubActionConfiguration struct { + CodeConfiguration *GitHubActionCodeConfiguration `json:"codeConfiguration,omitempty"` + ContainerConfiguration *GitHubActionContainerConfiguration `json:"containerConfiguration,omitempty"` + GenerateWorkflowFile *bool `json:"generateWorkflowFile,omitempty"` + IsLinux *bool `json:"isLinux,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_githubactioncontainerconfiguration.go b/resource-manager/web/2024-11-01/webapps/model_githubactioncontainerconfiguration.go new file mode 100644 index 00000000000..db70b234959 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_githubactioncontainerconfiguration.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GitHubActionContainerConfiguration struct { + ImageName *string `json:"imageName,omitempty"` + Password *string `json:"password,omitempty"` + ServerURL *string `json:"serverUrl,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_globalvalidation.go b/resource-manager/web/2024-11-01/webapps/model_globalvalidation.go new file mode 100644 index 00000000000..e3f6446954e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_globalvalidation.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GlobalValidation struct { + ExcludedPaths *[]string `json:"excludedPaths,omitempty"` + RedirectToProvider *string `json:"redirectToProvider,omitempty"` + RequireAuthentication *bool `json:"requireAuthentication,omitempty"` + UnauthenticatedClientAction *UnauthenticatedClientActionV2 `json:"unauthenticatedClientAction,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_google.go b/resource-manager/web/2024-11-01/webapps/model_google.go new file mode 100644 index 00000000000..739f5aba70b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_google.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Google struct { + Enabled *bool `json:"enabled,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *ClientRegistration `json:"registration,omitempty"` + Validation *AllowedAudiencesValidation `json:"validation,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_handlermapping.go b/resource-manager/web/2024-11-01/webapps/model_handlermapping.go new file mode 100644 index 00000000000..b5593f88002 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_handlermapping.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HandlerMapping struct { + Arguments *string `json:"arguments,omitempty"` + Extension *string `json:"extension,omitempty"` + ScriptProcessor *string `json:"scriptProcessor,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_hostingenvironmentprofile.go b/resource-manager/web/2024-11-01/webapps/model_hostingenvironmentprofile.go new file mode 100644 index 00000000000..e75ca71ee32 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_hostingenvironmentprofile.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostingEnvironmentProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_hostkeys.go b/resource-manager/web/2024-11-01/webapps/model_hostkeys.go new file mode 100644 index 00000000000..af8cb685979 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_hostkeys.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostKeys struct { + FunctionKeys *map[string]string `json:"functionKeys,omitempty"` + MasterKey *string `json:"masterKey,omitempty"` + SystemKeys *map[string]string `json:"systemKeys,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_hostnamebinding.go b/resource-manager/web/2024-11-01/webapps/model_hostnamebinding.go new file mode 100644 index 00000000000..4759b208afa --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_hostnamebinding.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostNameBinding struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HostNameBindingProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_hostnamebindingproperties.go b/resource-manager/web/2024-11-01/webapps/model_hostnamebindingproperties.go new file mode 100644 index 00000000000..89d397ba5fa --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_hostnamebindingproperties.go @@ -0,0 +1,16 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostNameBindingProperties struct { + AzureResourceName *string `json:"azureResourceName,omitempty"` + AzureResourceType *AzureResourceType `json:"azureResourceType,omitempty"` + CustomHostNameDnsRecordType *CustomHostNameDnsRecordType `json:"customHostNameDnsRecordType,omitempty"` + DomainId *string `json:"domainId,omitempty"` + HostNameType *HostNameType `json:"hostNameType,omitempty"` + SiteName *string `json:"siteName,omitempty"` + SslState *SslState `json:"sslState,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + VirtualIP *string `json:"virtualIP,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_hostnamesslstate.go b/resource-manager/web/2024-11-01/webapps/model_hostnamesslstate.go new file mode 100644 index 00000000000..a330c5447ea --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_hostnamesslstate.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HostNameSslState struct { + HostType *HostType `json:"hostType,omitempty"` + Name *string `json:"name,omitempty"` + SslState *SslState `json:"sslState,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` + ToUpdate *bool `json:"toUpdate,omitempty"` + VirtualIP *string `json:"virtualIP,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_httplogsconfig.go b/resource-manager/web/2024-11-01/webapps/model_httplogsconfig.go new file mode 100644 index 00000000000..006cccdc08f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_httplogsconfig.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPLogsConfig struct { + AzureBlobStorage *AzureBlobStorageHTTPLogsConfig `json:"azureBlobStorage,omitempty"` + FileSystem *FileSystemHTTPLogsConfig `json:"fileSystem,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_httpsettings.go b/resource-manager/web/2024-11-01/webapps/model_httpsettings.go new file mode 100644 index 00000000000..50a72c92e61 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_httpsettings.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPSettings struct { + ForwardProxy *ForwardProxy `json:"forwardProxy,omitempty"` + RequireHTTPS *bool `json:"requireHttps,omitempty"` + Routes *HTTPSettingsRoutes `json:"routes,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_httpsettingsroutes.go b/resource-manager/web/2024-11-01/webapps/model_httpsettingsroutes.go new file mode 100644 index 00000000000..deb06f51434 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_httpsettingsroutes.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HTTPSettingsRoutes struct { + ApiPrefix *string `json:"apiPrefix,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_hybridconnection.go b/resource-manager/web/2024-11-01/webapps/model_hybridconnection.go new file mode 100644 index 00000000000..57e4841bb22 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_hybridconnection.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnection struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *HybridConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_hybridconnectionproperties.go b/resource-manager/web/2024-11-01/webapps/model_hybridconnectionproperties.go new file mode 100644 index 00000000000..82c9d19bbb9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_hybridconnectionproperties.go @@ -0,0 +1,15 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionProperties struct { + Hostname *string `json:"hostname,omitempty"` + Port *int64 `json:"port,omitempty"` + RelayArmUri *string `json:"relayArmUri,omitempty"` + RelayName *string `json:"relayName,omitempty"` + SendKeyName *string `json:"sendKeyName,omitempty"` + SendKeyValue *string `json:"sendKeyValue,omitempty"` + ServiceBusNamespace *string `json:"serviceBusNamespace,omitempty"` + ServiceBusSuffix *string `json:"serviceBusSuffix,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_identifier.go b/resource-manager/web/2024-11-01/webapps/model_identifier.go new file mode 100644 index 00000000000..134faaa6890 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_identifier.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Identifier struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *IdentifierProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_identifierproperties.go b/resource-manager/web/2024-11-01/webapps/model_identifierproperties.go new file mode 100644 index 00000000000..3826ff38a2e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_identifierproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentifierProperties struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_identityproviders.go b/resource-manager/web/2024-11-01/webapps/model_identityproviders.go new file mode 100644 index 00000000000..383fb8243f3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_identityproviders.go @@ -0,0 +1,16 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityProviders struct { + Apple *Apple `json:"apple,omitempty"` + AzureActiveDirectory *AzureActiveDirectory `json:"azureActiveDirectory,omitempty"` + AzureStaticWebApps *AzureStaticWebApps `json:"azureStaticWebApps,omitempty"` + CustomOpenIdConnectProviders *map[string]CustomOpenIdConnectProvider `json:"customOpenIdConnectProviders,omitempty"` + Facebook *Facebook `json:"facebook,omitempty"` + GitHub *GitHub `json:"gitHub,omitempty"` + Google *Google `json:"google,omitempty"` + LegacyMicrosoftAccount *LegacyMicrosoftAccount `json:"legacyMicrosoftAccount,omitempty"` + Twitter *Twitter `json:"twitter,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_ipsecurityrestriction.go b/resource-manager/web/2024-11-01/webapps/model_ipsecurityrestriction.go new file mode 100644 index 00000000000..2d96d9b6520 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_ipsecurityrestriction.go @@ -0,0 +1,18 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPSecurityRestriction struct { + Action *string `json:"action,omitempty"` + Description *string `json:"description,omitempty"` + Headers *map[string][]string `json:"headers,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Name *string `json:"name,omitempty"` + Priority *int64 `json:"priority,omitempty"` + SubnetMask *string `json:"subnetMask,omitempty"` + SubnetTrafficTag *int64 `json:"subnetTrafficTag,omitempty"` + Tag *IPFilterTag `json:"tag,omitempty"` + VnetSubnetResourceId *string `json:"vnetSubnetResourceId,omitempty"` + VnetTrafficTag *int64 `json:"vnetTrafficTag,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_jwtclaimchecks.go b/resource-manager/web/2024-11-01/webapps/model_jwtclaimchecks.go new file mode 100644 index 00000000000..be04286a8e9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_jwtclaimchecks.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JwtClaimChecks struct { + AllowedClientApplications *[]string `json:"allowedClientApplications,omitempty"` + AllowedGroups *[]string `json:"allowedGroups,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_keyinfo.go b/resource-manager/web/2024-11-01/webapps/model_keyinfo.go new file mode 100644 index 00000000000..5463d9e53ce --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_keyinfo.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyInfo struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_legacymicrosoftaccount.go b/resource-manager/web/2024-11-01/webapps/model_legacymicrosoftaccount.go new file mode 100644 index 00000000000..77b7761115c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_legacymicrosoftaccount.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LegacyMicrosoftAccount struct { + Enabled *bool `json:"enabled,omitempty"` + Login *LoginScopes `json:"login,omitempty"` + Registration *ClientRegistration `json:"registration,omitempty"` + Validation *AllowedAudiencesValidation `json:"validation,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_localizablestring.go b/resource-manager/web/2024-11-01/webapps/model_localizablestring.go new file mode 100644 index 00000000000..1fac79f7d9f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_localizablestring.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LocalizableString struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_login.go b/resource-manager/web/2024-11-01/webapps/model_login.go new file mode 100644 index 00000000000..3e8e040d421 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_login.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Login struct { + AllowedExternalRedirectURLs *[]string `json:"allowedExternalRedirectUrls,omitempty"` + CookieExpiration *CookieExpiration `json:"cookieExpiration,omitempty"` + Nonce *Nonce `json:"nonce,omitempty"` + PreserveURLFragmentsForLogins *bool `json:"preserveUrlFragmentsForLogins,omitempty"` + Routes *LoginRoutes `json:"routes,omitempty"` + TokenStore *TokenStore `json:"tokenStore,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_loginroutes.go b/resource-manager/web/2024-11-01/webapps/model_loginroutes.go new file mode 100644 index 00000000000..8009af99b43 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_loginroutes.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoginRoutes struct { + LogoutEndpoint *string `json:"logoutEndpoint,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_loginscopes.go b/resource-manager/web/2024-11-01/webapps/model_loginscopes.go new file mode 100644 index 00000000000..4b1160d5562 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_loginscopes.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoginScopes struct { + Scopes *[]string `json:"scopes,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_migratemysqlrequest.go b/resource-manager/web/2024-11-01/webapps/model_migratemysqlrequest.go new file mode 100644 index 00000000000..7661e8391ae --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_migratemysqlrequest.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateMySqlRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MigrateMySqlRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_migratemysqlrequestproperties.go b/resource-manager/web/2024-11-01/webapps/model_migratemysqlrequestproperties.go new file mode 100644 index 00000000000..0a9492d11bb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_migratemysqlrequestproperties.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateMySqlRequestProperties struct { + ConnectionString string `json:"connectionString"` + MigrationType MySqlMigrationType `json:"migrationType"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_migratemysqlstatus.go b/resource-manager/web/2024-11-01/webapps/model_migratemysqlstatus.go new file mode 100644 index 00000000000..93e2c1806cd --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_migratemysqlstatus.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateMySqlStatus struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MigrateMySqlStatusProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_migratemysqlstatusproperties.go b/resource-manager/web/2024-11-01/webapps/model_migratemysqlstatusproperties.go new file mode 100644 index 00000000000..bb707fc1768 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_migratemysqlstatusproperties.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MigrateMySqlStatusProperties struct { + LocalMySqlEnabled *bool `json:"localMySqlEnabled,omitempty"` + MigrationOperationStatus *OperationStatus `json:"migrationOperationStatus,omitempty"` + OperationId *string `json:"operationId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_msdeploy.go b/resource-manager/web/2024-11-01/webapps/model_msdeploy.go new file mode 100644 index 00000000000..27ad333e0e5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_msdeploy.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeploy struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MSDeployProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_msdeploycore.go b/resource-manager/web/2024-11-01/webapps/model_msdeploycore.go new file mode 100644 index 00000000000..e87d9f960ad --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_msdeploycore.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeployCore struct { + AppOffline *bool `json:"appOffline,omitempty"` + ConnectionString *string `json:"connectionString,omitempty"` + DbType *string `json:"dbType,omitempty"` + PackageUri *string `json:"packageUri,omitempty"` + SetParameters *map[string]string `json:"setParameters,omitempty"` + SetParametersXmlFileUri *string `json:"setParametersXmlFileUri,omitempty"` + SkipAppData *bool `json:"skipAppData,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_msdeploylog.go b/resource-manager/web/2024-11-01/webapps/model_msdeploylog.go new file mode 100644 index 00000000000..344db502e39 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_msdeploylog.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeployLog struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MSDeployLogProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_msdeploylogentry.go b/resource-manager/web/2024-11-01/webapps/model_msdeploylogentry.go new file mode 100644 index 00000000000..b300f240305 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_msdeploylogentry.go @@ -0,0 +1,28 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeployLogEntry struct { + Message *string `json:"message,omitempty"` + Time *string `json:"time,omitempty"` + Type *MSDeployLogEntryType `json:"type,omitempty"` +} + +func (o *MSDeployLogEntry) GetTimeAsTime() (*time.Time, error) { + if o.Time == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Time, "2006-01-02T15:04:05Z07:00") +} + +func (o *MSDeployLogEntry) SetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Time = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_msdeploylogproperties.go b/resource-manager/web/2024-11-01/webapps/model_msdeploylogproperties.go new file mode 100644 index 00000000000..4d30fd74a57 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_msdeploylogproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeployLogProperties struct { + Entries *[]MSDeployLogEntry `json:"entries,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_msdeployproperties.go b/resource-manager/web/2024-11-01/webapps/model_msdeployproperties.go new file mode 100644 index 00000000000..2fdb5e36d60 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_msdeployproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeployProperties struct { + AddOnPackages *[]MSDeployCore `json:"addOnPackages,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_msdeploystatus.go b/resource-manager/web/2024-11-01/webapps/model_msdeploystatus.go new file mode 100644 index 00000000000..9f782217369 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_msdeploystatus.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeployStatus struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MSDeployStatusProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_msdeploystatusproperties.go b/resource-manager/web/2024-11-01/webapps/model_msdeploystatusproperties.go new file mode 100644 index 00000000000..739caae3f32 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_msdeploystatusproperties.go @@ -0,0 +1,42 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MSDeployStatusProperties struct { + Complete *bool `json:"complete,omitempty"` + Deployer *string `json:"deployer,omitempty"` + EndTime *string `json:"endTime,omitempty"` + ProvisioningState *MSDeployProvisioningState `json:"provisioningState,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *MSDeployStatusProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MSDeployStatusProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *MSDeployStatusProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *MSDeployStatusProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_namevaluepair.go b/resource-manager/web/2024-11-01/webapps/model_namevaluepair.go new file mode 100644 index 00000000000..db12fa3a313 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_namevaluepair.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NameValuePair struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_networkfeatures.go b/resource-manager/web/2024-11-01/webapps/model_networkfeatures.go new file mode 100644 index 00000000000..34cbbf7f121 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_networkfeatures.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkFeatures struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *NetworkFeaturesProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_networkfeaturesproperties.go b/resource-manager/web/2024-11-01/webapps/model_networkfeaturesproperties.go new file mode 100644 index 00000000000..a51a0260488 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_networkfeaturesproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkFeaturesProperties struct { + HybridConnections *[]RelayServiceConnectionEntity `json:"hybridConnections,omitempty"` + HybridConnectionsV2 *[]HybridConnection `json:"hybridConnectionsV2,omitempty"` + VirtualNetworkConnection *VnetInfo `json:"virtualNetworkConnection,omitempty"` + VirtualNetworkName *string `json:"virtualNetworkName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_networktrace.go b/resource-manager/web/2024-11-01/webapps/model_networktrace.go new file mode 100644 index 00000000000..4c22aec67e9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_networktrace.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkTrace struct { + Message *string `json:"message,omitempty"` + Path *string `json:"path,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_nonce.go b/resource-manager/web/2024-11-01/webapps/model_nonce.go new file mode 100644 index 00000000000..ae90e0008f5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_nonce.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Nonce struct { + NonceExpirationInterval *string `json:"nonceExpirationInterval,omitempty"` + ValidateNonce *bool `json:"validateNonce,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_openidconnectclientcredential.go b/resource-manager/web/2024-11-01/webapps/model_openidconnectclientcredential.go new file mode 100644 index 00000000000..11d3fe51886 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_openidconnectclientcredential.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenIdConnectClientCredential struct { + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` + Method *ClientCredentialMethod `json:"method,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_openidconnectconfig.go b/resource-manager/web/2024-11-01/webapps/model_openidconnectconfig.go new file mode 100644 index 00000000000..c76119be643 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_openidconnectconfig.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenIdConnectConfig struct { + AuthorizationEndpoint *string `json:"authorizationEndpoint,omitempty"` + CertificationUri *string `json:"certificationUri,omitempty"` + Issuer *string `json:"issuer,omitempty"` + TokenEndpoint *string `json:"tokenEndpoint,omitempty"` + WellKnownOpenIdConfiguration *string `json:"wellKnownOpenIdConfiguration,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_openidconnectlogin.go b/resource-manager/web/2024-11-01/webapps/model_openidconnectlogin.go new file mode 100644 index 00000000000..e8a1c2ae8ed --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_openidconnectlogin.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenIdConnectLogin struct { + NameClaimType *string `json:"nameClaimType,omitempty"` + Scopes *[]string `json:"scopes,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_openidconnectregistration.go b/resource-manager/web/2024-11-01/webapps/model_openidconnectregistration.go new file mode 100644 index 00000000000..faf47478e0c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_openidconnectregistration.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenIdConnectRegistration struct { + ClientCredential *OpenIdConnectClientCredential `json:"clientCredential,omitempty"` + ClientId *string `json:"clientId,omitempty"` + OpenIdConnectConfiguration *OpenIdConnectConfig `json:"openIdConnectConfiguration,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_operation.go b/resource-manager/web/2024-11-01/webapps/model_operation.go new file mode 100644 index 00000000000..19973cf1953 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_operation.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Operation struct { + CreatedTime *string `json:"createdTime,omitempty"` + Errors *[]ErrorEntity `json:"errors,omitempty"` + ExpirationTime *string `json:"expirationTime,omitempty"` + GeoMasterOperationId *string `json:"geoMasterOperationId,omitempty"` + Id *string `json:"id,omitempty"` + ModifiedTime *string `json:"modifiedTime,omitempty"` + Name *string `json:"name,omitempty"` + Status *OperationStatus `json:"status,omitempty"` +} + +func (o *Operation) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *Operation) GetExpirationTimeAsTime() (*time.Time, error) { + if o.ExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpirationTime = &formatted +} + +func (o *Operation) GetModifiedTimeAsTime() (*time.Time, error) { + if o.ModifiedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *Operation) SetModifiedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_outboundvnetrouting.go b/resource-manager/web/2024-11-01/webapps/model_outboundvnetrouting.go new file mode 100644 index 00000000000..d5595328db5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_outboundvnetrouting.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundVnetRouting struct { + AllTraffic *bool `json:"allTraffic,omitempty"` + ApplicationTraffic *bool `json:"applicationTraffic,omitempty"` + BackupRestoreTraffic *bool `json:"backupRestoreTraffic,omitempty"` + ContentShareTraffic *bool `json:"contentShareTraffic,omitempty"` + ImagePullTraffic *bool `json:"imagePullTraffic,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_perfmonresponse.go b/resource-manager/web/2024-11-01/webapps/model_perfmonresponse.go new file mode 100644 index 00000000000..9b5ecb7207b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_perfmonresponse.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PerfMonResponse struct { + Code *string `json:"code,omitempty"` + Data *PerfMonSet `json:"data,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_perfmonsample.go b/resource-manager/web/2024-11-01/webapps/model_perfmonsample.go new file mode 100644 index 00000000000..d431429707b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_perfmonsample.go @@ -0,0 +1,28 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PerfMonSample struct { + InstanceName *string `json:"instanceName,omitempty"` + Time *string `json:"time,omitempty"` + Value *float64 `json:"value,omitempty"` +} + +func (o *PerfMonSample) GetTimeAsTime() (*time.Time, error) { + if o.Time == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Time, "2006-01-02T15:04:05Z07:00") +} + +func (o *PerfMonSample) SetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Time = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_perfmonset.go b/resource-manager/web/2024-11-01/webapps/model_perfmonset.go new file mode 100644 index 00000000000..3c4b44ec647 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_perfmonset.go @@ -0,0 +1,42 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PerfMonSet struct { + EndTime *string `json:"endTime,omitempty"` + Name *string `json:"name,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeGrain *string `json:"timeGrain,omitempty"` + Values *[]PerfMonSample `json:"values,omitempty"` +} + +func (o *PerfMonSet) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PerfMonSet) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *PerfMonSet) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PerfMonSet) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_premieraddon.go b/resource-manager/web/2024-11-01/webapps/model_premieraddon.go new file mode 100644 index 00000000000..7d64dfe405d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_premieraddon.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOn struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *PremierAddOnProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_premieraddonpatchresource.go b/resource-manager/web/2024-11-01/webapps/model_premieraddonpatchresource.go new file mode 100644 index 00000000000..6d715b148db --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_premieraddonpatchresource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOnPatchResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PremierAddOnPatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_premieraddonpatchresourceproperties.go b/resource-manager/web/2024-11-01/webapps/model_premieraddonpatchresourceproperties.go new file mode 100644 index 00000000000..6a330db952e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_premieraddonpatchresourceproperties.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOnPatchResourceProperties struct { + MarketplaceOffer *string `json:"marketplaceOffer,omitempty"` + MarketplacePublisher *string `json:"marketplacePublisher,omitempty"` + Product *string `json:"product,omitempty"` + Sku *string `json:"sku,omitempty"` + Vendor *string `json:"vendor,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_premieraddonproperties.go b/resource-manager/web/2024-11-01/webapps/model_premieraddonproperties.go new file mode 100644 index 00000000000..1a0c2eeb3eb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_premieraddonproperties.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PremierAddOnProperties struct { + MarketplaceOffer *string `json:"marketplaceOffer,omitempty"` + MarketplacePublisher *string `json:"marketplacePublisher,omitempty"` + Product *string `json:"product,omitempty"` + Sku *string `json:"sku,omitempty"` + Vendor *string `json:"vendor,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_privateaccess.go b/resource-manager/web/2024-11-01/webapps/model_privateaccess.go new file mode 100644 index 00000000000..57bb75c3f6a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_privateaccess.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateAccess struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateAccessProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_privateaccessproperties.go b/resource-manager/web/2024-11-01/webapps/model_privateaccessproperties.go new file mode 100644 index 00000000000..654c66fb229 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_privateaccessproperties.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateAccessProperties struct { + Enabled *bool `json:"enabled,omitempty"` + VirtualNetworks *[]PrivateAccessVirtualNetwork `json:"virtualNetworks,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_privateaccesssubnet.go b/resource-manager/web/2024-11-01/webapps/model_privateaccesssubnet.go new file mode 100644 index 00000000000..c0308f0a6b1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_privateaccesssubnet.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateAccessSubnet struct { + Key *int64 `json:"key,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_privateaccessvirtualnetwork.go b/resource-manager/web/2024-11-01/webapps/model_privateaccessvirtualnetwork.go new file mode 100644 index 00000000000..1aa31d5386c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_privateaccessvirtualnetwork.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateAccessVirtualNetwork struct { + Key *int64 `json:"key,omitempty"` + Name *string `json:"name,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + Subnets *[]PrivateAccessSubnet `json:"subnets,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_privatelinkconnectionstate.go b/resource-manager/web/2024-11-01/webapps/model_privatelinkconnectionstate.go new file mode 100644 index 00000000000..0cb41b46def --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_privatelinkconnectionstate.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *string `json:"status,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_privatelinkresource.go b/resource-manager/web/2024-11-01/webapps/model_privatelinkresource.go new file mode 100644 index 00000000000..8ad526f8d22 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_privatelinkresource.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id string `json:"id"` + Name string `json:"name"` + Properties PrivateLinkResourceProperties `json:"properties"` + Type string `json:"type"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_privatelinkresourceproperties.go b/resource-manager/web/2024-11-01/webapps/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..681e7763d0b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_privatelinkresourceswrapper.go b/resource-manager/web/2024-11-01/webapps/model_privatelinkresourceswrapper.go new file mode 100644 index 00000000000..44ee0fa08c8 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_privatelinkresourceswrapper.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesWrapper struct { + Value []PrivateLinkResource `json:"value"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_processinfo.go b/resource-manager/web/2024-11-01/webapps/model_processinfo.go new file mode 100644 index 00000000000..fc0db143ae2 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_processinfo.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProcessInfo struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProcessInfoProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_processinfoproperties.go b/resource-manager/web/2024-11-01/webapps/model_processinfoproperties.go new file mode 100644 index 00000000000..705da9f398d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_processinfoproperties.go @@ -0,0 +1,73 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProcessInfoProperties struct { + Children *[]string `json:"children,omitempty"` + CommandLine *string `json:"command_line,omitempty"` + DeploymentName *string `json:"deployment_name,omitempty"` + Description *string `json:"description,omitempty"` + EnvironmentVariables *map[string]string `json:"environment_variables,omitempty"` + FileName *string `json:"file_name,omitempty"` + HandleCount *int64 `json:"handle_count,omitempty"` + Href *string `json:"href,omitempty"` + Identifier *int64 `json:"identifier,omitempty"` + IisProfileTimeoutInSeconds *float64 `json:"iis_profile_timeout_in_seconds,omitempty"` + IsIisProfileRunning *bool `json:"is_iis_profile_running,omitempty"` + IsProfileRunning *bool `json:"is_profile_running,omitempty"` + IsScmSite *bool `json:"is_scm_site,omitempty"` + IsWebjob *bool `json:"is_webjob,omitempty"` + Minidump *string `json:"minidump,omitempty"` + ModuleCount *int64 `json:"module_count,omitempty"` + Modules *[]ProcessModuleInfo `json:"modules,omitempty"` + NonPagedSystemMemory *int64 `json:"non_paged_system_memory,omitempty"` + OpenFileHandles *[]string `json:"open_file_handles,omitempty"` + PagedMemory *int64 `json:"paged_memory,omitempty"` + PagedSystemMemory *int64 `json:"paged_system_memory,omitempty"` + Parent *string `json:"parent,omitempty"` + PeakPagedMemory *int64 `json:"peak_paged_memory,omitempty"` + PeakVirtualMemory *int64 `json:"peak_virtual_memory,omitempty"` + PeakWorkingSet *int64 `json:"peak_working_set,omitempty"` + PrivateMemory *int64 `json:"private_memory,omitempty"` + PrivilegedCpuTime *string `json:"privileged_cpu_time,omitempty"` + StartTime *string `json:"start_time,omitempty"` + ThreadCount *int64 `json:"thread_count,omitempty"` + Threads *[]ProcessThreadInfo `json:"threads,omitempty"` + TimeStamp *string `json:"time_stamp,omitempty"` + TotalCpuTime *string `json:"total_cpu_time,omitempty"` + UserCpuTime *string `json:"user_cpu_time,omitempty"` + UserName *string `json:"user_name,omitempty"` + VirtualMemory *int64 `json:"virtual_memory,omitempty"` + WorkingSet *int64 `json:"working_set,omitempty"` +} + +func (o *ProcessInfoProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessInfoProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +func (o *ProcessInfoProperties) GetTimeStampAsTime() (*time.Time, error) { + if o.TimeStamp == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessInfoProperties) SetTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimeStamp = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_processmoduleinfo.go b/resource-manager/web/2024-11-01/webapps/model_processmoduleinfo.go new file mode 100644 index 00000000000..9f12d6c8bab --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_processmoduleinfo.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProcessModuleInfo struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProcessModuleInfoProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_processmoduleinfoproperties.go b/resource-manager/web/2024-11-01/webapps/model_processmoduleinfoproperties.go new file mode 100644 index 00000000000..170aa09c221 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_processmoduleinfoproperties.go @@ -0,0 +1,18 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProcessModuleInfoProperties struct { + BaseAddress *string `json:"base_address,omitempty"` + FileDescription *string `json:"file_description,omitempty"` + FileName *string `json:"file_name,omitempty"` + FilePath *string `json:"file_path,omitempty"` + FileVersion *string `json:"file_version,omitempty"` + Href *string `json:"href,omitempty"` + IsDebug *bool `json:"is_debug,omitempty"` + Language *string `json:"language,omitempty"` + ModuleMemorySize *int64 `json:"module_memory_size,omitempty"` + Product *string `json:"product,omitempty"` + ProductVersion *string `json:"product_version,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_processthreadinfo.go b/resource-manager/web/2024-11-01/webapps/model_processthreadinfo.go new file mode 100644 index 00000000000..f11e4d7370c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_processthreadinfo.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProcessThreadInfo struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ProcessThreadInfoProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_processthreadinfoproperties.go b/resource-manager/web/2024-11-01/webapps/model_processthreadinfoproperties.go new file mode 100644 index 00000000000..e115c1477b6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_processthreadinfoproperties.go @@ -0,0 +1,37 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProcessThreadInfoProperties struct { + BasePriority *int64 `json:"base_priority,omitempty"` + CurrentPriority *int64 `json:"current_priority,omitempty"` + Href *string `json:"href,omitempty"` + Identifier *int64 `json:"identifier,omitempty"` + PriorityLevel *string `json:"priority_level,omitempty"` + Process *string `json:"process,omitempty"` + StartAddress *string `json:"start_address,omitempty"` + StartTime *string `json:"start_time,omitempty"` + State *string `json:"state,omitempty"` + TotalProcessorTime *string `json:"total_processor_time,omitempty"` + UserProcessorTime *string `json:"user_processor_time,omitempty"` + WaitReason *string `json:"wait_reason,omitempty"` +} + +func (o *ProcessThreadInfoProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ProcessThreadInfoProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_publiccertificate.go b/resource-manager/web/2024-11-01/webapps/model_publiccertificate.go new file mode 100644 index 00000000000..41d2238cf35 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_publiccertificate.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicCertificate struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PublicCertificateProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_publiccertificateproperties.go b/resource-manager/web/2024-11-01/webapps/model_publiccertificateproperties.go new file mode 100644 index 00000000000..291d9a59a0f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_publiccertificateproperties.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublicCertificateProperties struct { + Blob *string `json:"blob,omitempty"` + PublicCertificateLocation *PublicCertificateLocation `json:"publicCertificateLocation,omitempty"` + Thumbprint *string `json:"thumbprint,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_pushsettings.go b/resource-manager/web/2024-11-01/webapps/model_pushsettings.go new file mode 100644 index 00000000000..c233a60ea49 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_pushsettings.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettings struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PushSettingsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_pushsettingsproperties.go b/resource-manager/web/2024-11-01/webapps/model_pushsettingsproperties.go new file mode 100644 index 00000000000..bdf39a78d98 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_pushsettingsproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PushSettingsProperties struct { + DynamicTagsJson *string `json:"dynamicTagsJson,omitempty"` + IsPushEnabled bool `json:"isPushEnabled"` + TagWhitelistJson *string `json:"tagWhitelistJson,omitempty"` + TagsRequiringAuth *string `json:"tagsRequiringAuth,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_rampuprule.go b/resource-manager/web/2024-11-01/webapps/model_rampuprule.go new file mode 100644 index 00000000000..2688d09f601 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_rampuprule.go @@ -0,0 +1,15 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RampUpRule struct { + ActionHostName *string `json:"actionHostName,omitempty"` + ChangeDecisionCallbackURL *string `json:"changeDecisionCallbackUrl,omitempty"` + ChangeIntervalInMinutes *int64 `json:"changeIntervalInMinutes,omitempty"` + ChangeStep *float64 `json:"changeStep,omitempty"` + MaxReroutePercentage *float64 `json:"maxReroutePercentage,omitempty"` + MinReroutePercentage *float64 `json:"minReroutePercentage,omitempty"` + Name *string `json:"name,omitempty"` + ReroutePercentage *float64 `json:"reroutePercentage,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_relayserviceconnectionentity.go b/resource-manager/web/2024-11-01/webapps/model_relayserviceconnectionentity.go new file mode 100644 index 00000000000..a2bfbf4739e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_relayserviceconnectionentity.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RelayServiceConnectionEntity struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RelayServiceConnectionEntityProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_relayserviceconnectionentityproperties.go b/resource-manager/web/2024-11-01/webapps/model_relayserviceconnectionentityproperties.go new file mode 100644 index 00000000000..608b034c0df --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_relayserviceconnectionentityproperties.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RelayServiceConnectionEntityProperties struct { + BiztalkUri *string `json:"biztalkUri,omitempty"` + EntityConnectionString *string `json:"entityConnectionString,omitempty"` + EntityName *string `json:"entityName,omitempty"` + Hostname *string `json:"hostname,omitempty"` + Port *int64 `json:"port,omitempty"` + ResourceConnectionString *string `json:"resourceConnectionString,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_remoteprivateendpointconnectionarmresource.go b/resource-manager/web/2024-11-01/webapps/model_remoteprivateendpointconnectionarmresource.go new file mode 100644 index 00000000000..2657ec83161 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_remoteprivateendpointconnectionarmresource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RemotePrivateEndpointConnectionARMResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_remoteprivateendpointconnectionarmresourceproperties.go b/resource-manager/web/2024-11-01/webapps/model_remoteprivateendpointconnectionarmresourceproperties.go new file mode 100644 index 00000000000..82a747ca53b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_remoteprivateendpointconnectionarmresourceproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RemotePrivateEndpointConnectionARMResourceProperties struct { + IPAddresses *[]string `json:"ipAddresses,omitempty"` + PrivateEndpoint *ArmIdWrapper `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_requestsbasedtrigger.go b/resource-manager/web/2024-11-01/webapps/model_requestsbasedtrigger.go new file mode 100644 index 00000000000..f8d9ec672d0 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_requestsbasedtrigger.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_resourceconfig.go b/resource-manager/web/2024-11-01/webapps/model_resourceconfig.go new file mode 100644 index 00000000000..14a70233fe9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_resourceconfig.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceConfig struct { + Cpu *float64 `json:"cpu,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_restorerequest.go b/resource-manager/web/2024-11-01/webapps/model_restorerequest.go new file mode 100644 index 00000000000..c56dde6c785 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_restorerequest.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RestoreRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_restorerequestproperties.go b/resource-manager/web/2024-11-01/webapps/model_restorerequestproperties.go new file mode 100644 index 00000000000..ea35e477253 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_restorerequestproperties.go @@ -0,0 +1,18 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RestoreRequestProperties struct { + AdjustConnectionStrings *bool `json:"adjustConnectionStrings,omitempty"` + AppServicePlan *string `json:"appServicePlan,omitempty"` + BlobName *string `json:"blobName,omitempty"` + Databases *[]DatabaseBackupSetting `json:"databases,omitempty"` + HostingEnvironment *string `json:"hostingEnvironment,omitempty"` + IgnoreConflictingHostNames *bool `json:"ignoreConflictingHostNames,omitempty"` + IgnoreDatabases *bool `json:"ignoreDatabases,omitempty"` + OperationType *BackupRestoreOperationType `json:"operationType,omitempty"` + Overwrite bool `json:"overwrite"` + SiteName *string `json:"siteName,omitempty"` + StorageAccountURL string `json:"storageAccountUrl"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_site.go b/resource-manager/web/2024-11-01/webapps/model_site.go new file mode 100644 index 00000000000..48c36824946 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_site.go @@ -0,0 +1,20 @@ +package webapps + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Site struct { + ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SiteProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_siteauthsettings.go b/resource-manager/web/2024-11-01/webapps/model_siteauthsettings.go new file mode 100644 index 00000000000..b1a8431fdcc --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_siteauthsettings.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteAuthSettings struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteAuthSettingsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_siteauthsettingsproperties.go b/resource-manager/web/2024-11-01/webapps/model_siteauthsettingsproperties.go new file mode 100644 index 00000000000..7ad71ad2704 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_siteauthsettingsproperties.go @@ -0,0 +1,45 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteAuthSettingsProperties struct { + AadClaimsAuthorization *string `json:"aadClaimsAuthorization,omitempty"` + AdditionalLoginParams *[]string `json:"additionalLoginParams,omitempty"` + AllowedAudiences *[]string `json:"allowedAudiences,omitempty"` + AllowedExternalRedirectURLs *[]string `json:"allowedExternalRedirectUrls,omitempty"` + AuthFilePath *string `json:"authFilePath,omitempty"` + ClientId *string `json:"clientId,omitempty"` + ClientSecret *string `json:"clientSecret,omitempty"` + ClientSecretCertificateThumbprint *string `json:"clientSecretCertificateThumbprint,omitempty"` + ClientSecretSettingName *string `json:"clientSecretSettingName,omitempty"` + ConfigVersion *string `json:"configVersion,omitempty"` + DefaultProvider *BuiltInAuthenticationProvider `json:"defaultProvider,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + FacebookAppId *string `json:"facebookAppId,omitempty"` + FacebookAppSecret *string `json:"facebookAppSecret,omitempty"` + FacebookAppSecretSettingName *string `json:"facebookAppSecretSettingName,omitempty"` + FacebookOAuthScopes *[]string `json:"facebookOAuthScopes,omitempty"` + GitHubClientId *string `json:"gitHubClientId,omitempty"` + GitHubClientSecret *string `json:"gitHubClientSecret,omitempty"` + GitHubClientSecretSettingName *string `json:"gitHubClientSecretSettingName,omitempty"` + GitHubOAuthScopes *[]string `json:"gitHubOAuthScopes,omitempty"` + GoogleClientId *string `json:"googleClientId,omitempty"` + GoogleClientSecret *string `json:"googleClientSecret,omitempty"` + GoogleClientSecretSettingName *string `json:"googleClientSecretSettingName,omitempty"` + GoogleOAuthScopes *[]string `json:"googleOAuthScopes,omitempty"` + IsAuthFromFile *string `json:"isAuthFromFile,omitempty"` + Issuer *string `json:"issuer,omitempty"` + MicrosoftAccountClientId *string `json:"microsoftAccountClientId,omitempty"` + MicrosoftAccountClientSecret *string `json:"microsoftAccountClientSecret,omitempty"` + MicrosoftAccountClientSecretSettingName *string `json:"microsoftAccountClientSecretSettingName,omitempty"` + MicrosoftAccountOAuthScopes *[]string `json:"microsoftAccountOAuthScopes,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` + TokenRefreshExtensionHours *float64 `json:"tokenRefreshExtensionHours,omitempty"` + TokenStoreEnabled *bool `json:"tokenStoreEnabled,omitempty"` + TwitterConsumerKey *string `json:"twitterConsumerKey,omitempty"` + TwitterConsumerSecret *string `json:"twitterConsumerSecret,omitempty"` + TwitterConsumerSecretSettingName *string `json:"twitterConsumerSecretSettingName,omitempty"` + UnauthenticatedClientAction *UnauthenticatedClientAction `json:"unauthenticatedClientAction,omitempty"` + ValidateIssuer *bool `json:"validateIssuer,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_siteauthsettingsv2.go b/resource-manager/web/2024-11-01/webapps/model_siteauthsettingsv2.go new file mode 100644 index 00000000000..ee79ab12848 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_siteauthsettingsv2.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteAuthSettingsV2 struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteAuthSettingsV2Properties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_siteauthsettingsv2properties.go b/resource-manager/web/2024-11-01/webapps/model_siteauthsettingsv2properties.go new file mode 100644 index 00000000000..9fe4cea0565 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_siteauthsettingsv2properties.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteAuthSettingsV2Properties struct { + GlobalValidation *GlobalValidation `json:"globalValidation,omitempty"` + HTTPSettings *HTTPSettings `json:"httpSettings,omitempty"` + IdentityProviders *IdentityProviders `json:"identityProviders,omitempty"` + Login *Login `json:"login,omitempty"` + Platform *AuthPlatform `json:"platform,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_sitecloneability.go b/resource-manager/web/2024-11-01/webapps/model_sitecloneability.go new file mode 100644 index 00000000000..ff7a0079247 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_sitecloneability.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteCloneability struct { + BlockingCharacteristics *[]SiteCloneabilityCriterion `json:"blockingCharacteristics,omitempty"` + BlockingFeatures *[]SiteCloneabilityCriterion `json:"blockingFeatures,omitempty"` + Result *CloneAbilityResult `json:"result,omitempty"` + UnsupportedFeatures *[]SiteCloneabilityCriterion `json:"unsupportedFeatures,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_sitecloneabilitycriterion.go b/resource-manager/web/2024-11-01/webapps/model_sitecloneabilitycriterion.go new file mode 100644 index 00000000000..89a4c57de83 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_sitecloneabilitycriterion.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteCloneabilityCriterion struct { + Description *string `json:"description,omitempty"` + Name *string `json:"name,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_siteconfig.go b/resource-manager/web/2024-11-01/webapps/model_siteconfig.go new file mode 100644 index 00000000000..8a3fe2086c5 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_siteconfig.go @@ -0,0 +1,98 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteConfig struct { + AcrUseManagedIdentityCreds *bool `json:"acrUseManagedIdentityCreds,omitempty"` + AcrUserManagedIdentityID *string `json:"acrUserManagedIdentityID,omitempty"` + AlwaysOn *bool `json:"alwaysOn,omitempty"` + ApiDefinition *ApiDefinitionInfo `json:"apiDefinition,omitempty"` + ApiManagementConfig *ApiManagementConfig `json:"apiManagementConfig,omitempty"` + AppCommandLine *string `json:"appCommandLine,omitempty"` + AppSettings *[]NameValuePair `json:"appSettings,omitempty"` + AutoHealEnabled *bool `json:"autoHealEnabled,omitempty"` + AutoHealRules *AutoHealRules `json:"autoHealRules,omitempty"` + AutoSwapSlotName *string `json:"autoSwapSlotName,omitempty"` + AzureStorageAccounts *map[string]AzureStorageInfoValue `json:"azureStorageAccounts,omitempty"` + ConnectionStrings *[]ConnStringInfo `json:"connectionStrings,omitempty"` + Cors *CorsSettings `json:"cors,omitempty"` + DefaultDocuments *[]string `json:"defaultDocuments,omitempty"` + DetailedErrorLoggingEnabled *bool `json:"detailedErrorLoggingEnabled,omitempty"` + DocumentRoot *string `json:"documentRoot,omitempty"` + ElasticWebAppScaleLimit *int64 `json:"elasticWebAppScaleLimit,omitempty"` + Experiments *Experiments `json:"experiments,omitempty"` + FtpsState *FtpsState `json:"ftpsState,omitempty"` + FunctionAppScaleLimit *int64 `json:"functionAppScaleLimit,omitempty"` + FunctionsRuntimeScaleMonitoringEnabled *bool `json:"functionsRuntimeScaleMonitoringEnabled,omitempty"` + HTTP20Enabled *bool `json:"http20Enabled,omitempty"` + HTTP20ProxyFlag *int64 `json:"http20ProxyFlag,omitempty"` + HTTPLoggingEnabled *bool `json:"httpLoggingEnabled,omitempty"` + HandlerMappings *[]HandlerMapping `json:"handlerMappings,omitempty"` + HealthCheckPath *string `json:"healthCheckPath,omitempty"` + IPSecurityRestrictions *[]IPSecurityRestriction `json:"ipSecurityRestrictions,omitempty"` + IPSecurityRestrictionsDefaultAction *DefaultAction `json:"ipSecurityRestrictionsDefaultAction,omitempty"` + JavaContainer *string `json:"javaContainer,omitempty"` + JavaContainerVersion *string `json:"javaContainerVersion,omitempty"` + JavaVersion *string `json:"javaVersion,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + Limits *SiteLimits `json:"limits,omitempty"` + LinuxFxVersion *string `json:"linuxFxVersion,omitempty"` + LoadBalancing *SiteLoadBalancing `json:"loadBalancing,omitempty"` + LocalMySqlEnabled *bool `json:"localMySqlEnabled,omitempty"` + LogsDirectorySizeLimit *int64 `json:"logsDirectorySizeLimit,omitempty"` + MachineKey *SiteMachineKey `json:"machineKey,omitempty"` + ManagedPipelineMode *ManagedPipelineMode `json:"managedPipelineMode,omitempty"` + ManagedServiceIdentityId *int64 `json:"managedServiceIdentityId,omitempty"` + Metadata *[]NameValuePair `json:"metadata,omitempty"` + MinTlsCipherSuite *TlsCipherSuites `json:"minTlsCipherSuite,omitempty"` + MinTlsVersion *SupportedTlsVersions `json:"minTlsVersion,omitempty"` + MinimumElasticInstanceCount *int64 `json:"minimumElasticInstanceCount,omitempty"` + NetFrameworkVersion *string `json:"netFrameworkVersion,omitempty"` + NodeVersion *string `json:"nodeVersion,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + PhpVersion *string `json:"phpVersion,omitempty"` + PowerShellVersion *string `json:"powerShellVersion,omitempty"` + PreWarmedInstanceCount *int64 `json:"preWarmedInstanceCount,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + PublishingUsername *string `json:"publishingUsername,omitempty"` + Push *PushSettings `json:"push,omitempty"` + PythonVersion *string `json:"pythonVersion,omitempty"` + RemoteDebuggingEnabled *bool `json:"remoteDebuggingEnabled,omitempty"` + RemoteDebuggingVersion *string `json:"remoteDebuggingVersion,omitempty"` + RequestTracingEnabled *bool `json:"requestTracingEnabled,omitempty"` + RequestTracingExpirationTime *string `json:"requestTracingExpirationTime,omitempty"` + ScmIPSecurityRestrictions *[]IPSecurityRestriction `json:"scmIpSecurityRestrictions,omitempty"` + ScmIPSecurityRestrictionsDefaultAction *DefaultAction `json:"scmIpSecurityRestrictionsDefaultAction,omitempty"` + ScmIPSecurityRestrictionsUseMain *bool `json:"scmIpSecurityRestrictionsUseMain,omitempty"` + ScmMinTlsVersion *SupportedTlsVersions `json:"scmMinTlsVersion,omitempty"` + ScmType *ScmType `json:"scmType,omitempty"` + TracingOptions *string `json:"tracingOptions,omitempty"` + Use32BitWorkerProcess *bool `json:"use32BitWorkerProcess,omitempty"` + VirtualApplications *[]VirtualApplication `json:"virtualApplications,omitempty"` + VnetName *string `json:"vnetName,omitempty"` + VnetPrivatePortsCount *int64 `json:"vnetPrivatePortsCount,omitempty"` + VnetRouteAllEnabled *bool `json:"vnetRouteAllEnabled,omitempty"` + WebSocketsEnabled *bool `json:"webSocketsEnabled,omitempty"` + WebsiteTimeZone *string `json:"websiteTimeZone,omitempty"` + WindowsFxVersion *string `json:"windowsFxVersion,omitempty"` + XManagedServiceIdentityId *int64 `json:"xManagedServiceIdentityId,omitempty"` +} + +func (o *SiteConfig) GetRequestTracingExpirationTimeAsTime() (*time.Time, error) { + if o.RequestTracingExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.RequestTracingExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteConfig) SetRequestTracingExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.RequestTracingExpirationTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_siteconfigresource.go b/resource-manager/web/2024-11-01/webapps/model_siteconfigresource.go new file mode 100644 index 00000000000..46d60ffe0b9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_siteconfigresource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteConfigResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteConfig `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_siteconfigurationsnapshotinfo.go b/resource-manager/web/2024-11-01/webapps/model_siteconfigurationsnapshotinfo.go new file mode 100644 index 00000000000..2fea88a6a47 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_siteconfigurationsnapshotinfo.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteConfigurationSnapshotInfo struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteConfigurationSnapshotInfoProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_siteconfigurationsnapshotinfoproperties.go b/resource-manager/web/2024-11-01/webapps/model_siteconfigurationsnapshotinfoproperties.go new file mode 100644 index 00000000000..8907cc179db --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_siteconfigurationsnapshotinfoproperties.go @@ -0,0 +1,27 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteConfigurationSnapshotInfoProperties struct { + SnapshotId *int64 `json:"snapshotId,omitempty"` + Time *string `json:"time,omitempty"` +} + +func (o *SiteConfigurationSnapshotInfoProperties) GetTimeAsTime() (*time.Time, error) { + if o.Time == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Time, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteConfigurationSnapshotInfoProperties) SetTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Time = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_sitecontainer.go b/resource-manager/web/2024-11-01/webapps/model_sitecontainer.go new file mode 100644 index 00000000000..ab2c105b488 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_sitecontainer.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteContainer struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteContainerProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_sitecontainerproperties.go b/resource-manager/web/2024-11-01/webapps/model_sitecontainerproperties.go new file mode 100644 index 00000000000..d3cef542cc9 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_sitecontainerproperties.go @@ -0,0 +1,50 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteContainerProperties struct { + AuthType *AuthType `json:"authType,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + EnvironmentVariables *[]EnvironmentVariable `json:"environmentVariables,omitempty"` + Image string `json:"image"` + InheritAppSettingsAndConnectionStrings *bool `json:"inheritAppSettingsAndConnectionStrings,omitempty"` + IsMain bool `json:"isMain"` + LastModifiedTime *string `json:"lastModifiedTime,omitempty"` + PasswordSecret *string `json:"passwordSecret,omitempty"` + StartUpCommand *string `json:"startUpCommand,omitempty"` + TargetPort *string `json:"targetPort,omitempty"` + UserManagedIdentityClientId *string `json:"userManagedIdentityClientId,omitempty"` + UserName *string `json:"userName,omitempty"` + VolumeMounts *[]VolumeMount `json:"volumeMounts,omitempty"` +} + +func (o *SiteContainerProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteContainerProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *SiteContainerProperties) GetLastModifiedTimeAsTime() (*time.Time, error) { + if o.LastModifiedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteContainerProperties) SetLastModifiedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_sitednsconfig.go b/resource-manager/web/2024-11-01/webapps/model_sitednsconfig.go new file mode 100644 index 00000000000..e378e356c3f --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_sitednsconfig.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteDnsConfig struct { + DnsAltServer *string `json:"dnsAltServer,omitempty"` + DnsLegacySortOrder *bool `json:"dnsLegacySortOrder,omitempty"` + DnsMaxCacheTimeout *int64 `json:"dnsMaxCacheTimeout,omitempty"` + DnsRetryAttemptCount *int64 `json:"dnsRetryAttemptCount,omitempty"` + DnsRetryAttemptTimeout *int64 `json:"dnsRetryAttemptTimeout,omitempty"` + DnsServers *[]string `json:"dnsServers,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_siteextensioninfo.go b/resource-manager/web/2024-11-01/webapps/model_siteextensioninfo.go new file mode 100644 index 00000000000..918563b2f1d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_siteextensioninfo.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteExtensionInfo struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteExtensionInfoProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_siteextensioninfoproperties.go b/resource-manager/web/2024-11-01/webapps/model_siteextensioninfoproperties.go new file mode 100644 index 00000000000..4a10138d54c --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_siteextensioninfoproperties.go @@ -0,0 +1,57 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteExtensionInfoProperties struct { + Authors *[]string `json:"authors,omitempty"` + Comment *string `json:"comment,omitempty"` + Description *string `json:"description,omitempty"` + DownloadCount *int64 `json:"download_count,omitempty"` + ExtensionId *string `json:"extension_id,omitempty"` + ExtensionType *SiteExtensionType `json:"extension_type,omitempty"` + ExtensionUrl *string `json:"extension_url,omitempty"` + FeedUrl *string `json:"feed_url,omitempty"` + IconUrl *string `json:"icon_url,omitempty"` + InstalledDateTime *string `json:"installed_date_time,omitempty"` + InstallerCommandLineParams *string `json:"installer_command_line_params,omitempty"` + LicenseUrl *string `json:"license_url,omitempty"` + LocalIsLatestVersion *bool `json:"local_is_latest_version,omitempty"` + LocalPath *string `json:"local_path,omitempty"` + ProjectUrl *string `json:"project_url,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + PublishedDateTime *string `json:"published_date_time,omitempty"` + Summary *string `json:"summary,omitempty"` + Title *string `json:"title,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *SiteExtensionInfoProperties) GetInstalledDateTimeAsTime() (*time.Time, error) { + if o.InstalledDateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.InstalledDateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteExtensionInfoProperties) SetInstalledDateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.InstalledDateTime = &formatted +} + +func (o *SiteExtensionInfoProperties) GetPublishedDateTimeAsTime() (*time.Time, error) { + if o.PublishedDateTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.PublishedDateTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteExtensionInfoProperties) SetPublishedDateTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.PublishedDateTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_sitelimits.go b/resource-manager/web/2024-11-01/webapps/model_sitelimits.go new file mode 100644 index 00000000000..271933cbb7d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_sitelimits.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteLimits struct { + MaxDiskSizeInMb *int64 `json:"maxDiskSizeInMb,omitempty"` + MaxMemoryInMb *int64 `json:"maxMemoryInMb,omitempty"` + MaxPercentageCPU *float64 `json:"maxPercentageCpu,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_sitelogsconfig.go b/resource-manager/web/2024-11-01/webapps/model_sitelogsconfig.go new file mode 100644 index 00000000000..91bb4451cde --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_sitelogsconfig.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteLogsConfig struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteLogsConfigProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_sitelogsconfigproperties.go b/resource-manager/web/2024-11-01/webapps/model_sitelogsconfigproperties.go new file mode 100644 index 00000000000..1b853da7ad6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_sitelogsconfigproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteLogsConfigProperties struct { + ApplicationLogs *ApplicationLogsConfig `json:"applicationLogs,omitempty"` + DetailedErrorMessages *EnabledConfig `json:"detailedErrorMessages,omitempty"` + FailedRequestsTracing *EnabledConfig `json:"failedRequestsTracing,omitempty"` + HTTPLogs *HTTPLogsConfig `json:"httpLogs,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_sitemachinekey.go b/resource-manager/web/2024-11-01/webapps/model_sitemachinekey.go new file mode 100644 index 00000000000..c6d65bc957d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_sitemachinekey.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteMachineKey struct { + Decryption *string `json:"decryption,omitempty"` + DecryptionKey *string `json:"decryptionKey,omitempty"` + Validation *string `json:"validation,omitempty"` + ValidationKey *string `json:"validationKey,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_sitepatchresource.go b/resource-manager/web/2024-11-01/webapps/model_sitepatchresource.go new file mode 100644 index 00000000000..ca1829f5c66 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_sitepatchresource.go @@ -0,0 +1,17 @@ +package webapps + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SitePatchResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SitePatchResourceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_sitepatchresourceproperties.go b/resource-manager/web/2024-11-01/webapps/model_sitepatchresourceproperties.go new file mode 100644 index 00000000000..5aae27842f3 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_sitepatchresourceproperties.go @@ -0,0 +1,80 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SitePatchResourceProperties struct { + AvailabilityState *SiteAvailabilityState `json:"availabilityState,omitempty"` + ClientAffinityEnabled *bool `json:"clientAffinityEnabled,omitempty"` + ClientAffinityProxyEnabled *bool `json:"clientAffinityProxyEnabled,omitempty"` + ClientCertEnabled *bool `json:"clientCertEnabled,omitempty"` + ClientCertExclusionPaths *string `json:"clientCertExclusionPaths,omitempty"` + ClientCertMode *ClientCertMode `json:"clientCertMode,omitempty"` + CloningInfo *CloningInfo `json:"cloningInfo,omitempty"` + ContainerSize *int64 `json:"containerSize,omitempty"` + CustomDomainVerificationId *string `json:"customDomainVerificationId,omitempty"` + DailyMemoryTimeQuota *int64 `json:"dailyMemoryTimeQuota,omitempty"` + DefaultHostName *string `json:"defaultHostName,omitempty"` + DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + HTTPSOnly *bool `json:"httpsOnly,omitempty"` + HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostNamesDisabled *bool `json:"hostNamesDisabled,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + InProgressOperationId *string `json:"inProgressOperationId,omitempty"` + IsDefaultContainer *bool `json:"isDefaultContainer,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + LastModifiedTimeUtc *string `json:"lastModifiedTimeUtc,omitempty"` + MaxNumberOfWorkers *int64 `json:"maxNumberOfWorkers,omitempty"` + OutboundIPAddresses *string `json:"outboundIpAddresses,omitempty"` + PossibleOutboundIPAddresses *string `json:"possibleOutboundIpAddresses,omitempty"` + RedundancyMode *RedundancyMode `json:"redundancyMode,omitempty"` + RepositorySiteName *string `json:"repositorySiteName,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ScmSiteAlsoStopped *bool `json:"scmSiteAlsoStopped,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteConfig *SiteConfig `json:"siteConfig,omitempty"` + SlotSwapStatus *SlotSwapStatus `json:"slotSwapStatus,omitempty"` + State *string `json:"state,omitempty"` + StorageAccountRequired *bool `json:"storageAccountRequired,omitempty"` + SuspendedTill *string `json:"suspendedTill,omitempty"` + TargetSwapSlot *string `json:"targetSwapSlot,omitempty"` + TrafficManagerHostNames *[]string `json:"trafficManagerHostNames,omitempty"` + UsageState *UsageState `json:"usageState,omitempty"` + VirtualNetworkSubnetId *string `json:"virtualNetworkSubnetId,omitempty"` +} + +func (o *SitePatchResourceProperties) GetLastModifiedTimeUtcAsTime() (*time.Time, error) { + if o.LastModifiedTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SitePatchResourceProperties) SetLastModifiedTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTimeUtc = &formatted +} + +func (o *SitePatchResourceProperties) GetSuspendedTillAsTime() (*time.Time, error) { + if o.SuspendedTill == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SuspendedTill, "2006-01-02T15:04:05Z07:00") +} + +func (o *SitePatchResourceProperties) SetSuspendedTillAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SuspendedTill = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_sitephperrorlogflag.go b/resource-manager/web/2024-11-01/webapps/model_sitephperrorlogflag.go new file mode 100644 index 00000000000..fd18d5d39f6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_sitephperrorlogflag.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SitePhpErrorLogFlag struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SitePhpErrorLogFlagProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_sitephperrorlogflagproperties.go b/resource-manager/web/2024-11-01/webapps/model_sitephperrorlogflagproperties.go new file mode 100644 index 00000000000..4a9465a064b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_sitephperrorlogflagproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SitePhpErrorLogFlagProperties struct { + LocalLogErrors *string `json:"localLogErrors,omitempty"` + LocalLogErrorsMaxLength *string `json:"localLogErrorsMaxLength,omitempty"` + MasterLogErrors *string `json:"masterLogErrors,omitempty"` + MasterLogErrorsMaxLength *string `json:"masterLogErrorsMaxLength,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_siteproperties.go b/resource-manager/web/2024-11-01/webapps/model_siteproperties.go new file mode 100644 index 00000000000..3bb785768dc --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_siteproperties.go @@ -0,0 +1,93 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteProperties struct { + AutoGeneratedDomainNameLabelScope *AutoGeneratedDomainNameLabelScope `json:"autoGeneratedDomainNameLabelScope,omitempty"` + AvailabilityState *SiteAvailabilityState `json:"availabilityState,omitempty"` + ClientAffinityEnabled *bool `json:"clientAffinityEnabled,omitempty"` + ClientAffinityPartitioningEnabled *bool `json:"clientAffinityPartitioningEnabled,omitempty"` + ClientAffinityProxyEnabled *bool `json:"clientAffinityProxyEnabled,omitempty"` + ClientCertEnabled *bool `json:"clientCertEnabled,omitempty"` + ClientCertExclusionPaths *string `json:"clientCertExclusionPaths,omitempty"` + ClientCertMode *ClientCertMode `json:"clientCertMode,omitempty"` + CloningInfo *CloningInfo `json:"cloningInfo,omitempty"` + ContainerSize *int64 `json:"containerSize,omitempty"` + CustomDomainVerificationId *string `json:"customDomainVerificationId,omitempty"` + DailyMemoryTimeQuota *int64 `json:"dailyMemoryTimeQuota,omitempty"` + DaprConfig *DaprConfig `json:"daprConfig,omitempty"` + DefaultHostName *string `json:"defaultHostName,omitempty"` + DnsConfiguration *SiteDnsConfig `json:"dnsConfiguration,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + EnabledHostNames *[]string `json:"enabledHostNames,omitempty"` + EndToEndEncryptionEnabled *bool `json:"endToEndEncryptionEnabled,omitempty"` + FunctionAppConfig *FunctionAppConfig `json:"functionAppConfig,omitempty"` + HTTPSOnly *bool `json:"httpsOnly,omitempty"` + HostNameSslStates *[]HostNameSslState `json:"hostNameSslStates,omitempty"` + HostNames *[]string `json:"hostNames,omitempty"` + HostNamesDisabled *bool `json:"hostNamesDisabled,omitempty"` + HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"` + HyperV *bool `json:"hyperV,omitempty"` + IPMode *IPMode `json:"ipMode,omitempty"` + InProgressOperationId *string `json:"inProgressOperationId,omitempty"` + IsDefaultContainer *bool `json:"isDefaultContainer,omitempty"` + IsXenon *bool `json:"isXenon,omitempty"` + KeyVaultReferenceIdentity *string `json:"keyVaultReferenceIdentity,omitempty"` + LastModifiedTimeUtc *string `json:"lastModifiedTimeUtc,omitempty"` + ManagedEnvironmentId *string `json:"managedEnvironmentId,omitempty"` + MaxNumberOfWorkers *int64 `json:"maxNumberOfWorkers,omitempty"` + OutboundIPAddresses *string `json:"outboundIpAddresses,omitempty"` + OutboundVnetRouting *OutboundVnetRouting `json:"outboundVnetRouting,omitempty"` + PossibleOutboundIPAddresses *string `json:"possibleOutboundIpAddresses,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + RedundancyMode *RedundancyMode `json:"redundancyMode,omitempty"` + RepositorySiteName *string `json:"repositorySiteName,omitempty"` + Reserved *bool `json:"reserved,omitempty"` + ResourceConfig *ResourceConfig `json:"resourceConfig,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ScmSiteAlsoStopped *bool `json:"scmSiteAlsoStopped,omitempty"` + ServerFarmId *string `json:"serverFarmId,omitempty"` + SiteConfig *SiteConfig `json:"siteConfig,omitempty"` + Sku *string `json:"sku,omitempty"` + SlotSwapStatus *SlotSwapStatus `json:"slotSwapStatus,omitempty"` + SshEnabled *bool `json:"sshEnabled,omitempty"` + State *string `json:"state,omitempty"` + StorageAccountRequired *bool `json:"storageAccountRequired,omitempty"` + SuspendedTill *string `json:"suspendedTill,omitempty"` + TargetSwapSlot *string `json:"targetSwapSlot,omitempty"` + TrafficManagerHostNames *[]string `json:"trafficManagerHostNames,omitempty"` + UsageState *UsageState `json:"usageState,omitempty"` + VirtualNetworkSubnetId *string `json:"virtualNetworkSubnetId,omitempty"` + WorkloadProfileName *string `json:"workloadProfileName,omitempty"` +} + +func (o *SiteProperties) GetLastModifiedTimeUtcAsTime() (*time.Time, error) { + if o.LastModifiedTimeUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastModifiedTimeUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetLastModifiedTimeUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastModifiedTimeUtc = &formatted +} + +func (o *SiteProperties) GetSuspendedTillAsTime() (*time.Time, error) { + if o.SuspendedTill == nil { + return nil, nil + } + return dates.ParseAsFormat(o.SuspendedTill, "2006-01-02T15:04:05Z07:00") +} + +func (o *SiteProperties) SetSuspendedTillAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.SuspendedTill = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_sitesourcecontrol.go b/resource-manager/web/2024-11-01/webapps/model_sitesourcecontrol.go new file mode 100644 index 00000000000..8b8a43b83b1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_sitesourcecontrol.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteSourceControl struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SiteSourceControlProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_sitesourcecontrolproperties.go b/resource-manager/web/2024-11-01/webapps/model_sitesourcecontrolproperties.go new file mode 100644 index 00000000000..9634590165d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_sitesourcecontrolproperties.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SiteSourceControlProperties struct { + Branch *string `json:"branch,omitempty"` + DeploymentRollbackEnabled *bool `json:"deploymentRollbackEnabled,omitempty"` + GitHubActionConfiguration *GitHubActionConfiguration `json:"gitHubActionConfiguration,omitempty"` + IsGitHubAction *bool `json:"isGitHubAction,omitempty"` + IsManualIntegration *bool `json:"isManualIntegration,omitempty"` + IsMercurial *bool `json:"isMercurial,omitempty"` + RepoURL *string `json:"repoUrl,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_slotconfignames.go b/resource-manager/web/2024-11-01/webapps/model_slotconfignames.go new file mode 100644 index 00000000000..34cbe7ce354 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_slotconfignames.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlotConfigNames struct { + AppSettingNames *[]string `json:"appSettingNames,omitempty"` + AzureStorageConfigNames *[]string `json:"azureStorageConfigNames,omitempty"` + ConnectionStringNames *[]string `json:"connectionStringNames,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_slotconfignamesresource.go b/resource-manager/web/2024-11-01/webapps/model_slotconfignamesresource.go new file mode 100644 index 00000000000..dea993a310d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_slotconfignamesresource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlotConfigNamesResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SlotConfigNames `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_slotdifference.go b/resource-manager/web/2024-11-01/webapps/model_slotdifference.go new file mode 100644 index 00000000000..433c86817c4 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_slotdifference.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlotDifference struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SlotDifferenceProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_slotdifferenceproperties.go b/resource-manager/web/2024-11-01/webapps/model_slotdifferenceproperties.go new file mode 100644 index 00000000000..79f90d274fa --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_slotdifferenceproperties.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlotDifferenceProperties struct { + Description *string `json:"description,omitempty"` + DiffRule *string `json:"diffRule,omitempty"` + Level *string `json:"level,omitempty"` + SettingName *string `json:"settingName,omitempty"` + SettingType *string `json:"settingType,omitempty"` + ValueInCurrentSlot *string `json:"valueInCurrentSlot,omitempty"` + ValueInTargetSlot *string `json:"valueInTargetSlot,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_slotswapstatus.go b/resource-manager/web/2024-11-01/webapps/model_slotswapstatus.go new file mode 100644 index 00000000000..c9eb5b7eeff --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_slotswapstatus.go @@ -0,0 +1,28 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlotSwapStatus struct { + DestinationSlotName *string `json:"destinationSlotName,omitempty"` + SourceSlotName *string `json:"sourceSlotName,omitempty"` + TimestampUtc *string `json:"timestampUtc,omitempty"` +} + +func (o *SlotSwapStatus) GetTimestampUtcAsTime() (*time.Time, error) { + if o.TimestampUtc == nil { + return nil, nil + } + return dates.ParseAsFormat(o.TimestampUtc, "2006-01-02T15:04:05Z07:00") +} + +func (o *SlotSwapStatus) SetTimestampUtcAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.TimestampUtc = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_slowrequestsbasedtrigger.go b/resource-manager/web/2024-11-01/webapps/model_slowrequestsbasedtrigger.go new file mode 100644 index 00000000000..6d2bb3b5050 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_slowrequestsbasedtrigger.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SlowRequestsBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + TimeTaken *string `json:"timeTaken,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_snapshot.go b/resource-manager/web/2024-11-01/webapps/model_snapshot.go new file mode 100644 index 00000000000..6a113202c94 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_snapshot.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Snapshot struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SnapshotProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_snapshotproperties.go b/resource-manager/web/2024-11-01/webapps/model_snapshotproperties.go new file mode 100644 index 00000000000..e6cf11407ff --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_snapshotproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotProperties struct { + Time *string `json:"time,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_snapshotrecoverysource.go b/resource-manager/web/2024-11-01/webapps/model_snapshotrecoverysource.go new file mode 100644 index 00000000000..5a9d31cacbb --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_snapshotrecoverysource.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotRecoverySource struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_snapshotrestorerequest.go b/resource-manager/web/2024-11-01/webapps/model_snapshotrestorerequest.go new file mode 100644 index 00000000000..f3b15067bd6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_snapshotrestorerequest.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotRestoreRequest struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SnapshotRestoreRequestProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_snapshotrestorerequestproperties.go b/resource-manager/web/2024-11-01/webapps/model_snapshotrestorerequestproperties.go new file mode 100644 index 00000000000..43d7139eb35 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_snapshotrestorerequestproperties.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotRestoreRequestProperties struct { + IgnoreConflictingHostNames *bool `json:"ignoreConflictingHostNames,omitempty"` + Overwrite bool `json:"overwrite"` + RecoverConfiguration *bool `json:"recoverConfiguration,omitempty"` + RecoverySource *SnapshotRecoverySource `json:"recoverySource,omitempty"` + SnapshotTime *string `json:"snapshotTime,omitempty"` + UseDRSecondary *bool `json:"useDRSecondary,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_statuscodesbasedtrigger.go b/resource-manager/web/2024-11-01/webapps/model_statuscodesbasedtrigger.go new file mode 100644 index 00000000000..38028980ea1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_statuscodesbasedtrigger.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + Status *int64 `json:"status,omitempty"` + SubStatus *int64 `json:"subStatus,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` + Win32Status *int64 `json:"win32Status,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_statuscodesrangebasedtrigger.go b/resource-manager/web/2024-11-01/webapps/model_statuscodesrangebasedtrigger.go new file mode 100644 index 00000000000..399920aec5a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_statuscodesrangebasedtrigger.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StatusCodesRangeBasedTrigger struct { + Count *int64 `json:"count,omitempty"` + Path *string `json:"path,omitempty"` + StatusCodes *string `json:"statusCodes,omitempty"` + TimeInterval *string `json:"timeInterval,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_storagemigrationoptions.go b/resource-manager/web/2024-11-01/webapps/model_storagemigrationoptions.go new file mode 100644 index 00000000000..45da1f0d070 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_storagemigrationoptions.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageMigrationOptions struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StorageMigrationOptionsProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_storagemigrationoptionsproperties.go b/resource-manager/web/2024-11-01/webapps/model_storagemigrationoptionsproperties.go new file mode 100644 index 00000000000..102ddb713f6 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_storagemigrationoptionsproperties.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageMigrationOptionsProperties struct { + AzurefilesConnectionString string `json:"azurefilesConnectionString"` + AzurefilesShare string `json:"azurefilesShare"` + BlockWriteAccessToSite *bool `json:"blockWriteAccessToSite,omitempty"` + SwitchSiteAfterMigration *bool `json:"switchSiteAfterMigration,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_storagemigrationresponse.go b/resource-manager/web/2024-11-01/webapps/model_storagemigrationresponse.go new file mode 100644 index 00000000000..9422d63effd --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_storagemigrationresponse.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageMigrationResponse struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *StorageMigrationResponseProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_storagemigrationresponseproperties.go b/resource-manager/web/2024-11-01/webapps/model_storagemigrationresponseproperties.go new file mode 100644 index 00000000000..780c084c664 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_storagemigrationresponseproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageMigrationResponseProperties struct { + OperationId *string `json:"operationId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_stringdictionary.go b/resource-manager/web/2024-11-01/webapps/model_stringdictionary.go new file mode 100644 index 00000000000..20fcaaa92b1 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_stringdictionary.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StringDictionary struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_swiftvirtualnetwork.go b/resource-manager/web/2024-11-01/webapps/model_swiftvirtualnetwork.go new file mode 100644 index 00000000000..db095809863 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_swiftvirtualnetwork.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwiftVirtualNetwork struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *SwiftVirtualNetworkProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_swiftvirtualnetworkproperties.go b/resource-manager/web/2024-11-01/webapps/model_swiftvirtualnetworkproperties.go new file mode 100644 index 00000000000..8c1ca0faa38 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_swiftvirtualnetworkproperties.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SwiftVirtualNetworkProperties struct { + SubnetResourceId *string `json:"subnetResourceId,omitempty"` + SwiftSupported *bool `json:"swiftSupported,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_tokenstore.go b/resource-manager/web/2024-11-01/webapps/model_tokenstore.go new file mode 100644 index 00000000000..4668774ac25 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_tokenstore.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TokenStore struct { + AzureBlobStorage *BlobStorageTokenStore `json:"azureBlobStorage,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + FileSystem *FileSystemTokenStore `json:"fileSystem,omitempty"` + TokenRefreshExtensionHours *float64 `json:"tokenRefreshExtensionHours,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_triggeredjobhistory.go b/resource-manager/web/2024-11-01/webapps/model_triggeredjobhistory.go new file mode 100644 index 00000000000..2eb9852d4b7 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_triggeredjobhistory.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggeredJobHistory struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *TriggeredJobHistoryProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_triggeredjobhistoryproperties.go b/resource-manager/web/2024-11-01/webapps/model_triggeredjobhistoryproperties.go new file mode 100644 index 00000000000..37c8ad7df32 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_triggeredjobhistoryproperties.go @@ -0,0 +1,8 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggeredJobHistoryProperties struct { + Runs *[]TriggeredJobRun `json:"runs,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_triggeredjobrun.go b/resource-manager/web/2024-11-01/webapps/model_triggeredjobrun.go new file mode 100644 index 00000000000..695a8d5a98d --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_triggeredjobrun.go @@ -0,0 +1,48 @@ +package webapps + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggeredJobRun struct { + Duration *string `json:"duration,omitempty"` + EndTime *string `json:"end_time,omitempty"` + ErrorUrl *string `json:"error_url,omitempty"` + JobName *string `json:"job_name,omitempty"` + OutputUrl *string `json:"output_url,omitempty"` + StartTime *string `json:"start_time,omitempty"` + Status *TriggeredWebJobStatus `json:"status,omitempty"` + Trigger *string `json:"trigger,omitempty"` + Url *string `json:"url,omitempty"` + WebJobId *string `json:"web_job_id,omitempty"` + WebJobName *string `json:"web_job_name,omitempty"` +} + +func (o *TriggeredJobRun) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *TriggeredJobRun) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *TriggeredJobRun) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *TriggeredJobRun) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/webapps/model_triggeredwebjob.go b/resource-manager/web/2024-11-01/webapps/model_triggeredwebjob.go new file mode 100644 index 00000000000..aab21f2dfae --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_triggeredwebjob.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggeredWebJob struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *TriggeredWebJobProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_triggeredwebjobproperties.go b/resource-manager/web/2024-11-01/webapps/model_triggeredwebjobproperties.go new file mode 100644 index 00000000000..0205e0bc246 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_triggeredwebjobproperties.go @@ -0,0 +1,19 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TriggeredWebJobProperties struct { + Error *string `json:"error,omitempty"` + ExtraInfoUrl *string `json:"extra_info_url,omitempty"` + HistoryUrl *string `json:"history_url,omitempty"` + LatestRun *TriggeredJobRun `json:"latest_run,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + RunCommand *string `json:"run_command,omitempty"` + SchedulerLogsUrl *string `json:"scheduler_logs_url,omitempty"` + Settings *map[string]interface{} `json:"settings,omitempty"` + StorageAccountRequired *bool `json:"storageAccountRequired,omitempty"` + Url *string `json:"url,omitempty"` + UsingSdk *bool `json:"using_sdk,omitempty"` + WebJobType *WebJobType `json:"web_job_type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_twitter.go b/resource-manager/web/2024-11-01/webapps/model_twitter.go new file mode 100644 index 00000000000..16018b814ad --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_twitter.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Twitter struct { + Enabled *bool `json:"enabled,omitempty"` + Registration *TwitterRegistration `json:"registration,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_twitterregistration.go b/resource-manager/web/2024-11-01/webapps/model_twitterregistration.go new file mode 100644 index 00000000000..15d70794ab7 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_twitterregistration.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TwitterRegistration struct { + ConsumerKey *string `json:"consumerKey,omitempty"` + ConsumerSecretSettingName *string `json:"consumerSecretSettingName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_user.go b/resource-manager/web/2024-11-01/webapps/model_user.go new file mode 100644 index 00000000000..0be0f9a3507 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_user.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type User struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *UserProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_userproperties.go b/resource-manager/web/2024-11-01/webapps/model_userproperties.go new file mode 100644 index 00000000000..42d228f76de --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_userproperties.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserProperties struct { + PublishingPassword *string `json:"publishingPassword,omitempty"` + PublishingPasswordHash *string `json:"publishingPasswordHash,omitempty"` + PublishingPasswordHashSalt *string `json:"publishingPasswordHashSalt,omitempty"` + PublishingUserName string `json:"publishingUserName"` + ScmUri *string `json:"scmUri,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_virtualapplication.go b/resource-manager/web/2024-11-01/webapps/model_virtualapplication.go new file mode 100644 index 00000000000..cd9a20e0a97 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_virtualapplication.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualApplication struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + PreloadEnabled *bool `json:"preloadEnabled,omitempty"` + VirtualDirectories *[]VirtualDirectory `json:"virtualDirectories,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_virtualdirectory.go b/resource-manager/web/2024-11-01/webapps/model_virtualdirectory.go new file mode 100644 index 00000000000..e12dd8d0b49 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_virtualdirectory.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualDirectory struct { + PhysicalPath *string `json:"physicalPath,omitempty"` + VirtualPath *string `json:"virtualPath,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_vnetgateway.go b/resource-manager/web/2024-11-01/webapps/model_vnetgateway.go new file mode 100644 index 00000000000..59ce757342b --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_vnetgateway.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetGateway struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetGatewayProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_vnetgatewayproperties.go b/resource-manager/web/2024-11-01/webapps/model_vnetgatewayproperties.go new file mode 100644 index 00000000000..e90b78642ee --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_vnetgatewayproperties.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetGatewayProperties struct { + VnetName *string `json:"vnetName,omitempty"` + VpnPackageUri string `json:"vpnPackageUri"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_vnetinfo.go b/resource-manager/web/2024-11-01/webapps/model_vnetinfo.go new file mode 100644 index 00000000000..9ef7b52d7de --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_vnetinfo.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetInfo struct { + CertBlob *string `json:"certBlob,omitempty"` + CertThumbprint *string `json:"certThumbprint,omitempty"` + DnsServers *string `json:"dnsServers,omitempty"` + IsSwift *bool `json:"isSwift,omitempty"` + ResyncRequired *bool `json:"resyncRequired,omitempty"` + Routes *[]VnetRoute `json:"routes,omitempty"` + VnetResourceId *string `json:"vnetResourceId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_vnetinforesource.go b/resource-manager/web/2024-11-01/webapps/model_vnetinforesource.go new file mode 100644 index 00000000000..6b6193e0fee --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_vnetinforesource.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetInfoResource struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetInfo `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_vnetroute.go b/resource-manager/web/2024-11-01/webapps/model_vnetroute.go new file mode 100644 index 00000000000..58365af2214 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_vnetroute.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRoute struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *VnetRouteProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_vnetrouteproperties.go b/resource-manager/web/2024-11-01/webapps/model_vnetrouteproperties.go new file mode 100644 index 00000000000..00d288ce7d7 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_vnetrouteproperties.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VnetRouteProperties struct { + EndAddress *string `json:"endAddress,omitempty"` + RouteType *RouteType `json:"routeType,omitempty"` + StartAddress *string `json:"startAddress,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_volumemount.go b/resource-manager/web/2024-11-01/webapps/model_volumemount.go new file mode 100644 index 00000000000..fd0456dd18e --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_volumemount.go @@ -0,0 +1,11 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeMount struct { + ContainerMountPath string `json:"containerMountPath"` + Data *string `json:"data,omitempty"` + ReadOnly *bool `json:"readOnly,omitempty"` + VolumeSubPath string `json:"volumeSubPath"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_webjob.go b/resource-manager/web/2024-11-01/webapps/model_webjob.go new file mode 100644 index 00000000000..6dfbc3f0a58 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_webjob.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebJob struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WebJobProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_webjobproperties.go b/resource-manager/web/2024-11-01/webapps/model_webjobproperties.go new file mode 100644 index 00000000000..b67f1af63a0 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_webjobproperties.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebJobProperties struct { + Error *string `json:"error,omitempty"` + ExtraInfoUrl *string `json:"extra_info_url,omitempty"` + RunCommand *string `json:"run_command,omitempty"` + Settings *map[string]interface{} `json:"settings,omitempty"` + Url *string `json:"url,omitempty"` + UsingSdk *bool `json:"using_sdk,omitempty"` + WebJobType *WebJobType `json:"web_job_type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_websiteinstancestatus.go b/resource-manager/web/2024-11-01/webapps/model_websiteinstancestatus.go new file mode 100644 index 00000000000..7cf30ebf35a --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_websiteinstancestatus.go @@ -0,0 +1,12 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebSiteInstanceStatus struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WebSiteInstanceStatusProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_websiteinstancestatusproperties.go b/resource-manager/web/2024-11-01/webapps/model_websiteinstancestatusproperties.go new file mode 100644 index 00000000000..56592442bc4 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_websiteinstancestatusproperties.go @@ -0,0 +1,14 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WebSiteInstanceStatusProperties struct { + ConsoleURL *string `json:"consoleUrl,omitempty"` + Containers *map[string]ContainerInfo `json:"containers,omitempty"` + DetectorURL *string `json:"detectorUrl,omitempty"` + HealthCheckURL *string `json:"healthCheckUrl,omitempty"` + PhysicalZone *string `json:"physicalZone,omitempty"` + State *SiteRuntimeState `json:"state,omitempty"` + StatusURL *string `json:"statusUrl,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_workflowartifacts.go b/resource-manager/web/2024-11-01/webapps/model_workflowartifacts.go new file mode 100644 index 00000000000..52498481889 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_workflowartifacts.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowArtifacts struct { + AppSettings *interface{} `json:"appSettings,omitempty"` + Files *map[string]interface{} `json:"files,omitempty"` + FilesToDelete *[]string `json:"filesToDelete,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_workflowenvelope.go b/resource-manager/web/2024-11-01/webapps/model_workflowenvelope.go new file mode 100644 index 00000000000..6f4ea5ce596 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_workflowenvelope.go @@ -0,0 +1,13 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowEnvelope struct { + Id *string `json:"id,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowEnvelopeProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_workflowenvelopeproperties.go b/resource-manager/web/2024-11-01/webapps/model_workflowenvelopeproperties.go new file mode 100644 index 00000000000..a14bffda962 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_workflowenvelopeproperties.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowEnvelopeProperties struct { + Files *map[string]interface{} `json:"files,omitempty"` + FlowState *WorkflowState `json:"flowState,omitempty"` + Health *WorkflowHealth `json:"health,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/webapps/model_workflowhealth.go b/resource-manager/web/2024-11-01/webapps/model_workflowhealth.go new file mode 100644 index 00000000000..f9ec376ba05 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/model_workflowhealth.go @@ -0,0 +1,9 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowHealth struct { + Error *ErrorEntity `json:"error,omitempty"` + State WorkflowHealthState `json:"state"` +} diff --git a/resource-manager/web/2024-11-01/webapps/predicates.go b/resource-manager/web/2024-11-01/webapps/predicates.go new file mode 100644 index 00000000000..3961c0e0cfd --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/predicates.go @@ -0,0 +1,788 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ApiKVReferenceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ApiKVReferenceOperationPredicate) Matches(input ApiKVReference) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type BackupItemOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p BackupItemOperationPredicate) Matches(input BackupItem) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type ContinuousWebJobOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ContinuousWebJobOperationPredicate) Matches(input ContinuousWebJob) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type CsmDeploymentStatusOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p CsmDeploymentStatusOperationPredicate) Matches(input CsmDeploymentStatus) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type CsmPublishingCredentialsPoliciesEntityOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p CsmPublishingCredentialsPoliciesEntityOperationPredicate) Matches(input CsmPublishingCredentialsPoliciesEntity) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type CsmUsageQuotaOperationPredicate struct { + CurrentValue *int64 + Limit *int64 + NextResetTime *string + Unit *string +} + +func (p CsmUsageQuotaOperationPredicate) Matches(input CsmUsageQuota) bool { + + if p.CurrentValue != nil && (input.CurrentValue == nil || *p.CurrentValue != *input.CurrentValue) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.NextResetTime != nil && (input.NextResetTime == nil || *p.NextResetTime != *input.NextResetTime) { + return false + } + + if p.Unit != nil && (input.Unit == nil || *p.Unit != *input.Unit) { + return false + } + + return true +} + +type DeploymentOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p DeploymentOperationPredicate) Matches(input Deployment) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type FunctionEnvelopeOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p FunctionEnvelopeOperationPredicate) Matches(input FunctionEnvelope) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type HostNameBindingOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p HostNameBindingOperationPredicate) Matches(input HostNameBinding) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type IdentifierOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p IdentifierOperationPredicate) Matches(input Identifier) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type PerfMonResponseOperationPredicate struct { + Code *string + Message *string +} + +func (p PerfMonResponseOperationPredicate) Matches(input PerfMonResponse) bool { + + if p.Code != nil && (input.Code == nil || *p.Code != *input.Code) { + return false + } + + if p.Message != nil && (input.Message == nil || *p.Message != *input.Message) { + return false + } + + return true +} + +type ProcessInfoOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ProcessInfoOperationPredicate) Matches(input ProcessInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type ProcessModuleInfoOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ProcessModuleInfoOperationPredicate) Matches(input ProcessModuleInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type ProcessThreadInfoOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p ProcessThreadInfoOperationPredicate) Matches(input ProcessThreadInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type PublicCertificateOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p PublicCertificateOperationPredicate) Matches(input PublicCertificate) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type RemotePrivateEndpointConnectionARMResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p RemotePrivateEndpointConnectionARMResourceOperationPredicate) Matches(input RemotePrivateEndpointConnectionARMResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SiteOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p SiteOperationPredicate) Matches(input Site) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SiteConfigResourceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SiteConfigResourceOperationPredicate) Matches(input SiteConfigResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SiteConfigurationSnapshotInfoOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SiteConfigurationSnapshotInfoOperationPredicate) Matches(input SiteConfigurationSnapshotInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SiteContainerOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SiteContainerOperationPredicate) Matches(input SiteContainer) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SiteExtensionInfoOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SiteExtensionInfoOperationPredicate) Matches(input SiteExtensionInfo) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SlotDifferenceOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SlotDifferenceOperationPredicate) Matches(input SlotDifference) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SnapshotOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p SnapshotOperationPredicate) Matches(input Snapshot) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type TriggeredJobHistoryOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p TriggeredJobHistoryOperationPredicate) Matches(input TriggeredJobHistory) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type TriggeredWebJobOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p TriggeredWebJobOperationPredicate) Matches(input TriggeredWebJob) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type WebJobOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p WebJobOperationPredicate) Matches(input WebJob) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type WebSiteInstanceStatusOperationPredicate struct { + Id *string + Kind *string + Name *string + Type *string +} + +func (p WebSiteInstanceStatusOperationPredicate) Matches(input WebSiteInstanceStatus) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type WorkflowEnvelopeOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p WorkflowEnvelopeOperationPredicate) Matches(input WorkflowEnvelope) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/webapps/version.go b/resource-manager/web/2024-11-01/webapps/version.go new file mode 100644 index 00000000000..43739efaa52 --- /dev/null +++ b/resource-manager/web/2024-11-01/webapps/version.go @@ -0,0 +1,10 @@ +package webapps + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/webapps/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/README.md b/resource-manager/web/2024-11-01/workflowrunactions/README.md new file mode 100644 index 00000000000..dd16ece43f5 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/README.md @@ -0,0 +1,186 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflowrunactions` Documentation + +The `workflowrunactions` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflowrunactions" +``` + + +### Client Initialization + +```go +client := workflowrunactions.NewWorkflowRunActionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowRunActionsClient.CopeRepetitionsGet` + +```go +ctx := context.TODO() +id := workflowrunactions.NewScopeRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "scopeRepetitionName") + +read, err := client.CopeRepetitionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowRunActionsClient.CopeRepetitionsList` + +```go +ctx := context.TODO() +id := workflowrunactions.NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName") + +// alternatively `client.CopeRepetitionsList(ctx, id)` can be used to do batched pagination +items, err := client.CopeRepetitionsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowRunActionsClient.Get` + +```go +ctx := context.TODO() +id := workflowrunactions.NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowRunActionsClient.List` + +```go +ctx := context.TODO() +id := workflowrunactions.NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName") + +// alternatively `client.List(ctx, id, workflowrunactions.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, workflowrunactions.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowRunActionsClient.ListExpressionTraces` + +```go +ctx := context.TODO() +id := workflowrunactions.NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName") + +// alternatively `client.ListExpressionTraces(ctx, id)` can be used to do batched pagination +items, err := client.ListExpressionTracesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowRunActionsClient.WorkflowRunActionRepetitionsGet` + +```go +ctx := context.TODO() +id := workflowrunactions.NewRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "repetitionName") + +read, err := client.WorkflowRunActionRepetitionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowRunActionsClient.WorkflowRunActionRepetitionsList` + +```go +ctx := context.TODO() +id := workflowrunactions.NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName") + +// alternatively `client.WorkflowRunActionRepetitionsList(ctx, id)` can be used to do batched pagination +items, err := client.WorkflowRunActionRepetitionsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowRunActionsClient.WorkflowRunActionRepetitionsListExpressionTraces` + +```go +ctx := context.TODO() +id := workflowrunactions.NewRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "repetitionName") + +// alternatively `client.WorkflowRunActionRepetitionsListExpressionTraces(ctx, id)` can be used to do batched pagination +items, err := client.WorkflowRunActionRepetitionsListExpressionTracesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowRunActionsClient.WorkflowRunActionRepetitionsRequestHistoriesGet` + +```go +ctx := context.TODO() +id := workflowrunactions.NewRequestHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "repetitionName", "requestHistoryName") + +read, err := client.WorkflowRunActionRepetitionsRequestHistoriesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowRunActionsClient.WorkflowRunActionRepetitionsRequestHistoriesList` + +```go +ctx := context.TODO() +id := workflowrunactions.NewRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "repetitionName") + +// alternatively `client.WorkflowRunActionRepetitionsRequestHistoriesList(ctx, id)` can be used to do batched pagination +items, err := client.WorkflowRunActionRepetitionsRequestHistoriesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-11-01/workflowrunactions/client.go b/resource-manager/web/2024-11-01/workflowrunactions/client.go new file mode 100644 index 00000000000..463cc06a5f9 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/client.go @@ -0,0 +1,26 @@ +package workflowrunactions + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunActionsClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowRunActionsClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowRunActionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "workflowrunactions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowRunActionsClient: %+v", err) + } + + return &WorkflowRunActionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/constants.go b/resource-manager/web/2024-11-01/workflowrunactions/constants.go new file mode 100644 index 00000000000..98029f459ce --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/constants.go @@ -0,0 +1,84 @@ +package workflowrunactions + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowStatus string + +const ( + WorkflowStatusAborted WorkflowStatus = "Aborted" + WorkflowStatusCancelled WorkflowStatus = "Cancelled" + WorkflowStatusFailed WorkflowStatus = "Failed" + WorkflowStatusFaulted WorkflowStatus = "Faulted" + WorkflowStatusIgnored WorkflowStatus = "Ignored" + WorkflowStatusNotSpecified WorkflowStatus = "NotSpecified" + WorkflowStatusPaused WorkflowStatus = "Paused" + WorkflowStatusRunning WorkflowStatus = "Running" + WorkflowStatusSkipped WorkflowStatus = "Skipped" + WorkflowStatusSucceeded WorkflowStatus = "Succeeded" + WorkflowStatusSuspended WorkflowStatus = "Suspended" + WorkflowStatusTimedOut WorkflowStatus = "TimedOut" + WorkflowStatusWaiting WorkflowStatus = "Waiting" +) + +func PossibleValuesForWorkflowStatus() []string { + return []string{ + string(WorkflowStatusAborted), + string(WorkflowStatusCancelled), + string(WorkflowStatusFailed), + string(WorkflowStatusFaulted), + string(WorkflowStatusIgnored), + string(WorkflowStatusNotSpecified), + string(WorkflowStatusPaused), + string(WorkflowStatusRunning), + string(WorkflowStatusSkipped), + string(WorkflowStatusSucceeded), + string(WorkflowStatusSuspended), + string(WorkflowStatusTimedOut), + string(WorkflowStatusWaiting), + } +} + +func (s *WorkflowStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowStatus(input string) (*WorkflowStatus, error) { + vals := map[string]WorkflowStatus{ + "aborted": WorkflowStatusAborted, + "cancelled": WorkflowStatusCancelled, + "failed": WorkflowStatusFailed, + "faulted": WorkflowStatusFaulted, + "ignored": WorkflowStatusIgnored, + "notspecified": WorkflowStatusNotSpecified, + "paused": WorkflowStatusPaused, + "running": WorkflowStatusRunning, + "skipped": WorkflowStatusSkipped, + "succeeded": WorkflowStatusSucceeded, + "suspended": WorkflowStatusSuspended, + "timedout": WorkflowStatusTimedOut, + "waiting": WorkflowStatusWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowStatus(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/id_action.go b/resource-manager/web/2024-11-01/workflowrunactions/id_action.go new file mode 100644 index 00000000000..d8931531676 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/id_action.go @@ -0,0 +1,163 @@ +package workflowrunactions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ActionId{}) +} + +var _ resourceids.ResourceId = &ActionId{} + +// ActionId is a struct representing the Resource ID for a Action +type ActionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string + ActionName string +} + +// NewActionID returns a new ActionId struct +func NewActionID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string, actionName string) ActionId { + return ActionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + ActionName: actionName, + } +} + +// ParseActionID parses 'input' into a ActionId +func ParseActionID(input string) (*ActionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ActionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ActionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseActionIDInsensitively parses 'input' case-insensitively into a ActionId +// note: this method should only be used for API response data and not user input +func ParseActionIDInsensitively(input string) (*ActionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ActionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ActionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ActionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + if id.ActionName, ok = input.Parsed["actionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "actionName", input) + } + + return nil +} + +// ValidateActionID checks that 'input' can be parsed as a Action ID +func ValidateActionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseActionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Action ID +func (id ActionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s/actions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName, id.ActionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Action ID +func (id ActionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runName"), + resourceids.StaticSegment("staticActions", "actions", "actions"), + resourceids.UserSpecifiedSegment("actionName", "actionName"), + } +} + +// String returns a human-readable description of this Action ID +func (id ActionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + fmt.Sprintf("Action Name: %q", id.ActionName), + } + return fmt.Sprintf("Action (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/id_action_test.go b/resource-manager/web/2024-11-01/workflowrunactions/id_action_test.go new file mode 100644 index 00000000000..1a7cdb61b0c --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/id_action_test.go @@ -0,0 +1,507 @@ +package workflowrunactions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ActionId{} + +func TestNewActionID(t *testing.T) { + id := NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.RunName != "runName" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runName") + } + + if id.ActionName != "actionName" { + t.Fatalf("Expected %q but got %q for Segment 'ActionName'", id.ActionName, "actionName") + } +} + +func TestFormatActionID(t *testing.T) { + actual := NewActionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseActionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ActionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName", + Expected: &ActionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + ActionName: "actionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseActionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + } +} + +func TestParseActionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ActionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName", + Expected: &ActionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + ActionName: "actionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE", + Expected: &ActionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + RunName: "rUnNaMe", + ActionName: "aCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseActionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + } +} + +func TestSegmentsForActionId(t *testing.T) { + segments := ActionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ActionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/id_repetition.go b/resource-manager/web/2024-11-01/workflowrunactions/id_repetition.go new file mode 100644 index 00000000000..eea587301e1 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/id_repetition.go @@ -0,0 +1,172 @@ +package workflowrunactions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RepetitionId{}) +} + +var _ resourceids.ResourceId = &RepetitionId{} + +// RepetitionId is a struct representing the Resource ID for a Repetition +type RepetitionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string + ActionName string + RepetitionName string +} + +// NewRepetitionID returns a new RepetitionId struct +func NewRepetitionID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string, actionName string, repetitionName string) RepetitionId { + return RepetitionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + ActionName: actionName, + RepetitionName: repetitionName, + } +} + +// ParseRepetitionID parses 'input' into a RepetitionId +func ParseRepetitionID(input string) (*RepetitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RepetitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RepetitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRepetitionIDInsensitively parses 'input' case-insensitively into a RepetitionId +// note: this method should only be used for API response data and not user input +func ParseRepetitionIDInsensitively(input string) (*RepetitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RepetitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RepetitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RepetitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + if id.ActionName, ok = input.Parsed["actionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "actionName", input) + } + + if id.RepetitionName, ok = input.Parsed["repetitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "repetitionName", input) + } + + return nil +} + +// ValidateRepetitionID checks that 'input' can be parsed as a Repetition ID +func ValidateRepetitionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRepetitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Repetition ID +func (id RepetitionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s/actions/%s/repetitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName, id.ActionName, id.RepetitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Repetition ID +func (id RepetitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runName"), + resourceids.StaticSegment("staticActions", "actions", "actions"), + resourceids.UserSpecifiedSegment("actionName", "actionName"), + resourceids.StaticSegment("staticRepetitions", "repetitions", "repetitions"), + resourceids.UserSpecifiedSegment("repetitionName", "repetitionName"), + } +} + +// String returns a human-readable description of this Repetition ID +func (id RepetitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + fmt.Sprintf("Action Name: %q", id.ActionName), + fmt.Sprintf("Repetition Name: %q", id.RepetitionName), + } + return fmt.Sprintf("Repetition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/id_repetition_test.go b/resource-manager/web/2024-11-01/workflowrunactions/id_repetition_test.go new file mode 100644 index 00000000000..9b2f3157fe9 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/id_repetition_test.go @@ -0,0 +1,552 @@ +package workflowrunactions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RepetitionId{} + +func TestNewRepetitionID(t *testing.T) { + id := NewRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "repetitionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.RunName != "runName" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runName") + } + + if id.ActionName != "actionName" { + t.Fatalf("Expected %q but got %q for Segment 'ActionName'", id.ActionName, "actionName") + } + + if id.RepetitionName != "repetitionName" { + t.Fatalf("Expected %q but got %q for Segment 'RepetitionName'", id.RepetitionName, "repetitionName") + } +} + +func TestFormatRepetitionID(t *testing.T) { + actual := NewRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "repetitionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRepetitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RepetitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName", + Expected: &RepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + ActionName: "actionName", + RepetitionName: "repetitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRepetitionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.RepetitionName != v.Expected.RepetitionName { + t.Fatalf("Expected %q but got %q for RepetitionName", v.Expected.RepetitionName, actual.RepetitionName) + } + + } +} + +func TestParseRepetitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RepetitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/rEpEtItIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName", + Expected: &RepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + ActionName: "actionName", + RepetitionName: "repetitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/rEpEtItIoNs/rEpEtItIoNnAmE", + Expected: &RepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + RunName: "rUnNaMe", + ActionName: "aCtIoNnAmE", + RepetitionName: "rEpEtItIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/rEpEtItIoNs/rEpEtItIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRepetitionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.RepetitionName != v.Expected.RepetitionName { + t.Fatalf("Expected %q but got %q for RepetitionName", v.Expected.RepetitionName, actual.RepetitionName) + } + + } +} + +func TestSegmentsForRepetitionId(t *testing.T) { + segments := RepetitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RepetitionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/id_requesthistory.go b/resource-manager/web/2024-11-01/workflowrunactions/id_requesthistory.go new file mode 100644 index 00000000000..d15a9523fb5 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/id_requesthistory.go @@ -0,0 +1,181 @@ +package workflowrunactions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RequestHistoryId{}) +} + +var _ resourceids.ResourceId = &RequestHistoryId{} + +// RequestHistoryId is a struct representing the Resource ID for a Request History +type RequestHistoryId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string + ActionName string + RepetitionName string + RequestHistoryName string +} + +// NewRequestHistoryID returns a new RequestHistoryId struct +func NewRequestHistoryID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string, actionName string, repetitionName string, requestHistoryName string) RequestHistoryId { + return RequestHistoryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + ActionName: actionName, + RepetitionName: repetitionName, + RequestHistoryName: requestHistoryName, + } +} + +// ParseRequestHistoryID parses 'input' into a RequestHistoryId +func ParseRequestHistoryID(input string) (*RequestHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RequestHistoryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RequestHistoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRequestHistoryIDInsensitively parses 'input' case-insensitively into a RequestHistoryId +// note: this method should only be used for API response data and not user input +func ParseRequestHistoryIDInsensitively(input string) (*RequestHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RequestHistoryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RequestHistoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RequestHistoryId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + if id.ActionName, ok = input.Parsed["actionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "actionName", input) + } + + if id.RepetitionName, ok = input.Parsed["repetitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "repetitionName", input) + } + + if id.RequestHistoryName, ok = input.Parsed["requestHistoryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "requestHistoryName", input) + } + + return nil +} + +// ValidateRequestHistoryID checks that 'input' can be parsed as a Request History ID +func ValidateRequestHistoryID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRequestHistoryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Request History ID +func (id RequestHistoryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s/actions/%s/repetitions/%s/requestHistories/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName, id.ActionName, id.RepetitionName, id.RequestHistoryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Request History ID +func (id RequestHistoryId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runName"), + resourceids.StaticSegment("staticActions", "actions", "actions"), + resourceids.UserSpecifiedSegment("actionName", "actionName"), + resourceids.StaticSegment("staticRepetitions", "repetitions", "repetitions"), + resourceids.UserSpecifiedSegment("repetitionName", "repetitionName"), + resourceids.StaticSegment("staticRequestHistories", "requestHistories", "requestHistories"), + resourceids.UserSpecifiedSegment("requestHistoryName", "requestHistoryName"), + } +} + +// String returns a human-readable description of this Request History ID +func (id RequestHistoryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + fmt.Sprintf("Action Name: %q", id.ActionName), + fmt.Sprintf("Repetition Name: %q", id.RepetitionName), + fmt.Sprintf("Request History Name: %q", id.RequestHistoryName), + } + return fmt.Sprintf("Request History (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/id_requesthistory_test.go b/resource-manager/web/2024-11-01/workflowrunactions/id_requesthistory_test.go new file mode 100644 index 00000000000..170be7c8e38 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/id_requesthistory_test.go @@ -0,0 +1,597 @@ +package workflowrunactions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RequestHistoryId{} + +func TestNewRequestHistoryID(t *testing.T) { + id := NewRequestHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "repetitionName", "requestHistoryName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.RunName != "runName" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runName") + } + + if id.ActionName != "actionName" { + t.Fatalf("Expected %q but got %q for Segment 'ActionName'", id.ActionName, "actionName") + } + + if id.RepetitionName != "repetitionName" { + t.Fatalf("Expected %q but got %q for Segment 'RepetitionName'", id.RepetitionName, "repetitionName") + } + + if id.RequestHistoryName != "requestHistoryName" { + t.Fatalf("Expected %q but got %q for Segment 'RequestHistoryName'", id.RequestHistoryName, "requestHistoryName") + } +} + +func TestFormatRequestHistoryID(t *testing.T) { + actual := NewRequestHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "repetitionName", "requestHistoryName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/requestHistories/requestHistoryName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRequestHistoryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RequestHistoryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/requestHistories", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/requestHistories/requestHistoryName", + Expected: &RequestHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + ActionName: "actionName", + RepetitionName: "repetitionName", + RequestHistoryName: "requestHistoryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/requestHistories/requestHistoryName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRequestHistoryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.RepetitionName != v.Expected.RepetitionName { + t.Fatalf("Expected %q but got %q for RepetitionName", v.Expected.RepetitionName, actual.RepetitionName) + } + + if actual.RequestHistoryName != v.Expected.RequestHistoryName { + t.Fatalf("Expected %q but got %q for RequestHistoryName", v.Expected.RequestHistoryName, actual.RequestHistoryName) + } + + } +} + +func TestParseRequestHistoryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RequestHistoryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/rEpEtItIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/rEpEtItIoNs/rEpEtItIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/requestHistories", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/rEpEtItIoNs/rEpEtItIoNnAmE/rEqUeStHiStOrIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/requestHistories/requestHistoryName", + Expected: &RequestHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + ActionName: "actionName", + RepetitionName: "repetitionName", + RequestHistoryName: "requestHistoryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/repetitions/repetitionName/requestHistories/requestHistoryName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/rEpEtItIoNs/rEpEtItIoNnAmE/rEqUeStHiStOrIeS/rEqUeStHiStOrYnAmE", + Expected: &RequestHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + RunName: "rUnNaMe", + ActionName: "aCtIoNnAmE", + RepetitionName: "rEpEtItIoNnAmE", + RequestHistoryName: "rEqUeStHiStOrYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/rEpEtItIoNs/rEpEtItIoNnAmE/rEqUeStHiStOrIeS/rEqUeStHiStOrYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRequestHistoryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.RepetitionName != v.Expected.RepetitionName { + t.Fatalf("Expected %q but got %q for RepetitionName", v.Expected.RepetitionName, actual.RepetitionName) + } + + if actual.RequestHistoryName != v.Expected.RequestHistoryName { + t.Fatalf("Expected %q but got %q for RequestHistoryName", v.Expected.RequestHistoryName, actual.RequestHistoryName) + } + + } +} + +func TestSegmentsForRequestHistoryId(t *testing.T) { + segments := RequestHistoryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RequestHistoryId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/id_run.go b/resource-manager/web/2024-11-01/workflowrunactions/id_run.go new file mode 100644 index 00000000000..50398640cd1 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/id_run.go @@ -0,0 +1,154 @@ +package workflowrunactions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RunId{}) +} + +var _ resourceids.ResourceId = &RunId{} + +// RunId is a struct representing the Resource ID for a Run +type RunId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string +} + +// NewRunID returns a new RunId struct +func NewRunID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string) RunId { + return RunId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + } +} + +// ParseRunID parses 'input' into a RunId +func ParseRunID(input string) (*RunId, error) { + parser := resourceids.NewParserFromResourceIdType(&RunId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RunId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRunIDInsensitively parses 'input' case-insensitively into a RunId +// note: this method should only be used for API response data and not user input +func ParseRunIDInsensitively(input string) (*RunId, error) { + parser := resourceids.NewParserFromResourceIdType(&RunId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RunId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RunId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + return nil +} + +// ValidateRunID checks that 'input' can be parsed as a Run ID +func ValidateRunID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRunID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Run ID +func (id RunId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Run ID +func (id RunId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runName"), + } +} + +// String returns a human-readable description of this Run ID +func (id RunId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + } + return fmt.Sprintf("Run (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/id_run_test.go b/resource-manager/web/2024-11-01/workflowrunactions/id_run_test.go new file mode 100644 index 00000000000..5b5fc911ae0 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/id_run_test.go @@ -0,0 +1,462 @@ +package workflowrunactions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RunId{} + +func TestNewRunID(t *testing.T) { + id := NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.RunName != "runName" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runName") + } +} + +func TestFormatRunID(t *testing.T) { + actual := NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRunID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RunId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRunID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + } +} + +func TestParseRunIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RunId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + RunName: "rUnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRunIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + } +} + +func TestSegmentsForRunId(t *testing.T) { + segments := RunId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RunId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/id_scoperepetition.go b/resource-manager/web/2024-11-01/workflowrunactions/id_scoperepetition.go new file mode 100644 index 00000000000..0e6e953b99e --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/id_scoperepetition.go @@ -0,0 +1,172 @@ +package workflowrunactions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ScopeRepetitionId{}) +} + +var _ resourceids.ResourceId = &ScopeRepetitionId{} + +// ScopeRepetitionId is a struct representing the Resource ID for a Scope Repetition +type ScopeRepetitionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string + ActionName string + ScopeRepetitionName string +} + +// NewScopeRepetitionID returns a new ScopeRepetitionId struct +func NewScopeRepetitionID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string, actionName string, scopeRepetitionName string) ScopeRepetitionId { + return ScopeRepetitionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + ActionName: actionName, + ScopeRepetitionName: scopeRepetitionName, + } +} + +// ParseScopeRepetitionID parses 'input' into a ScopeRepetitionId +func ParseScopeRepetitionID(input string) (*ScopeRepetitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopeRepetitionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopeRepetitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseScopeRepetitionIDInsensitively parses 'input' case-insensitively into a ScopeRepetitionId +// note: this method should only be used for API response data and not user input +func ParseScopeRepetitionIDInsensitively(input string) (*ScopeRepetitionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopeRepetitionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopeRepetitionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ScopeRepetitionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + if id.ActionName, ok = input.Parsed["actionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "actionName", input) + } + + if id.ScopeRepetitionName, ok = input.Parsed["scopeRepetitionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "scopeRepetitionName", input) + } + + return nil +} + +// ValidateScopeRepetitionID checks that 'input' can be parsed as a Scope Repetition ID +func ValidateScopeRepetitionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseScopeRepetitionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Scope Repetition ID +func (id ScopeRepetitionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s/actions/%s/scopeRepetitions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName, id.ActionName, id.ScopeRepetitionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Scope Repetition ID +func (id ScopeRepetitionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runName"), + resourceids.StaticSegment("staticActions", "actions", "actions"), + resourceids.UserSpecifiedSegment("actionName", "actionName"), + resourceids.StaticSegment("staticScopeRepetitions", "scopeRepetitions", "scopeRepetitions"), + resourceids.UserSpecifiedSegment("scopeRepetitionName", "scopeRepetitionName"), + } +} + +// String returns a human-readable description of this Scope Repetition ID +func (id ScopeRepetitionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + fmt.Sprintf("Action Name: %q", id.ActionName), + fmt.Sprintf("Scope Repetition Name: %q", id.ScopeRepetitionName), + } + return fmt.Sprintf("Scope Repetition (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/id_scoperepetition_test.go b/resource-manager/web/2024-11-01/workflowrunactions/id_scoperepetition_test.go new file mode 100644 index 00000000000..0b1db9c0160 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/id_scoperepetition_test.go @@ -0,0 +1,552 @@ +package workflowrunactions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ScopeRepetitionId{} + +func TestNewScopeRepetitionID(t *testing.T) { + id := NewScopeRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "scopeRepetitionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.RunName != "runName" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runName") + } + + if id.ActionName != "actionName" { + t.Fatalf("Expected %q but got %q for Segment 'ActionName'", id.ActionName, "actionName") + } + + if id.ScopeRepetitionName != "scopeRepetitionName" { + t.Fatalf("Expected %q but got %q for Segment 'ScopeRepetitionName'", id.ScopeRepetitionName, "scopeRepetitionName") + } +} + +func TestFormatScopeRepetitionID(t *testing.T) { + actual := NewScopeRepetitionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName", "actionName", "scopeRepetitionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/scopeRepetitions/scopeRepetitionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseScopeRepetitionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopeRepetitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/scopeRepetitions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/scopeRepetitions/scopeRepetitionName", + Expected: &ScopeRepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + ActionName: "actionName", + ScopeRepetitionName: "scopeRepetitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/scopeRepetitions/scopeRepetitionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopeRepetitionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.ScopeRepetitionName != v.Expected.ScopeRepetitionName { + t.Fatalf("Expected %q but got %q for ScopeRepetitionName", v.Expected.ScopeRepetitionName, actual.ScopeRepetitionName) + } + + } +} + +func TestParseScopeRepetitionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopeRepetitionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/scopeRepetitions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/sCoPeRePeTiTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/scopeRepetitions/scopeRepetitionName", + Expected: &ScopeRepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + ActionName: "actionName", + ScopeRepetitionName: "scopeRepetitionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/actions/actionName/scopeRepetitions/scopeRepetitionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/sCoPeRePeTiTiOnS/sCoPeRePeTiTiOnNaMe", + Expected: &ScopeRepetitionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + RunName: "rUnNaMe", + ActionName: "aCtIoNnAmE", + ScopeRepetitionName: "sCoPeRePeTiTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/aCtIoNs/aCtIoNnAmE/sCoPeRePeTiTiOnS/sCoPeRePeTiTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopeRepetitionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + if actual.ActionName != v.Expected.ActionName { + t.Fatalf("Expected %q but got %q for ActionName", v.Expected.ActionName, actual.ActionName) + } + + if actual.ScopeRepetitionName != v.Expected.ScopeRepetitionName { + t.Fatalf("Expected %q but got %q for ScopeRepetitionName", v.Expected.ScopeRepetitionName, actual.ScopeRepetitionName) + } + + } +} + +func TestSegmentsForScopeRepetitionId(t *testing.T) { + segments := ScopeRepetitionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ScopeRepetitionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/method_coperepetitionsget.go b/resource-manager/web/2024-11-01/workflowrunactions/method_coperepetitionsget.go new file mode 100644 index 00000000000..f860d0462b4 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/method_coperepetitionsget.go @@ -0,0 +1,53 @@ +package workflowrunactions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CopeRepetitionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowRunActionRepetitionDefinition +} + +// CopeRepetitionsGet ... +func (c WorkflowRunActionsClient) CopeRepetitionsGet(ctx context.Context, id ScopeRepetitionId) (result CopeRepetitionsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowRunActionRepetitionDefinition + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/method_coperepetitionslist.go b/resource-manager/web/2024-11-01/workflowrunactions/method_coperepetitionslist.go new file mode 100644 index 00000000000..8e3b1832ac8 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/method_coperepetitionslist.go @@ -0,0 +1,105 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CopeRepetitionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowRunActionRepetitionDefinition +} + +type CopeRepetitionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowRunActionRepetitionDefinition +} + +type CopeRepetitionsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *CopeRepetitionsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// CopeRepetitionsList ... +func (c WorkflowRunActionsClient) CopeRepetitionsList(ctx context.Context, id ActionId) (result CopeRepetitionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &CopeRepetitionsListCustomPager{}, + Path: fmt.Sprintf("%s/scopeRepetitions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowRunActionRepetitionDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// CopeRepetitionsListComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) CopeRepetitionsListComplete(ctx context.Context, id ActionId) (CopeRepetitionsListCompleteResult, error) { + return c.CopeRepetitionsListCompleteMatchingPredicate(ctx, id, WorkflowRunActionRepetitionDefinitionOperationPredicate{}) +} + +// CopeRepetitionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunActionsClient) CopeRepetitionsListCompleteMatchingPredicate(ctx context.Context, id ActionId, predicate WorkflowRunActionRepetitionDefinitionOperationPredicate) (result CopeRepetitionsListCompleteResult, err error) { + items := make([]WorkflowRunActionRepetitionDefinition, 0) + + resp, err := c.CopeRepetitionsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = CopeRepetitionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/method_get.go b/resource-manager/web/2024-11-01/workflowrunactions/method_get.go new file mode 100644 index 00000000000..c86b02f4ca2 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/method_get.go @@ -0,0 +1,53 @@ +package workflowrunactions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowRunAction +} + +// Get ... +func (c WorkflowRunActionsClient) Get(ctx context.Context, id ActionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowRunAction + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/method_list.go b/resource-manager/web/2024-11-01/workflowrunactions/method_list.go new file mode 100644 index 00000000000..084239bb128 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/method_list.go @@ -0,0 +1,138 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowRunAction +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowRunAction +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c WorkflowRunActionsClient) List(ctx context.Context, id RunId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/actions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowRunAction `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) ListComplete(ctx context.Context, id RunId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowRunActionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunActionsClient) ListCompleteMatchingPredicate(ctx context.Context, id RunId, options ListOperationOptions, predicate WorkflowRunActionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowRunAction, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/method_listexpressiontraces.go b/resource-manager/web/2024-11-01/workflowrunactions/method_listexpressiontraces.go new file mode 100644 index 00000000000..07ca3a3e829 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/method_listexpressiontraces.go @@ -0,0 +1,98 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListExpressionTracesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]interface{} +} + +type ListExpressionTracesCompleteResult struct { + LatestHttpResponse *http.Response + Items []interface{} +} + +type ListExpressionTracesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListExpressionTracesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListExpressionTraces ... +func (c WorkflowRunActionsClient) ListExpressionTraces(ctx context.Context, id ActionId) (result ListExpressionTracesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ListExpressionTracesCustomPager{}, + Path: fmt.Sprintf("%s/listExpressionTraces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]interface{} `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListExpressionTracesComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) ListExpressionTracesComplete(ctx context.Context, id ActionId) (result ListExpressionTracesCompleteResult, err error) { + items := make([]interface{}, 0) + + resp, err := c.ListExpressionTraces(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + items = append(items, v) + } + } + + result = ListExpressionTracesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/method_workflowrunactionrepetitionsget.go b/resource-manager/web/2024-11-01/workflowrunactions/method_workflowrunactionrepetitionsget.go new file mode 100644 index 00000000000..eb39d17169e --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/method_workflowrunactionrepetitionsget.go @@ -0,0 +1,53 @@ +package workflowrunactions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunActionRepetitionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowRunActionRepetitionDefinition +} + +// WorkflowRunActionRepetitionsGet ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsGet(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowRunActionRepetitionDefinition + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/method_workflowrunactionrepetitionslist.go b/resource-manager/web/2024-11-01/workflowrunactions/method_workflowrunactionrepetitionslist.go new file mode 100644 index 00000000000..6b6fadac68b --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/method_workflowrunactionrepetitionslist.go @@ -0,0 +1,105 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunActionRepetitionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowRunActionRepetitionDefinition +} + +type WorkflowRunActionRepetitionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowRunActionRepetitionDefinition +} + +type WorkflowRunActionRepetitionsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *WorkflowRunActionRepetitionsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// WorkflowRunActionRepetitionsList ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsList(ctx context.Context, id ActionId) (result WorkflowRunActionRepetitionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &WorkflowRunActionRepetitionsListCustomPager{}, + Path: fmt.Sprintf("%s/repetitions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowRunActionRepetitionDefinition `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// WorkflowRunActionRepetitionsListComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListComplete(ctx context.Context, id ActionId) (WorkflowRunActionRepetitionsListCompleteResult, error) { + return c.WorkflowRunActionRepetitionsListCompleteMatchingPredicate(ctx, id, WorkflowRunActionRepetitionDefinitionOperationPredicate{}) +} + +// WorkflowRunActionRepetitionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListCompleteMatchingPredicate(ctx context.Context, id ActionId, predicate WorkflowRunActionRepetitionDefinitionOperationPredicate) (result WorkflowRunActionRepetitionsListCompleteResult, err error) { + items := make([]WorkflowRunActionRepetitionDefinition, 0) + + resp, err := c.WorkflowRunActionRepetitionsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = WorkflowRunActionRepetitionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/method_workflowrunactionrepetitionslistexpressiontraces.go b/resource-manager/web/2024-11-01/workflowrunactions/method_workflowrunactionrepetitionslistexpressiontraces.go new file mode 100644 index 00000000000..a3f212a0cfe --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/method_workflowrunactionrepetitionslistexpressiontraces.go @@ -0,0 +1,98 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunActionRepetitionsListExpressionTracesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]interface{} +} + +type WorkflowRunActionRepetitionsListExpressionTracesCompleteResult struct { + LatestHttpResponse *http.Response + Items []interface{} +} + +type WorkflowRunActionRepetitionsListExpressionTracesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *WorkflowRunActionRepetitionsListExpressionTracesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// WorkflowRunActionRepetitionsListExpressionTraces ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListExpressionTraces(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsListExpressionTracesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &WorkflowRunActionRepetitionsListExpressionTracesCustomPager{}, + Path: fmt.Sprintf("%s/listExpressionTraces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]interface{} `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// WorkflowRunActionRepetitionsListExpressionTracesComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsListExpressionTracesComplete(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsListExpressionTracesCompleteResult, err error) { + items := make([]interface{}, 0) + + resp, err := c.WorkflowRunActionRepetitionsListExpressionTraces(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + items = append(items, v) + } + } + + result = WorkflowRunActionRepetitionsListExpressionTracesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistoriesget.go b/resource-manager/web/2024-11-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistoriesget.go new file mode 100644 index 00000000000..67800134834 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistoriesget.go @@ -0,0 +1,53 @@ +package workflowrunactions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunActionRepetitionsRequestHistoriesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RequestHistory +} + +// WorkflowRunActionRepetitionsRequestHistoriesGet ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesGet(ctx context.Context, id RequestHistoryId) (result WorkflowRunActionRepetitionsRequestHistoriesGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RequestHistory + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistorieslist.go b/resource-manager/web/2024-11-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistorieslist.go new file mode 100644 index 00000000000..c1d6265df03 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/method_workflowrunactionrepetitionsrequesthistorieslist.go @@ -0,0 +1,105 @@ +package workflowrunactions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunActionRepetitionsRequestHistoriesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RequestHistory +} + +type WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RequestHistory +} + +type WorkflowRunActionRepetitionsRequestHistoriesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *WorkflowRunActionRepetitionsRequestHistoriesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// WorkflowRunActionRepetitionsRequestHistoriesList ... +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesList(ctx context.Context, id RepetitionId) (result WorkflowRunActionRepetitionsRequestHistoriesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &WorkflowRunActionRepetitionsRequestHistoriesListCustomPager{}, + Path: fmt.Sprintf("%s/requestHistories", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RequestHistory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// WorkflowRunActionRepetitionsRequestHistoriesListComplete retrieves all the results into a single object +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesListComplete(ctx context.Context, id RepetitionId) (WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult, error) { + return c.WorkflowRunActionRepetitionsRequestHistoriesListCompleteMatchingPredicate(ctx, id, RequestHistoryOperationPredicate{}) +} + +// WorkflowRunActionRepetitionsRequestHistoriesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunActionsClient) WorkflowRunActionRepetitionsRequestHistoriesListCompleteMatchingPredicate(ctx context.Context, id RepetitionId, predicate RequestHistoryOperationPredicate) (result WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult, err error) { + items := make([]RequestHistory, 0) + + resp, err := c.WorkflowRunActionRepetitionsRequestHistoriesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = WorkflowRunActionRepetitionsRequestHistoriesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/model_contenthash.go b/resource-manager/web/2024-11-01/workflowrunactions/model_contenthash.go new file mode 100644 index 00000000000..3c0011433bc --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/model_contenthash.go @@ -0,0 +1,9 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentHash struct { + Algorithm *string `json:"algorithm,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/model_contentlink.go b/resource-manager/web/2024-11-01/workflowrunactions/model_contentlink.go new file mode 100644 index 00000000000..bd3dc0e8dbc --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/model_contentlink.go @@ -0,0 +1,12 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentLink struct { + ContentHash *ContentHash `json:"contentHash,omitempty"` + ContentSize *int64 `json:"contentSize,omitempty"` + ContentVersion *string `json:"contentVersion,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Uri *string `json:"uri,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/model_errorproperties.go b/resource-manager/web/2024-11-01/workflowrunactions/model_errorproperties.go new file mode 100644 index 00000000000..0c17755bd62 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/model_errorproperties.go @@ -0,0 +1,9 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorProperties struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/model_errorresponse.go b/resource-manager/web/2024-11-01/workflowrunactions/model_errorresponse.go new file mode 100644 index 00000000000..9856e5afdda --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/model_errorresponse.go @@ -0,0 +1,8 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorResponse struct { + Error *ErrorProperties `json:"error,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/model_repetitionindex.go b/resource-manager/web/2024-11-01/workflowrunactions/model_repetitionindex.go new file mode 100644 index 00000000000..ba809fd0741 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/model_repetitionindex.go @@ -0,0 +1,9 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RepetitionIndex struct { + ItemIndex int64 `json:"itemIndex"` + ScopeName *string `json:"scopeName,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/model_request.go b/resource-manager/web/2024-11-01/workflowrunactions/model_request.go new file mode 100644 index 00000000000..1ced5675ea2 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/model_request.go @@ -0,0 +1,10 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Request struct { + Headers *interface{} `json:"headers,omitempty"` + Method *string `json:"method,omitempty"` + Uri *string `json:"uri,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/model_requesthistory.go b/resource-manager/web/2024-11-01/workflowrunactions/model_requesthistory.go new file mode 100644 index 00000000000..61e48b714f3 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/model_requesthistory.go @@ -0,0 +1,13 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequestHistory struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RequestHistoryProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/model_requesthistoryproperties.go b/resource-manager/web/2024-11-01/workflowrunactions/model_requesthistoryproperties.go new file mode 100644 index 00000000000..86fd91ff9e0 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/model_requesthistoryproperties.go @@ -0,0 +1,41 @@ +package workflowrunactions + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequestHistoryProperties struct { + EndTime *string `json:"endTime,omitempty"` + Request *Request `json:"request,omitempty"` + Response *Response `json:"response,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *RequestHistoryProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RequestHistoryProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *RequestHistoryProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RequestHistoryProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/model_response.go b/resource-manager/web/2024-11-01/workflowrunactions/model_response.go new file mode 100644 index 00000000000..2697b1a5aab --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/model_response.go @@ -0,0 +1,10 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Response struct { + BodyLink *ContentLink `json:"bodyLink,omitempty"` + Headers *interface{} `json:"headers,omitempty"` + StatusCode *int64 `json:"statusCode,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/model_retryhistory.go b/resource-manager/web/2024-11-01/workflowrunactions/model_retryhistory.go new file mode 100644 index 00000000000..372ab23d01f --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/model_retryhistory.go @@ -0,0 +1,43 @@ +package workflowrunactions + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RetryHistory struct { + ClientRequestId *string `json:"clientRequestId,omitempty"` + Code *string `json:"code,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *ErrorResponse `json:"error,omitempty"` + ServiceRequestId *string `json:"serviceRequestId,omitempty"` + StartTime *string `json:"startTime,omitempty"` +} + +func (o *RetryHistory) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RetryHistory) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *RetryHistory) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *RetryHistory) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/model_runactioncorrelation.go b/resource-manager/web/2024-11-01/workflowrunactions/model_runactioncorrelation.go new file mode 100644 index 00000000000..dc7976ccc37 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/model_runactioncorrelation.go @@ -0,0 +1,10 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunActionCorrelation struct { + ActionTrackingId *string `json:"actionTrackingId,omitempty"` + ClientKeywords *[]string `json:"clientKeywords,omitempty"` + ClientTrackingId *string `json:"clientTrackingId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/model_workflowrunaction.go b/resource-manager/web/2024-11-01/workflowrunactions/model_workflowrunaction.go new file mode 100644 index 00000000000..443cf266c76 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/model_workflowrunaction.go @@ -0,0 +1,11 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunAction struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowRunActionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/model_workflowrunactionproperties.go b/resource-manager/web/2024-11-01/workflowrunactions/model_workflowrunactionproperties.go new file mode 100644 index 00000000000..515fd157766 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/model_workflowrunactionproperties.go @@ -0,0 +1,48 @@ +package workflowrunactions + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunActionProperties struct { + Code *string `json:"code,omitempty"` + Correlation *RunActionCorrelation `json:"correlation,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *interface{} `json:"error,omitempty"` + InputsLink *ContentLink `json:"inputsLink,omitempty"` + OutputsLink *ContentLink `json:"outputsLink,omitempty"` + RetryHistory *[]RetryHistory `json:"retryHistory,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + TrackedProperties *interface{} `json:"trackedProperties,omitempty"` + TrackingId *string `json:"trackingId,omitempty"` +} + +func (o *WorkflowRunActionProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunActionProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *WorkflowRunActionProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunActionProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/model_workflowrunactionrepetitiondefinition.go b/resource-manager/web/2024-11-01/workflowrunactions/model_workflowrunactionrepetitiondefinition.go new file mode 100644 index 00000000000..6705564dcf3 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/model_workflowrunactionrepetitiondefinition.go @@ -0,0 +1,13 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunActionRepetitionDefinition struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties WorkflowRunActionRepetitionProperties `json:"properties"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/model_workflowrunactionrepetitionproperties.go b/resource-manager/web/2024-11-01/workflowrunactions/model_workflowrunactionrepetitionproperties.go new file mode 100644 index 00000000000..759c33c6009 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/model_workflowrunactionrepetitionproperties.go @@ -0,0 +1,52 @@ +package workflowrunactions + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunActionRepetitionProperties struct { + Code *string `json:"code,omitempty"` + Correlation *RunActionCorrelation `json:"correlation,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *interface{} `json:"error,omitempty"` + Inputs *interface{} `json:"inputs,omitempty"` + InputsLink *ContentLink `json:"inputsLink,omitempty"` + IterationCount *int64 `json:"iterationCount,omitempty"` + Outputs *interface{} `json:"outputs,omitempty"` + OutputsLink *ContentLink `json:"outputsLink,omitempty"` + RepetitionIndexes *[]RepetitionIndex `json:"repetitionIndexes,omitempty"` + RetryHistory *[]RetryHistory `json:"retryHistory,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + TrackedProperties *interface{} `json:"trackedProperties,omitempty"` + TrackingId *string `json:"trackingId,omitempty"` +} + +func (o *WorkflowRunActionRepetitionProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunActionRepetitionProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *WorkflowRunActionRepetitionProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunActionRepetitionProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/predicates.go b/resource-manager/web/2024-11-01/workflowrunactions/predicates.go new file mode 100644 index 00000000000..fa466cf2c8e --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/predicates.go @@ -0,0 +1,83 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequestHistoryOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p RequestHistoryOperationPredicate) Matches(input RequestHistory) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type WorkflowRunActionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p WorkflowRunActionOperationPredicate) Matches(input WorkflowRunAction) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type WorkflowRunActionRepetitionDefinitionOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p WorkflowRunActionRepetitionDefinitionOperationPredicate) Matches(input WorkflowRunActionRepetitionDefinition) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/workflowrunactions/version.go b/resource-manager/web/2024-11-01/workflowrunactions/version.go new file mode 100644 index 00000000000..b4adea471b5 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowrunactions/version.go @@ -0,0 +1,10 @@ +package workflowrunactions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/workflowrunactions/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/workflowruns/README.md b/resource-manager/web/2024-11-01/workflowruns/README.md new file mode 100644 index 00000000000..99479ce10b1 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/README.md @@ -0,0 +1,69 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflowruns` Documentation + +The `workflowruns` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflowruns" +``` + + +### Client Initialization + +```go +client := workflowruns.NewWorkflowRunsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowRunsClient.Cancel` + +```go +ctx := context.TODO() +id := workflowruns.NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName") + +read, err := client.Cancel(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowRunsClient.Get` + +```go +ctx := context.TODO() +id := workflowruns.NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowRunsClient.List` + +```go +ctx := context.TODO() +id := workflowruns.NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + +// alternatively `client.List(ctx, id, workflowruns.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, workflowruns.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-11-01/workflowruns/client.go b/resource-manager/web/2024-11-01/workflowruns/client.go new file mode 100644 index 00000000000..73a34bf9d60 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/client.go @@ -0,0 +1,26 @@ +package workflowruns + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunsClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowRunsClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowRunsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "workflowruns", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowRunsClient: %+v", err) + } + + return &WorkflowRunsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/workflowruns/constants.go b/resource-manager/web/2024-11-01/workflowruns/constants.go new file mode 100644 index 00000000000..35a87b003f0 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/constants.go @@ -0,0 +1,146 @@ +package workflowruns + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ParameterType string + +const ( + ParameterTypeArray ParameterType = "Array" + ParameterTypeBool ParameterType = "Bool" + ParameterTypeFloat ParameterType = "Float" + ParameterTypeInt ParameterType = "Int" + ParameterTypeNotSpecified ParameterType = "NotSpecified" + ParameterTypeObject ParameterType = "Object" + ParameterTypeSecureObject ParameterType = "SecureObject" + ParameterTypeSecureString ParameterType = "SecureString" + ParameterTypeString ParameterType = "String" +) + +func PossibleValuesForParameterType() []string { + return []string{ + string(ParameterTypeArray), + string(ParameterTypeBool), + string(ParameterTypeFloat), + string(ParameterTypeInt), + string(ParameterTypeNotSpecified), + string(ParameterTypeObject), + string(ParameterTypeSecureObject), + string(ParameterTypeSecureString), + string(ParameterTypeString), + } +} + +func (s *ParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseParameterType(input string) (*ParameterType, error) { + vals := map[string]ParameterType{ + "array": ParameterTypeArray, + "bool": ParameterTypeBool, + "float": ParameterTypeFloat, + "int": ParameterTypeInt, + "notspecified": ParameterTypeNotSpecified, + "object": ParameterTypeObject, + "secureobject": ParameterTypeSecureObject, + "securestring": ParameterTypeSecureString, + "string": ParameterTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ParameterType(input) + return &out, nil +} + +type WorkflowStatus string + +const ( + WorkflowStatusAborted WorkflowStatus = "Aborted" + WorkflowStatusCancelled WorkflowStatus = "Cancelled" + WorkflowStatusFailed WorkflowStatus = "Failed" + WorkflowStatusFaulted WorkflowStatus = "Faulted" + WorkflowStatusIgnored WorkflowStatus = "Ignored" + WorkflowStatusNotSpecified WorkflowStatus = "NotSpecified" + WorkflowStatusPaused WorkflowStatus = "Paused" + WorkflowStatusRunning WorkflowStatus = "Running" + WorkflowStatusSkipped WorkflowStatus = "Skipped" + WorkflowStatusSucceeded WorkflowStatus = "Succeeded" + WorkflowStatusSuspended WorkflowStatus = "Suspended" + WorkflowStatusTimedOut WorkflowStatus = "TimedOut" + WorkflowStatusWaiting WorkflowStatus = "Waiting" +) + +func PossibleValuesForWorkflowStatus() []string { + return []string{ + string(WorkflowStatusAborted), + string(WorkflowStatusCancelled), + string(WorkflowStatusFailed), + string(WorkflowStatusFaulted), + string(WorkflowStatusIgnored), + string(WorkflowStatusNotSpecified), + string(WorkflowStatusPaused), + string(WorkflowStatusRunning), + string(WorkflowStatusSkipped), + string(WorkflowStatusSucceeded), + string(WorkflowStatusSuspended), + string(WorkflowStatusTimedOut), + string(WorkflowStatusWaiting), + } +} + +func (s *WorkflowStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowStatus(input string) (*WorkflowStatus, error) { + vals := map[string]WorkflowStatus{ + "aborted": WorkflowStatusAborted, + "cancelled": WorkflowStatusCancelled, + "failed": WorkflowStatusFailed, + "faulted": WorkflowStatusFaulted, + "ignored": WorkflowStatusIgnored, + "notspecified": WorkflowStatusNotSpecified, + "paused": WorkflowStatusPaused, + "running": WorkflowStatusRunning, + "skipped": WorkflowStatusSkipped, + "succeeded": WorkflowStatusSucceeded, + "suspended": WorkflowStatusSuspended, + "timedout": WorkflowStatusTimedOut, + "waiting": WorkflowStatusWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowStatus(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/workflowruns/id_managementworkflow.go b/resource-manager/web/2024-11-01/workflowruns/id_managementworkflow.go new file mode 100644 index 00000000000..b87857c4e6f --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/id_managementworkflow.go @@ -0,0 +1,145 @@ +package workflowruns + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagementWorkflowId{}) +} + +var _ resourceids.ResourceId = &ManagementWorkflowId{} + +// ManagementWorkflowId is a struct representing the Resource ID for a Management Workflow +type ManagementWorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string +} + +// NewManagementWorkflowID returns a new ManagementWorkflowId struct +func NewManagementWorkflowID(subscriptionId string, resourceGroupName string, siteName string, workflowName string) ManagementWorkflowId { + return ManagementWorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + } +} + +// ParseManagementWorkflowID parses 'input' into a ManagementWorkflowId +func ParseManagementWorkflowID(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagementWorkflowIDInsensitively parses 'input' case-insensitively into a ManagementWorkflowId +// note: this method should only be used for API response data and not user input +func ParseManagementWorkflowIDInsensitively(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagementWorkflowId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateManagementWorkflowID checks that 'input' can be parsed as a Management Workflow ID +func ValidateManagementWorkflowID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseManagementWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Management Workflow ID +func (id ManagementWorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Management Workflow ID +func (id ManagementWorkflowId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + } +} + +// String returns a human-readable description of this Management Workflow ID +func (id ManagementWorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Management Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/workflowruns/id_managementworkflow_test.go b/resource-manager/web/2024-11-01/workflowruns/id_managementworkflow_test.go new file mode 100644 index 00000000000..5895776d52c --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/id_managementworkflow_test.go @@ -0,0 +1,417 @@ +package workflowruns + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ManagementWorkflowId{} + +func TestNewManagementWorkflowID(t *testing.T) { + id := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } +} + +func TestFormatManagementWorkflowID(t *testing.T) { + actual := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagementWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseManagementWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForManagementWorkflowId(t *testing.T) { + segments := ManagementWorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagementWorkflowId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/workflowruns/id_run.go b/resource-manager/web/2024-11-01/workflowruns/id_run.go new file mode 100644 index 00000000000..968133f5c51 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/id_run.go @@ -0,0 +1,154 @@ +package workflowruns + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RunId{}) +} + +var _ resourceids.ResourceId = &RunId{} + +// RunId is a struct representing the Resource ID for a Run +type RunId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + RunName string +} + +// NewRunID returns a new RunId struct +func NewRunID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, runName string) RunId { + return RunId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + RunName: runName, + } +} + +// ParseRunID parses 'input' into a RunId +func ParseRunID(input string) (*RunId, error) { + parser := resourceids.NewParserFromResourceIdType(&RunId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RunId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRunIDInsensitively parses 'input' case-insensitively into a RunId +// note: this method should only be used for API response data and not user input +func ParseRunIDInsensitively(input string) (*RunId, error) { + parser := resourceids.NewParserFromResourceIdType(&RunId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RunId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RunId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.RunName, ok = input.Parsed["runName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "runName", input) + } + + return nil +} + +// ValidateRunID checks that 'input' can be parsed as a Run ID +func ValidateRunID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRunID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Run ID +func (id RunId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/runs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.RunName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Run ID +func (id RunId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticRuns", "runs", "runs"), + resourceids.UserSpecifiedSegment("runName", "runName"), + } +} + +// String returns a human-readable description of this Run ID +func (id RunId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Run Name: %q", id.RunName), + } + return fmt.Sprintf("Run (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/workflowruns/id_run_test.go b/resource-manager/web/2024-11-01/workflowruns/id_run_test.go new file mode 100644 index 00000000000..abacc74a502 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/id_run_test.go @@ -0,0 +1,462 @@ +package workflowruns + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RunId{} + +func TestNewRunID(t *testing.T) { + id := NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.RunName != "runName" { + t.Fatalf("Expected %q but got %q for Segment 'RunName'", id.RunName, "runName") + } +} + +func TestFormatRunID(t *testing.T) { + actual := NewRunID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "runName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRunID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RunId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRunID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + } +} + +func TestParseRunIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RunId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + RunName: "runName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/runs/runName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe", + Expected: &RunId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + RunName: "rUnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/rUnS/rUnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRunIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.RunName != v.Expected.RunName { + t.Fatalf("Expected %q but got %q for RunName", v.Expected.RunName, actual.RunName) + } + + } +} + +func TestSegmentsForRunId(t *testing.T) { + segments := RunId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RunId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/workflowruns/method_cancel.go b/resource-manager/web/2024-11-01/workflowruns/method_cancel.go new file mode 100644 index 00000000000..bb4d8b5ae55 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/method_cancel.go @@ -0,0 +1,47 @@ +package workflowruns + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CancelOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Cancel ... +func (c WorkflowRunsClient) Cancel(ctx context.Context, id RunId) (result CancelOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/cancel", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/workflowruns/method_get.go b/resource-manager/web/2024-11-01/workflowruns/method_get.go new file mode 100644 index 00000000000..17d61b2a5b1 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/method_get.go @@ -0,0 +1,53 @@ +package workflowruns + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowRun +} + +// Get ... +func (c WorkflowRunsClient) Get(ctx context.Context, id RunId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowRun + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/workflowruns/method_list.go b/resource-manager/web/2024-11-01/workflowruns/method_list.go new file mode 100644 index 00000000000..01f6d279698 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/method_list.go @@ -0,0 +1,138 @@ +package workflowruns + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowRun +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowRun +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c WorkflowRunsClient) List(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/runs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowRun `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c WorkflowRunsClient) ListComplete(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowRunOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowRunsClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions, predicate WorkflowRunOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowRun, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/workflowruns/model_contenthash.go b/resource-manager/web/2024-11-01/workflowruns/model_contenthash.go new file mode 100644 index 00000000000..88622a95a71 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/model_contenthash.go @@ -0,0 +1,9 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentHash struct { + Algorithm *string `json:"algorithm,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowruns/model_contentlink.go b/resource-manager/web/2024-11-01/workflowruns/model_contentlink.go new file mode 100644 index 00000000000..c373bce184c --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/model_contentlink.go @@ -0,0 +1,12 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentLink struct { + ContentHash *ContentHash `json:"contentHash,omitempty"` + ContentSize *int64 `json:"contentSize,omitempty"` + ContentVersion *string `json:"contentVersion,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Uri *string `json:"uri,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowruns/model_correlation.go b/resource-manager/web/2024-11-01/workflowruns/model_correlation.go new file mode 100644 index 00000000000..39ab7e52bc4 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/model_correlation.go @@ -0,0 +1,8 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Correlation struct { + ClientTrackingId *string `json:"clientTrackingId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowruns/model_resourcereference.go b/resource-manager/web/2024-11-01/workflowruns/model_resourcereference.go new file mode 100644 index 00000000000..b3a7c0a9505 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/model_resourcereference.go @@ -0,0 +1,10 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowruns/model_workflowoutputparameter.go b/resource-manager/web/2024-11-01/workflowruns/model_workflowoutputparameter.go new file mode 100644 index 00000000000..eafad5d773e --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/model_workflowoutputparameter.go @@ -0,0 +1,12 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowOutputParameter struct { + Description *string `json:"description,omitempty"` + Error *interface{} `json:"error,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Type *ParameterType `json:"type,omitempty"` + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowruns/model_workflowrun.go b/resource-manager/web/2024-11-01/workflowruns/model_workflowrun.go new file mode 100644 index 00000000000..10487050a8b --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/model_workflowrun.go @@ -0,0 +1,11 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRun struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowRunProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowruns/model_workflowrunproperties.go b/resource-manager/web/2024-11-01/workflowruns/model_workflowrunproperties.go new file mode 100644 index 00000000000..65670fb8d3a --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/model_workflowrunproperties.go @@ -0,0 +1,61 @@ +package workflowruns + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunProperties struct { + Code *string `json:"code,omitempty"` + Correlation *Correlation `json:"correlation,omitempty"` + CorrelationId *string `json:"correlationId,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *interface{} `json:"error,omitempty"` + Outputs *map[string]WorkflowOutputParameter `json:"outputs,omitempty"` + Response *WorkflowRunTrigger `json:"response,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + Trigger *WorkflowRunTrigger `json:"trigger,omitempty"` + WaitEndTime *string `json:"waitEndTime,omitempty"` + Workflow *ResourceReference `json:"workflow,omitempty"` +} + +func (o *WorkflowRunProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *WorkflowRunProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} + +func (o *WorkflowRunProperties) GetWaitEndTimeAsTime() (*time.Time, error) { + if o.WaitEndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.WaitEndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunProperties) SetWaitEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.WaitEndTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/workflowruns/model_workflowruntrigger.go b/resource-manager/web/2024-11-01/workflowruns/model_workflowruntrigger.go new file mode 100644 index 00000000000..64680149cd7 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/model_workflowruntrigger.go @@ -0,0 +1,63 @@ +package workflowruns + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunTrigger struct { + Code *string `json:"code,omitempty"` + Correlation *Correlation `json:"correlation,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *interface{} `json:"error,omitempty"` + Inputs *interface{} `json:"inputs,omitempty"` + InputsLink *ContentLink `json:"inputsLink,omitempty"` + Name *string `json:"name,omitempty"` + Outputs *interface{} `json:"outputs,omitempty"` + OutputsLink *ContentLink `json:"outputsLink,omitempty"` + ScheduledTime *string `json:"scheduledTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + TrackedProperties *interface{} `json:"trackedProperties,omitempty"` + TrackingId *string `json:"trackingId,omitempty"` +} + +func (o *WorkflowRunTrigger) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunTrigger) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *WorkflowRunTrigger) GetScheduledTimeAsTime() (*time.Time, error) { + if o.ScheduledTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ScheduledTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunTrigger) SetScheduledTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ScheduledTime = &formatted +} + +func (o *WorkflowRunTrigger) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowRunTrigger) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/workflowruns/predicates.go b/resource-manager/web/2024-11-01/workflowruns/predicates.go new file mode 100644 index 00000000000..ad76dae5873 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/predicates.go @@ -0,0 +1,27 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowRunOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p WorkflowRunOperationPredicate) Matches(input WorkflowRun) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/workflowruns/version.go b/resource-manager/web/2024-11-01/workflowruns/version.go new file mode 100644 index 00000000000..f29ffc8090c --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowruns/version.go @@ -0,0 +1,10 @@ +package workflowruns + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/workflowruns/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/workflows/README.md b/resource-manager/web/2024-11-01/workflows/README.md new file mode 100644 index 00000000000..7b3ab92bd3c --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/README.md @@ -0,0 +1,62 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflows` Documentation + +The `workflows` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflows" +``` + + +### Client Initialization + +```go +client := workflows.NewWorkflowsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowsClient.RegenerateAccessKey` + +```go +ctx := context.TODO() +id := workflows.NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + +payload := workflows.RegenerateActionParameter{ + // ... +} + + +read, err := client.RegenerateAccessKey(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowsClient.Validate` + +```go +ctx := context.TODO() +id := workflows.NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + +payload := workflows.Workflow{ + // ... +} + + +read, err := client.Validate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/web/2024-11-01/workflows/client.go b/resource-manager/web/2024-11-01/workflows/client.go new file mode 100644 index 00000000000..46648dbfe97 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/client.go @@ -0,0 +1,26 @@ +package workflows + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowsClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowsClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "workflows", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowsClient: %+v", err) + } + + return &WorkflowsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/workflows/constants.go b/resource-manager/web/2024-11-01/workflows/constants.go new file mode 100644 index 00000000000..856f9a16584 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/constants.go @@ -0,0 +1,402 @@ +package workflows + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyType string + +const ( + KeyTypeNotSpecified KeyType = "NotSpecified" + KeyTypePrimary KeyType = "Primary" + KeyTypeSecondary KeyType = "Secondary" +) + +func PossibleValuesForKeyType() []string { + return []string{ + string(KeyTypeNotSpecified), + string(KeyTypePrimary), + string(KeyTypeSecondary), + } +} + +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyType(input string) (*KeyType, error) { + vals := map[string]KeyType{ + "notspecified": KeyTypeNotSpecified, + "primary": KeyTypePrimary, + "secondary": KeyTypeSecondary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyType(input) + return &out, nil +} + +type Kind string + +const ( + KindStateful Kind = "Stateful" + KindStateless Kind = "Stateless" +) + +func PossibleValuesForKind() []string { + return []string{ + string(KindStateful), + string(KindStateless), + } +} + +func (s *Kind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKind(input string) (*Kind, error) { + vals := map[string]Kind{ + "stateful": KindStateful, + "stateless": KindStateless, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Kind(input) + return &out, nil +} + +type OpenAuthenticationProviderType string + +const ( + OpenAuthenticationProviderTypeAAD OpenAuthenticationProviderType = "AAD" +) + +func PossibleValuesForOpenAuthenticationProviderType() []string { + return []string{ + string(OpenAuthenticationProviderTypeAAD), + } +} + +func (s *OpenAuthenticationProviderType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOpenAuthenticationProviderType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOpenAuthenticationProviderType(input string) (*OpenAuthenticationProviderType, error) { + vals := map[string]OpenAuthenticationProviderType{ + "aad": OpenAuthenticationProviderTypeAAD, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OpenAuthenticationProviderType(input) + return &out, nil +} + +type ParameterType string + +const ( + ParameterTypeArray ParameterType = "Array" + ParameterTypeBool ParameterType = "Bool" + ParameterTypeFloat ParameterType = "Float" + ParameterTypeInt ParameterType = "Int" + ParameterTypeNotSpecified ParameterType = "NotSpecified" + ParameterTypeObject ParameterType = "Object" + ParameterTypeSecureObject ParameterType = "SecureObject" + ParameterTypeSecureString ParameterType = "SecureString" + ParameterTypeString ParameterType = "String" +) + +func PossibleValuesForParameterType() []string { + return []string{ + string(ParameterTypeArray), + string(ParameterTypeBool), + string(ParameterTypeFloat), + string(ParameterTypeInt), + string(ParameterTypeNotSpecified), + string(ParameterTypeObject), + string(ParameterTypeSecureObject), + string(ParameterTypeSecureString), + string(ParameterTypeString), + } +} + +func (s *ParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseParameterType(input string) (*ParameterType, error) { + vals := map[string]ParameterType{ + "array": ParameterTypeArray, + "bool": ParameterTypeBool, + "float": ParameterTypeFloat, + "int": ParameterTypeInt, + "notspecified": ParameterTypeNotSpecified, + "object": ParameterTypeObject, + "secureobject": ParameterTypeSecureObject, + "securestring": ParameterTypeSecureString, + "string": ParameterTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ParameterType(input) + return &out, nil +} + +type WorkflowProvisioningState string + +const ( + WorkflowProvisioningStateAccepted WorkflowProvisioningState = "Accepted" + WorkflowProvisioningStateCanceled WorkflowProvisioningState = "Canceled" + WorkflowProvisioningStateCompleted WorkflowProvisioningState = "Completed" + WorkflowProvisioningStateCreated WorkflowProvisioningState = "Created" + WorkflowProvisioningStateCreating WorkflowProvisioningState = "Creating" + WorkflowProvisioningStateDeleted WorkflowProvisioningState = "Deleted" + WorkflowProvisioningStateDeleting WorkflowProvisioningState = "Deleting" + WorkflowProvisioningStateFailed WorkflowProvisioningState = "Failed" + WorkflowProvisioningStateInProgress WorkflowProvisioningState = "InProgress" + WorkflowProvisioningStateMoving WorkflowProvisioningState = "Moving" + WorkflowProvisioningStateNotSpecified WorkflowProvisioningState = "NotSpecified" + WorkflowProvisioningStatePending WorkflowProvisioningState = "Pending" + WorkflowProvisioningStateReady WorkflowProvisioningState = "Ready" + WorkflowProvisioningStateRegistered WorkflowProvisioningState = "Registered" + WorkflowProvisioningStateRegistering WorkflowProvisioningState = "Registering" + WorkflowProvisioningStateRenewing WorkflowProvisioningState = "Renewing" + WorkflowProvisioningStateRunning WorkflowProvisioningState = "Running" + WorkflowProvisioningStateSucceeded WorkflowProvisioningState = "Succeeded" + WorkflowProvisioningStateUnregistered WorkflowProvisioningState = "Unregistered" + WorkflowProvisioningStateUnregistering WorkflowProvisioningState = "Unregistering" + WorkflowProvisioningStateUpdating WorkflowProvisioningState = "Updating" + WorkflowProvisioningStateWaiting WorkflowProvisioningState = "Waiting" +) + +func PossibleValuesForWorkflowProvisioningState() []string { + return []string{ + string(WorkflowProvisioningStateAccepted), + string(WorkflowProvisioningStateCanceled), + string(WorkflowProvisioningStateCompleted), + string(WorkflowProvisioningStateCreated), + string(WorkflowProvisioningStateCreating), + string(WorkflowProvisioningStateDeleted), + string(WorkflowProvisioningStateDeleting), + string(WorkflowProvisioningStateFailed), + string(WorkflowProvisioningStateInProgress), + string(WorkflowProvisioningStateMoving), + string(WorkflowProvisioningStateNotSpecified), + string(WorkflowProvisioningStatePending), + string(WorkflowProvisioningStateReady), + string(WorkflowProvisioningStateRegistered), + string(WorkflowProvisioningStateRegistering), + string(WorkflowProvisioningStateRenewing), + string(WorkflowProvisioningStateRunning), + string(WorkflowProvisioningStateSucceeded), + string(WorkflowProvisioningStateUnregistered), + string(WorkflowProvisioningStateUnregistering), + string(WorkflowProvisioningStateUpdating), + string(WorkflowProvisioningStateWaiting), + } +} + +func (s *WorkflowProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowProvisioningState(input string) (*WorkflowProvisioningState, error) { + vals := map[string]WorkflowProvisioningState{ + "accepted": WorkflowProvisioningStateAccepted, + "canceled": WorkflowProvisioningStateCanceled, + "completed": WorkflowProvisioningStateCompleted, + "created": WorkflowProvisioningStateCreated, + "creating": WorkflowProvisioningStateCreating, + "deleted": WorkflowProvisioningStateDeleted, + "deleting": WorkflowProvisioningStateDeleting, + "failed": WorkflowProvisioningStateFailed, + "inprogress": WorkflowProvisioningStateInProgress, + "moving": WorkflowProvisioningStateMoving, + "notspecified": WorkflowProvisioningStateNotSpecified, + "pending": WorkflowProvisioningStatePending, + "ready": WorkflowProvisioningStateReady, + "registered": WorkflowProvisioningStateRegistered, + "registering": WorkflowProvisioningStateRegistering, + "renewing": WorkflowProvisioningStateRenewing, + "running": WorkflowProvisioningStateRunning, + "succeeded": WorkflowProvisioningStateSucceeded, + "unregistered": WorkflowProvisioningStateUnregistered, + "unregistering": WorkflowProvisioningStateUnregistering, + "updating": WorkflowProvisioningStateUpdating, + "waiting": WorkflowProvisioningStateWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowProvisioningState(input) + return &out, nil +} + +type WorkflowSkuName string + +const ( + WorkflowSkuNameBasic WorkflowSkuName = "Basic" + WorkflowSkuNameFree WorkflowSkuName = "Free" + WorkflowSkuNameNotSpecified WorkflowSkuName = "NotSpecified" + WorkflowSkuNamePremium WorkflowSkuName = "Premium" + WorkflowSkuNameShared WorkflowSkuName = "Shared" + WorkflowSkuNameStandard WorkflowSkuName = "Standard" +) + +func PossibleValuesForWorkflowSkuName() []string { + return []string{ + string(WorkflowSkuNameBasic), + string(WorkflowSkuNameFree), + string(WorkflowSkuNameNotSpecified), + string(WorkflowSkuNamePremium), + string(WorkflowSkuNameShared), + string(WorkflowSkuNameStandard), + } +} + +func (s *WorkflowSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowSkuName(input string) (*WorkflowSkuName, error) { + vals := map[string]WorkflowSkuName{ + "basic": WorkflowSkuNameBasic, + "free": WorkflowSkuNameFree, + "notspecified": WorkflowSkuNameNotSpecified, + "premium": WorkflowSkuNamePremium, + "shared": WorkflowSkuNameShared, + "standard": WorkflowSkuNameStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowSkuName(input) + return &out, nil +} + +type WorkflowState string + +const ( + WorkflowStateCompleted WorkflowState = "Completed" + WorkflowStateDeleted WorkflowState = "Deleted" + WorkflowStateDisabled WorkflowState = "Disabled" + WorkflowStateEnabled WorkflowState = "Enabled" + WorkflowStateNotSpecified WorkflowState = "NotSpecified" + WorkflowStateSuspended WorkflowState = "Suspended" +) + +func PossibleValuesForWorkflowState() []string { + return []string{ + string(WorkflowStateCompleted), + string(WorkflowStateDeleted), + string(WorkflowStateDisabled), + string(WorkflowStateEnabled), + string(WorkflowStateNotSpecified), + string(WorkflowStateSuspended), + } +} + +func (s *WorkflowState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowState(input string) (*WorkflowState, error) { + vals := map[string]WorkflowState{ + "completed": WorkflowStateCompleted, + "deleted": WorkflowStateDeleted, + "disabled": WorkflowStateDisabled, + "enabled": WorkflowStateEnabled, + "notspecified": WorkflowStateNotSpecified, + "suspended": WorkflowStateSuspended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowState(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/workflows/id_managementworkflow.go b/resource-manager/web/2024-11-01/workflows/id_managementworkflow.go new file mode 100644 index 00000000000..47ad1eb715b --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/id_managementworkflow.go @@ -0,0 +1,145 @@ +package workflows + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagementWorkflowId{}) +} + +var _ resourceids.ResourceId = &ManagementWorkflowId{} + +// ManagementWorkflowId is a struct representing the Resource ID for a Management Workflow +type ManagementWorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string +} + +// NewManagementWorkflowID returns a new ManagementWorkflowId struct +func NewManagementWorkflowID(subscriptionId string, resourceGroupName string, siteName string, workflowName string) ManagementWorkflowId { + return ManagementWorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + } +} + +// ParseManagementWorkflowID parses 'input' into a ManagementWorkflowId +func ParseManagementWorkflowID(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagementWorkflowIDInsensitively parses 'input' case-insensitively into a ManagementWorkflowId +// note: this method should only be used for API response data and not user input +func ParseManagementWorkflowIDInsensitively(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagementWorkflowId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateManagementWorkflowID checks that 'input' can be parsed as a Management Workflow ID +func ValidateManagementWorkflowID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseManagementWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Management Workflow ID +func (id ManagementWorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Management Workflow ID +func (id ManagementWorkflowId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + } +} + +// String returns a human-readable description of this Management Workflow ID +func (id ManagementWorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Management Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/workflows/id_managementworkflow_test.go b/resource-manager/web/2024-11-01/workflows/id_managementworkflow_test.go new file mode 100644 index 00000000000..8499136fb32 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/id_managementworkflow_test.go @@ -0,0 +1,417 @@ +package workflows + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ManagementWorkflowId{} + +func TestNewManagementWorkflowID(t *testing.T) { + id := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } +} + +func TestFormatManagementWorkflowID(t *testing.T) { + actual := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagementWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseManagementWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForManagementWorkflowId(t *testing.T) { + segments := ManagementWorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagementWorkflowId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/workflows/method_regenerateaccesskey.go b/resource-manager/web/2024-11-01/workflows/method_regenerateaccesskey.go new file mode 100644 index 00000000000..6d15da4bbd2 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/method_regenerateaccesskey.go @@ -0,0 +1,51 @@ +package workflows + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegenerateAccessKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RegenerateAccessKey ... +func (c WorkflowsClient) RegenerateAccessKey(ctx context.Context, id ManagementWorkflowId, input RegenerateActionParameter) (result RegenerateAccessKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateAccessKey", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/workflows/method_validate.go b/resource-manager/web/2024-11-01/workflows/method_validate.go new file mode 100644 index 00000000000..14ed7cd27b9 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/method_validate.go @@ -0,0 +1,51 @@ +package workflows + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ValidateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Validate ... +func (c WorkflowsClient) Validate(ctx context.Context, id ManagementWorkflowId, input Workflow) (result ValidateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/validate", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/workflows/model_flowaccesscontrolconfiguration.go b/resource-manager/web/2024-11-01/workflows/model_flowaccesscontrolconfiguration.go new file mode 100644 index 00000000000..e110c491fc2 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/model_flowaccesscontrolconfiguration.go @@ -0,0 +1,11 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowAccessControlConfiguration struct { + Actions *FlowAccessControlConfigurationPolicy `json:"actions,omitempty"` + Contents *FlowAccessControlConfigurationPolicy `json:"contents,omitempty"` + Triggers *FlowAccessControlConfigurationPolicy `json:"triggers,omitempty"` + WorkflowManagement *FlowAccessControlConfigurationPolicy `json:"workflowManagement,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflows/model_flowaccesscontrolconfigurationpolicy.go b/resource-manager/web/2024-11-01/workflows/model_flowaccesscontrolconfigurationpolicy.go new file mode 100644 index 00000000000..e14581b5ddc --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/model_flowaccesscontrolconfigurationpolicy.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowAccessControlConfigurationPolicy struct { + AllowedCallerIPAddresses *[]IPAddressRange `json:"allowedCallerIpAddresses,omitempty"` + OpenAuthenticationPolicies *OpenAuthenticationAccessPolicies `json:"openAuthenticationPolicies,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflows/model_flowendpoints.go b/resource-manager/web/2024-11-01/workflows/model_flowendpoints.go new file mode 100644 index 00000000000..ab677222e7a --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/model_flowendpoints.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowEndpoints struct { + AccessEndpointIPAddresses *[]IPAddress `json:"accessEndpointIpAddresses,omitempty"` + OutgoingIPAddresses *[]IPAddress `json:"outgoingIpAddresses,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflows/model_flowendpointsconfiguration.go b/resource-manager/web/2024-11-01/workflows/model_flowendpointsconfiguration.go new file mode 100644 index 00000000000..19393db48ab --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/model_flowendpointsconfiguration.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowEndpointsConfiguration struct { + Connector *FlowEndpoints `json:"connector,omitempty"` + Workflow *FlowEndpoints `json:"workflow,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflows/model_ipaddress.go b/resource-manager/web/2024-11-01/workflows/model_ipaddress.go new file mode 100644 index 00000000000..0d10e34c4f8 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/model_ipaddress.go @@ -0,0 +1,8 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAddress struct { + Address *string `json:"address,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflows/model_ipaddressrange.go b/resource-manager/web/2024-11-01/workflows/model_ipaddressrange.go new file mode 100644 index 00000000000..347495131a8 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/model_ipaddressrange.go @@ -0,0 +1,8 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAddressRange struct { + AddressRange *string `json:"addressRange,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflows/model_openauthenticationaccesspolicies.go b/resource-manager/web/2024-11-01/workflows/model_openauthenticationaccesspolicies.go new file mode 100644 index 00000000000..a4b8fac5970 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/model_openauthenticationaccesspolicies.go @@ -0,0 +1,8 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationAccessPolicies struct { + Policies *map[string]OpenAuthenticationAccessPolicy `json:"policies,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflows/model_openauthenticationaccesspolicy.go b/resource-manager/web/2024-11-01/workflows/model_openauthenticationaccesspolicy.go new file mode 100644 index 00000000000..cf129596719 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/model_openauthenticationaccesspolicy.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationAccessPolicy struct { + Claims *[]OpenAuthenticationPolicyClaim `json:"claims,omitempty"` + Type *OpenAuthenticationProviderType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflows/model_openauthenticationpolicyclaim.go b/resource-manager/web/2024-11-01/workflows/model_openauthenticationpolicyclaim.go new file mode 100644 index 00000000000..3ab50a9ca9b --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/model_openauthenticationpolicyclaim.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationPolicyClaim struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflows/model_regenerateactionparameter.go b/resource-manager/web/2024-11-01/workflows/model_regenerateactionparameter.go new file mode 100644 index 00000000000..a01c112c1c1 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/model_regenerateactionparameter.go @@ -0,0 +1,8 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegenerateActionParameter struct { + KeyType *KeyType `json:"keyType,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflows/model_resourcereference.go b/resource-manager/web/2024-11-01/workflows/model_resourcereference.go new file mode 100644 index 00000000000..8541ecad863 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/model_resourcereference.go @@ -0,0 +1,10 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflows/model_workflow.go b/resource-manager/web/2024-11-01/workflows/model_workflow.go new file mode 100644 index 00000000000..7b9bb73f9b5 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/model_workflow.go @@ -0,0 +1,18 @@ +package workflows + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Workflow struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflows/model_workflowparameter.go b/resource-manager/web/2024-11-01/workflows/model_workflowparameter.go new file mode 100644 index 00000000000..c79cf198562 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/model_workflowparameter.go @@ -0,0 +1,11 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowParameter struct { + Description *string `json:"description,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Type *ParameterType `json:"type,omitempty"` + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflows/model_workflowproperties.go b/resource-manager/web/2024-11-01/workflows/model_workflowproperties.go new file mode 100644 index 00000000000..0dd6da80483 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/model_workflowproperties.go @@ -0,0 +1,51 @@ +package workflows + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowProperties struct { + AccessControl *FlowAccessControlConfiguration `json:"accessControl,omitempty"` + AccessEndpoint *string `json:"accessEndpoint,omitempty"` + ChangedTime *string `json:"changedTime,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + Definition *interface{} `json:"definition,omitempty"` + EndpointsConfiguration *FlowEndpointsConfiguration `json:"endpointsConfiguration,omitempty"` + IntegrationAccount *ResourceReference `json:"integrationAccount,omitempty"` + IntegrationServiceEnvironment *ResourceReference `json:"integrationServiceEnvironment,omitempty"` + Kind *Kind `json:"kind,omitempty"` + Parameters *map[string]WorkflowParameter `json:"parameters,omitempty"` + ProvisioningState *WorkflowProvisioningState `json:"provisioningState,omitempty"` + Sku *WorkflowSku `json:"sku,omitempty"` + State *WorkflowState `json:"state,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *WorkflowProperties) GetChangedTimeAsTime() (*time.Time, error) { + if o.ChangedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ChangedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowProperties) SetChangedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ChangedTime = &formatted +} + +func (o *WorkflowProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/workflows/model_workflowsku.go b/resource-manager/web/2024-11-01/workflows/model_workflowsku.go new file mode 100644 index 00000000000..64591de779f --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/model_workflowsku.go @@ -0,0 +1,9 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowSku struct { + Name WorkflowSkuName `json:"name"` + Plan *ResourceReference `json:"plan,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflows/version.go b/resource-manager/web/2024-11-01/workflows/version.go new file mode 100644 index 00000000000..277b947751b --- /dev/null +++ b/resource-manager/web/2024-11-01/workflows/version.go @@ -0,0 +1,10 @@ +package workflows + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/workflows/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/README.md b/resource-manager/web/2024-11-01/workflowtriggerhistories/README.md new file mode 100644 index 00000000000..6877ac8d935 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/README.md @@ -0,0 +1,65 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflowtriggerhistories` Documentation + +The `workflowtriggerhistories` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflowtriggerhistories" +``` + + +### Client Initialization + +```go +client := workflowtriggerhistories.NewWorkflowTriggerHistoriesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowTriggerHistoriesClient.Get` + +```go +ctx := context.TODO() +id := workflowtriggerhistories.NewTriggerHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName", "historyName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowTriggerHistoriesClient.List` + +```go +ctx := context.TODO() +id := workflowtriggerhistories.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName") + +// alternatively `client.List(ctx, id, workflowtriggerhistories.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, workflowtriggerhistories.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowTriggerHistoriesClient.Resubmit` + +```go +ctx := context.TODO() +id := workflowtriggerhistories.NewTriggerHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName", "historyName") + +if err := client.ResubmitThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/client.go b/resource-manager/web/2024-11-01/workflowtriggerhistories/client.go new file mode 100644 index 00000000000..e1a3815134e --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/client.go @@ -0,0 +1,26 @@ +package workflowtriggerhistories + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerHistoriesClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowTriggerHistoriesClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowTriggerHistoriesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "workflowtriggerhistories", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowTriggerHistoriesClient: %+v", err) + } + + return &WorkflowTriggerHistoriesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/constants.go b/resource-manager/web/2024-11-01/workflowtriggerhistories/constants.go new file mode 100644 index 00000000000..9ccf7819b12 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/constants.go @@ -0,0 +1,84 @@ +package workflowtriggerhistories + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowStatus string + +const ( + WorkflowStatusAborted WorkflowStatus = "Aborted" + WorkflowStatusCancelled WorkflowStatus = "Cancelled" + WorkflowStatusFailed WorkflowStatus = "Failed" + WorkflowStatusFaulted WorkflowStatus = "Faulted" + WorkflowStatusIgnored WorkflowStatus = "Ignored" + WorkflowStatusNotSpecified WorkflowStatus = "NotSpecified" + WorkflowStatusPaused WorkflowStatus = "Paused" + WorkflowStatusRunning WorkflowStatus = "Running" + WorkflowStatusSkipped WorkflowStatus = "Skipped" + WorkflowStatusSucceeded WorkflowStatus = "Succeeded" + WorkflowStatusSuspended WorkflowStatus = "Suspended" + WorkflowStatusTimedOut WorkflowStatus = "TimedOut" + WorkflowStatusWaiting WorkflowStatus = "Waiting" +) + +func PossibleValuesForWorkflowStatus() []string { + return []string{ + string(WorkflowStatusAborted), + string(WorkflowStatusCancelled), + string(WorkflowStatusFailed), + string(WorkflowStatusFaulted), + string(WorkflowStatusIgnored), + string(WorkflowStatusNotSpecified), + string(WorkflowStatusPaused), + string(WorkflowStatusRunning), + string(WorkflowStatusSkipped), + string(WorkflowStatusSucceeded), + string(WorkflowStatusSuspended), + string(WorkflowStatusTimedOut), + string(WorkflowStatusWaiting), + } +} + +func (s *WorkflowStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowStatus(input string) (*WorkflowStatus, error) { + vals := map[string]WorkflowStatus{ + "aborted": WorkflowStatusAborted, + "cancelled": WorkflowStatusCancelled, + "failed": WorkflowStatusFailed, + "faulted": WorkflowStatusFaulted, + "ignored": WorkflowStatusIgnored, + "notspecified": WorkflowStatusNotSpecified, + "paused": WorkflowStatusPaused, + "running": WorkflowStatusRunning, + "skipped": WorkflowStatusSkipped, + "succeeded": WorkflowStatusSucceeded, + "suspended": WorkflowStatusSuspended, + "timedout": WorkflowStatusTimedOut, + "waiting": WorkflowStatusWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowStatus(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/id_trigger.go b/resource-manager/web/2024-11-01/workflowtriggerhistories/id_trigger.go new file mode 100644 index 00000000000..185a7964307 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/id_trigger.go @@ -0,0 +1,154 @@ +package workflowtriggerhistories + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&TriggerId{}) +} + +var _ resourceids.ResourceId = &TriggerId{} + +// TriggerId is a struct representing the Resource ID for a Trigger +type TriggerId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + TriggerName string +} + +// NewTriggerID returns a new TriggerId struct +func NewTriggerID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, triggerName string) TriggerId { + return TriggerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + TriggerName: triggerName, + } +} + +// ParseTriggerID parses 'input' into a TriggerId +func ParseTriggerID(input string) (*TriggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTriggerIDInsensitively parses 'input' case-insensitively into a TriggerId +// note: this method should only be used for API response data and not user input +func ParseTriggerIDInsensitively(input string) (*TriggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TriggerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.TriggerName, ok = input.Parsed["triggerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggerName", input) + } + + return nil +} + +// ValidateTriggerID checks that 'input' can be parsed as a Trigger ID +func ValidateTriggerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseTriggerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Trigger ID +func (id TriggerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/triggers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.TriggerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Trigger ID +func (id TriggerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticTriggers", "triggers", "triggers"), + resourceids.UserSpecifiedSegment("triggerName", "triggerName"), + } +} + +// String returns a human-readable description of this Trigger ID +func (id TriggerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Trigger Name: %q", id.TriggerName), + } + return fmt.Sprintf("Trigger (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/id_trigger_test.go b/resource-manager/web/2024-11-01/workflowtriggerhistories/id_trigger_test.go new file mode 100644 index 00000000000..a7e902f354d --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/id_trigger_test.go @@ -0,0 +1,462 @@ +package workflowtriggerhistories + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &TriggerId{} + +func TestNewTriggerID(t *testing.T) { + id := NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.TriggerName != "triggerName" { + t.Fatalf("Expected %q but got %q for Segment 'TriggerName'", id.TriggerName, "triggerName") + } +} + +func TestFormatTriggerID(t *testing.T) { + actual := NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTriggerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + TriggerName: "triggerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + } +} + +func TestParseTriggerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + TriggerName: "triggerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS/tRiGgErNaMe", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + TriggerName: "tRiGgErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS/tRiGgErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + } +} + +func TestSegmentsForTriggerId(t *testing.T) { + segments := TriggerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TriggerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/id_triggerhistory.go b/resource-manager/web/2024-11-01/workflowtriggerhistories/id_triggerhistory.go new file mode 100644 index 00000000000..248b48c2216 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/id_triggerhistory.go @@ -0,0 +1,163 @@ +package workflowtriggerhistories + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&TriggerHistoryId{}) +} + +var _ resourceids.ResourceId = &TriggerHistoryId{} + +// TriggerHistoryId is a struct representing the Resource ID for a Trigger History +type TriggerHistoryId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + TriggerName string + HistoryName string +} + +// NewTriggerHistoryID returns a new TriggerHistoryId struct +func NewTriggerHistoryID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, triggerName string, historyName string) TriggerHistoryId { + return TriggerHistoryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + TriggerName: triggerName, + HistoryName: historyName, + } +} + +// ParseTriggerHistoryID parses 'input' into a TriggerHistoryId +func ParseTriggerHistoryID(input string) (*TriggerHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerHistoryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerHistoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTriggerHistoryIDInsensitively parses 'input' case-insensitively into a TriggerHistoryId +// note: this method should only be used for API response data and not user input +func ParseTriggerHistoryIDInsensitively(input string) (*TriggerHistoryId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerHistoryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerHistoryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TriggerHistoryId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.TriggerName, ok = input.Parsed["triggerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggerName", input) + } + + if id.HistoryName, ok = input.Parsed["historyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "historyName", input) + } + + return nil +} + +// ValidateTriggerHistoryID checks that 'input' can be parsed as a Trigger History ID +func ValidateTriggerHistoryID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseTriggerHistoryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Trigger History ID +func (id TriggerHistoryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/triggers/%s/histories/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.TriggerName, id.HistoryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Trigger History ID +func (id TriggerHistoryId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticTriggers", "triggers", "triggers"), + resourceids.UserSpecifiedSegment("triggerName", "triggerName"), + resourceids.StaticSegment("staticHistories", "histories", "histories"), + resourceids.UserSpecifiedSegment("historyName", "historyName"), + } +} + +// String returns a human-readable description of this Trigger History ID +func (id TriggerHistoryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Trigger Name: %q", id.TriggerName), + fmt.Sprintf("History Name: %q", id.HistoryName), + } + return fmt.Sprintf("Trigger History (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/id_triggerhistory_test.go b/resource-manager/web/2024-11-01/workflowtriggerhistories/id_triggerhistory_test.go new file mode 100644 index 00000000000..9acaaf52faa --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/id_triggerhistory_test.go @@ -0,0 +1,507 @@ +package workflowtriggerhistories + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &TriggerHistoryId{} + +func TestNewTriggerHistoryID(t *testing.T) { + id := NewTriggerHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName", "historyName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.TriggerName != "triggerName" { + t.Fatalf("Expected %q but got %q for Segment 'TriggerName'", id.TriggerName, "triggerName") + } + + if id.HistoryName != "historyName" { + t.Fatalf("Expected %q but got %q for Segment 'HistoryName'", id.HistoryName, "historyName") + } +} + +func TestFormatTriggerHistoryID(t *testing.T) { + actual := NewTriggerHistoryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName", "historyName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/histories/historyName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTriggerHistoryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerHistoryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/histories", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/histories/historyName", + Expected: &TriggerHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + TriggerName: "triggerName", + HistoryName: "historyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/histories/historyName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerHistoryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestParseTriggerHistoryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerHistoryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS/tRiGgErNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/histories", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS/tRiGgErNaMe/hIsToRiEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/histories/historyName", + Expected: &TriggerHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + TriggerName: "triggerName", + HistoryName: "historyName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/histories/historyName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS/tRiGgErNaMe/hIsToRiEs/hIsToRyNaMe", + Expected: &TriggerHistoryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + TriggerName: "tRiGgErNaMe", + HistoryName: "hIsToRyNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS/tRiGgErNaMe/hIsToRiEs/hIsToRyNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerHistoryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + if actual.HistoryName != v.Expected.HistoryName { + t.Fatalf("Expected %q but got %q for HistoryName", v.Expected.HistoryName, actual.HistoryName) + } + + } +} + +func TestSegmentsForTriggerHistoryId(t *testing.T) { + segments := TriggerHistoryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TriggerHistoryId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/method_get.go b/resource-manager/web/2024-11-01/workflowtriggerhistories/method_get.go new file mode 100644 index 00000000000..25ba7f1b42f --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/method_get.go @@ -0,0 +1,53 @@ +package workflowtriggerhistories + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowTriggerHistory +} + +// Get ... +func (c WorkflowTriggerHistoriesClient) Get(ctx context.Context, id TriggerHistoryId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowTriggerHistory + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/method_list.go b/resource-manager/web/2024-11-01/workflowtriggerhistories/method_list.go new file mode 100644 index 00000000000..fa03f7faa25 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/method_list.go @@ -0,0 +1,138 @@ +package workflowtriggerhistories + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowTriggerHistory +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowTriggerHistory +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c WorkflowTriggerHistoriesClient) List(ctx context.Context, id TriggerId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/histories", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowTriggerHistory `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c WorkflowTriggerHistoriesClient) ListComplete(ctx context.Context, id TriggerId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowTriggerHistoryOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowTriggerHistoriesClient) ListCompleteMatchingPredicate(ctx context.Context, id TriggerId, options ListOperationOptions, predicate WorkflowTriggerHistoryOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowTriggerHistory, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/method_resubmit.go b/resource-manager/web/2024-11-01/workflowtriggerhistories/method_resubmit.go new file mode 100644 index 00000000000..3608c02e4dc --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/method_resubmit.go @@ -0,0 +1,69 @@ +package workflowtriggerhistories + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResubmitOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Resubmit ... +func (c WorkflowTriggerHistoriesClient) Resubmit(ctx context.Context, id TriggerHistoryId) (result ResubmitOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resubmit", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResubmitThenPoll performs Resubmit then polls until it's completed +func (c WorkflowTriggerHistoriesClient) ResubmitThenPoll(ctx context.Context, id TriggerHistoryId) error { + result, err := c.Resubmit(ctx, id) + if err != nil { + return fmt.Errorf("performing Resubmit: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Resubmit: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/model_contenthash.go b/resource-manager/web/2024-11-01/workflowtriggerhistories/model_contenthash.go new file mode 100644 index 00000000000..685fd29e9f7 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/model_contenthash.go @@ -0,0 +1,9 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentHash struct { + Algorithm *string `json:"algorithm,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/model_contentlink.go b/resource-manager/web/2024-11-01/workflowtriggerhistories/model_contentlink.go new file mode 100644 index 00000000000..73c25f49ab8 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/model_contentlink.go @@ -0,0 +1,12 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentLink struct { + ContentHash *ContentHash `json:"contentHash,omitempty"` + ContentSize *int64 `json:"contentSize,omitempty"` + ContentVersion *string `json:"contentVersion,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Uri *string `json:"uri,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/model_correlation.go b/resource-manager/web/2024-11-01/workflowtriggerhistories/model_correlation.go new file mode 100644 index 00000000000..e052b2efb68 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/model_correlation.go @@ -0,0 +1,8 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Correlation struct { + ClientTrackingId *string `json:"clientTrackingId,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/model_resourcereference.go b/resource-manager/web/2024-11-01/workflowtriggerhistories/model_resourcereference.go new file mode 100644 index 00000000000..ac6b3afa7c3 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/model_resourcereference.go @@ -0,0 +1,10 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/model_workflowtriggerhistory.go b/resource-manager/web/2024-11-01/workflowtriggerhistories/model_workflowtriggerhistory.go new file mode 100644 index 00000000000..a1d64aebe3c --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/model_workflowtriggerhistory.go @@ -0,0 +1,11 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerHistory struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowTriggerHistoryProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/model_workflowtriggerhistoryproperties.go b/resource-manager/web/2024-11-01/workflowtriggerhistories/model_workflowtriggerhistoryproperties.go new file mode 100644 index 00000000000..42821930e6a --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/model_workflowtriggerhistoryproperties.go @@ -0,0 +1,61 @@ +package workflowtriggerhistories + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerHistoryProperties struct { + Code *string `json:"code,omitempty"` + Correlation *Correlation `json:"correlation,omitempty"` + EndTime *string `json:"endTime,omitempty"` + Error *interface{} `json:"error,omitempty"` + Fired *bool `json:"fired,omitempty"` + InputsLink *ContentLink `json:"inputsLink,omitempty"` + OutputsLink *ContentLink `json:"outputsLink,omitempty"` + Run *ResourceReference `json:"run,omitempty"` + ScheduledTime *string `json:"scheduledTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + TrackingId *string `json:"trackingId,omitempty"` +} + +func (o *WorkflowTriggerHistoryProperties) GetEndTimeAsTime() (*time.Time, error) { + if o.EndTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerHistoryProperties) SetEndTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.EndTime = &formatted +} + +func (o *WorkflowTriggerHistoryProperties) GetScheduledTimeAsTime() (*time.Time, error) { + if o.ScheduledTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ScheduledTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerHistoryProperties) SetScheduledTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ScheduledTime = &formatted +} + +func (o *WorkflowTriggerHistoryProperties) GetStartTimeAsTime() (*time.Time, error) { + if o.StartTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerHistoryProperties) SetStartTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/predicates.go b/resource-manager/web/2024-11-01/workflowtriggerhistories/predicates.go new file mode 100644 index 00000000000..20fca9c869f --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/predicates.go @@ -0,0 +1,27 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerHistoryOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p WorkflowTriggerHistoryOperationPredicate) Matches(input WorkflowTriggerHistory) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/workflowtriggerhistories/version.go b/resource-manager/web/2024-11-01/workflowtriggerhistories/version.go new file mode 100644 index 00000000000..ac120fd5db9 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggerhistories/version.go @@ -0,0 +1,10 @@ +package workflowtriggerhistories + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/workflowtriggerhistories/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/README.md b/resource-manager/web/2024-11-01/workflowtriggers/README.md new file mode 100644 index 00000000000..59db22d02f9 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/README.md @@ -0,0 +1,97 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflowtriggers` Documentation + +The `workflowtriggers` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflowtriggers" +``` + + +### Client Initialization + +```go +client := workflowtriggers.NewWorkflowTriggersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowTriggersClient.Get` + +```go +ctx := context.TODO() +id := workflowtriggers.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowTriggersClient.GetSchemaJson` + +```go +ctx := context.TODO() +id := workflowtriggers.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName") + +read, err := client.GetSchemaJson(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowTriggersClient.List` + +```go +ctx := context.TODO() +id := workflowtriggers.NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + +// alternatively `client.List(ctx, id, workflowtriggers.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, workflowtriggers.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkflowTriggersClient.ListCallbackURL` + +```go +ctx := context.TODO() +id := workflowtriggers.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName") + +read, err := client.ListCallbackURL(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowTriggersClient.Run` + +```go +ctx := context.TODO() +id := workflowtriggers.NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName") + +if err := client.RunThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/web/2024-11-01/workflowtriggers/client.go b/resource-manager/web/2024-11-01/workflowtriggers/client.go new file mode 100644 index 00000000000..06e7b704ecf --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/client.go @@ -0,0 +1,26 @@ +package workflowtriggers + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggersClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowTriggersClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowTriggersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "workflowtriggers", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowTriggersClient: %+v", err) + } + + return &WorkflowTriggersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/constants.go b/resource-manager/web/2024-11-01/workflowtriggers/constants.go new file mode 100644 index 00000000000..344f92609e4 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/constants.go @@ -0,0 +1,397 @@ +package workflowtriggers + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DayOfWeek string + +const ( + DayOfWeekFriday DayOfWeek = "Friday" + DayOfWeekMonday DayOfWeek = "Monday" + DayOfWeekSaturday DayOfWeek = "Saturday" + DayOfWeekSunday DayOfWeek = "Sunday" + DayOfWeekThursday DayOfWeek = "Thursday" + DayOfWeekTuesday DayOfWeek = "Tuesday" + DayOfWeekWednesday DayOfWeek = "Wednesday" +) + +func PossibleValuesForDayOfWeek() []string { + return []string{ + string(DayOfWeekFriday), + string(DayOfWeekMonday), + string(DayOfWeekSaturday), + string(DayOfWeekSunday), + string(DayOfWeekThursday), + string(DayOfWeekTuesday), + string(DayOfWeekWednesday), + } +} + +func (s *DayOfWeek) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDayOfWeek(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDayOfWeek(input string) (*DayOfWeek, error) { + vals := map[string]DayOfWeek{ + "friday": DayOfWeekFriday, + "monday": DayOfWeekMonday, + "saturday": DayOfWeekSaturday, + "sunday": DayOfWeekSunday, + "thursday": DayOfWeekThursday, + "tuesday": DayOfWeekTuesday, + "wednesday": DayOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DayOfWeek(input) + return &out, nil +} + +type DaysOfWeek string + +const ( + DaysOfWeekFriday DaysOfWeek = "Friday" + DaysOfWeekMonday DaysOfWeek = "Monday" + DaysOfWeekSaturday DaysOfWeek = "Saturday" + DaysOfWeekSunday DaysOfWeek = "Sunday" + DaysOfWeekThursday DaysOfWeek = "Thursday" + DaysOfWeekTuesday DaysOfWeek = "Tuesday" + DaysOfWeekWednesday DaysOfWeek = "Wednesday" +) + +func PossibleValuesForDaysOfWeek() []string { + return []string{ + string(DaysOfWeekFriday), + string(DaysOfWeekMonday), + string(DaysOfWeekSaturday), + string(DaysOfWeekSunday), + string(DaysOfWeekThursday), + string(DaysOfWeekTuesday), + string(DaysOfWeekWednesday), + } +} + +func (s *DaysOfWeek) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDaysOfWeek(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDaysOfWeek(input string) (*DaysOfWeek, error) { + vals := map[string]DaysOfWeek{ + "friday": DaysOfWeekFriday, + "monday": DaysOfWeekMonday, + "saturday": DaysOfWeekSaturday, + "sunday": DaysOfWeekSunday, + "thursday": DaysOfWeekThursday, + "tuesday": DaysOfWeekTuesday, + "wednesday": DaysOfWeekWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DaysOfWeek(input) + return &out, nil +} + +type RecurrenceFrequency string + +const ( + RecurrenceFrequencyDay RecurrenceFrequency = "Day" + RecurrenceFrequencyHour RecurrenceFrequency = "Hour" + RecurrenceFrequencyMinute RecurrenceFrequency = "Minute" + RecurrenceFrequencyMonth RecurrenceFrequency = "Month" + RecurrenceFrequencyNotSpecified RecurrenceFrequency = "NotSpecified" + RecurrenceFrequencySecond RecurrenceFrequency = "Second" + RecurrenceFrequencyWeek RecurrenceFrequency = "Week" + RecurrenceFrequencyYear RecurrenceFrequency = "Year" +) + +func PossibleValuesForRecurrenceFrequency() []string { + return []string{ + string(RecurrenceFrequencyDay), + string(RecurrenceFrequencyHour), + string(RecurrenceFrequencyMinute), + string(RecurrenceFrequencyMonth), + string(RecurrenceFrequencyNotSpecified), + string(RecurrenceFrequencySecond), + string(RecurrenceFrequencyWeek), + string(RecurrenceFrequencyYear), + } +} + +func (s *RecurrenceFrequency) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecurrenceFrequency(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecurrenceFrequency(input string) (*RecurrenceFrequency, error) { + vals := map[string]RecurrenceFrequency{ + "day": RecurrenceFrequencyDay, + "hour": RecurrenceFrequencyHour, + "minute": RecurrenceFrequencyMinute, + "month": RecurrenceFrequencyMonth, + "notspecified": RecurrenceFrequencyNotSpecified, + "second": RecurrenceFrequencySecond, + "week": RecurrenceFrequencyWeek, + "year": RecurrenceFrequencyYear, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecurrenceFrequency(input) + return &out, nil +} + +type WorkflowState string + +const ( + WorkflowStateCompleted WorkflowState = "Completed" + WorkflowStateDeleted WorkflowState = "Deleted" + WorkflowStateDisabled WorkflowState = "Disabled" + WorkflowStateEnabled WorkflowState = "Enabled" + WorkflowStateNotSpecified WorkflowState = "NotSpecified" + WorkflowStateSuspended WorkflowState = "Suspended" +) + +func PossibleValuesForWorkflowState() []string { + return []string{ + string(WorkflowStateCompleted), + string(WorkflowStateDeleted), + string(WorkflowStateDisabled), + string(WorkflowStateEnabled), + string(WorkflowStateNotSpecified), + string(WorkflowStateSuspended), + } +} + +func (s *WorkflowState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowState(input string) (*WorkflowState, error) { + vals := map[string]WorkflowState{ + "completed": WorkflowStateCompleted, + "deleted": WorkflowStateDeleted, + "disabled": WorkflowStateDisabled, + "enabled": WorkflowStateEnabled, + "notspecified": WorkflowStateNotSpecified, + "suspended": WorkflowStateSuspended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowState(input) + return &out, nil +} + +type WorkflowStatus string + +const ( + WorkflowStatusAborted WorkflowStatus = "Aborted" + WorkflowStatusCancelled WorkflowStatus = "Cancelled" + WorkflowStatusFailed WorkflowStatus = "Failed" + WorkflowStatusFaulted WorkflowStatus = "Faulted" + WorkflowStatusIgnored WorkflowStatus = "Ignored" + WorkflowStatusNotSpecified WorkflowStatus = "NotSpecified" + WorkflowStatusPaused WorkflowStatus = "Paused" + WorkflowStatusRunning WorkflowStatus = "Running" + WorkflowStatusSkipped WorkflowStatus = "Skipped" + WorkflowStatusSucceeded WorkflowStatus = "Succeeded" + WorkflowStatusSuspended WorkflowStatus = "Suspended" + WorkflowStatusTimedOut WorkflowStatus = "TimedOut" + WorkflowStatusWaiting WorkflowStatus = "Waiting" +) + +func PossibleValuesForWorkflowStatus() []string { + return []string{ + string(WorkflowStatusAborted), + string(WorkflowStatusCancelled), + string(WorkflowStatusFailed), + string(WorkflowStatusFaulted), + string(WorkflowStatusIgnored), + string(WorkflowStatusNotSpecified), + string(WorkflowStatusPaused), + string(WorkflowStatusRunning), + string(WorkflowStatusSkipped), + string(WorkflowStatusSucceeded), + string(WorkflowStatusSuspended), + string(WorkflowStatusTimedOut), + string(WorkflowStatusWaiting), + } +} + +func (s *WorkflowStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowStatus(input string) (*WorkflowStatus, error) { + vals := map[string]WorkflowStatus{ + "aborted": WorkflowStatusAborted, + "cancelled": WorkflowStatusCancelled, + "failed": WorkflowStatusFailed, + "faulted": WorkflowStatusFaulted, + "ignored": WorkflowStatusIgnored, + "notspecified": WorkflowStatusNotSpecified, + "paused": WorkflowStatusPaused, + "running": WorkflowStatusRunning, + "skipped": WorkflowStatusSkipped, + "succeeded": WorkflowStatusSucceeded, + "suspended": WorkflowStatusSuspended, + "timedout": WorkflowStatusTimedOut, + "waiting": WorkflowStatusWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowStatus(input) + return &out, nil +} + +type WorkflowTriggerProvisioningState string + +const ( + WorkflowTriggerProvisioningStateAccepted WorkflowTriggerProvisioningState = "Accepted" + WorkflowTriggerProvisioningStateCanceled WorkflowTriggerProvisioningState = "Canceled" + WorkflowTriggerProvisioningStateCompleted WorkflowTriggerProvisioningState = "Completed" + WorkflowTriggerProvisioningStateCreated WorkflowTriggerProvisioningState = "Created" + WorkflowTriggerProvisioningStateCreating WorkflowTriggerProvisioningState = "Creating" + WorkflowTriggerProvisioningStateDeleted WorkflowTriggerProvisioningState = "Deleted" + WorkflowTriggerProvisioningStateDeleting WorkflowTriggerProvisioningState = "Deleting" + WorkflowTriggerProvisioningStateFailed WorkflowTriggerProvisioningState = "Failed" + WorkflowTriggerProvisioningStateMoving WorkflowTriggerProvisioningState = "Moving" + WorkflowTriggerProvisioningStateNotSpecified WorkflowTriggerProvisioningState = "NotSpecified" + WorkflowTriggerProvisioningStateReady WorkflowTriggerProvisioningState = "Ready" + WorkflowTriggerProvisioningStateRegistered WorkflowTriggerProvisioningState = "Registered" + WorkflowTriggerProvisioningStateRegistering WorkflowTriggerProvisioningState = "Registering" + WorkflowTriggerProvisioningStateRunning WorkflowTriggerProvisioningState = "Running" + WorkflowTriggerProvisioningStateSucceeded WorkflowTriggerProvisioningState = "Succeeded" + WorkflowTriggerProvisioningStateUnregistered WorkflowTriggerProvisioningState = "Unregistered" + WorkflowTriggerProvisioningStateUnregistering WorkflowTriggerProvisioningState = "Unregistering" + WorkflowTriggerProvisioningStateUpdating WorkflowTriggerProvisioningState = "Updating" +) + +func PossibleValuesForWorkflowTriggerProvisioningState() []string { + return []string{ + string(WorkflowTriggerProvisioningStateAccepted), + string(WorkflowTriggerProvisioningStateCanceled), + string(WorkflowTriggerProvisioningStateCompleted), + string(WorkflowTriggerProvisioningStateCreated), + string(WorkflowTriggerProvisioningStateCreating), + string(WorkflowTriggerProvisioningStateDeleted), + string(WorkflowTriggerProvisioningStateDeleting), + string(WorkflowTriggerProvisioningStateFailed), + string(WorkflowTriggerProvisioningStateMoving), + string(WorkflowTriggerProvisioningStateNotSpecified), + string(WorkflowTriggerProvisioningStateReady), + string(WorkflowTriggerProvisioningStateRegistered), + string(WorkflowTriggerProvisioningStateRegistering), + string(WorkflowTriggerProvisioningStateRunning), + string(WorkflowTriggerProvisioningStateSucceeded), + string(WorkflowTriggerProvisioningStateUnregistered), + string(WorkflowTriggerProvisioningStateUnregistering), + string(WorkflowTriggerProvisioningStateUpdating), + } +} + +func (s *WorkflowTriggerProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowTriggerProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowTriggerProvisioningState(input string) (*WorkflowTriggerProvisioningState, error) { + vals := map[string]WorkflowTriggerProvisioningState{ + "accepted": WorkflowTriggerProvisioningStateAccepted, + "canceled": WorkflowTriggerProvisioningStateCanceled, + "completed": WorkflowTriggerProvisioningStateCompleted, + "created": WorkflowTriggerProvisioningStateCreated, + "creating": WorkflowTriggerProvisioningStateCreating, + "deleted": WorkflowTriggerProvisioningStateDeleted, + "deleting": WorkflowTriggerProvisioningStateDeleting, + "failed": WorkflowTriggerProvisioningStateFailed, + "moving": WorkflowTriggerProvisioningStateMoving, + "notspecified": WorkflowTriggerProvisioningStateNotSpecified, + "ready": WorkflowTriggerProvisioningStateReady, + "registered": WorkflowTriggerProvisioningStateRegistered, + "registering": WorkflowTriggerProvisioningStateRegistering, + "running": WorkflowTriggerProvisioningStateRunning, + "succeeded": WorkflowTriggerProvisioningStateSucceeded, + "unregistered": WorkflowTriggerProvisioningStateUnregistered, + "unregistering": WorkflowTriggerProvisioningStateUnregistering, + "updating": WorkflowTriggerProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowTriggerProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/id_managementworkflow.go b/resource-manager/web/2024-11-01/workflowtriggers/id_managementworkflow.go new file mode 100644 index 00000000000..7f55952af52 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/id_managementworkflow.go @@ -0,0 +1,145 @@ +package workflowtriggers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagementWorkflowId{}) +} + +var _ resourceids.ResourceId = &ManagementWorkflowId{} + +// ManagementWorkflowId is a struct representing the Resource ID for a Management Workflow +type ManagementWorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string +} + +// NewManagementWorkflowID returns a new ManagementWorkflowId struct +func NewManagementWorkflowID(subscriptionId string, resourceGroupName string, siteName string, workflowName string) ManagementWorkflowId { + return ManagementWorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + } +} + +// ParseManagementWorkflowID parses 'input' into a ManagementWorkflowId +func ParseManagementWorkflowID(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagementWorkflowIDInsensitively parses 'input' case-insensitively into a ManagementWorkflowId +// note: this method should only be used for API response data and not user input +func ParseManagementWorkflowIDInsensitively(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagementWorkflowId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateManagementWorkflowID checks that 'input' can be parsed as a Management Workflow ID +func ValidateManagementWorkflowID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseManagementWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Management Workflow ID +func (id ManagementWorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Management Workflow ID +func (id ManagementWorkflowId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + } +} + +// String returns a human-readable description of this Management Workflow ID +func (id ManagementWorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Management Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/id_managementworkflow_test.go b/resource-manager/web/2024-11-01/workflowtriggers/id_managementworkflow_test.go new file mode 100644 index 00000000000..1ca968f9de0 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/id_managementworkflow_test.go @@ -0,0 +1,417 @@ +package workflowtriggers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ManagementWorkflowId{} + +func TestNewManagementWorkflowID(t *testing.T) { + id := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } +} + +func TestFormatManagementWorkflowID(t *testing.T) { + actual := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagementWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseManagementWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForManagementWorkflowId(t *testing.T) { + segments := ManagementWorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagementWorkflowId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/id_trigger.go b/resource-manager/web/2024-11-01/workflowtriggers/id_trigger.go new file mode 100644 index 00000000000..3980bdfb0bc --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/id_trigger.go @@ -0,0 +1,154 @@ +package workflowtriggers + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&TriggerId{}) +} + +var _ resourceids.ResourceId = &TriggerId{} + +// TriggerId is a struct representing the Resource ID for a Trigger +type TriggerId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + TriggerName string +} + +// NewTriggerID returns a new TriggerId struct +func NewTriggerID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, triggerName string) TriggerId { + return TriggerId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + TriggerName: triggerName, + } +} + +// ParseTriggerID parses 'input' into a TriggerId +func ParseTriggerID(input string) (*TriggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTriggerIDInsensitively parses 'input' case-insensitively into a TriggerId +// note: this method should only be used for API response data and not user input +func ParseTriggerIDInsensitively(input string) (*TriggerId, error) { + parser := resourceids.NewParserFromResourceIdType(&TriggerId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TriggerId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TriggerId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.TriggerName, ok = input.Parsed["triggerName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "triggerName", input) + } + + return nil +} + +// ValidateTriggerID checks that 'input' can be parsed as a Trigger ID +func ValidateTriggerID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseTriggerID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Trigger ID +func (id TriggerId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/triggers/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.TriggerName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Trigger ID +func (id TriggerId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticTriggers", "triggers", "triggers"), + resourceids.UserSpecifiedSegment("triggerName", "triggerName"), + } +} + +// String returns a human-readable description of this Trigger ID +func (id TriggerId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Trigger Name: %q", id.TriggerName), + } + return fmt.Sprintf("Trigger (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/id_trigger_test.go b/resource-manager/web/2024-11-01/workflowtriggers/id_trigger_test.go new file mode 100644 index 00000000000..c101bbec5e7 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/id_trigger_test.go @@ -0,0 +1,462 @@ +package workflowtriggers + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &TriggerId{} + +func TestNewTriggerID(t *testing.T) { + id := NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.TriggerName != "triggerName" { + t.Fatalf("Expected %q but got %q for Segment 'TriggerName'", id.TriggerName, "triggerName") + } +} + +func TestFormatTriggerID(t *testing.T) { + actual := NewTriggerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "triggerName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTriggerID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + TriggerName: "triggerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + } +} + +func TestParseTriggerIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TriggerId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + TriggerName: "triggerName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/triggers/triggerName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS/tRiGgErNaMe", + Expected: &TriggerId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + TriggerName: "tRiGgErNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/tRiGgErS/tRiGgErNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTriggerIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.TriggerName != v.Expected.TriggerName { + t.Fatalf("Expected %q but got %q for TriggerName", v.Expected.TriggerName, actual.TriggerName) + } + + } +} + +func TestSegmentsForTriggerId(t *testing.T) { + segments := TriggerId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TriggerId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/method_get.go b/resource-manager/web/2024-11-01/workflowtriggers/method_get.go new file mode 100644 index 00000000000..d1bcd504fe2 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/method_get.go @@ -0,0 +1,53 @@ +package workflowtriggers + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowTrigger +} + +// Get ... +func (c WorkflowTriggersClient) Get(ctx context.Context, id TriggerId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowTrigger + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/method_getschemajson.go b/resource-manager/web/2024-11-01/workflowtriggers/method_getschemajson.go new file mode 100644 index 00000000000..c26d831b302 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/method_getschemajson.go @@ -0,0 +1,54 @@ +package workflowtriggers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetSchemaJsonOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *JsonSchema +} + +// GetSchemaJson ... +func (c WorkflowTriggersClient) GetSchemaJson(ctx context.Context, id TriggerId) (result GetSchemaJsonOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/schemas/json", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model JsonSchema + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/method_list.go b/resource-manager/web/2024-11-01/workflowtriggers/method_list.go new file mode 100644 index 00000000000..e311d6393de --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/method_list.go @@ -0,0 +1,138 @@ +package workflowtriggers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowTrigger +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowTrigger +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c WorkflowTriggersClient) List(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/triggers", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowTrigger `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c WorkflowTriggersClient) ListComplete(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowTriggerOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowTriggersClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions, predicate WorkflowTriggerOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowTrigger, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/method_listcallbackurl.go b/resource-manager/web/2024-11-01/workflowtriggers/method_listcallbackurl.go new file mode 100644 index 00000000000..4fa4045250d --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/method_listcallbackurl.go @@ -0,0 +1,54 @@ +package workflowtriggers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListCallbackURLOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowTriggerCallbackURL +} + +// ListCallbackURL ... +func (c WorkflowTriggersClient) ListCallbackURL(ctx context.Context, id TriggerId) (result ListCallbackURLOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listCallbackUrl", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowTriggerCallbackURL + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/method_run.go b/resource-manager/web/2024-11-01/workflowtriggers/method_run.go new file mode 100644 index 00000000000..2fa34636832 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/method_run.go @@ -0,0 +1,70 @@ +package workflowtriggers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Run ... +func (c WorkflowTriggersClient) Run(ctx context.Context, id TriggerId) (result RunOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/run", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RunThenPoll performs Run then polls until it's completed +func (c WorkflowTriggersClient) RunThenPoll(ctx context.Context, id TriggerId) error { + result, err := c.Run(ctx, id) + if err != nil { + return fmt.Errorf("performing Run: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Run: %+v", err) + } + + return nil +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/model_jsonschema.go b/resource-manager/web/2024-11-01/workflowtriggers/model_jsonschema.go new file mode 100644 index 00000000000..9dbec86f757 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/model_jsonschema.go @@ -0,0 +1,9 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JsonSchema struct { + Content *string `json:"content,omitempty"` + Title *string `json:"title,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/model_recurrenceschedule.go b/resource-manager/web/2024-11-01/workflowtriggers/model_recurrenceschedule.go new file mode 100644 index 00000000000..7ea8413d4cd --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/model_recurrenceschedule.go @@ -0,0 +1,12 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecurrenceSchedule struct { + Hours *[]int64 `json:"hours,omitempty"` + Minutes *[]int64 `json:"minutes,omitempty"` + MonthDays *[]int64 `json:"monthDays,omitempty"` + MonthlyOccurrences *[]RecurrenceScheduleOccurrence `json:"monthlyOccurrences,omitempty"` + WeekDays *[]DaysOfWeek `json:"weekDays,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/model_recurrencescheduleoccurrence.go b/resource-manager/web/2024-11-01/workflowtriggers/model_recurrencescheduleoccurrence.go new file mode 100644 index 00000000000..39f417c38d7 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/model_recurrencescheduleoccurrence.go @@ -0,0 +1,9 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecurrenceScheduleOccurrence struct { + Day *DayOfWeek `json:"day,omitempty"` + Occurrence *int64 `json:"occurrence,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/model_resourcereference.go b/resource-manager/web/2024-11-01/workflowtriggers/model_resourcereference.go new file mode 100644 index 00000000000..f96ba2e28a0 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/model_resourcereference.go @@ -0,0 +1,10 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/model_workflowtrigger.go b/resource-manager/web/2024-11-01/workflowtriggers/model_workflowtrigger.go new file mode 100644 index 00000000000..b2502e9f9c4 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/model_workflowtrigger.go @@ -0,0 +1,11 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTrigger struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowTriggerProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/model_workflowtriggercallbackurl.go b/resource-manager/web/2024-11-01/workflowtriggers/model_workflowtriggercallbackurl.go new file mode 100644 index 00000000000..710a39b43aa --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/model_workflowtriggercallbackurl.go @@ -0,0 +1,13 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerCallbackURL struct { + BasePath *string `json:"basePath,omitempty"` + Method *string `json:"method,omitempty"` + Queries *WorkflowTriggerListCallbackURLQueries `json:"queries,omitempty"` + RelativePath *string `json:"relativePath,omitempty"` + RelativePathParameters *[]string `json:"relativePathParameters,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/model_workflowtriggerlistcallbackurlqueries.go b/resource-manager/web/2024-11-01/workflowtriggers/model_workflowtriggerlistcallbackurlqueries.go new file mode 100644 index 00000000000..f4e969fd7ab --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/model_workflowtriggerlistcallbackurlqueries.go @@ -0,0 +1,12 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerListCallbackURLQueries struct { + ApiVersion *string `json:"api-version,omitempty"` + Se *string `json:"se,omitempty"` + Sig *string `json:"sig,omitempty"` + Sp *string `json:"sp,omitempty"` + Sv *string `json:"sv,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/model_workflowtriggerproperties.go b/resource-manager/web/2024-11-01/workflowtriggers/model_workflowtriggerproperties.go new file mode 100644 index 00000000000..b860a57a39c --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/model_workflowtriggerproperties.go @@ -0,0 +1,70 @@ +package workflowtriggers + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerProperties struct { + ChangedTime *string `json:"changedTime,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + LastExecutionTime *string `json:"lastExecutionTime,omitempty"` + NextExecutionTime *string `json:"nextExecutionTime,omitempty"` + ProvisioningState *WorkflowTriggerProvisioningState `json:"provisioningState,omitempty"` + Recurrence *WorkflowTriggerRecurrence `json:"recurrence,omitempty"` + State *WorkflowState `json:"state,omitempty"` + Status *WorkflowStatus `json:"status,omitempty"` + Workflow *ResourceReference `json:"workflow,omitempty"` +} + +func (o *WorkflowTriggerProperties) GetChangedTimeAsTime() (*time.Time, error) { + if o.ChangedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ChangedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerProperties) SetChangedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ChangedTime = &formatted +} + +func (o *WorkflowTriggerProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} + +func (o *WorkflowTriggerProperties) GetLastExecutionTimeAsTime() (*time.Time, error) { + if o.LastExecutionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastExecutionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerProperties) SetLastExecutionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastExecutionTime = &formatted +} + +func (o *WorkflowTriggerProperties) GetNextExecutionTimeAsTime() (*time.Time, error) { + if o.NextExecutionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.NextExecutionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowTriggerProperties) SetNextExecutionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.NextExecutionTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/model_workflowtriggerrecurrence.go b/resource-manager/web/2024-11-01/workflowtriggers/model_workflowtriggerrecurrence.go new file mode 100644 index 00000000000..ec9873b4518 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/model_workflowtriggerrecurrence.go @@ -0,0 +1,13 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerRecurrence struct { + EndTime *string `json:"endTime,omitempty"` + Frequency *RecurrenceFrequency `json:"frequency,omitempty"` + Interval *int64 `json:"interval,omitempty"` + Schedule *RecurrenceSchedule `json:"schedule,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/predicates.go b/resource-manager/web/2024-11-01/workflowtriggers/predicates.go new file mode 100644 index 00000000000..724f6388737 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/predicates.go @@ -0,0 +1,27 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowTriggerOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p WorkflowTriggerOperationPredicate) Matches(input WorkflowTrigger) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/workflowtriggers/version.go b/resource-manager/web/2024-11-01/workflowtriggers/version.go new file mode 100644 index 00000000000..abb03202274 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowtriggers/version.go @@ -0,0 +1,10 @@ +package workflowtriggers + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/workflowtriggers/2024-11-01" +} diff --git a/resource-manager/web/2024-11-01/workflowversions/README.md b/resource-manager/web/2024-11-01/workflowversions/README.md new file mode 100644 index 00000000000..710836b348d --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflowversions` Documentation + +The `workflowversions` SDK allows for interaction with Azure Resource Manager `web` (API Version `2024-11-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/web/2024-11-01/workflowversions" +``` + + +### Client Initialization + +```go +client := workflowversions.NewWorkflowVersionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkflowVersionsClient.Get` + +```go +ctx := context.TODO() +id := workflowversions.NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "versionId") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkflowVersionsClient.List` + +```go +ctx := context.TODO() +id := workflowversions.NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + +// alternatively `client.List(ctx, id, workflowversions.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, workflowversions.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/web/2024-11-01/workflowversions/client.go b/resource-manager/web/2024-11-01/workflowversions/client.go new file mode 100644 index 00000000000..b569325e0f3 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/client.go @@ -0,0 +1,26 @@ +package workflowversions + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowVersionsClient struct { + Client *resourcemanager.Client +} + +func NewWorkflowVersionsClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkflowVersionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "workflowversions", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkflowVersionsClient: %+v", err) + } + + return &WorkflowVersionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/web/2024-11-01/workflowversions/constants.go b/resource-manager/web/2024-11-01/workflowversions/constants.go new file mode 100644 index 00000000000..fe1be75f3e9 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/constants.go @@ -0,0 +1,317 @@ +package workflowversions + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationProviderType string + +const ( + OpenAuthenticationProviderTypeAAD OpenAuthenticationProviderType = "AAD" +) + +func PossibleValuesForOpenAuthenticationProviderType() []string { + return []string{ + string(OpenAuthenticationProviderTypeAAD), + } +} + +func (s *OpenAuthenticationProviderType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOpenAuthenticationProviderType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOpenAuthenticationProviderType(input string) (*OpenAuthenticationProviderType, error) { + vals := map[string]OpenAuthenticationProviderType{ + "aad": OpenAuthenticationProviderTypeAAD, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OpenAuthenticationProviderType(input) + return &out, nil +} + +type ParameterType string + +const ( + ParameterTypeArray ParameterType = "Array" + ParameterTypeBool ParameterType = "Bool" + ParameterTypeFloat ParameterType = "Float" + ParameterTypeInt ParameterType = "Int" + ParameterTypeNotSpecified ParameterType = "NotSpecified" + ParameterTypeObject ParameterType = "Object" + ParameterTypeSecureObject ParameterType = "SecureObject" + ParameterTypeSecureString ParameterType = "SecureString" + ParameterTypeString ParameterType = "String" +) + +func PossibleValuesForParameterType() []string { + return []string{ + string(ParameterTypeArray), + string(ParameterTypeBool), + string(ParameterTypeFloat), + string(ParameterTypeInt), + string(ParameterTypeNotSpecified), + string(ParameterTypeObject), + string(ParameterTypeSecureObject), + string(ParameterTypeSecureString), + string(ParameterTypeString), + } +} + +func (s *ParameterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseParameterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseParameterType(input string) (*ParameterType, error) { + vals := map[string]ParameterType{ + "array": ParameterTypeArray, + "bool": ParameterTypeBool, + "float": ParameterTypeFloat, + "int": ParameterTypeInt, + "notspecified": ParameterTypeNotSpecified, + "object": ParameterTypeObject, + "secureobject": ParameterTypeSecureObject, + "securestring": ParameterTypeSecureString, + "string": ParameterTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ParameterType(input) + return &out, nil +} + +type WorkflowProvisioningState string + +const ( + WorkflowProvisioningStateAccepted WorkflowProvisioningState = "Accepted" + WorkflowProvisioningStateCanceled WorkflowProvisioningState = "Canceled" + WorkflowProvisioningStateCompleted WorkflowProvisioningState = "Completed" + WorkflowProvisioningStateCreated WorkflowProvisioningState = "Created" + WorkflowProvisioningStateCreating WorkflowProvisioningState = "Creating" + WorkflowProvisioningStateDeleted WorkflowProvisioningState = "Deleted" + WorkflowProvisioningStateDeleting WorkflowProvisioningState = "Deleting" + WorkflowProvisioningStateFailed WorkflowProvisioningState = "Failed" + WorkflowProvisioningStateInProgress WorkflowProvisioningState = "InProgress" + WorkflowProvisioningStateMoving WorkflowProvisioningState = "Moving" + WorkflowProvisioningStateNotSpecified WorkflowProvisioningState = "NotSpecified" + WorkflowProvisioningStatePending WorkflowProvisioningState = "Pending" + WorkflowProvisioningStateReady WorkflowProvisioningState = "Ready" + WorkflowProvisioningStateRegistered WorkflowProvisioningState = "Registered" + WorkflowProvisioningStateRegistering WorkflowProvisioningState = "Registering" + WorkflowProvisioningStateRenewing WorkflowProvisioningState = "Renewing" + WorkflowProvisioningStateRunning WorkflowProvisioningState = "Running" + WorkflowProvisioningStateSucceeded WorkflowProvisioningState = "Succeeded" + WorkflowProvisioningStateUnregistered WorkflowProvisioningState = "Unregistered" + WorkflowProvisioningStateUnregistering WorkflowProvisioningState = "Unregistering" + WorkflowProvisioningStateUpdating WorkflowProvisioningState = "Updating" + WorkflowProvisioningStateWaiting WorkflowProvisioningState = "Waiting" +) + +func PossibleValuesForWorkflowProvisioningState() []string { + return []string{ + string(WorkflowProvisioningStateAccepted), + string(WorkflowProvisioningStateCanceled), + string(WorkflowProvisioningStateCompleted), + string(WorkflowProvisioningStateCreated), + string(WorkflowProvisioningStateCreating), + string(WorkflowProvisioningStateDeleted), + string(WorkflowProvisioningStateDeleting), + string(WorkflowProvisioningStateFailed), + string(WorkflowProvisioningStateInProgress), + string(WorkflowProvisioningStateMoving), + string(WorkflowProvisioningStateNotSpecified), + string(WorkflowProvisioningStatePending), + string(WorkflowProvisioningStateReady), + string(WorkflowProvisioningStateRegistered), + string(WorkflowProvisioningStateRegistering), + string(WorkflowProvisioningStateRenewing), + string(WorkflowProvisioningStateRunning), + string(WorkflowProvisioningStateSucceeded), + string(WorkflowProvisioningStateUnregistered), + string(WorkflowProvisioningStateUnregistering), + string(WorkflowProvisioningStateUpdating), + string(WorkflowProvisioningStateWaiting), + } +} + +func (s *WorkflowProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowProvisioningState(input string) (*WorkflowProvisioningState, error) { + vals := map[string]WorkflowProvisioningState{ + "accepted": WorkflowProvisioningStateAccepted, + "canceled": WorkflowProvisioningStateCanceled, + "completed": WorkflowProvisioningStateCompleted, + "created": WorkflowProvisioningStateCreated, + "creating": WorkflowProvisioningStateCreating, + "deleted": WorkflowProvisioningStateDeleted, + "deleting": WorkflowProvisioningStateDeleting, + "failed": WorkflowProvisioningStateFailed, + "inprogress": WorkflowProvisioningStateInProgress, + "moving": WorkflowProvisioningStateMoving, + "notspecified": WorkflowProvisioningStateNotSpecified, + "pending": WorkflowProvisioningStatePending, + "ready": WorkflowProvisioningStateReady, + "registered": WorkflowProvisioningStateRegistered, + "registering": WorkflowProvisioningStateRegistering, + "renewing": WorkflowProvisioningStateRenewing, + "running": WorkflowProvisioningStateRunning, + "succeeded": WorkflowProvisioningStateSucceeded, + "unregistered": WorkflowProvisioningStateUnregistered, + "unregistering": WorkflowProvisioningStateUnregistering, + "updating": WorkflowProvisioningStateUpdating, + "waiting": WorkflowProvisioningStateWaiting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowProvisioningState(input) + return &out, nil +} + +type WorkflowSkuName string + +const ( + WorkflowSkuNameBasic WorkflowSkuName = "Basic" + WorkflowSkuNameFree WorkflowSkuName = "Free" + WorkflowSkuNameNotSpecified WorkflowSkuName = "NotSpecified" + WorkflowSkuNamePremium WorkflowSkuName = "Premium" + WorkflowSkuNameShared WorkflowSkuName = "Shared" + WorkflowSkuNameStandard WorkflowSkuName = "Standard" +) + +func PossibleValuesForWorkflowSkuName() []string { + return []string{ + string(WorkflowSkuNameBasic), + string(WorkflowSkuNameFree), + string(WorkflowSkuNameNotSpecified), + string(WorkflowSkuNamePremium), + string(WorkflowSkuNameShared), + string(WorkflowSkuNameStandard), + } +} + +func (s *WorkflowSkuName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowSkuName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowSkuName(input string) (*WorkflowSkuName, error) { + vals := map[string]WorkflowSkuName{ + "basic": WorkflowSkuNameBasic, + "free": WorkflowSkuNameFree, + "notspecified": WorkflowSkuNameNotSpecified, + "premium": WorkflowSkuNamePremium, + "shared": WorkflowSkuNameShared, + "standard": WorkflowSkuNameStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowSkuName(input) + return &out, nil +} + +type WorkflowState string + +const ( + WorkflowStateCompleted WorkflowState = "Completed" + WorkflowStateDeleted WorkflowState = "Deleted" + WorkflowStateDisabled WorkflowState = "Disabled" + WorkflowStateEnabled WorkflowState = "Enabled" + WorkflowStateNotSpecified WorkflowState = "NotSpecified" + WorkflowStateSuspended WorkflowState = "Suspended" +) + +func PossibleValuesForWorkflowState() []string { + return []string{ + string(WorkflowStateCompleted), + string(WorkflowStateDeleted), + string(WorkflowStateDisabled), + string(WorkflowStateEnabled), + string(WorkflowStateNotSpecified), + string(WorkflowStateSuspended), + } +} + +func (s *WorkflowState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkflowState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkflowState(input string) (*WorkflowState, error) { + vals := map[string]WorkflowState{ + "completed": WorkflowStateCompleted, + "deleted": WorkflowStateDeleted, + "disabled": WorkflowStateDisabled, + "enabled": WorkflowStateEnabled, + "notspecified": WorkflowStateNotSpecified, + "suspended": WorkflowStateSuspended, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkflowState(input) + return &out, nil +} diff --git a/resource-manager/web/2024-11-01/workflowversions/id_managementworkflow.go b/resource-manager/web/2024-11-01/workflowversions/id_managementworkflow.go new file mode 100644 index 00000000000..29c5ebda9ab --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/id_managementworkflow.go @@ -0,0 +1,145 @@ +package workflowversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagementWorkflowId{}) +} + +var _ resourceids.ResourceId = &ManagementWorkflowId{} + +// ManagementWorkflowId is a struct representing the Resource ID for a Management Workflow +type ManagementWorkflowId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string +} + +// NewManagementWorkflowID returns a new ManagementWorkflowId struct +func NewManagementWorkflowID(subscriptionId string, resourceGroupName string, siteName string, workflowName string) ManagementWorkflowId { + return ManagementWorkflowId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + } +} + +// ParseManagementWorkflowID parses 'input' into a ManagementWorkflowId +func ParseManagementWorkflowID(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagementWorkflowIDInsensitively parses 'input' case-insensitively into a ManagementWorkflowId +// note: this method should only be used for API response data and not user input +func ParseManagementWorkflowIDInsensitively(input string) (*ManagementWorkflowId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagementWorkflowId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagementWorkflowId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagementWorkflowId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + return nil +} + +// ValidateManagementWorkflowID checks that 'input' can be parsed as a Management Workflow ID +func ValidateManagementWorkflowID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseManagementWorkflowID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Management Workflow ID +func (id ManagementWorkflowId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Management Workflow ID +func (id ManagementWorkflowId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + } +} + +// String returns a human-readable description of this Management Workflow ID +func (id ManagementWorkflowId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + } + return fmt.Sprintf("Management Workflow (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/workflowversions/id_managementworkflow_test.go b/resource-manager/web/2024-11-01/workflowversions/id_managementworkflow_test.go new file mode 100644 index 00000000000..fb252bd145e --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/id_managementworkflow_test.go @@ -0,0 +1,417 @@ +package workflowversions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ManagementWorkflowId{} + +func TestNewManagementWorkflowID(t *testing.T) { + id := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } +} + +func TestFormatManagementWorkflowID(t *testing.T) { + actual := NewManagementWorkflowID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagementWorkflowID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestParseManagementWorkflowIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagementWorkflowId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Expected: &ManagementWorkflowId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagementWorkflowIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + } +} + +func TestSegmentsForManagementWorkflowId(t *testing.T) { + segments := ManagementWorkflowId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagementWorkflowId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/workflowversions/id_version.go b/resource-manager/web/2024-11-01/workflowversions/id_version.go new file mode 100644 index 00000000000..d1585eebfb1 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/id_version.go @@ -0,0 +1,154 @@ +package workflowversions + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VersionId{}) +} + +var _ resourceids.ResourceId = &VersionId{} + +// VersionId is a struct representing the Resource ID for a Version +type VersionId struct { + SubscriptionId string + ResourceGroupName string + SiteName string + WorkflowName string + VersionId string +} + +// NewVersionID returns a new VersionId struct +func NewVersionID(subscriptionId string, resourceGroupName string, siteName string, workflowName string, versionId string) VersionId { + return VersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SiteName: siteName, + WorkflowName: workflowName, + VersionId: versionId, + } +} + +// ParseVersionID parses 'input' into a VersionId +func ParseVersionID(input string) (*VersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVersionIDInsensitively parses 'input' case-insensitively into a VersionId +// note: this method should only be used for API response data and not user input +func ParseVersionIDInsensitively(input string) (*VersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SiteName, ok = input.Parsed["siteName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "siteName", input) + } + + if id.WorkflowName, ok = input.Parsed["workflowName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workflowName", input) + } + + if id.VersionId, ok = input.Parsed["versionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionId", input) + } + + return nil +} + +// ValidateVersionID checks that 'input' can be parsed as a Version ID +func ValidateVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Version ID +func (id VersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s/hostRuntime/runtime/webHooks/workflow/api/management/workflows/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SiteName, id.WorkflowName, id.VersionId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Version ID +func (id VersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftWeb", "Microsoft.Web", "Microsoft.Web"), + resourceids.StaticSegment("staticSites", "sites", "sites"), + resourceids.UserSpecifiedSegment("siteName", "siteName"), + resourceids.StaticSegment("staticHostRuntime", "hostRuntime", "hostRuntime"), + resourceids.StaticSegment("staticRuntime", "runtime", "runtime"), + resourceids.StaticSegment("staticWebHooks", "webHooks", "webHooks"), + resourceids.StaticSegment("staticWorkflow", "workflow", "workflow"), + resourceids.StaticSegment("staticApi", "api", "api"), + resourceids.StaticSegment("staticManagement", "management", "management"), + resourceids.StaticSegment("staticWorkflows", "workflows", "workflows"), + resourceids.UserSpecifiedSegment("workflowName", "workflowName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionId", "versionId"), + } +} + +// String returns a human-readable description of this Version ID +func (id VersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Site Name: %q", id.SiteName), + fmt.Sprintf("Workflow Name: %q", id.WorkflowName), + fmt.Sprintf("Version: %q", id.VersionId), + } + return fmt.Sprintf("Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/web/2024-11-01/workflowversions/id_version_test.go b/resource-manager/web/2024-11-01/workflowversions/id_version_test.go new file mode 100644 index 00000000000..5398d232c03 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/id_version_test.go @@ -0,0 +1,462 @@ +package workflowversions + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VersionId{} + +func TestNewVersionID(t *testing.T) { + id := NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "versionId") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SiteName != "siteName" { + t.Fatalf("Expected %q but got %q for Segment 'SiteName'", id.SiteName, "siteName") + } + + if id.WorkflowName != "workflowName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkflowName'", id.WorkflowName, "workflowName") + } + + if id.VersionId != "versionId" { + t.Fatalf("Expected %q but got %q for Segment 'VersionId'", id.VersionId, "versionId") + } +} + +func TestFormatVersionID(t *testing.T) { + actual := NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "siteName", "workflowName", "versionId").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/versions/versionId" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/versions/versionId", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + VersionId: "versionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/versions/versionId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.VersionId != v.Expected.VersionId { + t.Fatalf("Expected %q but got %q for VersionId", v.Expected.VersionId, actual.VersionId) + } + + } +} + +func TestParseVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/versions/versionId", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SiteName: "siteName", + WorkflowName: "workflowName", + VersionId: "versionId", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Web/sites/siteName/hostRuntime/runtime/webHooks/workflow/api/management/workflows/workflowName/versions/versionId/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/vErSiOnS/vErSiOnId", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SiteName: "sItEnAmE", + WorkflowName: "wOrKfLoWnAmE", + VersionId: "vErSiOnId", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.wEb/sItEs/sItEnAmE/hOsTrUnTiMe/rUnTiMe/wEbHoOkS/wOrKfLoW/aPi/mAnAgEmEnT/wOrKfLoWs/wOrKfLoWnAmE/vErSiOnS/vErSiOnId/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SiteName != v.Expected.SiteName { + t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName) + } + + if actual.WorkflowName != v.Expected.WorkflowName { + t.Fatalf("Expected %q but got %q for WorkflowName", v.Expected.WorkflowName, actual.WorkflowName) + } + + if actual.VersionId != v.Expected.VersionId { + t.Fatalf("Expected %q but got %q for VersionId", v.Expected.VersionId, actual.VersionId) + } + + } +} + +func TestSegmentsForVersionId(t *testing.T) { + segments := VersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/web/2024-11-01/workflowversions/method_get.go b/resource-manager/web/2024-11-01/workflowversions/method_get.go new file mode 100644 index 00000000000..f2ae2ecca09 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/method_get.go @@ -0,0 +1,53 @@ +package workflowversions + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkflowVersion +} + +// Get ... +func (c WorkflowVersionsClient) Get(ctx context.Context, id VersionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkflowVersion + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/web/2024-11-01/workflowversions/method_list.go b/resource-manager/web/2024-11-01/workflowversions/method_list.go new file mode 100644 index 00000000000..05d795dfb2d --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/method_list.go @@ -0,0 +1,134 @@ +package workflowversions + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkflowVersion +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkflowVersion +} + +type ListOperationOptions struct { + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c WorkflowVersionsClient) List(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkflowVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c WorkflowVersionsClient) ListComplete(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, WorkflowVersionOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkflowVersionsClient) ListCompleteMatchingPredicate(ctx context.Context, id ManagementWorkflowId, options ListOperationOptions, predicate WorkflowVersionOperationPredicate) (result ListCompleteResult, err error) { + items := make([]WorkflowVersion, 0) + + resp, err := c.List(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/web/2024-11-01/workflowversions/model_flowaccesscontrolconfiguration.go b/resource-manager/web/2024-11-01/workflowversions/model_flowaccesscontrolconfiguration.go new file mode 100644 index 00000000000..4d1b24e5c47 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/model_flowaccesscontrolconfiguration.go @@ -0,0 +1,11 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowAccessControlConfiguration struct { + Actions *FlowAccessControlConfigurationPolicy `json:"actions,omitempty"` + Contents *FlowAccessControlConfigurationPolicy `json:"contents,omitempty"` + Triggers *FlowAccessControlConfigurationPolicy `json:"triggers,omitempty"` + WorkflowManagement *FlowAccessControlConfigurationPolicy `json:"workflowManagement,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowversions/model_flowaccesscontrolconfigurationpolicy.go b/resource-manager/web/2024-11-01/workflowversions/model_flowaccesscontrolconfigurationpolicy.go new file mode 100644 index 00000000000..623db6898d9 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/model_flowaccesscontrolconfigurationpolicy.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowAccessControlConfigurationPolicy struct { + AllowedCallerIPAddresses *[]IPAddressRange `json:"allowedCallerIpAddresses,omitempty"` + OpenAuthenticationPolicies *OpenAuthenticationAccessPolicies `json:"openAuthenticationPolicies,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowversions/model_flowendpoints.go b/resource-manager/web/2024-11-01/workflowversions/model_flowendpoints.go new file mode 100644 index 00000000000..78fd2c63224 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/model_flowendpoints.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowEndpoints struct { + AccessEndpointIPAddresses *[]IPAddress `json:"accessEndpointIpAddresses,omitempty"` + OutgoingIPAddresses *[]IPAddress `json:"outgoingIpAddresses,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowversions/model_flowendpointsconfiguration.go b/resource-manager/web/2024-11-01/workflowversions/model_flowendpointsconfiguration.go new file mode 100644 index 00000000000..dd3a411d472 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/model_flowendpointsconfiguration.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlowEndpointsConfiguration struct { + Connector *FlowEndpoints `json:"connector,omitempty"` + Workflow *FlowEndpoints `json:"workflow,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowversions/model_ipaddress.go b/resource-manager/web/2024-11-01/workflowversions/model_ipaddress.go new file mode 100644 index 00000000000..2594d6696b1 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/model_ipaddress.go @@ -0,0 +1,8 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAddress struct { + Address *string `json:"address,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowversions/model_ipaddressrange.go b/resource-manager/web/2024-11-01/workflowversions/model_ipaddressrange.go new file mode 100644 index 00000000000..c663c9f3a9e --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/model_ipaddressrange.go @@ -0,0 +1,8 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPAddressRange struct { + AddressRange *string `json:"addressRange,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowversions/model_openauthenticationaccesspolicies.go b/resource-manager/web/2024-11-01/workflowversions/model_openauthenticationaccesspolicies.go new file mode 100644 index 00000000000..5b41cfe9f74 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/model_openauthenticationaccesspolicies.go @@ -0,0 +1,8 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationAccessPolicies struct { + Policies *map[string]OpenAuthenticationAccessPolicy `json:"policies,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowversions/model_openauthenticationaccesspolicy.go b/resource-manager/web/2024-11-01/workflowversions/model_openauthenticationaccesspolicy.go new file mode 100644 index 00000000000..2a53bfad87e --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/model_openauthenticationaccesspolicy.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationAccessPolicy struct { + Claims *[]OpenAuthenticationPolicyClaim `json:"claims,omitempty"` + Type *OpenAuthenticationProviderType `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowversions/model_openauthenticationpolicyclaim.go b/resource-manager/web/2024-11-01/workflowversions/model_openauthenticationpolicyclaim.go new file mode 100644 index 00000000000..2df917da9bc --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/model_openauthenticationpolicyclaim.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OpenAuthenticationPolicyClaim struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowversions/model_resourcereference.go b/resource-manager/web/2024-11-01/workflowversions/model_resourcereference.go new file mode 100644 index 00000000000..095116732d9 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/model_resourcereference.go @@ -0,0 +1,10 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowversions/model_workflowparameter.go b/resource-manager/web/2024-11-01/workflowversions/model_workflowparameter.go new file mode 100644 index 00000000000..4adc5e9fef6 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/model_workflowparameter.go @@ -0,0 +1,11 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowParameter struct { + Description *string `json:"description,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + Type *ParameterType `json:"type,omitempty"` + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowversions/model_workflowsku.go b/resource-manager/web/2024-11-01/workflowversions/model_workflowsku.go new file mode 100644 index 00000000000..d5bcab2e40e --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/model_workflowsku.go @@ -0,0 +1,9 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowSku struct { + Name WorkflowSkuName `json:"name"` + Plan *ResourceReference `json:"plan,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowversions/model_workflowversion.go b/resource-manager/web/2024-11-01/workflowversions/model_workflowversion.go new file mode 100644 index 00000000000..ae7647f4412 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/model_workflowversion.go @@ -0,0 +1,13 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowVersion struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkflowVersionProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/web/2024-11-01/workflowversions/model_workflowversionproperties.go b/resource-manager/web/2024-11-01/workflowversions/model_workflowversionproperties.go new file mode 100644 index 00000000000..0d9459677c9 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/model_workflowversionproperties.go @@ -0,0 +1,49 @@ +package workflowversions + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowVersionProperties struct { + AccessControl *FlowAccessControlConfiguration `json:"accessControl,omitempty"` + AccessEndpoint *string `json:"accessEndpoint,omitempty"` + ChangedTime *string `json:"changedTime,omitempty"` + CreatedTime *string `json:"createdTime,omitempty"` + Definition *interface{} `json:"definition,omitempty"` + EndpointsConfiguration *FlowEndpointsConfiguration `json:"endpointsConfiguration,omitempty"` + IntegrationAccount *ResourceReference `json:"integrationAccount,omitempty"` + Parameters *map[string]WorkflowParameter `json:"parameters,omitempty"` + ProvisioningState *WorkflowProvisioningState `json:"provisioningState,omitempty"` + Sku *WorkflowSku `json:"sku,omitempty"` + State *WorkflowState `json:"state,omitempty"` + Version *string `json:"version,omitempty"` +} + +func (o *WorkflowVersionProperties) GetChangedTimeAsTime() (*time.Time, error) { + if o.ChangedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ChangedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowVersionProperties) SetChangedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ChangedTime = &formatted +} + +func (o *WorkflowVersionProperties) GetCreatedTimeAsTime() (*time.Time, error) { + if o.CreatedTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *WorkflowVersionProperties) SetCreatedTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedTime = &formatted +} diff --git a/resource-manager/web/2024-11-01/workflowversions/predicates.go b/resource-manager/web/2024-11-01/workflowversions/predicates.go new file mode 100644 index 00000000000..1458230244b --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/predicates.go @@ -0,0 +1,32 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkflowVersionOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p WorkflowVersionOperationPredicate) Matches(input WorkflowVersion) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/web/2024-11-01/workflowversions/version.go b/resource-manager/web/2024-11-01/workflowversions/version.go new file mode 100644 index 00000000000..5ae7d834519 --- /dev/null +++ b/resource-manager/web/2024-11-01/workflowversions/version.go @@ -0,0 +1,10 @@ +package workflowversions + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-11-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/workflowversions/2024-11-01" +}